feat: unify widget hiding into a single hideable-state system
Closes #428 (my proposal from earlier today; happy to rework or split).
Nine per-widget hide keys (hideNoGit, hideNoJj, hideNoRemote, hideZero, hideWhenEmpty, hideIfDisabled, hideStatus, hideTitle, hideWhenNotFork) become one mechanism: widgets declare conditions via an optional getHideableStates(), enabled states live in metadata.hide as a comma-separated list, and a shared (h)ide… keybind opens a checklist for the selected widget.
Diff guide (116 files): ~55 widget files are the same mechanical conversion; most test changes are one-line key swaps.
| Group | Files | What changed |
|---|---|---|
| Core | shared/hideable.ts (new), types/Widget.ts |
state declarations + isHidden/get/set (~95 lines) |
| Migration | utils/migrations.ts, types/Settings.ts |
v3 -> v4 converts legacy keys per widget type (hideNoGit also covered (no upstream) on Ahead/Behind and the no-PR placeholder on Git PR; on-disk git-pr alias handled); one test per mapping |
| TUI | HideStatesEditor.tsx (new), items-editor wiring |
one injected h keybind opens the checklist |
| Renderer | utils/renderer.ts |
merge-target-hidden pass: decorative custom-text/symbol items collapse with their merge target |
| Widgets | ~55 files | drop the bespoke toggle, declare states, call isHidden() |
| Tests | ~42 files | new: hideable/migration/renderer suites; existing: one-line key swaps |
| Docs | USAGE.md, AGENTS.md |
new "Hiding Widgets Conditionally" section |
Behavior:
- Existing configs render identically after migration
- Ahead/Behind's hardcoded 0/0 auto-hide becomes a default-enabled
zerostate, now opt-out-able - New opt-in states:
zero(token widgets, session cost/clock, git counters),no-data(speed widgets, Block Timer, usage widgets'[No credentials]-style errors),default-value(Output Style) - Reset timers are excluded from
no-data: they bindhfor the hour toggle; a registry test enforces thehreservation - Instant
htoggles become a checklist (Space toggle, Enter save) - Downgrade: older versions ignore
metadata.hide, so hidden placeholders reappear until upgrading back (in USAGE.md) - Dropped the dead
hide: z.boolean()fromWidgetItemSchema; noupdatemessageadded since rendering is unchanged
Open question: stock Ahead/Behind items now show (hide: zero) in the editor since defaults are surfaced honestly. Want default-enabled states suppressed from that annotation?
Happy to split (core conversion / new states / renderer pass) in whatever order you prefer.
Rebased onto current main. Since this PR opened, #431 (symbol override) and #417/#418 (extra-usage currency) merged, so the shared Git/JJ widgets now carry both their symbol-override changes and this PR's hideable conversion. The conversion was also extended to widgets that landed on main after this PR opened, so the unification stays complete:
- Cache Hit Rate / Cache Read / Cache Write: the
hideWhenEmptyoption becomes theemptyhideable state (the separate turn/session scope toggle is unchanged). - Extra Usage Used: the
hideIfDisabledoption becomes thedisabledhideable state, matching Extra Usage Remaining / Utilization. migrations.tsgains matchingcache-read/cache-write/cache-hit-rate/extra-usage-usedrules so existing configs migrate cleanly.
Tested: bun run lint clean; bun test green except the same Windows-environment failures main has; exercised against my real config inside and outside repos.
Note: #347 (rules engine) reuses the hide: z.boolean() field this PR removes and adds rule-based hiding; if that lands first I'll rebase the schema change and align the hide semantics with it.
@zachthedev Can you go ahead and rebase this on main and resolve any issues?
@zachthedev Can you go ahead and rebase this on main and resolve any issues?
Will do sometime in the next 24 hours
Rebased onto main, conflicts resolved. #431 had merged into the same Git/JJ widgets, so they now carry both symbol-override and hideable; also extended the conversion to the Cache and Extra Usage Used widgets that landed since, with v3 -> v4 migration. lint clean; bun test green bar the pre-existing Windows-env failures. Ready for review.
Merge-order note: #457 (Closes #450) also touches CompactionCounter hide-zero. It adds per-metric hide-zero on hideZero; this PR migrates hideZero to the unified system. Whichever merges second needs a small reconcile; if #457 lands first, this PR's conversion must also cover the metric mode.
@zachthedev Can you go ahead and rebase this on main and resolve any issues?
Ready for review. Thanks much!