Skip to content

Show the time until reset when a limit is Hot or used up - #16

Draft
1r0 wants to merge 22 commits into
gagoar:mainfrom
1r0:feature/reset-note
Draft

1r0 wants to merge 22 commits into
gagoar:mainfrom
1r0:feature/reset-note

Conversation

@1r0

@1r0 1r0 commented Nov 7, 2026 •

Copy link
Copy Markdown

Stacked on #15. This branch builds on that PR and the ones before it. Until the maintainer merges them, the Files changed tab lists their commits too. The new work is the last commit, "Show the time until reset when a limit is Hot or used up". To see only the new work, open the last commit in the Commits tab.

Brief

When a usage limit is running hot, the useful question is how long until it resets. So a Hot or used-up 5-hour or 7-day limit now shows the time left, in brackets after the percent. It uses the colour of the percent, for example 7d 🦅 60% (reset in 5d 14h). The time is short, from 42m to 5d 4h, and a new setting picks when it shows. A limit that is not Hot looks the same as before.

Change map

Flow 1: Input 1 -> A Hot or used-up limit shows the time until it resets

%%{init: {"theme":"base","flowchart":{"curve":"step","nodeSpacing":28,"rankSpacing":48,"diagramPadding":40},"themeVariables":{"darkMode":true,"background":"#0d1117","fontFamily":"Inter, Helvetica, Arial","fontSize":"13px","dropShadow":"none","primaryColor":"#14181e","primaryTextColor":"#e6edf3","primaryBorderColor":"#383d43","nodeTextColor":"#e6edf3","textColor":"#e6edf3","mainBkg":"#14181e","nodeBorder":"#383d43","lineColor":"#3d444d","clusterBkg":"#0d1117","clusterBorder":"#383d43","titleColor":"#9198a1","edgeLabelBackground":"#0d1117"}}}%%
graph LR
  subgraph IN["Input"]
    I1(["Input 1"])
  end
  subgraph FN["Functions"]
    F1["usageSegment"]:::modified
    F2["resetNote"]:::added
    F3["showsResetNote"]:::added
    F4["formatRemaining"]:::added
    F5["twoUnits"]:::added
  end
  subgraph OUT["Output"]
    O1["Output 1"]
  end
  I1 --> F1
  F1 ==> F2
  F2 ==> F3
  F2 ==> F4
  F4 ==> F5
  F1 --> O1
  F5 ~~~ O1
  classDef default fill:#14181e,stroke:#383d43,stroke-width:0.75px,color:#e6edf3,font-weight:500
  classDef added fill:#12221d,stroke:#3fb950,stroke-width:1px,color:#e6edf3,font-weight:500
  classDef modified fill:#211f18,stroke:#d29922,stroke-width:1px,color:#e6edf3,font-weight:500
  classDef removed fill:#24171c,stroke:#f85149,stroke-width:1px,stroke-dasharray:4 4,color:#e6edf3,font-weight:500
  classDef context fill:#14181e,stroke:#383d43,stroke-width:0.75px,color:#9198a1,font-weight:500
  classDef risk fill:#14181e,stroke:#f85149,stroke-width:2px,color:#e6edf3,font-weight:500
  classDef riskadded fill:#12221d,stroke:#f85149,stroke-width:2px,color:#e6edf3,font-weight:500
  classDef zone fill:#0d1117,stroke:#383d43,stroke-width:1px,color:#9198a1,font-weight:600,font-size:12px
  class IN,FN,OUT zone
  linkStyle 0,5 stroke:#3d444d,stroke-width:1px
  linkStyle 1,2,3,4 stroke:#3d444d,stroke-width:2px
Loading

Legend: 🟩 added · 🟧 modified

Ref What Detail
Input 1 tricorder statusline Claude Code sends each limit with resets_at, the end of its window in epoch seconds.
Output 1 The status line text For example 5h 🐉 100% (reset in 42m). The note has the colour of the band.

