Skip to content

feat(mod): on a subscription show one next-message figure for the cache state - #1096

Merged
amiddavid merged 2 commits into
mainfrom
band-next-tokens
Nov 12, 2026
Merged

amiddavid merged 2 commits into
mainfrom
band-next-tokens

Conversation

@amiddavid

@amiddavid amiddavid commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Behavior change

  • Who: subscription users of the band (Claude Pro/Max, no API key).
  • Old: row 1 showed next message 67.3k rd · 67.3k wr if cold while warm. The two numbers are always the same. The pane showed both lines too.
  • New: one figure for the cache state now.
    • Warm: next message 67.3k rd, in the success color.
    • Cold: ○ cache cold · next message 67.3k wr, in the warning color.
    • The pane's NEXT MESSAGE block shows the same single figure.
  • Dollar mode (API key) does not change, with one exception. A warm cache with no price at all used to draw a bare next message label with nothing after it. Now row 1 draws no label in that state, in both modes. This part needs the owner's yes (review round 1, commit e1ceb93).
  • How to turn it off: there is no switch. Revert this PR.
  • Approved by David Amid in chat on 2026-11-11.

Note: on main, row 1 already showed the cold figure when the cache was cold (○ cache cold · next message 90.0k wr, an existing test pins it). This PR keeps that row. The real change on row 1 is the warm state: the · wr if cold part goes away.

Summary

On a subscription the next-message read and write figures are the same token count (the cached prefix). Showing both says nothing about cost. This PR shows one figure, for the state the cache is in now. Part of #1095 (points 2 and 3). The 5-hour share (point 1) comes later, after the #1068 weights.

What changed

  • context-guru-plugin/hooks/model.ts: nextPrice returns a tagged NextPrice.
    • usd (API key): warm and cold dollar prices, as before.
    • tokens (subscription): now (<tokens> rd warm, <tokens> wr cold) and color (success or warning).
    • The doc comment marks where a share kind goes for the 5-hour share. It is not built.
  • context-guru-plugin/hooks/register.tsx:
    • Band row 1 takes the one subscription figure for the current state. Dollar mode keeps its pair.
    • Pane NEXT MESSAGE: one next message <figure> line on a subscription. Dollar mode keeps its two lines.
  • context-guru-plugin/hooks/register.test.tsx: updated the 90.0k rd · 90.0k wr if cold test and the pane test. Added tests:
    • Warm band, 140 and 60 columns: 90.0k rd, success color, no wr.
    • Cold band: 90.0k wr, warning color, no rd.
    • Pane, warm and cold: one line, the right color, no if the cache is warm lines.
    • API key: band and pane dollar output stays as before.

Data dependence

Metadata only (token counts). No change.

How it was tested

  • claude plugin test context-guru-plugin: 103 pass, 1 fail.
  • The 1 failure (no data: the band is left to the engine, no implementation for clock.now) also fails on unmodified origin/main (98 pass, 1 fail there). It is not part of this change.

🤖 Generated with Claude Code

…he state

On a subscription the band showed `90.0k rd · 90.0k wr if cold`. Both
numbers are the same cached prefix, so the pair says nothing about cost.

- nextPrice returns a tagged NextPrice. With an API key it is `usd`
  (warm and cold, unchanged). On a subscription it is `tokens`: one
  figure for the cache state now, `rd` warm (success color) or `wr`
  cold (warning color).
- Band row 1: `next message 90.0k rd` warm,
  `○ cache cold · next message 90.0k wr` cold.
- Pane NEXT MESSAGE: one `next message <figure>` line on a subscription.
  Dollar mode keeps its two lines.
- nextPrice's doc comment marks where the 5-hour share kind goes once
  the #1068 weights are learned (#1095 point 1, not built).

Part of #1095.

Assisted-By: Claude
Signed-off-by: DAVID AMID <[email protected]>

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 2 5e79ff6c5e1a approve

Verdict: approve

Findings

None. The change does what issue #1095 points 2 and 3 ask, and nothing else.

