Skip to content

feat(usage): let the reset timers hide their no-data placeholders - #542

Draft
zachthedev wants to merge 2 commits into
sirmalloc:mainfrom
zachthedev:feat-reset-timer-hide
Draft

feat(usage): let the reset timers hide their no-data placeholders#542
zachthedev wants to merge 2 commits into
sirmalloc:mainfrom
zachthedev:feat-reset-timer-hide

Conversation

@zachthedev

Copy link
Copy Markdown
Contributor

Closes #541.

Stacked on #430, so this targets main and the diff below includes that PR
until it merges. The commit to review here is just the last one,
feat(usage): let the reset timers hide their no-data placeholders, which is 8
files. I will retarget once #430 lands.

Block Reset Timer and Weekly Reset Timer rendered [Loading] and the
[No credentials] family with no way to turn either off, while the usage
percentage widgets answer the same condition with a hide state. Both now declare
USAGE_NO_DATA_HIDEABLE_STATE and gate the whole no-window branch on it, so one
state covers the loading placeholder and the error text together. It is opt-in,
so nothing changes for anyone who does not enable it.

aae5add is what widened this: it replaced a return null with a persistent
placeholder, leaving no way back to the self-hiding behavior.

Two keybinds move off h, which the shared hide checklist claims:

Widget Was Now
Weekly Reset Timer h hours only o (o)nly hours
both, via usage-display h 12/24 hour f 12/24 (f)ormat

The second one is forced rather than cosmetic, and it is the part worth a look.
HOUR_FORMAT_TOGGLE_KEYBIND is offered in date mode only, so an item-free
getCustomKeybinds() call never sees it. Without the move, h in date mode
would toggle 12/24 instead of opening the checklist, making the state this PR
adds unreachable in that mode on exactly the two widgets it adds it to. Only
these two widgets pass includeHourFormat, so nothing else is affected.

That gap was invisible to the reservation test in #430, which called
getCustomKeybinds() with no item and therefore only ever saw one branch. It now
probes the display-mode metadata the usage and timer widgets branch on. Putting
the toggle back on h fails it, which is how I found the collision.

o and f were free against everything those widgets can offer (p, v, s,
t, w, z, l) and against the editor's own binds (a, c, d, i, k,
m, r).

Tested: bun run lint clean; bun test 2072 pass, plus the one
global-command-resolution failure main already has on this host.

zachthedev and others added 2 commits August 5, 2026 19:25
Implements the unified hideable-state system proposed in sirmalloc#428.

- Add src/widgets/shared/hideable.ts: widgets declare hideable conditions
  via getHideableStates(); a single metadata.hide key stores enabled state
  keys as a comma-separated list; isHidden() replaces the nine per-widget
  accessors (hideNoGit, hideNoJj, hideNoRemote, hideZero, hideWhenEmpty,
  hideIfDisabled, hideStatus/hideTitle, hideWhenNotFork)
- Convert existing configs through the standard settings migration
  (v3 -> v4): legacy boolean flags map to the states each widget type
  actually hid, so existing configs render identically; default-enabled
  states are folded into written lists to preserve behavior
- Replace per-widget hide toggles with one (h)ide… keybind that opens a
  shared checklist editor (HideStatesEditor); the items editor injects the
  keybind for any widget declaring states and shows enabled states as
  (hide: no-git, zero); 'h' is reserved for this purpose, enforced by a
  registry-wide test
- Add previously missing hide options: zero for token/session-cost/
  session-clock widgets and for the git count widgets (changes,
  insertions, deletions, staged/unstaged/untracked files, conflicts),
  no-data for speed widgets, Block Timer, and the usage widgets' error
  placeholders, default-value for Output Style, and a separate no-data
  state for Git PR
- Git Ahead/Behind's hardcoded 0/0 auto-hide becomes a declared
  default-enabled zero state, so it can now be opted out to show ↑0↓0
- Decorative custom-text/custom-symbol items can opt into
  merge-target-hidden: the renderer collapses them when the widget they
  are merged with renders nothing, so icon prefixes no longer orphan
- Remove the dead top-level hide field from WidgetItemSchema
- Remove shared/git-no-git.ts; slim shared/git-remote.ts and
  shared/extra-usage-disabled.ts to their remaining responsibilities
- Update docs/USAGE.md and tests; add coverage for the hideable module,
  the v3 -> v4 migration, the renderer merge-target pass, and all newly
  hideable states

Co-authored-by: Claude <noreply@anthropic.com>
Block Reset Timer and Weekly Reset Timer rendered [Loading] and the usage
error placeholders with no way to turn either off, while the usage
percentage widgets answer the same condition with a hideable state. Both
now declare USAGE_NO_DATA_HIDEABLE_STATE and gate the whole no-window
branch on it. The state is opt-in, so the default display is unchanged.

aae5add is what widened this: it replaced a return null with a persistent
placeholder, leaving no way back to the self-hiding behavior.

Two keybinds move off 'h', which the shared hide checklist claims:

- Weekly Reset Timer's '(h)ours only' becomes '(o)nly hours'
- the shared '12/24 (h)our' toggle becomes '12/24 (f)ormat'

The second is forced rather than cosmetic. It is offered in date mode
only, so without the move the hide checklist would be unreachable there
on exactly the two widgets this change gives a hide state to. Only these
two widgets pass includeHourFormat, so nothing else is affected.

The reservation test only called getCustomKeybinds() with no item, which
sees one branch and cannot observe a mode-dependent bind. It now probes
the display-mode metadata the usage and timer widgets branch on.
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.

Reset timer [Loading] and usage-error placeholders cannot be hidden

1 participant