Repository navigation
feat(prune): fix image pruning, add usage summary, progress, stopped containers and prune-all - #83
Merged
Merged
Conversation
…containers and prune-all
Agent
- Select prune candidates per image ID, sorted by creation time (Docker does not
guarantee list order, so the wrong versions could be kept). Multi-tag images are
counted/removed once, tag by tag; images shared with an in-use repo are kept.
- Never remove images or containers that rollback snapshots depend on.
- Report space freed excluding layers shared with remaining images.
- Optional removal of stopped containers (never -ww-old/-ww-new or snapshot ones).
- New PRUNE_PREVIEW (disk usage + candidates), PRUNE_PROGRESS, and a PRUNE_RESULT
that is sent on every path (invalid payload, concurrent run) with a requestId.
Controller
- PruneService: validated options (keepPrevious 0-10, booleans), one prune per
agent (409), timeouts/disconnects reported as failures, preview endpoint, and a
sequential prune-all run that skips offline agents and returns a summary.
- Routes: POST /api/agents/:id/prune, GET .../prune/preview, POST /api/prune,
GET /api/prune/current. PRUNE_COMPLETE/PROGRESS/RUN_* are now broadcast to the UI
(PRUNE_COMPLETE was previously sent but never handled).
UI
- Prune card shows total image size, reclaimable space and stopped-container
count, an opt-in "also remove stopped containers" checkbox, a dry-run list,
a progress bar, and a result toast ("removed 3 images, freed ~1.2 GB").
- Empty/invalid "keep previous" no longer silently means 0.
- "Prune all" on the Agents page with live progress and a per-agent summary.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EeNrf1VXC34bbCKDsfL4TS
Contributor
🧪 Test Results — ✅ All tests passed
Commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The per-agent "Prune Images" feature had correctness gaps and gave the user no feedback. This PR fixes the pruning logic and adds a usage summary, progress, an opt-in for stopped containers, and a "Prune all agents" run.
Bugs fixed
PRUNE_COMPLETEwas broadcast but not typed or handled; dry run said "check agent logs". Now the UI gets progress and the result, and the agent replies on every path (invalid payload, concurrent run) with arequestId.Number('') === 0). The UI now blocks invalid input and the controller validateskeepPrevious(integer 0–10) and the flags (400 otherwise).New
PRUNE_PREVIEW+GET /api/agents/:id/prune/preview.containers/images, n/total, current item) and a toast such as "Pruned web-1: removed 3 images, 1 container, freed ~1.2 GB" (errors reported separately).-ww-old/-ww-newcontainers and snapshot-protected ones are never removed.POST /api/pruneruns agents sequentially, skips offline ones, continues past failures, and shows a per-agent summary with totals (GET /api/prune/currentrestores state after a reload).Notes / deviations from the plan
includeStoppedand cannot serve the preview.Testing
pruner_test.go(12 tests: ordering, keep 0, multi-tag, rollback protection, shared-layer size, stopped-container opt-in, dry run, error handling, preview).go vetclean. The only failures ingo test ./...are the 4TestRecoverOrphans_*tests that already fail onmain.prune-service.test.tsandprune.test.ts(validation, 404/409/504, concurrency, partial/failed outcomes, sequential prune-all with offline/failed agents).tscclean. These two files were run without the Postgres test container (no container runtime in my sandbox); the Postgres-backed suites (including thehub.tschanges) rely on CI.PruneCard, prune helpers and the store events;npm run build, lint and all 112 tests pass./pr-beta, then on an agent with some old image versions and a stopped container, try Dry Run, Prune with/without the checkbox, and "Prune all".Generated by Claude Code