Non-blocking

  • context-guru-plugin/hooks/register.tsx:529 — the pane line reads next message 90.0k rd directly under the NEXT MESSAGE header. The label repeats the header. The band needs the label; the pane does not.
  • context-guru-plugin/hooks/register.tsx:346 and :354 — the band hardcodes success and warning for the subscription figure, while model.ts already returns the same colors in NextPrice.color (the pane uses it). Two sources of truth for one color. The doc comment promises a third share kind later; that is the moment this bites.
  • context-guru-plugin/hooks/model.ts:59 — the priced gate checks only the current state's price. A warm thread whose server sent next_cold_usd but not next_warm_usd would show no figure, where main still showed · 90.0k wr if cold. I checked dash/cachestate.go:442 (nextPtrs): the proxy sets both prices in one call, so the shape cannot occur today.
  • Test coverage gaps, both small: the cold subscription band is tested at 140 columns only (warm is tested at 60 and 140); the unknown figure of the tokens kind (no price or no tokens) has no test in band or pane.

What I checked

  • The full diff (one commit, three files) and the code around every change: model.ts, register.tsx and register.test.tsx read in full.
  • Behavior parity with main: on main the band already showed one figure per state (warm needed warmUsd, cold needed coldUsd). The only band change is the dropped · wr if cold tail, exactly what the PR claims. The pane changes from two if the cache is warm / if it is cold lines to one line. Dollar mode renders through the unchanged usd branch.
  • nextPrice consumers: only the band and the pane (grep over ts/tsx/py/go). scripts/statusline.py draws no such pair, so no other display diverges.
  • The redraw path: the subscription figure depends on isWarm, tokens, warmUsd, coldUsd and the engine's fiveHour; all of these reach the render through the snapshot/context atoms and signature (which lists isWarm, both prices and tokens), so a warm→cold flip redraws the band.
  • The new tests' regexes traced against the render tree: row shapes (◆ next message 90.0k rd … , ◆ ○ cache cold · next message 90.0k wr), the negative matches (/wr|cold/, /\brd\b/ cannot hit hide, dash ↗, [ Ping ]), and the color assertions via props.color.
  • TypeScript: the NextPrice discriminated union narrows correctly at every use (price.warm/price.cold behind kind === 'usd', price.now/price.color behind the tokens branch).
  • Repo rules: the behavior change is named at the top of the PR with who it affects, old and new behavior, how to turn it off, and the owner's approval (2026-11-11), as CLAUDE.md and RELEASING.md require. Data dependence stated (metadata only, no change) — the figure is built from token counts that already reach the mod.
  • The PR reports 103 pass, 1 fail, with the one failure also failing on unmodified origin/main. Live tests were not approved for this review, so I did not re-run them.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 5e79ff6c5e1a blocking

Verdict: blocking

