Skip to content

Add Disk Usage plugin - #1

Merged
charpeni merged 2 commits into
mainfrom
bb/prototype-disk-usage-plugin-thr_74hy2ta7kp
Aug 17, 2026
Merged

Add Disk Usage plugin#1
charpeni merged 2 commits into
mainfrom
bb/prototype-disk-usage-plugin-thr_74hy2ta7kp

Conversation

@charpeni

Copy link
Copy Markdown
Owner

What

A new Disk Usage plugin: see what's taking up disk space on the bb server host, ncdu-style. Scan a directory, get its immediate children sorted by recursive size, and drill down until you find the culprit.

  • Disk Usage panel — scans a directory (default: the server home directory) and lists children largest-first with share bars, breadcrumbs, click-to-drill-down, and a free-form path input. While a scan runs, a live progress card streams entries visited, bytes so far, and the directory currently being walked (over bb.realtime).
  • Per-path cache — the last result per path is kept in memory (LRU-capped), so drilling back up or reopening the panel is instant; the header shows the snapshot's age and Rescan forces a fresh walk. Concurrent requests for the same path join a single walk.
  • bb disk-usage CLI — the same scan for agents and scripts: bb disk-usage [path] [--top N] [--json] [--refresh].

How sizes are measured

  • Allocated disk blocks (blocks × 512), not apparent size, so sparse files report what they actually occupy.
  • Symlinks are never followed; hardlinked files are counted once per scan.
  • Unreadable entries are skipped and counted, never fatal.
  • Directories are walked concurrently (bounded semaphore), and a scan visits at most 500,000 entries — past that it stops descending and flags the result as truncated, with the budget spread across the tree instead of exhausted depth-first.

Testing

  • 7 unit tests via createFakePluginHost covering recursive sizes, cache/refresh semantics, concurrent-scan dedupe, realtime progress signals, and CLI output (human, cached, JSON, and error paths).
  • pnpm run validate, typecheck, lint, fmt:check, and bb plugin build all pass.
  • Exercised live: installed as a path plugin, verified the panel (cached instant load, live progress card, drill-down) and the CLI against a real ~500k-entry home directory.

Not yet listed in marketplace.json — that needs a disk-usage/v0.1.0 release tag, which can follow once this merges.

@charpeni
charpeni merged commit d164063 into main Aug 17, 2026
7 checks passed
@charpeni
charpeni deleted the bb/prototype-disk-usage-plugin-thr_74hy2ta7kp branch August 17, 2026 23:03
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.

1 participant