Flow 2: Input 2 -> The preview shows the note

%%{init: {"theme":"base","flowchart":{"curve":"step","nodeSpacing":28,"rankSpacing":48,"diagramPadding":40},"themeVariables":{"darkMode":true,"background":"#0d1117","fontFamily":"Inter, Helvetica, Arial","fontSize":"13px","dropShadow":"none","primaryColor":"#14181e","primaryTextColor":"#e6edf3","primaryBorderColor":"#383d43","nodeTextColor":"#e6edf3","textColor":"#e6edf3","mainBkg":"#14181e","nodeBorder":"#383d43","lineColor":"#3d444d","clusterBkg":"#0d1117","clusterBorder":"#383d43","titleColor":"#9198a1","edgeLabelBackground":"#0d1117"}}}%%
graph LR
  subgraph IN["Input"]
    I2(["Input 2"])
  end
  subgraph FN["Functions"]
    F1["renderPreviewSession"]:::modified
    F2["renderStatusline"]:::context
  end
  subgraph OUT["Output"]
    O2["Output 2"]
  end
  I2 --> F1
  F1 --> F2
  F2 --> O2
  F2 ~~~ O2
  classDef default fill:#14181e,stroke:#383d43,stroke-width:0.75px,color:#e6edf3,font-weight:500
  classDef added fill:#12221d,stroke:#3fb950,stroke-width:1px,color:#e6edf3,font-weight:500
  classDef modified fill:#211f18,stroke:#d29922,stroke-width:1px,color:#e6edf3,font-weight:500
  classDef removed fill:#24171c,stroke:#f85149,stroke-width:1px,stroke-dasharray:4 4,color:#e6edf3,font-weight:500
  classDef context fill:#14181e,stroke:#383d43,stroke-width:0.75px,color:#9198a1,font-weight:500
  classDef risk fill:#14181e,stroke:#f85149,stroke-width:2px,color:#e6edf3,font-weight:500
  classDef riskadded fill:#12221d,stroke:#f85149,stroke-width:2px,color:#e6edf3,font-weight:500
  classDef zone fill:#0d1117,stroke:#383d43,stroke-width:1px,color:#9198a1,font-weight:600,font-size:12px
  class IN,FN,OUT zone
  linkStyle 0,1,2 stroke:#3d444d,stroke-width:1px
Loading

Legend: 🟧 modified · ⬜ unchanged context

Ref What Detail
Input 2 tricorder fields preview It takes no argument.
Output 2 Plain text on standard output The made-up 7-day limit is now Hot (60% used, 20% of the window gone), so the note shows: (reset in 5d 14h). The pace is 60 - 20 = +40 points, above the Hot edge of +20.

Review guide

Size: 12 files changed, 4 of them tests (33%), 44% of the changed lines are tests

The bands: they come from #12. The pace is the share of the limit used minus the share of the window gone. Hot means the pace is more than 20 points above an even pace.

The time format: under an hour 42m, under a day 3h 32m, longer 5d 4h. A zero part is dropped (3h, not 3h 0m). The time is rounded up to the next minute, so it never shows 0m.

Hand check: 2,520 seconds left is 42m. 12,720 seconds is 3h 32m. 446,400 seconds is 5d 4h.

The setting: statusline.pace.resetNoteFrom. The value hot (default) shows the note for Hot and used-up limits. watchOut starts at Watch out. always shows it whenever the reset time is known. off never shows it.

What changed:

  • Flow 1, usageSegment: Changed. When a note applies, it adds the note after the percent in the same colour.
  • Flow 1, resetNote: New. It returns the text (reset in ...), or nothing when no time is left or the setting says no.
  • Flow 1, showsResetNote: New. It maps the band and the setting to yes or no. Without a pace, only always shows the note.
  • Flow 1, formatRemaining: New. It turns seconds into the short text and rounds up to the next minute.
  • Flow 1, twoUnits: New. It writes a big and a small unit, such as 3h 32m, and drops the small one when it is zero.
  • Flow 2, renderPreviewSession: Changed. The made-up 7-day limit goes from Chill to Hot.
  • Flow 2, renderStatusline: Unchanged. It is the real status line code.
  • Not in a diagram, mergePace: Changed. It keeps a valid resetNoteFrom and replaces anything else with the default.
  • Not in a diagram, isResetNoteFrom: New. It is true for off, watchOut, hot and always.
  • Not in a diagram, the field text: The explanation of the two usage fields now mentions the note.