Findings

  1. docs/plugin/statusline.md:200 — the doc still describes the display this PR removes

    • What fails: the PR changes the band and the pane on a subscription to one figure. The doc keeps the old rule. A reader of statusline.md learns the wrong behavior.
    • Proof: the diff touches only context-guru-plugin/hooks/{model.ts,register.tsx,register.test.tsx} — no docs file. docs/plugin/statusline.md:200 still says: "the next message shows tokens … next message 90.0k rd · 90.0k wr if cold … The pane shows the same figures." After this PR the band shows next message 90.0k rd (warm) or ○ cache cold · next message 90.0k wr (cold), and the pane shows one next message <figure> line. The doc is the reference for what the band means (CLAUDE.md points users at docs/).
    • Fix: rewrite the Subscription bullet in docs/plugin/statusline.md for the new one-figure rule, warm and cold, band and pane. Say the 5-hour share comes later (#1095 point 1).
  2. context-guru-plugin/hooks/model.ts:59 — a warm cache with no warm price now draws a label with no figure

    • What fails: subscription user, warm cache, proxy that sends no next_warm_usd (a proxy that predates the warm figure — docs/plugin/statusline.md:164 documents this skew). Row 1 draws ◆ next message and then nothing. The label dangles. On main the same state drew next message 90.0k wr if cold, a usable figure.
    • Proof: trace. nextPrice (model.ts:59-60) gates now on priced = m.isWarm ? m.warmUsd !== undefined : …. With warmUsd missing, now is undefined. In the band (register.tsx:330-331) warm and cold are then both undefined, but the warm branch (register.tsx:345-348) prints the dim next message label unconditionally. Before this PR the old nextPrice set cold = "90.0k wr" whenever coldUsd existed, so a figure showed. The pane handles the same state honestly (next message unknown, register.tsx:530); the band does not. No test covers the { kind: 'tokens' } return with now undefined, in the band or the pane.
    • Fix: in the band's warm branch, treat a missing figure as the pane does — print a dim unknown, or print no label at all. Add a test: subscription, warm, next_warm_usd absent, next_cold_usd present; pin what row 1 shows.

Non-blocking

  • The band hardcodes success/warning (register.tsx:346, 354) while the pane uses next.color. The two agree today. If a share kind is added later (#1095 point 1), read the color from the model in both places.

What I checked

  • The full diff 202087de..HEAD (3 files) and the code around each change: model.ts, register.tsx, register.test.tsx.
  • The new NextPrice union: TS narrowing at both call sites, the usd path byte-for-byte unchanged, the band's warm/cold branch mapping (warm = m.isWarm ? price.now : undefined).
  • Redraw path: signature (model.ts:326) covers every field nextPrice reads (isWarm, warmUsd, coldUsd, tokens), so a state flip redraws the band.
  • All new and changed tests: warm band at 140 and 60 columns, cold band, pane warm and cold, the API-key pair test. Checked the regexes against the drawn rows (not.toMatch(/wr|cold/), \brd\b) — no false pass found.
  • Docs: searched all of docs/ and README.md for the old display; only statusline.md:200 is stale (finding 1). The dollar examples and row-2 token figures elsewhere are unchanged by this PR.
  • Issue #1095 and the PR description: the behavior change is named at the top, approved by David Amid, data dependence stated (metadata only). The PR implements points 2-4 of the issue; point 1 (5-hour share) is correctly left as a documented hook.
  • Live tests were not run (not approved for this review). The PR reports 103 pass, 1 fail, with the failure pre-existing on origin/main.

Round 1 of #1096:
- Band row 1 shows no "next message" label when there is no figure for the
  current cache state (a proxy with no warm price).
- The band takes the subscription colors from nextPrice, as the pane does.
- docs/plugin/statusline.md describes the one-figure rule.
- New tests: the cold band at 60 columns, and a warm cache with no warm price
  in the band and the pane.

Assisted-By: Claude
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 1 answers. All fixes are in commit e1ceb93.

Reviewer 1 (blocking)

  1. docs/plugin/statusline.md described the old pair: fixed. The Subscription bullet now gives the one-figure rule: warm next message 90.0k rd in green, cold ○ cache cold · next message 90.0k wr in amber, the pane the same. It says the 5-hour share comes later (band: on a subscription the next-message rd and wr figures are always equal #1095).
  2. A warm cache with no warm price drew a bare next message label: fixed. Row 1 now draws the label only when it has a figure. The pane keeps next message unknown. New test: subscription, warm, no next_warm_usd. It checks the band (no label, no rd/wr) and the pane (unknown).

Non-blocking, fixed too: the band now takes the subscription colors from nextPrice, as the pane does.

Reviewer 2 (approve)

  • Colors in two places: fixed, as above.
  • Warm thread with no warm price: fixed, as above. Thank you for the check of nextPtrs. The fix costs nothing, so I kept it.
  • Test gaps: added the cold band at 60 columns, and the no-figure case in band and pane.
  • The pane's next message label repeats the header: kept. The line must read alone when a person scans the pane. It is also the same words as the band.

Tests: claude plugin test context-guru-plugin: 105 pass, 1 fail. The failing test, no data: the band is left to the engine, also fails on unchanged origin/main.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 2 e1ceb934ef83 approve

Verdict: approve

Findings

None. Both round-1 findings are fixed and tested.

Earlier findings

  1. Mine, finding 1 (stale doc, docs/plugin/statusline.md:200): fixed. The Subscription bullet now gives the one-figure rule: warm next message 90.0k rd in green, cold ○ cache cold · next message 90.0k wr in amber, the pane the same figure and color, no next message label when the proxy has no figure, and the 5-hour share named as later work (#1095, #1068). I checked each claim against the code. All match.
  2. Mine, finding 2 (bare next message label, model.ts:59): fixed. The warm branch now renders only when it has a figure: m.isWarm && (warm !== undefined || cold !== undefined) (register.tsx:346). Trace of the new test's state — subscription, warm, next_warm_usd dropped from the doc and the main thread, next_cold_usd 0.78, tokens 90000: priced is false, now is undefined, warm and cold are both undefined, so no label. Row 1 is ◆, Ping, hide, the link. The test pins not.toMatch(/next message/) and not.toMatch(/\b(rd|wr)\b/) on the band, and next message unknown in the pane. The regexes cannot false-pass against hide, dash ↗ or [ Ping ].
  3. Mine, non-blocking (band colors hardcoded): fixed. warmColor/coldColor come from price.color for the tokens kind (register.tsx:332-334). For the usd kind they stay success/warning, byte-for-byte the old rendering.
  4. Reviewer 2, non-blocking (colors in two places): fixed, same change as point 3. Checked it myself.
  5. Reviewer 2, non-blocking (warm thread with no warm price): fixed, same change as point 2.
  6. Reviewer 2, non-blocking (test gaps): fixed. The cold band is now tested at 60 columns too, and the no-figure case has tests in band and pane.
  7. Reviewer 2, non-blocking (the pane's next message label repeats the header): kept by the author. The reason: the line must read alone when a person scans the pane, and it uses the band's words. I accept it. It is a display choice, and it was non-blocking.

What I checked

  • Last review: round 1, 5e79ff6c5e1a551df164e75c76e3154a75d9f7eb, 2026-11-11T16:13:57Z.
  • New commits read: 1 — e1ceb934 "fix(mod): no bare next-message label; colors from the model; doc".
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three saved files).
  • New items since my last review: commit e1ceb934 (reviewed below); the author's round-1 answer comment at 16:15:48Z (each claim checked against the commit); reviewer 2's round-1 review at 16:13:46Z (posted before mine but unread in round 1 — read now in full; its non-blocking items are dispositioned above).
  • The full diff 5e79ff6c..e1ceb934 and the code around each change: the band's row-1 gate, the color ternaries, both new tests, the rewritten doc bullet.
  • The new gate's reach beyond the subscription: for the usd kind with both prices missing, row 1 also drops the label now. On main that state drew the same bare label. Same rule, an improvement, no figure is lost.
  • The new doc bullet claim by claim against register.tsx and model.ts: colors, both row shapes, the pane's single figure, the no-label rule. No false statement found.
  • The commit message: DCO Signed-off-by, Assisted-By, conventional title. Correct.
  • Live tests were not run (not approved). The author reports 105 pass, 1 fail, the failure pre-existing on origin/main.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 2 e1ceb934ef83 approve

Verdict: approve

Findings

None. Commit e1ceb934 fixes both of reviewer 1's findings and my non-blocking notes. I verified each fix by trace. No new defect.

Earlier findings

  • Reviewer 1, finding 1 (stale doc): fixed. docs/plugin/statusline.md:200 now states the one-figure rule — warm 90.0k rd green, cold ○ cache cold · next message 90.0k wr amber, the pane the same figure and color, the 5-hour share later (#1095). I read the new bullet in full. It also names the no-label case. It matches the code.
  • Reviewer 1, finding 2 (bare next message label): fixed. register.tsx:346 now gates the whole warm branch on (warm !== undefined || cold !== undefined). Trace: warm subscription, next_warm_usd absent → priced false → now undefined → warm and cold both undefined → no label, no figure. The pane keeps next message unknown (register.tsx:530), which is honest. The new test drives exactly this shape (doc and main thread with next_warm_usd dropped, next_cold_usd kept) and pins band and pane.
  • Reviewer 1 non-blocking (colors in two places): fixed. register.tsx:333-334 takes price.color for the tokens kind; usd keeps success/warning as before. One source of truth per kind now.
  • My non-blocking, test gaps: fixed. The cold band at 60 columns and the no-figure case (band and pane) both have tests now.
  • My non-blocking, pane label repeats the header: rejected by the author. Reason: the line must read alone when a person scans the pane, and it uses the band's words. I accept the reason. It is a wording choice, not a defect.

Non-blocking

  • register.tsx:346 — the no-label gate also covers the usd kind. On main, an API-key warm cache with no prices at all drew a dangling next message label; now it draws nothing. This is a second, tiny behavior change beyond the subscription case named in the PR. It is strictly an improvement (an empty label said nothing), and the fix commit is authored by the owner, so the permission rule is met. Noted for the record only.

What I checked

  • Last review: round 1, 5e79ff6c5e1a551df164e75c76e3154a75d9f7eb, 2026-11-11T16:13:46Z.
  • New commits read: 1 — e1ceb934 fix(mod): no bare next-message label; colors from the model; doc.
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three saved files; the inline file is empty).
  • New items since my last review:
    • Reviewer 1's round-1 review (blocking, 2 findings + 1 non-blocking): checked each against the fix commit — see "Earlier findings".
    • The author's round-1 answers (comment, 2026-11-11T16:15:48Z): every claim in it matches the diff — doc rewritten, gate added, colors from the model, two new tests. The reported test run is 105 pass, 1 fail, the failure pre-existing on origin/main; live tests were not approved, so I did not re-run them.
    • Commit e1ceb934 (3 files): full diff read, plus register.tsx around the change. Verified the commit message follows the repo conventions (conventional title, Assisted-By:, Signed-off-by:).
  • The two new tests traced against the render tree: the cold 60-column row is ◆ ○ cache cold · next message 90.0k wr … hide dash ↗ (about 53 cells, fits the 56-cell budget); the no-figure band row is ◆ … [ Ping ] hide dashboard ↗ with no next message and no rd/wr; the pane line is next message unknown.
  • Regression check on the gate: every existing test that expects the next message label runs with prices present (usd kind: next_warm_usd: 0.06), so the gate does not hide the label where a test or main behavior expects it. The cold branch is unchanged in shape.

@amiddavid
amiddavid merged commit fff61bf into main Nov 12, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 12, 2026
amiddavid added a commit that referenced this pull request Nov 19, 2026
Plugin versions for v0.7.4:
- Claude Code plugin 0.7.3 -> 0.7.4 (#1096, #1135, #1174, #1177, #1199,
  #1216).
- Codex plugin 0.2.12 -> 0.2.13 (#1115, #1135).
- Pi package 0.1.1 -> 0.1.2 (#1113).
- Bob plugin 0.1.1 -> 0.1.2 (#1093, #1111, #1118, #1124, #1126, #1127).
  The owner's Bob hold (#1221) covers release tests only.
- OpenCode: PINNED_VERSION v0.7.3 -> v0.7.4 in opencode-plugin/index.js,
  its README, docs/how-to/install-opencode-plugin.md and 3 tests.

Behavior change: the version numbers; the OpenCode plugin's first start
downloads proxy v0.7.4. Release bumps are approved by the owner ("I
approve version bumps").

Data dependence: none.

Reviews: 2 offload review rounds (GLM): both approve at ab79001. After
it: 1422093, a merge of main with no hand resolution (remerge-diff 0;
approval-still-valid: SAME CHANGE).

Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant