Repository navigation
feat(usage): Block Reset Timer can hide until the 5-hour block hits 100% - #71
Closed
eric-engberg wants to merge 68 commits into
Closed
eric-engberg wants to merge 68 commits into
eric-engberg wants to merge 68 commits into
Conversation
…, save guard return) (sirmalloc#689) * fix(tui): let m clear a merge left on the last widget The merge toggle was guarded to widgets with another widget after them, because the last one has nothing to merge into. But a widget can become last with its merge still set: merge Git Branch into the widget after it, then delete that widget. Git Branch still shows "(merged→)", m does nothing, and "(m)erge" is gone from the help line, so the flag can't be cleared. The next widget added after it then merges into it silently (`⎇ mainModel: Claude` in the preview). On the last widget, m now clears a merge that is set, and the help line offers it there. It still can't set a merge on the last widget, and the merged, merged-without-padding and off cycle is unchanged elsewhere. * fix(tui): keep the other items in order when a move wraps Move mode wraps past either end of the list, but it did so by swapping the moved item with the one at the other end. Moving Model up from the top of Model, Context Length, Git Branch, Git Changes gave Git Changes, Context Length, Git Branch, Model: Model reached the bottom, but Git Changes jumped from the bottom to the top. The line selector's move mode did the same with whole lines. Both move modes now take the item out and put it back in at the target, so wrapping past either end moves only that item and the rest keep their order. A move to a neighbour is still a swap. * fix(tui): return to the current screen from the invalid-settings save guard When settings.json is invalid, Ctrl+S first asks before overwriting it. The question can come up on any screen, but both answers went to the main menu: with Edit Line 1 open, Ctrl+S then ESC (or Yes) left the line editor, and you had to navigate back in to carry on. The guard now returns to the screen Ctrl+S was pressed on, for both answers. Save & Exit, the other route into the guard, starts from the main menu and still returns there. The screen comes back as it does when you navigate to it: a sub-editor that was open on it, such as the label editor, and its unsaved text aren't restored. * test(tui): put chalk's color level back after a whole-App test The App sets chalk's global color level from the settings it loads, and the whole-App test helper didn't restore it. Test files that run later in the same process then rendered at that level instead of their own: a No Color check could see 256-color codes. The sandbox now restores the level along with the mocks and the config path.
…ers (sirmalloc#688) * fix(jj-bookmarks): keep bookmarks on different heads apart JJ Bookmarks lists the bookmarks of heads(::@ & bookmarks()) with the template "bookmarks". jj log --no-graph prints each commit's template output back to back with nothing in between, so when @ sits on a merge of two bookmarked heads the names ran together: "feature-afeature-b". The template now ends each head's output with a newline, which the whitespace split already handles; bookmarks on one commit were always space-separated and still are. * fix(speed): switch to "k" at the rounding boundary formatSpeed switched to "k" at exactly 1000 t/s, but values just below round up when shown: 999.96 t/s rendered as "1000.0 t/s" instead of "1.0k t/s" (and 999.6 as "1000 t/s" with whole numbers). It now switches once the value would round to 1000 at the shown precision, 1000 - 0.5 / 10^decimals, the same boundary formatTokens uses for "M". * fix(usage): show "time cursor" only on widgets that draw one The time cursor is a usage bar setting (cursor metadata), and the widget picker keeps metadata when it changes a widget's type. After changing a usage bar with the cursor on to Block Timer, Block Reset Timer or Extra Usage Utilization, the editor row said "time cursor", though those widgets never draw one and have no key to turn it off. The modifier text now lists the cursor only for widgets that ask for it, as it already does for compact and date: the usage percent widgets, which draw it. The metadata itself is left alone, so changing back to a usage bar keeps the setting. * refactor(jj-bookmarks): write the template as a raw string String.raw shows the template exactly as jj reads it, "\n" included, instead of a doubled backslash. * test(usage): check only that a carried-over cursor isn't shown The three time-cursor tests compared the whole modifier text, so they'd also break on any change to how the bar mode itself is described. They now check the part they're about: the bar mode still shows, and the time cursor doesn't.
…fter its resets (sirmalloc#687) * fix(renderer): keep a preserve-colors widget's Powerline background after its resets In Powerline mode a widget that preserves its own colors (a Custom Command with preserve colors on) gets its segment background once, before its text. Command output usually ends with \x1b[0m, and Custom Command appends one after cutting colored output to its max width; that reset cleared the background too, so the trailing padding, and any text after a reset mid-output, showed the terminal's background before the separator arrow: \x1b[48;5;26m \x1b[31mhello\x1b[0m \x1b[0m<arrow> Re-apply the segment background after each SGR sequence in the preserved text that clears it: a full reset (0 or an empty parameter, alone or combined like 0;32) or 49. The arguments of extended colors (38/48/58;5;n and ;2;r;g;b) are skipped, so a 0 or 49 among them isn't read as a reset. The command's own colors, including its own backgrounds, are kept, and the full reset after the widget is unchanged. Widgets without a background, and plain mode (which colors the padding separately), are untouched. * fix(renderer): honor backgrounds set after resets in combined SGR codes Powerline widgets with preserveColors enabled restored the segment background whenever an SGR sequence contained a reset. For output such as ESC[0;41m, that restoration overwrote the explicit red background set later in the same sequence. Indexed and truecolor backgrounds were also affected. Process all SGR parameters in order and track the final background operation. Restore the segment background only when the sequence leaves it cleared; preserve standard, bright, indexed, and truecolor backgrounds set after a reset. Continue skipping extended color arguments so channel values such as 0 and 49 are not interpreted as background operations. Add parameterized helper and Powerline renderer regression coverage for reset-before-color and color-before-reset ordering, empty reset parameters, extended color arguments, and restoration after a subsequent reset. Confirmed 16 new cases fail before the fix. Validation: - bun test: 2811 passed, 0 failed - Targeted ANSI and Powerline tests: 63 passed, 0 failed - bun run lint: TypeScript and ESLint passed - git diff --check passed --------- Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
…loc#686) * fix(colors): stop number keys from leaving Edit Colors ink-select-input selects the item at a digit key's position, the same as Enter on it. Edit Colors ignored digits in its own key handler, but its list still passed them to onSelect, and choosing the Back entry there called onBack. So on a line with two colorable widgets, pressing 3 left the screen; with eight, 9 did. Edit Colors now handles Enter on Back itself and gives the list no onSelect, so digits do nothing, as the handler already intended. Enter on a widget still does nothing, and Enter on Back and ESC still go back. * fix(colors): keep a live highlight when hiding separators With separators shown in Edit Colors, highlighting one and pressing s again hid it but left the highlight pointing at it. The list redrew with the marker on the first item, but every key that acts on the highlighted item looked up the hidden separator and found nothing: b, d, r and left/right did nothing, a color entered after a, h or g was dropped, and the "Current foreground" line went blank. When hiding separators takes away the highlighted one, the highlight now moves to the first widget, where the list already draws the marker. Showing separators, or hiding them while a widget is highlighted, keeps the highlight where it was.
…ry segment count (sirmalloc#685) With abbreviate-home on, the leading "~" counted as one of the kept segments. ~/a/b with segments=2 had three parts, so it rendered "~/.../a/b" though nothing was left out; /a/b with segments=2 renders "/a/b". The "~" is always kept in front, so it no longer counts. The preview was a set of fixed strings for one or two segments, so segments=3 or 4 still previewed two (".../example/project"), and those strings didn't come from the sample path itself. The preview now runs the same segment logic over the sample path that a real path goes through, so it shows what the setting produces.
…rmalloc#684) The status payload schema accepted null for context_window, effort, vim, worktree and rate_limits, but not for version, cost, workspace or output_style. A payload with any of those four set to null failed validation as a whole: the CLI printed "Invalid status JSON format" and exited 1, so no status line rendered, even when no widget on the line reads that field. Mark the four fields nullable like the others. Every reader already goes through optional chaining or a truthiness check (Version, Session Cost, Session Clock, Output Style, and the git and Claude settings lookups that fall back from workspace to cwd), so a null field renders the same as a missing one. Wrong types are still rejected.
…e-dated usage cache (sirmalloc#683) * fix(usage): time out keychain reads and back off when no login is found On macOS the usage credentials come from `security find-generic-password` and, for the default profile on a miss, `security dump-keychain`. Neither call had a timeout, so a `security` that blocks (for example on a keychain unlock prompt) held the whole status line until someone answered it. With a fake `security` that sleeps 12s, every render took 24s. Both calls now time out after 5s, like the git and usage API calls. A lookup that finds no OAuth login was also repeated on every render: an API-key user with a usage widget has nothing to cache, so each render ran both `security` calls, the full keychain dump included. The miss is now remembered for 30s across renders (as it already was within one process), in ~/.cache/ccstatusline/usage-credentials.lock. The record names the credential stores it covers (the keychain service and config directory), so one profile's miss never suppresses another profile's lookup. As with the usage lock, a deadline further ahead than the backoff itself is ignored, so a clock set back cannot stretch it. With the same fake `security`, the first render now takes 10s and the next ones inside the backoff about 0.2s. * fix(usage): stop counting a usage cache dated in the future as fresh The file cache is fresh while `now - mtime` is under 180s. For a file modified in the future that age is negative, so it always passed. After one render under a clock running ahead (since corrected, e.g. by NTP or a VM resume), the cached usage stayed on screen with no refetch until real time passed that mtime plus three minutes: a clock a day fast froze the usage widgets for a day. A file dated ahead of now now counts as fresh only within one cache lifetime. That still covers a concurrent render writing the file just after this one read the clock; anything further ahead cannot be right and is refetched. The usage lock already ignores deadlines too far ahead for the same reason. * fix(terminal): report no width instead of tput's default of 80 When the ancestor walk finds no terminal, the probe fell back to `tput cols`. That runs with piped stdio, so tput cannot see a terminal either: it prints $COLUMNS if exported, otherwise the terminfo default for $TERM, which is 80. So with no terminal found and TERM set, the status line was truncated at 74 columns in full-width mode (40 in full-minus-40) however wide the real terminal was, and flex separators padded to that made-up width. It also meant the probe never returned null in that case, so the per-session "no TTY" cache was never written and the whole `ps` ancestor walk re-ran on every render. The fallback is gone. With no terminal found the probe returns null, which the renderer already handles: no truncation, and flex separators render as plain separators. That result is now cached per session as intended. CCSTATUSLINE_WIDTH still overrides detection for anyone who wants a fixed width.
) Edit Colors' (r)eset and (c)lear all removed each widget's numberFormat along with its colors, bold and dim. Precision used to be cycled from Edit Colors, but it moved to Edit Lines (the `.` key), and the reset paths kept clearing it. So resetting a widget's colors silently undid its number style: a Context Length set to whole numbers went from `Ctx: 19k` back to `Ctx: 18.6k`, though neither the key help nor the clear-all confirmation mentions anything but colors. Reset and clear all now remove only color, background, bold and dim.
…it (sirmalloc#681) * fix(tui): keep the TUI usable after updating the pinned install from it Running a global update from Check for Updates records the new version as the pinned install. On the next render the TUI, still the older version, saw a pinned install newer than itself and replaced everything with the "Pinned Install Version Mismatch" screen, whose only option is Exit. Ctrl+S is a no-op on that screen, so any edits made before the update were lost. That screen exists so a TUI doesn't write settings for a pinned runtime of a different version. Here, though, the settings being edited were loaded before the update, so saving them afterwards is the same as saving a moment earlier. The TUI now remembers the version its own update installed and doesn't treat that version as a mismatch for the rest of the session, so the menus and both save paths stay available. A fresh launch of the older TUI still gets the mismatch screen. * test(tui): put chalk's color level back after a whole-App test The App sets chalk's global color level from the settings it loads, and the whole-App test helper didn't restore it. Test files that run later in the same process then rendered at that level instead of their own: a No Color check could see 256-color codes. The sandbox now restores the level along with the mocks and the config path. --------- Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
… as v1 (sirmalloc#680) loadSettings treats a file as v1 only when it has no `version` key, but needsMigration/detectVersion treat any `version` that isn't a number as v1. A current config with `"version": "4"` or `"version": null` (after a hand edit, for example) therefore skipped v1 validation and then ran the v1->v2 migration anyway. That migration rebuilds the config from `lines` and the v1 fields only, so the result validated and was written back over the file: Powerline, defaultPaddingSide, minimalistMode, separators and every other v2+ setting were dropped, widget ids were regenerated, and the status line announced "ccstatusline updated to v2.0.2". needsMigration now reports no migration for a version that is present but not a number. The config then reaches schema validation, which rejects it, so it takes the existing invalid-file path: defaults in memory, the load error recorded for the warning badge and TUI banner, and the file left untouched. Import validation shares needsMigration, so an import file with a non-numeric version is now rejected instead of being reduced to its v1 fields.
…nd wide PR titles (sirmalloc#679) * fix(git-branch): show detached HEADs and branches shadowed by a tag On a detached HEAD (a tag checkout, a rebase in progress, a bisect), `git symbolic-ref` fails, so Git Branch showed "no git" (or hid itself with hide-no-git) inside a perfectly good work tree. It now shows the short commit in parentheses, as git prompts do, e.g. "⎇ (0449a12)", and the repo link points at that commit. When a tag has the same name as the current branch, `symbolic-ref --short` disambiguates the name to "heads/<branch>", so the widget showed "⎇ heads/release" and linked to .../tree/heads/release. It now reads the full ref and strips "refs/heads/", which is always the plain branch name. * fix(git-worktree): recognize the main worktree in submodules and separate git dirs Git Worktree decided "main worktree" by the git dir's path: ".git" at the end, else a ".../worktrees/<name>" pattern. A submodule's git dir is .git/modules/<name> and a --separate-git-dir repo's is wherever it was put (e.g. /x/repo.git), so both showed "no git". The path pattern could also misread a repo kept under a directory named "worktrees". It now asks git for both the git dir and the common dir in one call. A linked worktree's git dir is always <common dir>/worktrees/<name>; any other git dir belongs to the main worktree. * fix(git-pr): truncate titles by display width and whole characters PR titles were cut with title.slice(0, 29), counting UTF-16 code units. An emoji at the cut lost its second half and showed as U+FFFD ("�"), and a CJK title passed the 30-unit limit while taking 59 columns, since each character is two columns wide. Truncation now goes through the same display-cluster and width logic the renderer uses for max widths, keeping the 30-column limit and the single "…" ellipsis. * refactor(git-worktree): swap path separators with replaceAll A plain replaceAll says what the line does without a global regex. * fix(git): preserve Node.js 14 worktree path normalization --------- Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
…rs at No Color (sirmalloc#678) * fix(renderer): keep truncating when the reserved width leaves no columns Full minus 40, and Full until compact past its threshold, subtract 40 columns from the terminal width; Full subtracts 6. On a narrow terminal that went to 0 or below, and every width check treated a non-positive width as "no width detected": the line printed at full length and wrapped, while 41 columns still truncated to a single ".". The TUI preview cut the line at the terminal edge instead, so it no longer matched what Claude Code received. Clamp the effective width at 0 and treat any detected width, 0 included, as known, in both the plain and Powerline renderers. When the reserve takes the whole terminal the line now truncates to nothing, the continuation of what 41-43 columns already show. An undetected width (null, or 0 from the caller) keeps the fallback behavior. * fix(renderer): stop reading widget text FLEX as a flex separator The plain renderer stood each flex separator in the assembled line as the string 'FLEX' and later split the line on that string. A widget whose rendered text was exactly FLEX with no color codes around it (No Color mode, or a color name the palette doesn't have) matched too: its text vanished and the line got a second flex gap. Push null for a flex separator instead, which no widget output can equal. Powerline mode already uses its own marker and is unchanged. * fix(colors): emit no 256-color or truecolor escapes at Basic and No Color getColorAnsiCode returned raw 256-color and truecolor escapes for hex: and ansi256: colors at every color level. With No Color selected, which the TUI describes as disabling all color output, a widget colored hex:FF0000 on hex:0000FF still printed \x1b[48;2;0;0;255m\x1b[38;2;255;0;0m; Basic did the same. Return no code for these formats at the ansi16 level (Basic and No Color), as the function already does for gradient specs. This matches the TUI, which only offers these formats at 256 Color and Truecolor and clears them from widgets when switching to Basic or No Color, so they only reach these modes through a hand-edited config. Named colors are unchanged. * refactor(renderer): flatten the no-width flex fallback branch The else branch re-checked terminalWidth === null, which the preceding condition (a flex separator and a known width) already implies when a flex separator is present. Chain it as else-if on hasFlexSeparator instead of nesting an if/else inside the else. * test(custom-command): start each runtime once before its capture tests On a fresh CI machine the first start of a runtime can take seconds while its binary is read from a cold disk. The capture tests start Node for the first time in their opening case, so that case once ran past its 5s limit (5018 ms) while the same case one test later took 146 ms and the rest about 60 ms. Each runtime now starts once in a setup hook with its own timeout, before the timed tests.
…c#677) Customizing a Powerline theme (c in the theme list) copied the theme's colors onto the widgets by counting every widget in a line, restarting at the first color on each line. The renderer counts differently: a widget merged into the next one shares that group's color, and with Continue Theme on, each line picks up where the previous one stopped. So the copy could differ from what the theme had just shown. With Model merged into Context Length, the pair shared one background under the theme, but the copy gave Context Length the next color and shifted every widget after it; with Continue Theme on, every line after the first restarted at the first color. Number the widgets with the same slot rule the renderer uses to carry the theme across lines, now shared from powerline-theme-index, and continue the numbering across lines when Continue Theme is on. Lines without merges and with Continue Theme off get the same colors as before.
…s too (sirmalloc#670) * feat: label Extra Usage as spend on accounts without plan limits On usage-based plans (Claude Enterprise) the usage API reports every rate-limit window as null and no limits[] entries: there's no plan limit to go over, and extra usage is the account's whole spend. The Extra Usage widgets still called it overage ("Overage Used: $123.45"), and their picker descriptions only mentioned pay-as-you-go overage, so Enterprise users had no reason to think these widgets were theirs. Searching the picker for "enterprise" or "spend" didn't find them. The parser now flags a response that explicitly reports no plan limits (`noPlanLimits`). The flag is kept in the usage cache and through the merge with statusline rate_limits, and the three widgets label their value "Spend Used", "Spend Left" and "Spend" when it's set. Only an explicit null counts and any limits[] entry counts as a limit, so every uncertain case keeps the "Overage" label. A cache written before this change keeps the old label until its next refresh. The widget descriptions now mention both Pro/Max overage and Enterprise spend, which also makes the picker's search find them. * test: cover the Spend label with an edited label Upstream's label editor (sirmalloc#601) gives each widget one default label, while Extra Usage Used, Remaining and Utilization pick "Overage" or "Spend" by account. The editor offers the Overage label, since it has no usage data, and an edited label replaces whichever one the account would show. * refactor: keep the Enterprise wording, drop the Spend label detection With the label editor (sirmalloc#601) in main, anyone on a usage-based Enterprise plan can relabel the Extra Usage widgets' "Overage" to "Spend" in a few keys, so detecting those accounts from the usage API's response shape isn't worth its cache field and heuristics. What stays is the wording: the three widgets' descriptions say they cover Pro/Max overage and Enterprise spend, the docs say the same and point at the label editor, and picker searches for "enterprise" or "spend" list the three widgets first, which a new test checks. * test: check the picker lists the Extra Usage widgets first, however many there are * test: look for the Extra Usage widgets among the widgets that mention the word * refactor(widgets): share Extra Usage Used and Remaining's code The two widgets were the same class apart from how the amount is worked out, and their label, name, description and preview sample. They now extend ExtraUsageAmountWidget, the way the Tokens widgets share TokenCountWidget. Rendering is unchanged.
…rmalloc#668) Until the first extra-usage charge of the month, the usage API reports `utilization: null` alongside the monthly limit and the amount spent ($0). The widget treated the missing utilization as no data and rendered nothing, so it looked broken on every account with extra usage enabled until the first charge. When the API reports no utilization, work it out from the amount spent and the monthly limit. An API-reported value still wins, and accounts without a monthly limit render nothing, as before. Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
…malloc#673) The separator editor wrote `separatorInvertBackground[i]` straight into a copy of the saved list. That list is often shorter than the separators: its schema default is `[false]`, and hand-edited or imported configs commonly add separators without extending it. Toggling (t) or cycling (left/right) a separator past the end of the list left holes in the array, which JSON saves as `null`. With three separators and the default list, selecting the third and pressing `t` saved `[false, null, true]`; the next load failed validation, so both the TUI and the status line fell back to defaults with the invalid-config warning. Pad the list to one entry per separator, defaulting to false, before any edit. Missing entries already rendered as not inverted, so nothing changes visually; add, insert and delete now also work on aligned entries.
* feat(tui): edit a widget's label with e The label editor opened with b (la(b)el…). Custom Text, Custom Command, Custom Symbol and Link already open their text editors with e, so the line editor's "edit this widget's text" key differed by widget. Labels now use e too, shown as (e)dit label…, which also reads more plainly. None of the widgets that bind e has a label, so e is free wherever the label editor appears; the existing check that labeled widgets leave the label key unbound now runs against e. * docs: name the e key where the label editor hides in raw value mode The label key moved to e, but one sentence still said b is hidden while raw value is on.
…alloc#667) * fix: show the max width in Git Branch and Git Root Dir previews (w) caps how wide the branch or repository name gets, but the TUI preview returned its sample before applying the cap, and the samples (`main`, `my-repo`) were too short to cut anyway. With a cap set, the previews now use a longer sample and cut it the way the status line cuts a real name, so the setting shows as you make it. * refactor: move Git Branch's preview into its own method render() had grown a preview branch with its own sample, width and link handling; it reads more easily on its own.
…#669) * fix(tui): ignore letter shortcuts when ctrl or alt is held Letter shortcuts compared the typed character without checking modifiers, so ctrl+letter and alt+letter ran the plain-letter action: ctrl+r toggled raw value, ctrl+d deleted a widget, and on macOS alt+arrow (sent as ESC + letter) fired whatever letter followed. A few handlers patched ctrl+s one key at a time with `&& !key.ctrl`; widget keybinds checked ctrl but not alt. Shortcuts now compare against getPlainInput(), which is empty while ctrl or alt/option is held, across the line editor, widget keybinds, Edit Colors, Global Overrides, Powerline setup/themes/separators, the line selector and the hide-state checklist. Arrows, Enter, ESC, shift and text entry are unchanged, and modifier combos are free for bindings of their own. * test(tui): wait for each shortcut's effect instead of a fixed delay The shortcut tests sent keys and checked the result after a fixed 25 ms. On a busy machine Ink can take longer, so the bare-key cases could fail even though the shortcut works. They now wait until the shortcut's effect shows (up to 3 s), and a follow-up key waits for the previous key's redraw. Checks that a modified key does nothing give it 150 ms to act. After each wait the test also gives React two setImmediate turns: React draws a frame, then attaches the new input listener in a scheduled effect, so a key sent the moment the frame shows could reach no listener. --------- Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
…rmalloc#674) Saving settings with a hook-enabled widget (Skills) syncs Claude Code hooks that run `<statusLine.command> --hook`. That happened whatever the status line command was. With ccstatusline configured but another tool installed as the status line (for example `bash ~/.claude/statusline.sh`), every ctrl+s or Save & Exit added PreToolUse(Skill) and UserPromptSubmit hooks running that script with `--hook`. The script then ran on every prompt and Skill call, and Claude Code adds UserPromptSubmit output to the conversation, so whatever it printed reached the model. Hooks are now added only when the status line command contains `ccstatusline`, the same test the legacy-hook cleanup already uses to recognize ccstatusline hook commands. npx/bunx with any version, a global or absolute-path binary, a local ccstatusline.ts checkout and shell-wrapped commands keep their hooks. For any other command the sync only removes ccstatusline-managed entries, which also cleans up hooks an earlier save pointed at another tool's script.
…ine (sirmalloc#675) * fix(jsonl): stop the reverse reader looping on a chunk's leading newline iterateJsonlLinesReverseSync walks each chunk backwards with chunk.lastIndexOf(0x0a, end - 1). When the newline it just consumed sat at index 0, end became 0 and the next search ran with an offset of -1, which Buffer.lastIndexOf counts from the end of the buffer. The reader jumped back to the chunk's last newline and yielded the same lines again, forever. That happens whenever a transcript starts with an empty line, or when the byte at size - k * 1 MiB is a newline. Thinking Effort falls back to this reader when the payload's effort.level is present but not a level it accepts (for example ""), so a matching transcript kept the status line spinning at full CPU and never printing. Stop searching once end reaches the start of the chunk. * refactor(jsonl): route both reverse newline searches through one helper The reverse reader searched for the previous newline in two places, and only the one inside the loop needed the guard against an offset of -1. lastNewlineBefore() holds the guard and the reason for it, so both searches behave the same and the loop body stays as simple as it was before the fix.
…sirmalloc#676) * fix(tui): hold install and update screens until their action finishes Confirming an install, uninstall or global update started its async action and left the Yes/No dialog live. A second Enter started the same action again, so `npm install -g` ran twice at once and both runs went on to write Claude's settings.json. ESC returned to the previous menu while the action kept running, and when it finished it jumped the TUI to the main menu (or the Install Complete notice) from wherever the user had gone. The pinned version mismatch screen's "Update npm global install" item had the same problem. App now runs these actions one at a time. While one runs, the confirm dialog and the mismatch screen show a working line in place of their options and ignore ESC; a ref blocks a second start even before that screen re-renders. When the action settles, its own navigation takes over as before, including the failure paths. * test(tui): share the whole-App render harness Move the scratch config, probe stubs and Ink rendering used by the App tests into helpers/render-app.ts, next to wait-for-ink.ts, so other tests that drive the whole TUI can use the same setup. * test(tui): put chalk's color level back after a whole-App test The App sets chalk's global color level from the settings it loads, and the whole-App test helper didn't restore it. Test files that run later in the same process then rendered at that level instead of their own: a No Color check could see 256-color codes. The sandbox now restores the level along with the mocks and the config path. --------- Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
* feat: add an Extra Usage Daily Budget widget With a monthly extra usage limit, the useful number during a day is how much can still be spent per day without running out before the limit resets. Extra Usage Daily Budget shows what's left of the monthly limit divided by the days left in the month, today included, so it rises on light days and falls on heavy ones. Monthly limits reset at 00:00 UTC on the 1st, so days are UTC days. A `w` keybind switches to counting weekdays only (Saturday and Sunday in UTC); today always counts, even a weekend day, so the budget never divides by zero. Once the limit is used up it shows $0.00; without a monthly limit it shows nothing, like Extra Usage Remaining. * fix: enable daily budget label editing --------- Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
* feat: add a Session Cost Rate widget Session Cost shows what a session has cost so far, but not how fast it's spending. Session Cost Rate divides the session cost by time, the agent's hourly rate: `Rate: $5.00/hr`. By default it divides by the time Claude spent working (the API duration Claude Code reports), which reads as the rate for the hours it actually worked. A `t` keybind switches to clock time, the whole session including time spent waiting for the user, which reads as the burn rate. It shows nothing until a full minute of the chosen time has passed, since a rate over the first seconds swings wildly. * fix: enable session cost rate label editing --------- Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
Disable fsmonitor and implicit bare-repository discovery for status-line Git calls. Override untrusted repository-local filters for status and diff, disable external diff and textconv, and ignore dirty submodule contents. Pass the base protections to Git invoked through gh and glab. Preserve user/system filters and supported Git LFS and git-crypt commands. Implicit bare-repository protection requires Git 2.38 or newer. Security advisory: GHSA-rf4f-gc2h-c9vp Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
Resolve git, gh, glab, ssh, jj and chcp.com to full executable paths before starting them while rendering. Skip empty and relative PATH entries and treat missing programs as unavailable, preventing a project-local program from taking precedence over the installed tool on Windows. Keep executable resolution mocked in Git and JJ unit tests so they remain independent of the host platform and installed tools. Security advisory: GHSA-5frh-5xp4-g95v Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
Summarize the latest security improvements, safer imports, proxy handling, cache fixes, and text rendering improvements. Add a standalone v2.2.32 Recent Updates section, synchronize usage and development documentation, and bump the package version to 2.2.32.
eric-engberg
marked this pull request as ready for review
October 9, 2026 19:19
…ge API The under-limit hide state read the session percent from the status payload's rate_limits whenever it had one. That percent comes from the session's own last API response, so it stops moving while the session sits idle: with several sessions open, one left idle while another used up the 5-hour limit kept its timer hidden at the limit. After a reset it could also keep showing a timer from the old window's 100%. The state now fetches the usage API's percent even when the payload has one, and keeps it apart from the merged data as apiSessionUsage, so Session Usage and every other widget still show the payload's percent. The API's answer is the account's, cached for 3 minutes and shared by every session, so this costs at most one request per 3 minutes. When the fetch fails, the payload's percent stands in, without an error.
The under-limit state's checklist label read "when session usage is under 100%", but ccstatusline also says "session" for the Claude Code conversation (Session Clock, Session Cost), and the timers for the 5-hour window say "block". The label now reads "when the 5-hour block is under 100%", and the docs, comments and test names say the block's percent too. "Session" stays where it means a Claude Code session, such as a session left idle. Code names that follow the usage data's `sessionUsage` field keep it.
Another change renames Session Usage to Block Usage. Say "usage percent" where the under-limit state's docs and two test comments named it, so they read right with either name.
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 4.1.11 to 5.0.0. - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md) - [Commits](https://github.com/vitest-dev/vitest/commits/v5.0.0/packages/vitest) --- updated-dependencies: - dependency-name: vitest dependency-version: 5.0.0 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…loc#722) Bumps [react-devtools-core](https://github.com/react/react/tree/HEAD/packages/react-devtools-core) from 7.0.1 to 8.0.0. - [Release notes](https://github.com/react/react/releases) - [Changelog](https://github.com/react/react/blob/main/CHANGELOG.md) - [Commits](https://github.com/react/react/commits/react-devtools@8.0.0/packages/react-devtools-core) --- updated-dependencies: - dependency-name: react-devtools-core dependency-version: 8.0.0 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 7.0.0 to 7.1.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](actions/setup-node@8207627...949feb2) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: 7.1.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ith 6 updates (sirmalloc#733) Bumps the dev-dependencies group with 6 updates in the / directory: | Package | From | To | | --- | --- | --- | | [@remotion/cli](https://github.com/remotion-dev/remotion) | `4.0.532` | `4.0.534` | | [eslint](https://github.com/eslint/eslint) | `10.11.0` | `10.12.0` | | [globals](https://github.com/sindresorhus/globals) | `17.12.0` | `17.13.0` | | [remotion](https://github.com/remotion-dev/remotion) | `4.0.532` | `4.0.534` | | [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint) | `8.70.1` | `8.71.1` | | [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) | `5.0.0` | `5.0.3` | Updates `@remotion/cli` from 4.0.532 to 4.0.534 - [Release notes](https://github.com/remotion-dev/remotion/releases) - [Commits](remotion-dev/remotion@v4.0.532...v4.0.534) Updates `eslint` from 10.11.0 to 10.12.0 - [Release notes](https://github.com/eslint/eslint/releases) - [Commits](eslint/eslint@v10.11.0...v10.12.0) Updates `globals` from 17.12.0 to 17.13.0 - [Release notes](https://github.com/sindresorhus/globals/releases) - [Commits](sindresorhus/globals@v17.12.0...v17.13.0) Updates `remotion` from 4.0.532 to 4.0.534 - [Release notes](https://github.com/remotion-dev/remotion/releases) - [Commits](remotion-dev/remotion@v4.0.532...v4.0.534) Updates `typescript-eslint` from 8.70.1 to 8.71.1 - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.71.1/packages/typescript-eslint) Updates `vitest` from 5.0.0 to 5.0.3 - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md) - [Commits](https://github.com/vitest-dev/vitest/commits/v5.0.3/packages/vitest) --- updated-dependencies: - dependency-name: "@remotion/cli" dependency-version: 4.0.534 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: eslint dependency-version: 10.12.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: globals dependency-version: 17.13.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: remotion dependency-version: 4.0.534 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: typescript-eslint dependency-version: 8.71.1 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: vitest dependency-version: 5.0.3 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…rmalloc#695) Claude Code 2.1.251 added rate_limits.spend_limit to the status line payload for developers behind a Claude apps gateway. Parse it and show it with two widgets that read the payload only and never call the usage API. Closes sirmalloc#572 Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
…#710) * fix: draw the text cursor as a bar so trailing spaces show The label editor quotes the label so a trailing space stays visible, but the cursor was a highlighted block: over a character, or a highlighted space after the text when at the end. So a label ending in a space with the cursor on it ("Weekly:" + block) looked the same as a label with no space and the cursor past the end ("7d" + block), and "7d" read as "7d ". Draw the cursor as a bar between characters instead. It never covers a character, so a trailing space shows as a gap before it, and the end of the text adds nothing that looks like a space. Custom Text shares the cursor, so it gets the bar too. * feat(tui): preview label edits live and blink editor cursors --------- Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
…el clash (sirmalloc#708) * fix(usage): call Session Usage Block Usage, ending its "Session:" label clash Three widgets printed the label "Session: " and meant two different things by it. Session Clock and Session Name mean the Claude Code conversation; Session Usage meant the 5-hour usage window. On one line, "Session: 42% | Session: 1hr 5m" reads as two facts about the same session when they aren't. The 5-hour window already has a name here: Block Timer and Block Reset Timer call it the block. Session Usage becomes Block Usage, labeled "Block: ", with the description "Shows the current 5-hour block's usage percentage". Its type stays session-usage, so saved configs keep working, and anyone who prefers the old label can set "Session: " back with the label editor (e). The docs follow; past release notes keep the name they shipped with. * fix(usage): label Block Usage "5h: " rather than "Block: " "Block: " is already Block Timer's label, for the block's elapsed time ("Block: 3hr 45m"), so Block Usage beside it would print two "Block:" figures. Label it "5h: " instead, which says which window the percent is of and pairs with Weekly Usage's "Weekly: ". The name stays Block Usage, and a "Session: " override still sets the old label back. --------- Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
…es whole (sirmalloc#704) * fix(ansi): strip 8-bit color codes as well as ESC [ ones The ANSI parser reads the 8-bit CSI (0x9b) as an escape sequence, but stripSgrCodes only matched color codes written with ESC [. Text colored with \x9b31m kept its colors where they should go: a global foreground override left a preserveColors widget's own colors in place, and a Custom Command cut by its max width never got its closing reset, so its color ran into the separators and widgets after it. Match both introducers. restoreBackgroundAfterResets shares the pattern, so an 8-bit reset now gets the background re-applied after it too; its parameter parsing skips a one-character introducer for those. * fix(sanitize): keep 8-bit color codes and drop other 8-bit sequences whole The terminal sanitizer dropped 8-bit C1 controls one character at a time. For a sequence started by one, that removed only the introducer and left the rest as text: a command printing \x9b31mred\x9b39m showed "31mred39m", and an 8-bit hyperlink or title string showed its URL or payload. Read each 8-bit introducer as the ESC sequence it stands for: CSI (0x9b) as ESC [, OSC (0x9d) as ESC ], and DCS, SOS, PM and APC likewise, with ST (0x9c) ending strings. Color codes and safe hyperlinks are kept, in their 7-bit form, which every terminal reads and the rest of the renderer parses; any other sequence is dropped whole. Lone 8-bit controls that start no sequence, such as NEL or a stray ST, are still dropped.
…irmalloc#701) * feat(claude-status): optionally link the widget to the status page Claude Status shows "minor" or "major" when something's wrong, but the details are on status.claude.com, which you have to look up. Git Branch and Git Root Dir can already link to the repo or IDE. Press `l` on Claude Status to make the whole widget an OSC 8 hyperlink to https://status.claude.com, the site it reads the status from: label, status and the history strip, and an unknown "?" too, when the page is most worth a look. It's off by default, like the other links, and the editor row shows "status link". Terminals without OSC 8 support show the text as before. * fix(preview): preserve enabled widget hyperlinks --------- Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
The usage API's answer is cached for 3 minutes, and kept for as long as the API keeps failing. Across a reset, under-limit took that answer's 100% for the new block's, so the reset countdown showed at the start of a fresh block (at 40%, say) until a fetch succeeded. The API's percent now counts only while its block hasn't reset; otherwise the payload's percent stands in, as when the fetch fails.
While the usage API can't be reached (a 429 backoff, a failed request, no credentials), fetchUsageData serves the last good cache however old it is, and nothing tells it apart from a fresh answer: unlike a failed fetch it carries no error. Block Reset Timer's under-limit state took that cache's 5-hour percent as the API's current answer, so the payload's percent never stood in. Through a backoff, which a Retry-After can stretch to an hour, a cache written at 97% kept the reset countdown hidden after the payload had reached 100% in the same block. fetchUsageData now marks the stale fallback it returns, including when a later call serves it again from memory. The prefetch takes the block's API percent only from the API or a current cache, so a stale fallback counts as the API being unreachable, like a failed fetch, and the payload's percent decides, as the under-limit state's docs describe. Only a cache that has outlived a refresh is marked: one older than the 3-minute cache lifetime plus the 30-second lock a fetch holds while in flight. Another session's ordinary refresh serves the cache through that lock too, seconds past its 3 minutes and as current as the shared cache ever is, and marking it would let an idle session's frozen payload percent override the API's for that render.
…ith 9 updates (sirmalloc#745) Bumps the dev-dependencies group with 9 updates in the / directory: | Package | From | To | | --- | --- | --- | | [@remotion/cli](https://github.com/remotion-dev/remotion) | `4.0.534` | `4.0.538` | | [@types/bun](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/bun) | `1.4.2` | `1.4.4` | | [eslint](https://github.com/eslint/eslint) | `10.12.0` | `10.13.0` | | [react](https://github.com/react/react/tree/HEAD/packages/react) | `19.3.0` | `19.3.1` | | [react-dom](https://github.com/react/react/tree/HEAD/packages/react-dom) | `19.3.0` | `19.3.1` | | [remotion](https://github.com/remotion-dev/remotion) | `4.0.534` | `4.0.538` | | [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint) | `8.71.1` | `8.71.2` | | [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) | `5.0.3` | `5.0.5` | | [zod](https://github.com/colinhacks/zod) | `4.6.5` | `4.6.7` | Updates `@remotion/cli` from 4.0.534 to 4.0.538 - [Release notes](https://github.com/remotion-dev/remotion/releases) - [Commits](remotion-dev/remotion@v4.0.534...v4.0.538) Updates `@types/bun` from 1.4.2 to 1.4.4 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/bun) Updates `eslint` from 10.12.0 to 10.13.0 - [Release notes](https://github.com/eslint/eslint/releases) - [Commits](eslint/eslint@v10.12.0...v10.13.0) Updates `react` from 19.3.0 to 19.3.1 - [Release notes](https://github.com/react/react/releases) - [Changelog](https://github.com/react/react/blob/main/CHANGELOG.md) - [Commits](https://github.com/react/react/commits/v19.3.1/packages/react) Updates `react-dom` from 19.3.0 to 19.3.1 - [Release notes](https://github.com/react/react/releases) - [Changelog](https://github.com/react/react/blob/main/CHANGELOG.md) - [Commits](https://github.com/react/react/commits/v19.3.1/packages/react-dom) Updates `remotion` from 4.0.534 to 4.0.538 - [Release notes](https://github.com/remotion-dev/remotion/releases) - [Commits](remotion-dev/remotion@v4.0.534...v4.0.538) Updates `typescript-eslint` from 8.71.1 to 8.71.2 - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.71.2/packages/typescript-eslint) Updates `vitest` from 5.0.3 to 5.0.5 - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md) - [Commits](https://github.com/vitest-dev/vitest/commits/v5.0.5/packages/vitest) Updates `zod` from 4.6.5 to 4.6.7 - [Release notes](https://github.com/colinhacks/zod/releases) - [Commits](colinhacks/zod@v4.6.5...v4.6.7) --- updated-dependencies: - dependency-name: "@remotion/cli" dependency-version: 4.0.538 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: "@types/bun" dependency-version: 1.4.4 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: eslint dependency-version: 10.13.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: react dependency-version: 19.3.1 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: react-dom dependency-version: 19.3.1 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: remotion dependency-version: 4.0.538 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: typescript-eslint dependency-version: 8.71.2 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: vitest dependency-version: 5.0.5 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: zod dependency-version: 4.6.7 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
The under-limit hide state preferred apiSessionUsage and fell back to the merged sessionUsage field. When the status payload omitted its percentage, that merged field retained the API value even if prefetch rejected it as stale or from a block that had already reset. An old cached 100% could therefore show a new block's countdown from a reset-only payload. Read the fallback percentage directly from the original status payload in the render context. Continue preferring the API percentage accepted by prefetch, and treat missing or null payload percentages as unknown so the timer stays hidden. Keep general usage merging and other widgets unchanged. Add prefetch-to-render regression coverage for expired and stale cached 100% readings with missing, null, zero, 97%, and 100% payload percentages, plus an entirely absent payload. Verify that merged usage is preserved while rejected API values cannot decide visibility. Update widget fixtures to supply their fallback percentages through the original payload. Validation: - Both new regression cases reproduced the erroneous countdown before the fix. - Targeted prefetch and Block Reset Timer tests: 96 passed. - bun run lint: passed (TypeScript and ESLint). - bun test: 3,191 passed; two local proxy listener tests failed because the sandbox blocked binding to 127.0.0.1. Both passed outside the sandbox (the status-service file: 30 passed; the usage proxy timeout test: 1 passed).
Bring in main through cf73531, including the dependency updates from sirmalloc#745. The merge applies cleanly and preserves the Block Reset Timer under-limit feature and the fix that keeps rejected API percentages out of its fallback. Install the merged dependency versions with bun install --frozen-lockfile. No conflict resolutions or additional source changes were required. Validation: - bun run lint: passed (TypeScript and ESLint). - bun test: 3,193 passed, 0 failed across 178 files, with local proxy listeners permitted so the proxy timeout tests execute successfully. - git diff --check and git diff --cached --check: passed.
|
Owner
Author
|
Merged upstream as sirmalloc#697. |
eric-engberg
added a commit
that referenced
this pull request
Oct 26, 2026
Brings in #72's review fixes and today's main, which has #71 as upstream merged it, with sirmalloc's fix: Block Reset Timer's under-limit state reads the usage API's percent when prefetch accepted one, then the payload's own, never an API percent prefetch rejected. The shared isAtSessionLimit check takes the render context for that, as on #89's rebuilt branch, so Block Usage's at-limit state swaps with it at the same render. The forecast passes only its usage data: a payload percent at 100 already ends the forecast.
eric-engberg
added a commit
that referenced
this pull request
Oct 26, 2026
Brings in #72's review fixes and today's main, which has #71 as upstream merged it. #115's cached-answer check and #72's fetch time meet in fetchUsageData's file cache: a cache that answers the request is served with its file's write time. Block Usage's at-limit check follows #89's rebuilt branch, which reads the percent as Block Reset Timer now does.
eric-engberg
added a commit
that referenced
this pull request
Oct 30, 2026
…build The branch was rebuilt on today's updated #115 and #80, which hold upstream main; #71 and #89, which it also merged, are upstream (sirmalloc#697, sirmalloc#747) and in #115 through main. This keeps the old history so the push is a fast-forward; the tree is the rebuild's.
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.



Standalone, cut from
main.What
Block Reset Timer's
(h)ide…list has a new entry, "when the 5-hour block is under 100%" (under-limit). With it checked, the timer stays out of the status line until the 5-hour limit is hit, then shows the usualReset: 1hr 43mso you know how long until you can work again.Why
Until you hit the 5-hour limit, the time until the block resets doesn't change what you do, but it takes space on every line. Once you're at 100% it's the one number that matters. Today the timer is all or nothing; this lets it appear only when it's useful.
How
sessionUsage >= 100, not when Block Usage's rounded text reads100%. With whole numbers, 99.7% reads as100%but you can still work, so the timer stays hidden.rate_limitsand no usage data) means the timer stays hidden, rather than showing a countdown it can't justify. A usage error is hidden the same way.sessionUsageonly for timers that have the state checked, the same way Block Usage's time cursor asks for the reset time. It fetches it from the usage API even when the status payload'srate_limitshas one. The payload's percent comes from that session's last API response, so it stops moving while the session sits idle. With several sessions open, one left idle while another used up the limit would keep its timer hidden at the limit. After a reset it could also show a timer from the old block's 100%.apiSessionUsage), so Block Usage and every other widget still show the payload's percent as before.Reset: 4hr 30m), since the widget returns the preview before any hide check, as the existingno-datastate does. With the state off, nothing changes. Combined withno-data, a timer at 100% with no reset window yet stays hidden instead of showing[Loading].Update: Don't let a stale usage cache decide the under-limit state
fetchUsageDataserves the last good cache however old it is, with no error set, so nothing told it apart from a fresh answer. The prefetch took that cache's 5-hour percent as the API's current answer, so the payload's percent never stood in. During a backoff, which a Retry-After can stretch to an hour, a cache written at 97% kept the reset countdown hidden after the payload had reached 100% in the same block.fetchUsageDatanow marks the stale fallback it returns, including when a later call serves it again from memory. It keeps aWeakSetand exportsisStaleUsageFallback. The prefetch doesn't take the block's API percent from a marked result. A stale fallback therefore counts as the API being unreachable, like a failed fetch, and the payload's percent decides, as the under-limit docs describe.statSyncof the cache file in a small helper next toreadStaleUsageCache, and it counts a failed stat as outlived.Demo
A fake status payload with the 5-hour block at 60% and then 100%, with the reset 1hr 43m away. Before, the timer shows at both; after, only at 100%. The recording has no usage API credentials, so the payload's percent stands in, which is what the API would report at these percents. Reading the API changes which percent decides, not how the widget looks, so the media only changed for the new wording.
Powerline, before and after:
Plain, before and after:
A new block at 40% in the payload while the usage API cache (fake login and data) still holds the last block's answer: 100%, with a reset 20 minutes ago, as when the API kept failing across the reset. Before, the countdown shows at 40%; after, the cached answer is ignored and the timer stays hidden.
Powerline, before and after:
Plain, before and after:
Turning it on in the line editor: select the timer,
h, check the new entry, Enter.Powerline
Plain
Update
Block Usage and Block Reset Timer (hidden 'under-limit'), piped with fake data while the usage API is in a 429 backoff for the next hour. Its last cached answer is 40 minutes old and for the current 5-hour block, and nothing is fetched. Before, the stale cache decided: at 100% the countdown stayed hidden because the cache said 97%, and at 97% it showed because the cache said 100%. After, the payload's percent decides both ways, so the countdown shows at 100% and is hidden at 97%.
Powerline, before and after:
Plain, before and after:
Testing
[Loading]at 100% with no reset window whenno-datais also on; the declared states.rate_limitshas one, and kept apart so Block Usage keeps the payload's; a failed fetch for it alone is suppressed, with the payload's percent standing in.bun test: 2794 pass, 0 fail.bun run lintpasses. The changed test files never write toHOME(run withHOMEpointed at an empty directory).main).main(the timer is hidden); at 100% it matchesmain. The TUI opens and exits cleanly under both.bun test3070 pass, 0 fail;bun run lintpasses; under Node (Vitest) both changed test files pass, 84 of 84. Built CLI under Bun 1.4.2 and Node 26.10.0 with payloads at 97% and 100% and no credentials: identical across runtimes and to the previous commit in plain and Powerline modes. Against the live API, with a made-up payload at 100% while the account was at 12%: the timer stays hidden, where the previous commit showedReset: 1hr 42m.bun test3070 pass, 0 fail;bun run lintpasses; under Node (Vitest) both changed test files pass, 84 of 84. The media is re-recorded for the new label.bun test3185 pass, 0 fail;bun run lintpasses; under Node (Vitest) the prefetch test file passes, 54 of 54. Built CLI under Bun 1.4.2 and Node 26.10.0, plain and Powerline, from a scratchHOMEwhose fresh cache holds the old block's 100%: before,5h: 40.0% | Reset: 4hr 39m; after,5h: 40.0%, identical across runtimes.Update:
usage-fetch.test.ts: a newit.eachcase covers a render that lands while another render's refresh is in flight (atimeoutlock with 28s left). A cache 185s old is not marked as a stale fallback; before the threshold this case failed with[true, true]against[false, false]. A cache 215s old is marked, which pins the other side of the threshold. The two cases that check a stale cache served through a backoff and through a failed request now use a 40-minute-old cache.usage-prefetch.test.ts: the test 'falls back to rate_limits' block percent when the under-limit fetch only has a stale cache' now ties the stale mark to the exact objectfetchUsageDatareturned. If the check reads the wrong variable it fails, receivingapiSessionUsage97, and it also fails if the check is removed. The old mock passed in both cases.bun test: 3191 pass, 0 fail, across 178 files (3189 before, plus the 2 new cases).bun run lint(tsc and ESLint) passes.usage-prefetch.test.tspasses 55/55.usage-fetch.test.tscan't run its probe subprocess under plain Node, because Node can't resolveusage.ts's extensionless imports: 46 cases fail withERR_MODULE_NOT_FOUND, the 44 known before plus the 2 new probe cases. To cover it on Node, I built the dist and ran it under Node 26.10.0 and Bun 1.4.2 in 9 scenarios: a cache hit after a reset, a stale fallback after a reset, a 429 backoff in both directions, a control, and an in-flight refresh at 185s and 215s in both directions. Each ran from a scratch HOME with fake credentials and a deadHTTPS_PROXY. Both runtimes gave the same output, and the cache and lock files were never touched.5h: 100.0%to5h: 100.0% | Reset: 1hr 59m. During another session's refresh (cache 185s old at 100%, payload 97%), it stays5h: 97.0% | Reset: 1hr 59m, as before.