Read these first

File Why it is delicate What to check
src/pace.ts:106 It holds the rule for when the note shows and how the time is written. Check the rounding and the edges: 59 minutes, 60 minutes, and exactly 1 day.
src/statusline.ts:185 It builds the text of each limit on every redraw. Check that a limit whose payload has no resets_at gets no note, even with always.
src/preview.ts:32 It changes the made-up 7-day limit so the preview can show the note. Check the numbers: 60% used with 20% of the window gone is Hot.
src/config.ts:112 It checks the new setting. Check that an unknown value keeps the default, hot.

Review order: Start at formatRemaining, then read showsResetNote, then follow Flow 1 up to usageSegment.

Other changed files (8) · tests: 4 · docs: 2 · generated: 1
  • README.md
  • plugin/README.md
  • plugin/bin/tricorder
  • src/fields.ts
  • test/cli.test.ts
  • test/fields.test.ts
  • test/pace.test.ts
  • test/usage.test.ts

1r0 and others added 22 commits November 6, 2026 16:57
Adds a catalogue of statusline fields (src/fields.ts) and a
statusline.fields block in the config. Each existing field (location, PR
tags, context gauge, model, mute icon, plan link, other worktrees,
sub-agents, start-up animation) can now be switched off. All default to on,
so nothing changes for existing users, and an older config without the
block keeps everything on.

New commands:
- tricorder fields describe: explains each field and shows if it is on.
- tricorder fields set <ids|all>: chooses which fields are shown.

Adds a test setup (npm test: esbuild bundles the tests, node --test runs
them) and runs it in CI.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… test builds

No new flags from the ts-patterns checker: named constants instead of bare
numbers, no raw loops, no nested ternary, .length coerced instead of
compared with zero, regexes explained with examples. Upstream's own
existing flags are untouched.

npm test now deletes build/test first, so compiled tests left over from
another branch cannot run by mistake.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The catalogue (and so `fields describe`, the README and the config)
now goes mute icon, location, PR tags, context, model, plan link, then the
worktrees line, the sub-agents line and the start-up animation.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
`tricorder detect` reports whether the account is a subscription or pay
per use, read from the account's own .claude.json (the one in
CLAUDE_CONFIG_DIR, else ~/.claude.json). Fields now say which account
types they apply to, `fields describe` lists only the ones that apply,
and `statusline.mode` can force the type (auto, subscription, payg).

/tricorder:setup uses that to explain each field that applies, then asks
which to show (multi-select, "Enable all" first, options in the order
the statusline draws them) and saves the choice.

- `tricorder fields questions` builds the exact questions in code (unique
  text per question, 2 to 4 options each, at most 4 questions per call),
  so the command passes them through unchanged. A trial run had failed
  once when the command assembled them by hand.
- `tricorder fields preview` draws the statusline for a made-up session
  with the chosen fields, using the real statusline code in a throwaway
  home folder, so every field that is on can be seen. A trial run showed
  only 4 of 9 fields because a session-less preview has no PRs, plan,
  worktrees or sub-agents.

The command's Bash access is limited to the plugin's own binary.
setup.sh points to the command when it finishes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A yellow * after the branch name (my-repo(main*), or 🌳 fix-login* in a
worktree) when the folder has edited, staged or new files that are not
committed. Nothing is shown outside a git repository.

