Skip to content

Show 5-hour and 7-day usage with a pace animal (subscriptions) - #12

Draft
1r0 wants to merge 14 commits into
gagoar:mainfrom
1r0:feature/usage-pace
Draft

1r0 wants to merge 14 commits into
gagoar:mainfrom
1r0:feature/usage-pace

Conversation

@1r0

@1r0 1r0 commented Nov 6, 2026 •

Copy link
Copy Markdown

Stacked on #11. 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 three commits: the usage and pace change, the sloth, and a small wording fix. To see only the new work, open the last three commits in the Commits tab.

Brief

On a subscription account, the status line now shows how much of the 5-hour and 7-day usage limits you have used. Each figure carries an animal that says if you use the limit faster or slower than an even pace over its window. The pace is the share of the limit used minus the share of the window that has passed. The animal and colour show the pace, from a turtle for well under it to a dragon for a used-up limit. Two settings tune it, and pay-per-use accounts are not offered these fields.

Change map

Flow 1: Input 1 -> The status line shows the limits with a pace animal

%%{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["renderStatusline"]:::context
    F2["line1"]:::modified
    F3["usageSegment"]:::added
    F4["elapsedPct"]:::added
    F5["limitBand"]:::added
    F6["bandForDeviation"]:::added
  end
  subgraph OUT["Output"]
    O1["Output 1"]
  end
  I1 --> F1
  F1 --> F2
  F2 ==> F3
  F3 ==> F4
  F3 ==> F5
  F5 ==> F6
  F1 --> O1
  F6 ~~~ 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,1,6 stroke:#3d444d,stroke-width:1px
  linkStyle 2,3,4,5 stroke:#3d444d,stroke-width:2px
Loading

Legend: 🟩 added · 🟧 modified · ⬜ unchanged context

Ref What Detail
Input 1 tricorder statusline Claude Code sends the limits in rate_limits: for five_hour and seven_day, a used_percentage and a resets_at time in epoch seconds.
Output 1 The status line text For example 5h 🐕 37% · 7d 🐢 12%. The percent has the colour of the band.

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

%%{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["previewFields"]:::context
    F2["renderPreviewSession"]:::modified
    F3["resetsAt"]:::added
    F4["renderStatusline"]:::context
  end
  subgraph OUT["Output"]
    O2["Output 2"]
  end
  I2 --> F1
  F1 --> F2
  F2 ==> F3
  F2 --> F4
  F1 --> O2
  F3 ~~~ 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,3,4 stroke:#3d444d,stroke-width:1px
  linkStyle 2 stroke:#3d444d,stroke-width:2px
Loading

Legend: 🟩 added · 🟧 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 status line. It now includes a 5-hour limit that is On track and a 7-day limit that is Chill.

Review guide

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

The pace bands, with the default margin of 10 points. The pace is the share of the limit used minus the share of the window gone.

Animal Band Colour When
🦥 Just started grey Less than 3% of the window has passed, too early to tell
🐢 Chill green More than 10 points under an even pace
🐕 On track blue Within 10 points either side
🐎 Watch out orange 10 to 20 points over
🦅 Hot red More than 20 points over
🐉 Over magenta The limit reaches 100%

Example: a 5-hour window with 2.5 hours gone is 50% gone. With 55% used the pace is +5 (On track). With 65% it is +15 (Watch out). With 75% it is +25 (Hot). With 30% it is -20 (Chill).

What changed:

  • Flow 1, renderStatusline: Unchanged. It is the entry point.
  • Flow 1, line1: Changed. After the model, it adds the 5h and 7d segments when their fields are on.
  • Flow 1, usageSegment: New. It draws the label, the animal and the percent in the band colour. Without a usable pace it draws the label and the percent. Without a number from Claude Code it draws nothing.
  • Flow 1, elapsedPct: New. From the reset time, it gives the share of the window that has passed.
  • Flow 1, limitBand: New. A limit used up (100% or more) is Over at any time. An unknown window gives no pace. Under the minimum share the sloth shows. Otherwise the pace decides.
  • Flow 1, bandForDeviation: New. It maps the pace to a band. A value on an edge takes the calmer band: exactly +10 is On track, and exactly +20 is Watch out.
  • Flow 2, previewFields: Unchanged.
  • Flow 2, renderPreviewSession: Changed. It adds made-up limits to the payload.
  • Flow 2, resetsAt: New. It turns "this share of the window has passed" into a reset time. A 5-hour window that is 50% gone ends in 2.5 hours.
  • Flow 2, renderStatusline: See Flow 1.
  • Not in a diagram, mergePace: New. It keeps valid pace settings: a margin above 0, and a minimum share from 0 up to 100. Anything else keeps the default.
  • Not in a diagram, PACE_STYLES: New. The name, colour and animal of each band.
  • Not in a diagram, the field list: Two new fields, usage5h and usage7d. They apply to subscription accounts only, so setup does not offer them to pay-per-use accounts.
  • Not in a diagram, the defaults: The default margin is 10 points and the default minimum share is 3%. Both are my choices. Both are settings under statusline.pace in ~/.claude/tricorder/config.json.

Read these first

File Why it is delicate What to check
src/pace.ts:1 It holds every pace rule, as pure functions. Check the band edges (an edge belongs to the calmer band) and that a used-up limit is Over even early in the window.
src/statusline.ts:166 It reads the limits from the payload that Claude Code sends. Check the field names: rate_limits.five_hour and seven_day, each with used_percentage and resets_at in epoch seconds.
src/config.ts:100 It checks the two new settings. Check that a bad margin or minimum share keeps its default.
src/fields.ts:111 It adds two fields for subscriptions only. Check appliesTo: pay-per-use accounts must not see them.
src/preview.ts:28 It invents limits so the preview can show them. Check that the numbers give On track for 5h and Chill for 7d.

Review order: Start at limitBand in the pace file, then follow Flow 1 up to usageSegment.

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

1r0 and others added 8 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>
1r0 and others added 6 commits November 9, 2026 10:49
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>

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