Skip to content

feat(#80): Brew Doctor + Cleanup cache maintenance - #82

Merged
msitarzewski merged 3 commits into
mainfrom
feat/doctor-cleanup
Jun 14, 2026
Merged

msitarzewski merged 3 commits into
mainfrom
feat/doctor-cleanup

Conversation

@msitarzewski

Copy link
Copy Markdown
Owner

Closes #80.

Summary

Adds Brew Doctor and Cleanup as cache-maintenance actions on the Dashboard Storage card (which already shows the Download cache size), per @modeezie's request in #80. Both shells, in parity.

  • 🩺 Run brew doctor — streams brew doctor into the Activity drawer. A non-zero exit (advisories) is treated as success, so the diagnostics show in the log without a scary "failed" notice.
  • 🧹 Clean up cache…brew cleanup --prune=all --scrub [--verbose], streamed. Confirm-gated (destructive of cached downloads incl. current versions; installed packages untouched), with a "frees ~X" estimate from a brew cleanup -n dry-run and a verbose toggle (default on, per the reporter).
  • The Storage card already rendered the cache size, so the "visual" ask was mostly existing infra — this adds the reclaimable estimate + the two actions.

Design notes

  • brew_doctor_stream is named to avoid colliding with the existing onboarding brew_doctor env-probe.
  • Doctor's non-zero-on-advisories is classified the same way as the upgrade-warnings path (doctor_advisory_exit), in both shells.
  • Cleanup is destructive-ish → inline confirm with plain-English copy + the reclaimable figure. Never one-click.

Tests

cargo 649 (+6) · vitest 35 · swift 137 (+6) · svelte-check 0 errors. New tests cover the doctor classifier and the size-token / reclaimable parsing in both Rust and Swift (same fixtures).

Follow-up question for the reporter

Default --scrub on (most aggressive, frees the most), or offer non-scrub as the default? Currently scrub-on with a verbose toggle. Open to feedback.

Scoped plan: memory-bank/tasks/2026-06/15-doctor-cleanup-plan.md.

🤖 Generated with Claude Code

msitarzewski and others added 3 commits June 14, 2026 03:03
Scoped PLAN for issue #80 (doctor + cleanup buttons, cache visual). Grounded
in the existing streaming-action path (actions.rs brew_update -> exec.rs
run_brew_streaming), the already-measured Download cache entry in disk_usage.rs
/ the Storage card, and the warnings-only non-zero classification for doctor.
Heavy reuse, both shells in parity, confirm-gated destructive cleanup. Not yet
built — targets the 0.x.1 batch.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Adds cache-maintenance actions on the Dashboard Storage card (which already
shows the Download cache size), per issue #80.

Backend:
- brew_doctor_stream + brew_cleanup(verbose) — streaming commands mirroring
  brew_update (run_brew_streaming). Named *_stream to avoid colliding with the
  existing env-probe brew_doctor. cleanup runs --prune=all --scrub [--verbose].
- doctor_advisory_exit() classifier: brew doctor exits 1 on advisories, so
  exec.rs treats a non-zero doctor exit as effective-success (advisory text
  lands in the Activity log, no error toast).
- brew_cleanup_preview command + parse_reclaimable/parse_size_token: dry-run
  estimate for the 'frees ~X' hint. Best-effort (None hides the hint).
- cleanup invalidates only the disk-usage cache (packages unchanged).

Frontend:
- api wrappers brewDoctorStream / brewCleanup / brewCleanupPreview.
- Storage-card maintenance row: Run brew doctor + Clean up cache… buttons (both
  stream into the Activity drawer), reclaimable hint, and an inline confirm
  gate for the destructive cleanup with a verbose toggle (default on).

Tests: +6 (doctor classifier, size-token + reclaimable parsing). cargo 649,
vitest 35, svelte-check 0 errors.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Mirrors the Tauri implementation in the SwiftUI build:
- BrewErrorPatterns.doctorAdvisoryExit + parseReclaimableBytes/parseSizeToken
  (byte-identical behavior to the Rust catalog; same test fixtures).
- startJob treats a non-zero brew doctor exit as success (advisories).
- BrewService.cleanupReclaimableBytes() — dry-run estimate.
- AppModel.runDoctor / runCleanup(verbose:) + reclaimable/busy state;
  loadStorage also fetches the estimate; cleanup re-measures storage on success.
- StorageCard maintenance row (stock SwiftUI: Button/Label/Toggle/role:.destructive
  confirm) with the same copy + reclaimable hint as Tauri.

Tests: +6 parity (swift 137).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Brew Doctor/Cleanup feature

1 participant