It is a new optional field, "dirty", on by default like the others, so it
appears in /tricorder:setup and can be switched off. git is only asked
when the field is on. The preview builds a small real repository with one
new file, so the mark shows there too.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
On a subscription account Claude Code sends how much of the 5-hour and
7-day limits is used and when each window ends. Two new optional fields,
usage5h and usage7d, show it as "5h 🐕 37% · 7d 🐢 12%".

The animal is the pace: % of the limit used minus % of the window gone, in
percentage points. 🐢 Chill (green) more than 10 under, 🐕 On track (blue)
within 10, 🐎 Watch out (orange) up to 20 over, 🦅 Hot (red) beyond, and
🐉 Over (magenta) when the limit is used up. The margin (default 10) and
the minimum share of the window before a pace is shown (default 3%) are
settings under statusline.pace. The bands live in src/pace.ts as pure
functions, with hand-checkable tests: half the window gone and 55% / 65% /
75% / 30% used gives On track / Watch out / Hot / Chill.

The two fields apply to subscription accounts only, so pay-per-use users
are not offered them in /tricorder:setup. The preview feeds made-up limits
so both appear.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Before, the first 3% of a 5-hour or 7-day window showed only the percent,
because a pace that early is noise. It now shows a grey sloth, so the
reader can tell "too early to tell" from "no data". A limit that is used
up still shows the dragon, even early. With no reset time from Claude Code
the percent still shows alone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The comments and the README said the default margin of 10 points follows
the default of Claude's own Pacing Sensitivity screen. That could not be
checked, so the text now says only that 10 is the default and can be
changed in the config. No behaviour changes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Accounts that pay per use have no 5-hour or 7-day limit, so they get a
"spend" field instead: "💰 $62/$200 🐕 31%". It is what this month has
cost, the monthly budget, an animal for the pace and the share spent.

- Claude Code reports only the cost of the running session, so tricorder
  keeps its own running total: one small file per session and month under
  ~/.claude/tricorder/spend/, summed on demand. A resumed session (cost
  back to zero) counts as new spending; a session that crosses into a new
  month puts the later part in the new month. It is an estimate, not the
  invoice, and the docs say what it misses.
- Pace is share of the budget spent minus share of the calendar month (UTC)
  gone, with the same animals as the usage fields. 🐉 Over means more than
  100% of the budget; exactly 100% is not over. 🦥 in the first 3% of the
  month.
- `tricorder budget <dollars|off>` sets the budget (US dollars; not a
  limit). With none, only the spend is shown.
- /tricorder:setup asks for the budget, for pay-per-use accounts only, with
  the question built in code (`tricorder budget questions`).
- Claude Code also sends a (notional) cost on subscriptions, so the field is
  shown only to pay-per-use accounts, or when the type is unknown and the
  payload has no usage limits.
- The preview sends a made-up cost and an example budget for pay-per-use
  accounts, usage limits for subscriptions.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A new optional field, "account", shows the email you are signed in with in
grey at the right edge of the first line, after the plan link. It tells a
personal and a work account apart when they run side by side.

Claude Code does not send the email to the statusline, so it is read from
the account's own file (CLAUDE_CONFIG_DIR/.claude.json, else
~/.claude.json). That file is internal to Claude Code; if the email cannot
be found, nothing is shown. The file is now read once per redraw and shared
with the account-type check.

While the email shows, 6 columns are kept empty at the right edge so the
end of the address is not clipped by the terminal or Claude Code's own
padding. Without the email the plan link keeps its old position (1
column).

On by default like the other fields; the docs say it also appears in
screenshots and how to switch it off. Pay-per-use logins have no account
entry, so nothing is shown for them. The preview uses a reserved example
address.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A new optional field, "remote", shows "📡 remote" on the first line while
Remote Control is on for the session.

Claude Code does not put this in the statusline data. It records it in its
own per-session file, sessions/<pid>.json in the account's config folder,
as bridgeSessionId (text while on, null otherwise). The record is matched
to the session by sessionId. The file is internal to Claude Code and not a
documented interface, so every read is guarded and anything unexpected
means "not remote". Files from processes that have ended can stay behind,
so a record only counts while its process is running, and if several
match the newest one decides.

