feat(usage): let the reset timers hide their no-data placeholders - #542
Draft
zachthedev wants to merge 2 commits into
Draft
feat(usage): let the reset timers hide their no-data placeholders#542zachthedev wants to merge 2 commits into
zachthedev wants to merge 2 commits into
Conversation
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.
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.
Closes #541.
Stacked on #430, so this targets
mainand the diff below includes that PRuntil 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 8files. 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 usagepercentage widgets answer the same condition with a hide state. Both now declare
USAGE_NO_DATA_HIDEABLE_STATEand gate the whole no-window branch on it, so onestate 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 nullwith a persistentplaceholder, leaving no way back to the self-hiding behavior.
Two keybinds move off
h, which the shared hide checklist claims:hhours onlyo(o)nly hoursusage-displayh12/24 hourf12/24 (f)ormatThe second one is forced rather than cosmetic, and it is the part worth a look.
HOUR_FORMAT_TOGGLE_KEYBINDis offered in date mode only, so an item-freegetCustomKeybinds()call never sees it. Without the move,hin date modewould 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 nowprobes the display-mode metadata the usage and timer widgets branch on. Putting
the toggle back on
hfails it, which is how I found the collision.oandfwere 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 lintclean;bun test2072 pass, plus the oneglobal-command-resolutionfailuremainalready has on this host.