On by default like the other fields; it applies to every account type.
The preview writes a record for a running process in its throwaway home.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
For a subscription's 5-hour or 7-day limit, a Hot pace or a used-up limit
now carries the time until the window resets, after the percent and in the
same colour: "7d 🦅 60% (reset in 5d 14h)". That is the useful number when
the question is whether to slow down or wait.

The time is short and rounded up to the next minute: 42m under an hour,
3h 32m under a day, 5d 4h beyond (a zero part is dropped, and it never
shows 0m). A new setting, statusline.pace.resetNoteFrom, picks when it
shows: hot (default: Hot and used up), watchOut, always or off. An invalid
value keeps the default. Without a reset time from Claude Code there is no
note. The preview now has a Hot 7-day limit so the note is visible.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
npm test passed a folder to `node --test`; Node 24 (the CI runner) reads
that as one missing file. List the compiled test files instead.

Also address review: coerce empty checks (!others.length, filter(Boolean))
and explain each type cast. Rebuilt plugin/bin/tricorder to match.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…from a table

buildFields() is now the only place that casts to Record<FieldId, boolean>, so
defaultFields, setFields and the config merge need no casts of their own.
`fields <name>` looks the name up in a table (own keys only, so "toString" is
not a sub-command) instead of an if-chain. Coerce an empty check, mark the
test-only `as never`, make the config's field table read-only.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…type

Merges feature/optional-fields (test script for Node 24, coerced checks,
buildFields, sub-command table) and then applies the review of this PR:
- account types, modes and detected types are derived from one declaration
  (SUBSCRIPTION / PAYG / UNKNOWN / AUTO), not retyped as strings
- `fields describe|questions <type>` reports an unknown type instead of
  silently using the detected one
- every fields sub-command is in the dispatch table
- JSON fields are read with one checked helper (readField), not casts
- drop the unused FieldInfo.line; preview fails loudly without a script path
- tests: name a constant for the call count, mark `as never`

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Merges feature/account-detect-setup. Then: git status output and the folder
path are checked with Boolean() instead of comparing to "", and the new
"dirty" field drops the removed `line` property.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…_PER_S

Merges feature/dirty-flag, then:
- PaceBand is derived from PACE_STYLES (one place to add a band)
- MS_PER_S and the inverse of elapsedPct (resetsAtS) live in pace.ts, with a
  hand-checked test; preview, statusline and tests stop redefining them
- the pace config merge reads user JSON with the checked readField helper
- the "too early" percent in the legend is read from the default, not retyped
- tests: the band names are checked against the source with `satisfies`

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Merges feature/usage-pace, then:
- budget: what the user typed is one of amount / off / invalid (tagged result),
  so "no budget" can no longer be confused with a typo
- spend ledger: an unreadable file is reported to the log (the total would be
  too low) instead of silently counting as $0; files are written to a temporary
  name and renamed, so a redraw never reads half a file; module stays free of
  logging so tests need none
- statusline skips reading the (large) account file when the payload already
  carries usage limits, which only subscriptions have
- one MS_PER_S, the "too early" percent in the legend read from the default,
  comment moved back to the config it describes, account types as constants

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Merges feature/spend-budget. emailOf uses readField instead of a cast, and
the new account field drops the removed `line` property.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…mote.ts

Merges feature/account-email. Empty-string and undefined checks in the new
remote code use plain truthiness, the one error-code cast says why it is
safe, and the new remote field drops the removed `line` property.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Merges feature/remote-marker, then:
- the reset-note bands are one table with a compile-time check that every
  setting has a row, so showsResetNote needs no cast
- an unknown reset time is null, not 0, so "no time" and "0 seconds left"
  cannot be confused
- the optional pieces of a usage segment are joined by one helper
- the legend text that describes the reset note is built from the defaults

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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