Repository navigation
feat(dash): on a Claude subscription show saved tokens, with the 5-hour share as an estimate - #988
Conversation
…ur share as an estimate On a Claude subscription the Overview headline now shows saved tokens, not dollars: `saved 1.2M rd / 85k wr`. A dim line below it shows `≈ 3% of the 5-hour limit (estimate at API-price weights)`. - The page reads GET /api/me/limits (#984). A live `five_hour` window turns on the token headline. `{}`, a failed call or a window that is over keeps the dollar view, unchanged. - The estimate is used% x saved / spent for the 5-hour window, read from /api/stats?lean=1&since=<window start>. It shows only after $0.50 of spend and 2% used in the window. - A manager's Overview spans other accounts, so it keeps the dollar view. - The cards below the headline keep their dollar figures. Data dependence: metadata only (token counts and limit numbers), the same at each storage level. Closes #985 Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Eval box result:
|
amiddavid
left a comment
There was a problem hiding this comment.
| 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.319 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | e3c6dc535102 |
blocking |
Verdict: blocking
Findings
- dash/ui/savings.js:99 — the 5-hour estimate can show more than 100% of the limit, and more than the most that can be saved
- What fails: a subscriber at ~60% of the 5-hour limit whose saving is ~2x their spend in the window sees
≈ 120% of the 5-hour limit (estimate at API-price weights). No user can save 120% of a limit. The line then reads as broken, not as an estimate. - Proof:
fiveHourSavedPctreturns(used * saved) / costwith no upper bound. Under the code's own assumption (limit usage tracks API-priced tokens), the without-context-guru usage isused * (cost + saved) / cost, so the points saved areused * saved / cost— the same formula, so it is right while the counterfactual stays under 100%. But the provider stops a user at 100% of the limit. So the points actually saved can never exceed100 - used. Example:used = 60,cost = $10,saved = $20→ the function returns 120; the most savable is 40. The inputs are normal for this product:saved / costiss / (1 - s), so a 67% saving share gives 2x, and the repo's own Overview quotes saving shares around and above that. The low end is guarded (cost < 0.5 || used < 2); the top end is not. - Fix: clamp the returned percent to
100 - used(the throttled counterfactual), or cap the display at 100 and say "more than the limit". Add a test for the caseused * saved / cost > 100 - used.
- What fails: a subscriber at ~60% of the 5-hour limit whose saving is ~2x their spend in the window sees
Non-blocking
- Merge order.
ctl('/api/me/limits')has no route in this tree. The server half is PR #991, still open. Until it merges, the call 404s and the page keeps the dollar view — I traced the fail-open path (app.js:1892-1907, thecatchleavesstate.subnull). Merge #991 first, or say so in the PR. - The manager guard has no test.
app.js:1896throws for a manager so their Overview keeps the dollar view. The Go test checks wiring strings only; nothing covers this branch. The mjs tests coversubscriptionHeadline, not this. - A stale
loadOverviewLimitscan overwrite a newer one. Two refreshes in a row: the slower first call lands last and setsstate.subfrom older data.keepAliveLedgerguards this withstate.kaLedgerKey; this loader has no such guard. The data is at most one refresh stale, so the effect is small. - An unpriced deployment never shows the token headline.
renderSavedLedgergates the hero onpriced(app.js:1713,1742). Token counts need no prices, but a subscription user with no price table sees "Nothing priced yet in this period." This matches the rest of the page, so I leave it as a note.
What I checked
- Read the full diff (6 files) and the code around each change:
renderSavedLedger,loadOverview,loadOverviewLimits,savings.js, both test files,style.css, the data-dependence row. - Verified the
/api/me/limitscontract against PR #991'sdash/limits.go(read from the localfeat/limit-headersbranch): field names and units match the mocked shape (utilization0..1,reset_sunix seconds). Confirmed the route does not exist in this tree, and that the 404 fails open to the dollar view. - Verified the stats fields the code reads exist:
replay_tokensandsaved_uniquein the fullOverview(dash/overview.go:103,101);cost_usdandtotal_saved_usdin the lean window read (dash/overview_lean.go:68,77). Checked the lean branch's precondition (since != 0,dash/api.go:1354) and thatsinceis epoch ms (filterFrom), whichfiveHourStartMsreturns. - Checked the first-paint path: the lean read omits
replay_tokens, but the hero body only draws whenready = priced && !partial, so no "saved 0 rd" flash. - Checked the manager-guard timing:
probeAccount()resolves beforeapplyURL()starts the loaders, soaccount.tenant.roleis known whenloadOverviewLimitsruns. - Checked
probeAccount/gate interplay, script load order (savings.jsbeforeapp.js),compactformatting against the test'sfmt,stripComments/readUIhelpers, CSS specificity for.ov-hero-v.ov-hero-sub, and the mjs test arithmetic by hand (all assertions consistent with the code). - Checked the data-dependence row: present, metadata only, decided-by filled.
amiddavid
left a comment
There was a problem hiding this comment.
| 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.319 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | e3c6dc535102 |
blocking |
Verdict: blocking
Findings
- dash/ui/savings.js:99 — the 5-hour estimate can show more than 100% of the limit, in context-guru's own normal regime
- What fails: a window where context-guru saves more than it costs (its normal result), with the limit partly used, renders
≈ 135% of the 5-hour limit. A share of a limit cannot be above 100%. The reader sees an impossible figure stated with confidence. - Proof:
fiveHourSavedPctreturns(used * saved) / costwith no upper bound, andsubscriptionHeadlinerendersMath.round(p)as-is (savings.js:110). Example:cost_usd15,total_saved_usd45 (a 75% cut),utilization0.45 → 45 × 45 / 15 = 135 →≈ 135% of the 5-hour limit (estimate at API-price weights). The formula linearizes the counterfactual as uncapped spend. Past the limit the counterfactual is throttled, so the true saved share is at most100% − used(here ≤ 55%). The replay cap does not prevent the regime:dash/replaycap.gocaps replay credit per conversation, never at cost, sosaved > coststays possible — and it is the product's pitch. The $0.50 and 2% gates do not boundsaved / cost. - Fix: bound the rendering. When the raw value is ≥ 100, show
≈ the whole 5-hour limit(or≥ 100%); or estimate the saved share of the counterfactual,used × saved / (saved + cost), which stays below the used share.
- What fails: a window where context-guru saves more than it costs (its normal result), with the limit partly used, renders
Non-blocking
- The PR body says "Depends on #984". #984 is the issue. The PR that adds
GET /api/me/limitsis #991, still open. Name #991, so the merge order is unambiguous. Until it merges, the route 404s and every subscription user silently keeps the dollar view — fail-open, so safe. - The window read
/api/stats?lean=1&since=…can be up to 10 minutes old (the server's stale-while-revalidate cache). The estimate line does not say its age; the Overview's other figures do. - The token headline and the estimate cover two different periods: the page's filter vs the current 5-hour window. PR open questions 2 and 3 already name this.
- A manager who filters to their own tenant (
tenant=me) still gets the dollar view. PR open question 4 names this. savings.test.mjsre-implementscompact()as its own localfmt, so a drift incompact()would not fail these tests.loadOverviewLimitsusesthrow new Error('manager')for control flow inside its own try. An early return reads clearer.
What I checked
- The full diff (6 files) and the code around each change:
app.jsloadOverview/renderSavedLedger,savings.js, both test files,style.css,docs/data-dependence.md. - Hand-checked the arithmetic of every new
.mjsassertion; each passes by hand (I ran nothing — live tests are not approved). Checked the liveness boundary: a reset at this exact moment counts as over. - Verified each string
TestOverviewSubscriptionHeadlineIsWiredpins sits on a code line ofapp.js(stripCommentsdrops only comment lines), and that the test compiles against the existing helpers. - Verified the
/api/me/limitscontract against PR #991: shape{subscription, at_ms, five_hour: {utilization, reset_s, status}},utilization0..1,reset_sunix seconds,{}for an API key.liveFiveHourhandles a missingreset_s(null) and a missingutilization(estimate hidden, tokens still show). - Verified
sinceis epoch milliseconds server-side (r.ts >= since), matchingfiveHourStartMs. - Verified the lean window read returns
cost_usdandtotal_saved_usd(overviewLeanWindow), and that a manager's/api/statsspans all tenants — the manager exclusion is therefore right. - Verified the hero is gated on
ready(the full stats read), soreplay_tokenscomes from the fullOverview(), which fills it (overview.go:720); the lean read does not, and the PR body says so. - Verified
savings.jsloads beforeapp.js(index.html, bothdefer), no global name collisions with the other page scripts, all output goes throughel()/textContent(noinnerHTML), no inline styles (CSP). - Verified the sign-out/sign-in path re-runs
loadOverviewLimits, sostate.subcannot outlive an account switch, and every failure path sets it to null (dollar view). - Verified the data-dependence row matches the table's columns, is metadata only, and names the decider (#985, David Amid, 2026-11-09).
The provider stops a user at 100% of the 5-hour limit, so the share saved can never be more than 100 - used. Before, used 45%, $15 spent and $45 saved showed "≈ 135% of the 5-hour limit". - The share is now min(used x saved / cost, 100 - used). - At the cap the line reads "≈ without context-guru you would have hit the 5-hour limit (estimate at API-price weights)". - loadOverviewLimits returns early for a manager (readsLimits) and drops an answer that a newer call replaced. - New tests: the cap (used 45, cost 15, saved 45), just below it, and the manager rule. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
Review round 1 of #989. - The estimate is min(used x saved / cost, 100 - used). The provider stops a user at 100%. At the cap the line says "without context-guru you would have hit the 5-hour limit", with the same words as #988. - /api/me/limits is read once per run; `insights` draws three screens. - _statusline() accepts only a module that has _saved_tokens_text, so a stray statusline module in the Codex copy cannot crash the screens. - Tests: over, at and just below the cap; one limits read per run; subscription with no session id and no open window. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Round 1 replies. Fixed in 0558248.
Tests: |
|
Eval box result on 0558248:
|
amiddavid
left a comment
There was a problem hiding this comment.
| 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.319 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | 0558248dc3bf |
approve |
Verdict: approve
Findings
None.
Earlier findings
- My finding 1 (estimate above 100% of the limit) — fixed.
fiveHourSavedPctnow returnsmin(used × saved / cost, 100 − used)with ahitflag (savings.js:97-103). At the cap the line reads "≈ without context-guru you would have hit the 5-hour limit". I checked the math by hand: used 45, cost $15, saved $45 → raw 135, room 55, hit. Saved $18 → raw 54, no hit.room = max(0, 100 − used)also holds at used = 100 (always a hit, which is right). Both callers were updated to the new{pct, hit}shape; no other caller exists. - Reviewer 1's finding 1 — same defect, fixed the same way. Agree with their analysis; nothing to add.
- My non-blocking notes: manager guard now has a test (
readsLimitsinsavings.js:109, tested in the mjs file) — fixed. Stale-answer overwrite now guarded bystate.subSeq(app.js:1894-1897) — fixed. Merge order — the PR body now says "Depends on #991 … and #992. Merge those first."; I read the body back from the API. The unpriced-deployment note stands as accepted behavior. - Author's rejections: none. Every finding and note was fixed or noted.
Non-blocking
- The info text under the headline (
app.js:1760-1765) still describes only the raw formula ("the share of the limit used, times what context-guru saved, divided by what you spent"). It does not mention the100 − usedcap or the "would have hit the limit" line. A reader who opens the info box next to that line finds no explanation of it.
What I checked
- Last review: round 1, e3c6dc5, 2026-11-09T17:10:41Z.
- New commits read: 1 (
0558248dfix(dash): cap the 5-hour share saved at the room that was left). - Read in full: 2 reviews, 3 comments, 0 inline comments (from the three files).
- New items since my last review, and what I did about each:
- Commit
0558248d: read the full diff and the final state ofsavings.js,app.jsloadOverviewLimits, and both test files. Verified the cap arithmetic, the{pct, hit}return shape against every caller, thereadsLimitsmanager rule (manager: no read, dollar view; member and local proxy: read), and the sequence guard (an older answer is dropped when a newer call has started). - Author's round-1 reply (17:15:11): checked each claim against the code — all five hold.
- Eval-box comments (16:51:46 on
e3c6dc53, 17:26:04 on0558248d):./dash/...passes with-race;savings.test.mjs15 pass locally. I ran nothing myself. - The two new Go wiring pins (
readsLimitscall,seq !== state.subSeq) match code lines inapp.js;stripCommentsdrops only comment lines, so both pins sit on code. - PR body: dependency line names #991 and #992, as the author said.
- Commit
- Hand-checked the new mjs assertions: cap case (135 → 55, hit), below-cap case (54), the threshold case re-shaped to
{pct: 2, hit: false}, and thereadsLimitscases. All consistent with the code. - Confirmed the earlier pinned strings in
TestOverviewSubscriptionHeadlineIsWiredstill match the newapp.js.
amiddavid
left a comment
There was a problem hiding this comment.
| 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.319 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | 0558248dc3bf |
approve |
Verdict: approve
Findings
None new. The fix commit changes only what the reviews asked for, and I found no defect in it.
Earlier findings
- Reviewer 1, round 1 — the estimate could show more than 100% of the limit. Fixed.
fiveHourSavedPctnow returnsmin(used × saved / cost, 100 − used)with ahitflag (savings.js:101-103). At the cap the line reads "≈ without context-guru you would have hit the 5-hour limit (estimate at API-price weights)". The wording is right:raw ≥ roommeans the counterfactual reaches 100%, which is exactly "would have hit the limit". I checked the new tests by hand, including the floating-point boundary: at exactly the cap (saved = 15 × 55 / 45,used = 45), the product rounds to 825.0 andraw = 55 = room, sohitis true as the test asserts. Reviewer 2 raised the same finding; same verdict. - Reviewer 1, round 1 (non-blocking) — "Depends on #984" named the issue, not the PR. Fixed. The PR body now says #991 and #992, and both exist and are open. Note: #992 (lean
replay_tokens) is not strictly needed by this PR — it reads rd from the full/api/stats— but merge order stays safe either way. - Reviewer 1, round 1 (non-blocking) —
throwfor control flow in the manager branch. Fixed.readsLimits(tenant)returns early, nothrow, and it is tested insavings.test.mjs(manager no, member yes, no tenant yes). - Reviewer 2, round 1 (non-blocking) — a stale
loadOverviewLimitscould overwrite a newer one. Fixed. Each call takes a sequence number (state.subSeq); an older answer is dropped indone(). I traced the sign-out/sign-in path: a new Overview load bumps the sequence, so an in-flight old answer cannot land. - Reviewer 2, round 1 (non-blocking) — the manager guard had no test. Fixed (item 3 above), plus two new pinned strings in
TestOverviewSubscriptionHeadlineIsWired. - Reviewer 2, round 1 (non-blocking) — an unpriced deployment never shows the token headline. Not changed. The author left it matching the rest of the page. I agree: the hero already gates on
pricedfor everyone, so a subscription user without a price table sees the same "Nothing priced yet" as an API-key user. No change needed.
Non-blocking
- The estimate line still does not say its age. The window read can be up to 10 minutes old (the server's stale-while-revalidate cache). The Overview's other figures show data age.
- The token headline (the page's period) and the estimate (the 5-hour window) still cover two periods. PR open questions 2 and 3 name this; it is a wording choice, not a defect.
What I checked
- Last review: round 1, e3c6dc5, 2026-11-09T17:12:21Z.
- New commits read: 1 —
0558248d"fix(dash): cap the 5-hour share saved at the room that was left". - Read in full: 2 reviews, 3 comments, 0 inline comments (from
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt). - New items since my last review, and what I did about each:
- Commit
0558248d: read the full diff and the final state ofapp.jsloadOverviewLimits,savings.jsfiveHourSavedPct/readsLimits/subscriptionHeadline, both test files. Checked the cap arithmetic, thehitboundary, the sequence guard, and the export list. - Comment at 17:15:11 (author's round-1 replies): checked each claim against the code; all five hold.
- Comment at 17:26:04 (eval box on
0558248d):./dash/...with-racepasses in both halves, 972 pass, 0 fail;savings.test.mjs15 pass locally. Nothing to act on. - PR body edit: read it back from the server; the dependency line now names #991 and #992, both open PRs.
- Commit
- Hand-checked every new and changed
.mjsassertion, including the exact floating-point values of100 × 0.45,100 × 0.02and45 × (825 / 45)(all round to the exact values the tests assert). I ran nothing — live tests are not approved. - Verified the two new strings pinned by
TestOverviewSubscriptionHeadlineIsWiredsit on code lines ofapp.js(lines 1896 and 1900), sostripCommentskeeps them. - Checked
readsLimitsandstate.subSeqfor name collisions with the other page scripts: none. - Checked that the return-shape change of
fiveHourSavedPct(number →{pct, hit}) reaches every caller: onlysubscriptionHeadlineand the tests. - Re-checked the cap semantics at the edges:
usedat 100% givesroom0 andhittrue; a smallrawwith little room left also reads "would have hit the limit", which is correct — the counterfactual still crosses 100%.
|
On hold (owner's decision, 2026-11-09). This PR is approved, but it waits for #998 part 1. #998 stores the accountant's tier tokens, so that every saving can be shown in tokens: compaction, cache split, keep-alive and TTL. Today only compaction has a token count. Once #998 part 1 merges, this PR switches its token source to those fields, and the dollar figures go away on a subscription. |
The lean stats read never set saved_gross or replay_tokens. It always answered 0. The status line, the mod band and the status screens then showed only "wr", never "rd". overviewLeanWindow now computes both as the full read does, from the columns it already scans. No new query. Closes #990 Behavior change: a fix of wrong output. - Who: everyone who reads /api/stats?lean=1 with a session or a time window (status line, mod band, subscription screens in #988, #989). - Old: "saved 593 wr". The "rd" half never showed. - New: "saved 1.2M rd / 593 wr". - Turn off: no switch. Revert this PR. Owner's yes, 2026-11-10, in the integrator session: "I approve the chhange in 981, 991 and 992". Data dependence: metadata only (token counts). No change. Reviews: 2 offload reviews (GLM), round 1, both approve at 0cbd4d7. c3662e6 changes only comment lines (approval-still-valid: comments only). Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]>
…pi/stats (#999) Part 1 of #998. The dashboard stored only the dollars of each saving. The tokens were lost after the write. This PR stores the tokens by tier beside the dollars. - 8 new columns in request_components and 32 in requests (default 0). Tokens follow the same attribution as the dollars. - /api/stats (full and lean=1) now returns tokens, tokens_unmeasured_requests and the two keepalive_ping token fields. Both paths call one function, DB.AccTokens. - PRs #988 and #989 use the new fields as their token source. Behavior change: none stated; new fields in /api/stats. No existing figure, field or column changes its value. Owner's yes, 2026-11-10, in the integrator session: "999 approve". Data dependence: metadata only. The new columns are token counts. They are the same at each storage level. docs/data-dependence.md row "Accountant savings" is updated. Reviews: 2 offload reviews (GLM), round 4 (owner granted round 4), both approve at 3ae7056. Round 4 reviewed the rebase onto main after #991, which merged #991's limit columns and #999's token columns by hand in 4 files. Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]>
The Overview on a Claude subscription now reads the accountant's tier tokens from /api/stats (#999), not saved_unique and replay_tokens. - The total: tokens.saved, and tokens.caused plus the keep-alive ping tokens as cost. One display rule: tiers that are not 0, in the order wr, wr1h, rd, in; the cost after. Tiers are never added. - Each card shows tokens from tokens.by_feature: Cache (keepalive, cachesplit, ttl; the pings as keep-alive cost), Preset (every other component and ended_change), Tools and skills filter (toolfilter), Tool deferral (tooldefer). - The subscription view starts on the auth kind (subscription: true), not only on an open 5-hour window. The estimate still needs one. - A note under the total counts requests not measured in tokens. - No dollars on a subscription: the replay-cap and estimated-request notes leave them out. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Part 2 of #998, on a268464. The subscription view now reads the accountant's tier tokens (#999). Changes since review round 1 (0558248):
Tests
For the owner: items 5 and the ping tokens in the total's cost (item 2) are choices I made from "on a subscription, tokens". Please confirm. |
The owner's rule for every screen: the keep-alive ping tokens are not in the total and not in any card's cost. The band's lean read has no ping tokens, so this is the one rule all screens can follow. - totalTokens: the cost is tokens.caused only. - featureTokens: the keep-alive and Cache flows leave the pings out. - A line "Keep-alive pings (not in the total): cost ..." shows under the total and on the Cache card, with the same words as #989. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Keep-alive pings on their own line, on f9227dc. This follows the owner's rule for every screen. What changed:
The Tests
|
amiddavid
left a comment
There was a problem hiding this comment.
| 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 | 3 of 3 | f9227dc9d66d |
approve |
Verdict: approve
Findings
None.
Earlier findings
- Round 1/2, the estimate cap — still fixed.
fiveHourSavedPctkeepsmin(used × saved / cost, 100 − used)with thehitflag; the newsubscriptionHeadlinecarries it over unchanged (savings.js). The docs page now states the formula and the cap line (docs/dashboard.md, "On a subscription, the Overview shows tokens"). - My round-2 non-blocking note (the info text omits the cap) — still open, still non-blocking. See below.
- Reviewer 1's round-2 non-blocking notes (estimate age, two periods) — not addressed. Both are wording choices the PR's open questions already name. I agree they stay.
- No earlier finding was rejected.
What the new commits do, and what I verified
9b078a61(merge of main). Brings in #991 (/api/me/limits), #999 (tier tokens), #996, #1009, #981. I read the two this PR depends on:dash/limits.go(#991, merged version):subscriptionnow comes from the auth kind (LatestAuthSubscription, requests'auth_subscription), not from the limit headers. This closes the stale-flag edge I worried about: an account that moves from a subscription to an API key gets{}at once, so the dollar view returns. The response shape matchesisSubscriptionandliveFiveHourexactly.dash/acctokens.go(#999):tokens.saved/tokens.causedare the sums overby_feature(addFeatureadds to both), so the cards' add-up claim holds. A ping row stores zeros in every token column (requestStoredTokenArgs), so no feature'scausedever contains the pings;keepalive_ping_tokensis read separately from the ping rows' own usage. That is exactly the rulef9227dc9displays. The lean read has the totals and the unmeasured count, noby_featureand no ping tokens — and the UI never reads those on a partial render (cards say "Loading…", the hero waits forready).
a268464f(every saving in tokens). Verified the display rule (tierText,tokenLine: nonzero tiers in the order wr, wr1h, rd, in, cost after), the partition (featureTokens: cache = keepalive + cachesplit + ttl; filter = toolfilter; defer = tooldefer; compaction = every otherby_featurekey — exhaustive, so the cards cover the whole map),totalTokens(tokens.saved / tokens.caused only), and the no-dollar paths (capNotewith a null formatter, the estimated-requests note). Hand-checked every new.mjsassertion, including the card/total add-up tier by tier and the ping line. All consistent.f9227dc9(pings on their own line). The total's cost istokens.causedonly; the pings show under the total and on the Cache card with one label (PING_LABEL), only when they paid something. Matches the server rule above and the docs.
Non-blocking
- The
subscription: truestart rule awaits the owner's yes. The token view now starts on the auth kind alone, with no open 5-hour window (no estimate then). The author flagged this themselves (comment at 08:45:03, "Please confirm"; at 12:02:11, "The owner is still deciding it"). Confirm before merge. The merged #991 makes this rule sound — the auth kind is fresh, not a stale header — so my only point is the pending decision, not the code. - The in-page info text (
app.jssubInfo) still does not mention the100 − usedcap or the "would have hit the limit" line. The docs page explains both. Carried from round 2. - The hero's kind line reads "wr cache write, rd cache read, in fresh input" —
wr1his missing from the list, though it can appear in the lines. The info box explains it. - On a server from before #999 (no
tokensat all), the Cache card's split box can render as an empty sunken<ul>: every row is null because no feature has tokens. Cosmetic, and only until the server is updated.
What I checked
- Last review: round 2, 0558248, 2026-11-09T17:28:35Z.
- New commits read: 3 on the branch (
9b078a61merge origin/main;a268464ffeat(dash): on a subscription show every saving in tokens;f9227dc9fix(dash): show the keep-alive pings on a line of their own). The merge also brought main's #991, #999, #996, #1009 and #981; I read #991's and #999's code in full because this PR depends on both, and the merge-conflict surface (dash files both touch) reads clean in the final tree. - Read in full: 4 reviews, 6 comments, 0 inline comments (from the three files).
- New items since my last review, and what I did about each:
- Comment 20:07:57 (on hold for #998 part 1): noted; #999 has since merged and this PR now builds on it.
- Comment 08:45:03 (part 2 changes): checked each of the six claims against the code and against #999's server fields — all hold.
- Comment 12:02:11 (pings line): checked the five claims — all hold.
- Commits
a268464fandf9227dc9: full diff read (7 files); verified the JSON field names againstdash/overview.go(tokens,tokens_unmeasured_requests,keepalive_ping_tokens), the tier JSON names againstTierTokens, andEndedChangeComponent=ended_change. - The new Go wiring pins (8 new strings in
TestOverviewSubscriptionHeadlineIsWired): each matches a code line ofapp.js;stripCommentsdrops only comment lines. - Eval-box and local test results in the comments (19 pass mjs;
./dash/...with-racepasses on both heads): read; I ran nothing myself.
- Hand-checked the arithmetic of every new and changed
.mjsassertion (token lines, the feature split, the add-up per tier, the ping line,capNotewith a null formatter). All pass by hand. - Checked for name collisions of the new globals (
isSubscription,tierText,addTiers,tokenLine,hasTokens,featureTokens,totalTokens,pingLine,PING_LABEL,TOKEN_TIERS,CACHE_FEATURES) against the other page scripts: none. - The data-dependence row now names #998 beside #985, still metadata only, decider filled.
amiddavid
left a comment
There was a problem hiding this comment.
| 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 | 3 of 3 | f9227dc9d66d |
approve |
Verdict: approve
Findings
None new. Part 2 (a268464f) and the pings line (f9227dc9) rework what the reviews already saw, on the #999 token fields. I found no defect in either commit.
Earlier findings
- Round 1 (blocking) — the estimate could show more than 100% of the limit. Still fixed. Part 2 did not touch
fiveHourSavedPct; themin(used × saved / cost, 100 − used)cap and thehitflag are as verified in round 2. - Round 1 (non-blocking) — the PR body named the issue, not the PRs. Fixed in round 2. The rewritten body names #991, #992 and #999. All three are in main now.
- Round 1 (non-blocking) —
throwfor control flow in the manager branch. Still fixed.readsLimitsreturns early. Part 2 kept it. - Round 2 (reviewer 2, non-blocking) — a stale limits answer could overwrite a newer one. Still fixed.
state.subSeqguardsloadOverviewLimits, and part 2 kept the guard when it added theisSubscriptiongate. - Round 2 (reviewer 2, non-blocking) — the manager guard had no test. Still fixed.
readsLimitsis tested insavings.test.mjs; the Go wiring test pins the call. - Round 2 (reviewer 2, non-blocking) — an unpriced deployment never shows the token headline. Accepted in round 2. Part 2 keeps the same hero gate (
priced), so the behavior matches the rest of the page. No change needed.
Non-blocking
- The
subscription: truestart rule still needs the owner's yes. The author's comment at 12:02:11 says the owner is still deciding it (PR open question 1). The repo rule says an agent never decides a behavior change. Merge only after the owner answers. The rest of the change — tokens on a subscription, no dollars — is decided on #985 and #998. - The info text still does not explain the cap. Reviewer 2 raised this in round 2; it stands. The info text under the headline describes only the raw formula. It does not mention the
100 − usedcap or the "would have hit the limit" line. - Two token figures on the Preset and Filter cards. On a subscription these cards show the new tier figure and the old "Tokens removed" figure. The Cache card drops its old derived figure. The old figures are measured (
tokens_before − tokens_after,decl_filter_reads), so the PR-body claim holds:saved_uniqueandreplay_tokensare out of the subscription view. A presentation choice, not a defect. - The Cache card's breakdown can render empty. On a subscription,
cacheRancan be true while every token row is null. Example: only manual pings ran, and no request has accountant tokens or ping tokens. Theov-splitlist then renders with no rows. Cosmetic. - The hero's "by kind" explainer omits
wr1h. The hero line under the total says "wr cache write, rd cache read, in fresh input". The info button does explainwr1h. Minor. - The estimate line still does not say its age. Carried from round 2. The window read can be up to 10 minutes old.
What I checked
- Last review: round 2, 0558248, 2026-11-09T17:29:44Z.
- New commits read: 2 PR commits (
a268464fpart 2,f9227dc9the pings line), plus the merge9b078a61. The other commits in0558248d..HEADcame from main through the merge; each was reviewed in its own PR (#979, #983, #987, #968, #977, #971, #982, #992, #981, #991, #996, #1009, #999). - Read in full: 4 reviews, 6 comments, 0 inline comments (from
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt). - New items since my last review, and what I did about each:
- Comment at 20:07:57 (on hold for #998 part 1): noted. #999 is in main now, so the hold is over.
- Comment at 08:45:03 (part 2 on
a268464f): checked each claim against the code. All hold, with one exception the author fixed himself in the next commit: ata268464fthe total's cost still included the ping tokens, against the owner's rule that a ping is not agent traffic. - Comment at 12:02:11 (the pings line on
f9227dc9): checked each claim.totalTokensno longer addskeepalive_ping_tokens. The pings show on their own line under the total and as a row on the Cache card. The words matchPING_LABEL, which #989 also uses. - Commit
a268464f: read the full diff and the final state ofsavings.js,app.js(renderSavedLedger,loadOverviewLimits),savings.test.mjs,savingsparts_test.go,style.css,docs/dashboard.md,docs/data-dependence.md. - Commit
f9227dc9: read the full diff. The pings line, the Cache card row, both test files, the docs. - Merge
9b078a61: main merged with no conflict into the subscription view. - PR body (rewritten): read in full. Checked each claim against the code. All hold (see non-blocking 3 for the "no longer used" claim).
- Verified the frontend/backend contract end to end:
/api/statstokens(saved,caused,by_feature,keepalive_ping_tokens,tokens_unmeasured_requests) againstdash/acctokens.go; theby_featurekeys against the accountant's component names andenvelopeComponents; the lean read (noby_feature, no ping tokens) against the hero'sreadygate, so the token view waits for the full read. - Hand-checked every assertion in
savings.test.mjs(19 tests) by arithmetic: the display rule, theby_featuresplit into cards, the cards-add-up invariant (the total's cost istokens.caused; no card's cost has the pings; the pings line shows only when the pings paid something), the cap cases,readsLimits,isSubscriptionwith a window that is over,capNotewithout dollars. I ran nothing — live tests are not approved. - Verified the 13 strings pinned by
TestOverviewSubscriptionHeadlineIsWiredsit on code lines ofapp.js, sostripCommentskeeps them. - Checked for name collisions of the new globals (
TOKEN_TIERS,PING_LABEL, and the new functions) across the page scripts: none. - Checked the fail-open path: a
/api/me/limitsfailure leavesstate.subnull, so the Overview falls back to the dollar view. - Checked the data-dependence row ("Subscription headline", metadata only, decided by David Amid on #985 and #998): it matches the code. Token counts, auth kind and rate-limit numbers only.
Review round 2 on #988. - tokenFigure in savings.js: one rule for every token figure. A priced zero reads "saved 0 tokens"; an all-zero figure with unpriced requests, or a server with no tokens, reads "not measured". The Overview cards and the headline use it: a feature left out of by_feature on a priced period now reads "saved 0 tokens". - The 5-hour estimate hides while a page filter is on: it is for the whole account. The info text says so, and explains the 100 - used cap and the "would have hit the 5-hour limit" line. - The hero legend names wr1h. - The Cache card: no empty list; the pings line is computed once; the rescue row reads "Keep-alive rescue"; the info text describes the token figures on a subscription. - Drop the "net is the rescue less the pings" claim: the tiers have no common unit. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Round 2 fixes, on 407534d. Owner decisions (2026-11-10)
What changed
Tests
|
Merges #988 at 407534d, which adds tokenFigure: one rule for zero against "not measured" on every screen. Conflict resolution and the follow-up change: - kaTokenLines takes the rescue text and its `measured` flag from tokenFigure. The three sentences still branch on the flag. - A ledger with no `tokens` (a server from before #999) now reads "not measured", as tokenFigure says. - The "Cache rewrites avoided" fact reads "up to 85.0k wr · cost 40.0k rd", without a second "saved". - savings.test.mjs keeps both sides' new tests. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
The Tokens saved cell now follows #988's shared rule for zero against "not measured" (tokenFigure), scoped to the session row. An all-zero figure with any unpriced request of the session, or a row with no tokens, reads "not measured". The dagger shows on a measured figure only. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
| 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 | 4 of 4 | 407534d103ac |
approve |
Verdict: approve
Findings
None.
Earlier findings and notes
- Round 1/2, the estimate cap — still fixed, unchanged by this commit.
- My round-3 non-blocking notes — all fixed in
407534d1:- The
subscription: truestart rule: the owner approved it as built (comment at 13:13:00, "Owner decisions (2026-11-10)"). The merge gate is closed. - The info text now explains the
100 − usedcap, the "would have hit the limit" line, and that the estimate is account-wide and hides under a filter. - The hero legend names
wr1h. - The Cache card no longer renders an empty
<ul>:subRowsis filtered and the list is drawn only when a row exists.
- The
- Reviewer 1's round-3 notes: the info-text cap (fixed), the empty list (fixed),
wr1h(fixed), the owner's yes (given). Their note 3 (two token figures on the Preset and Filter cards) is a presentation choice they already accepted; note 6 (the estimate's age) stays open as a wording choice. I agree with both dispositions. - No earlier finding was rejected.
What the new commit does, and what I verified
tokenFigure(flow, scope, fmt)— one rule for zero against "not measured". I traced every branch: a flow with tokens shows its line; an all-zero flow readssaved 0 tokensonly when the scope hastokensandtokens_unmeasured_requestsis 0; otherwisenot measured. This errs toward "not measured", which is the right direction (a missing figure never claims a measured zero). It matches the server:addFeatureleaves a zero feature out ofby_feature, and both reads always carrytokenspost-#999. The headline and all four cards now go through it; I hand-checked both new.mjstests, including the changed{tokens: {}}fixture (correct under the new rule: a scope with notokensreads "not measured").pageFiltered()hides the account-wide estimate while a filter narrows the page. I checked it against the real filter model:state.filterkeys come fromDIMS(model, provider, agent, preset, mode, component, reason, accounting, effort, thinking, stop_reason, session, tenant) plusq,projectand the time range. All narrow excepttenant, which the function excludes on purpose — and the tenant pick is a manager feature (wideScope()), while managers never see the estimate (readsLimits). Correct.subscriptionHeadlinetakes the flag as a sixth parameter; the one production caller passespageFiltered(), and an omitted flag stays falsy, so the tests and any other caller keep the old behavior.- The Cache card computes
pingLineonce, renames the rescue row to "Keep-alive rescue" (it no longer reads like the pings line below it), and draws the list only with rows. The subscription info text for the card now describes the token figures. - The "net is the rescue less the pings" claim is gone from the code comment and both docs sections. Right call: the tiers have no common unit, so the subtraction was not well defined.
- The two new Go wiring pins (
tokenFigure(flow, o, compact).text,subRows.length ? el('ul') and the updatedpageFiltered()pin all match code lines ofapp.js.
Non-blocking
- Reviewer 1's carried note: the estimate line still does not say its age (the window read can be up to 10 minutes old from the server's stale-while-revalidate cache). A wording choice, still open.
tokenFigure'smeasuredflag is exported but unused by this PR (the comment names #1041 and #1042 as its consumers). Not a defect.
What I checked
- Last review: round 3, f9227dc, 2026-11-10T12:07:16Z.
- New commits read: 1 (
407534d1fix(dash): one rule for zero against not measured, and round 2 fixes).git log f9227dc9..HEADlists exactly this one commit. - Read in full: 6 reviews, 7 comments, 0 inline comments (from the three files).
- New items since my last review, and what I did about each:
- Reviewer 1's round-3 review (12:11:20, approve): read in full; their six non-blocking notes checked against the code — items 1, 2, 4, 5 are now fixed by
407534d1, items 3 and 6 stand as accepted choices. - Comment 13:13:00 (round 2 fixes and owner decisions): checked all seven claims against the diff — all hold. The owner's approval of the
subscription: truestart rule closes my round-3 merge gate. - Commit
407534d1: read the full diff (5 files) and the final state ofsavings.js,app.js(pageFiltered,renderSavedLedger, the Cache card), both test files, and both docs sections.
- Reviewer 1's round-3 review (12:11:20, approve): read in full; their six non-blocking notes checked against the code — items 1, 2, 4, 5 are now fixed by
- Hand-checked the arithmetic of both new
.mjstests and the one changed assertion. All pass by hand. The author reports 21 pass locally and./dash/...with-racepassing on the box; I ran nothing myself. - Verified
pageFiltered()againstDIMS,qs(),setFilterandwideScope(); no non-narrowing filter key is missed. - Checked every caller of the changed signatures (
subscriptionHeadlinesixth parameter,tokenFigure): the production caller, the mjs tests, and the Go pin all updated in the same commit.
amiddavid
left a comment
There was a problem hiding this comment.
| 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 | 4 of 4 | 407534d103ac |
approve |
Verdict: approve
Findings
None new. The commit 407534d1 answers the review notes and the owner's round 2. I found no defect in it.
Earlier findings
- Round 1 (blocking) — the estimate could show more than 100% of the limit. Still fixed. This commit did not touch
fiveHourSavedPct. - Round 1 (non-blocking) — the PR body named the issue, not the PRs. Fixed in round 2. The body still names #991, #992 and #999, all in main.
- Round 1 (non-blocking) —
throwfor control flow in the manager branch. Still fixed.readsLimitsreturns early. - Round 2 (reviewer 2, non-blocking) — a stale limits answer could overwrite a newer one. Still fixed.
state.subSeqguardsloadOverviewLimits. - Round 2 (reviewer 2, non-blocking) — the manager guard had no test. Still fixed.
- Round 2 (reviewer 2, non-blocking) — an unpriced deployment never shows the token headline. Accepted. The hero gate is unchanged.
- My round-3 note 1 — the
subscription: truestart rule needed the owner's yes. Resolved. The author's comment at 13:13:00 records the owner's decision of 2026-11-10: approved as built. The PR body's open question is gone. - My round-3 note 2 and reviewer 2's round-2/3 note — the info text did not explain the cap. Fixed.
subInfonow has two new paragraphs: the100 − usedcap with the "would have hit the limit" line, and the filter rule. - My round-3 note 4 and reviewer 2's round-3 note — the Cache card's list could render empty. Fixed.
subRows.filter(Boolean), and the<ul>draws only when a row exists. - My round-3 note 5 and reviewer 2's round-3 note — the hero legend omitted
wr1h. Fixed. The hero line now reads "wr cache write, wr1h 1-hour cache write, rd cache read, in fresh input".
Non-blocking
- Two token figures beside each other. The Preset and Filter cards still show the old "Tokens removed" figure next to the new tier figure on a subscription, and the hero keeps "Input tokens removed" next to the tier total. The old figures are measured (
tokens_before − tokens_after,decl_filter_reads). A presentation choice, carried from round 3. - The estimate line still does not say its age. Carried from round 2. The window read can be up to 10 minutes old.
tokenFigurereturns ameasuredflag this PR does not use. Only.textis read here. The comment says #1041 and #1042 will switch to it. Harmless.
What I checked
- Last review: round 3, f9227dc, 2026-11-10T12:11:20Z.
- New commits read: 1 —
407534d1"fix(dash): one rule for zero against not measured, and round 2 fixes". - Read in full: 6 reviews, 7 comments, 0 inline comments (from
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt). - New items since my last review, and what I did about each:
- Commit
407534d1: read the full diff (5 files) and the final state ofsavings.js,app.js(renderSavedLedger,pageFiltered, the hero and the Cache card), both test files,docs/dashboard.md. - Author's comment at 13:13:00 (round-2 fixes, owner decisions): checked each of the seven claims against the code. All hold.
- Reviewer 2's round-3 review (12:07:16, posted while my round 3 was in flight, so I read it now for the first time): read in full. Its four non-blocking notes match mine from round 3. This commit addresses three of them; the fourth (the start rule) the owner decided.
- PR body edit: read it back in full. Line 32 now names the hidden estimate and the new info text. The open question about the start rule is gone, matching the owner's decision. Every claim I checked holds.
- Commit
- The zero rule (
tokenFigure). Verified the premise server-side:addFeatureindash/acctokens.goadds noby_featureentry for an all-zero figure, so a missing feature on a priced period is a measured zero. Verified the three branches against the code: tokens → its line; all-zero withtokenspresent and no unmeasured request →saved 0 tokens; otherwise →not measured. The conservative direction is right: with unmeasured requests, an all-zero figure can be a true zero or an unknown, and the rule says unknown. - The hidden estimate (
pageFiltered). Verifiedstate.filter(starts{}, values are set strings, cleared keys are deleted), sov && k !== 'tenant'is safe. The window read carries no filter params (lean=1&since=…), so the estimate was always account-wide; hiding it under a filter stops a wrong reading. The tenant pick is a manager control, and a manager never sees the estimate, so excluding it is right. The dollar view is untouched:pageFilteredfeeds only the subscription headline. - Hand-checked every new and changed
.mjsassertion (21 tests now): the zero-rule cases (priced zero, unpriced zero, notokens, a figure with tokens while unmeasured), the headline on the same rule, and the estimate under a filter (used 54, cost $90, saved $5 → raw 3, room 46 →≈ 3%). The changedsaved 0 tokensassertion now passes a scope withtokenspresent, which the new rule requires. I ran nothing — live tests are not approved. - Verified the three new Go pins sit on code lines of
app.js: thepageFiltered()argument (line 1751),tokenFigure(flow, o, compact).text(line 1811),subRows.length ? el('ul'(line 1827). - Checked
tokenFigureandpageFilteredfor name collisions across the page scripts: none.pageFilteredsits besidehasRange, both function declarations. - Checked the fail-open paths again:
state.subnull → dollar view;tokenFigureon a scope withouttokens→not measured, never NaN. - Checked the Cache card's new subscription info text and the "Keep-alive rescue" rename against the rows that draw: the row list and the info text name the same four things (rescue, pings, reorder, 1-hour cache).
- Checked the docs against the code: the zero rule, the no-empty-list rule, the pings-apart rule without the old "net is the rescue less the pings" claim, and the filter rule all match
savings.jsandapp.js.
Resolve the one conflict in dash/ui/app.js: keep the "Not counted in Your preset." text from main and the saving() cell from this branch. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
| 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 | 5 of 6 | 6da758398741 |
approve |
Verdict: approve
Findings
None new. The branch's only new commit is a merge of origin/main. It changes one line of this PR's code besides the merge itself, and I found no defect in the resolution or in its interaction with the subscription view.
Earlier findings
All earlier findings and notes stay as tracked in round 4. The merge touches none of the code behind them: the cap, readsLimits, state.subSeq, tokenFigure, pageFiltered, the hero legend and the Cache card are all unchanged. The owner's approval of the subscription: true start rule (comment at 13:13:00) still stands.
Non-blocking
- Two token figures beside each other. Carried from round 3. The Preset and Filter cards show the old "Tokens removed" figure next to the tier figure, and the hero keeps "Input tokens removed". Presentation choice.
- The estimate line still does not say its age. Carried from round 2.
tokenFigure'smeasuredflag is still unused here. #1041 and #1042 are named as its consumers. Harmless.
What I checked
- Last review: round 4, 407534d, 2026-11-10T13:17:50Z.
- New commits read: 1 —
6da75839"Merge origin/main into feat/dash-subscription". The main-line commits it brought (#1002, #1046, #720, #483, #1034, #1003, #1035, #1011, #1018, #1014, #989, #1020, #1012, #1010) each went through its own PR review; I read their commit messages and checked the two that touch this PR's files. - Read in full: 8 reviews, 7 comments, 0 inline comments (from
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt). - New items since my last review, and what I did about each:
- Merge commit
6da75839: read the full diff of the branch's own files across the merge (app.js,savings.js,style.css, both test files,docs/dashboard.md) and the code around each change. Onlyapp.jschanged, in two places. - Reviewer 2's round-4 review (13:17:16, posted 34 s before my round-4 post, so it was not in my round-4 snapshot): read it now in full. Verdict approve. Its verification of
tokenFigureandpageFilteredmatches mine; it adds one detail I re-checked, thatstate.filtercan also hold aprojectkey —pageFiltered's generic check counts it, so no narrowing filter is missed. Nothing to act on. - PR body: read it back and diffed it against my round-4 copy. Unchanged.
- Merge commit
- The one hand resolution.
dash/ui/app.js:1896-1900: the merge keeps main's "Not counted in Your preset." on the Tool deferral card's what-text and this branch'ssaving('saved-defer-usd', parts.defer, ft && ft.defer, true)cell. Both intents survive. The kept claim is also true in the token view:featureTokensputstooldeferin its own group, outside the Preset card's group, so the deferral's tokens are not counted in the Preset card either. - The merge's other
app.jschange is #720's warm-sweep reason labels inREASON_TEXT. The subscription view does not read them. No interaction. - The interaction with #1003 (the defer split, merged through this merge): it moves deferral dollars from "Your preset" to "Tool deferral" on the priced rows. The token view is unaffected:
by_featurestill carriestooldeferas its own key, so the cards-add-up invariant and the defer card's tokens hold as before. - The interaction with #1002 (the repricing, the new base): I checked whether a repriced row could turn into a false "measured zero". It cannot.
tokens_unmeasured_requestscounts rows withacc_priced = 0(dash/acctokens.go,unmeasuredTerm), anddash/reprice.gonever writesacc_priced— it setstoken_accounting=completeand the dollar columns only. So the zero rule's premise is untouched. - Verified the Go pins from
TestOverviewSubscriptionHeadlineIsWiredstill sit on code lines: the merge touched only the defer card's what-text (line 1899) andREASON_TEXT(line 2345+), far from every pinned line. - Verified the branch's other files are byte-identical to round 4's head: the merge diff shows no change to
savings.js,style.css,savings.test.mjs,savingsparts_test.go,docs/dashboard.md.
amiddavid
left a comment
There was a problem hiding this comment.
| 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 | 5 of 6 | 6da758398741 |
approve |
Verdict: approve
Findings
None.
Earlier findings and notes
- Round 1/2, the estimate cap — still fixed. The merge did not touch
fiveHourSavedPctor any ofsavings.js; the file is byte-identical to the round-4 head. - My round-4 non-blocking notes — unchanged, still open as accepted: the estimate line does not say its age;
tokenFigure'smeasuredflag waits for #1041 and #1042. - Reviewer 1's round-4 notes — unchanged. Their two token figures beside each other (presentation choice) and the estimate's age stand. I agree with both.
- No earlier finding was rejected.
What the new commit does, and what I verified
The branch has one new commit: 6da75839, a merge of origin/main (87b29db). The PR's own files are otherwise unchanged: savings.js, savings.test.mjs, savingsparts_test.go, docs/dashboard.md and style.css are not in the merge diff. What I checked:
- The one conflict (
dash/ui/app.js, the Tool deferral card). The merge keeps main's "Not counted in Your preset." sentence (from #1003, which moved the deferral dollars out of the preset's saving) and this branch'ssaving(...)cell (the subscription token view). Both sit on the merged line and read together correctly. The card's gateparts.defer !== 0 || (ft && hasTokens(ft.defer))is unchanged. - #1003 (tool deferral priced by the library) — the main change that touches this PR's view. The library now prices deferral from the bodies, under the component name
tooldefer(DeferComponent). That is exactly the key this PR'sfeatureTokensmaps to the Tool deferral card, so the subscription card can now show a token figure where before #1003 it always read "not measured". No double count:by_feature["tooldefer"]is its own entry, and the Preset card's bucket is "every other entry", so the token view keeps the deferral out of the preset — the same split the new card text states for dollars. The baseline losesdeferFig, so the dollar side does not count it twice either. - #1002 (reprice loop) — no effect on this PR's figures.
dash/reprice.goupdates onlycost_usd,baseline_cost_usd,cache_saved_usd,billed_token_factorandtoken_accounting. It does not touchacc_priced, thetok_*columns orkeepalive, sotokens_unmeasured_requestsand every token figure this PR reads are unchanged by repricing. - #720 (sweep warm path) — falls in the existing buckets. It adds sweep reason labels to
REASON_TEXTinapp.jsand warm counters to the sweep ledger, but no newby_featurekey and no new card. A sweep component's tokens land in the Preset bucket ("every other entry"), so the partition stays exhaustive and the cards still add up to the total. - The column changes in
dash/query.goanddash/store.go(defer_cost_usd,sweep_false_expands_warm) insert the new columns before the token columns in both the SELECT list and the INSERT list, with the scan targets and args in the same order.requestTokenSelect,requestTokenDestandrequestStoredTokenArgsare untouched. - All 12 wiring pins in
TestOverviewSubscriptionHeadlineIsWiredstill sit on code lines of the mergedapp.js(I grepped each string; every one matches). The merge changed no pinned line. docs/dashboard.mdis unchanged and still accurate: the card list ("Tool deferral:tooldefer", "Preset: every other entry") matches the merged server, and the zero rule's premise (a zero feature is left out ofby_feature) still holds.
Non-blocking
- The Tool deferral card's description on the token view. The merged text ends "Net of the names list and the searches. Not counted in Your preset." On a subscription the card shows
by_feature["tooldefer"]: saved = the definitions left out, cost = the names list growth. The searches come back in the response, so they have no request-token figure at all. The sentence is exact for the dollar view and approximate for the token view. Wording only; the Cache card's subscription info text shows the pattern to follow if the author wants it. - Reviewer 1's carried notes stand: two token figures beside each other on the Preset and Filter cards, and the estimate line's age.
What I checked
- Last review: round 4, 407534d, 2026-11-10T13:17:16Z.
- New commits read: 1 (
6da75839Merge origin/main into feat/dash-subscription).git log --first-parent 407534d1..HEADlists exactly this one commit. - Read in full: 9 reviews, 7 comments, 0 inline comments (from the three files).
- New items since my last review, and what I did about each:
- Reviewer 1's round-4 review (13:17:50, approve): read in full. Nothing addressed to me; their carried notes match mine.
- Merge
6da75839(the base moved from7fd26dcdto87b29db): read the conflict resolution (git show), thengit diff 407534d1..HEADfor every dash file the merge changed —app.js,tools.js,overview.go,query.go,store.go,sweepattr.go,event.go,accountant_price.go— anddash/reprice.goin full. Confirmedsavings.js, both test files anddocs/dashboard.mdare absent from that diff (unchanged). - The main commits the merge carries (#1002, #1003, #720, #1046 and the plugin/Pi/test PRs) were each reviewed in their own PRs; I read the three that touch this PR's data (#1002, #1003, #720) at the level of their interaction with the subscription view, as described above.
- Verified all 12 wiring-pin strings from
savingsparts_test.goagainst the mergedapp.js— all match. - Verified the merged defer card line in the final tree (
app.js:1897-1900): both parents' changes present, gate unchanged. - Checked the data-dependence rows the merge touched (#1002, #1003, #720 updated their own rows); this PR's row is unchanged.
- I ran nothing — live tests are not approved. The author's merge message and the main PRs' comments report
./dash/...green on the merged tree.
No conflicts. Second merge, after 6da7583 landed on the branch. Earlier hand resolution (Tool deferral card in dash/ui/app.js) is kept by 6da7583 and is intact. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
The approval of 6da7583 still counts.
|
|
Merged origin/main into this branch (head 138324a). No rebase. Hand resolution (1 file, 1 line)
Adapted fields: none. Semantic check
Tests (shared box, -race)
|
It carries the main changes #988 took before its squash merge. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
#988 is now on main as a squash. Each conflicted file was unchanged on main since the #988 head 138324a, so this branch keeps its own version. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
It carries the main changes #988 took before its squash merge. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
#988 is now on main as a squash. Each conflicted file was unchanged on main since the #988 head 138324a, so this branch keeps its own version. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
…1022) (#1042) On a Claude subscription, the dashboard Cache strategy tab shows the measured rescue and the ping cost in tokens, by tier, not dollars. The source is the accountant's tier tokens stored by #999. The forecast, "Ahead"/"Behind", the winner/loser split and the "costs more than it saves" banner keep the same dollar rule, and say they are at API-price weights. A ledger with no token rows shows "saved 0 tokens" and the "not measured" note. Fixes #1022. Behavior change: members and local proxies on a Claude subscription (/api/me/limits says subscription: true, or a 5-hour window is open). Old: every measured figure in dollars. New: tokens by tier, as above. Managers, API-key, Bedrock and Vertex users and hosted mode keep dollars. No switch; it follows the subscription signal, as #988 does. Owner's yes, 2026-11-11, in the integrator session: "1042 has my approval". Data dependence: metadata only (token counts by tier, already stored by #999). No change at any storage level. Reviews: 2 offload reviews (GLM), round 5 (owner granted it), both approve at f893c22; round 5 confirmed the PR's own change is byte-identical to the round-4 approval at 6b586a6. After it: a merge of main with no hand resolution (remerge-diff 0), tested on the merged tree. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
…1041) On a Claude subscription, the Sessions tab shows tokens, not dollars, in its three dollar columns: Cost becomes Tokens used, Net saved becomes Tokens saved (a dagger marks a session with unmeasured requests), and Keep-alive net becomes Keep-alive, with the pings on a line of their own, never added into a total. /api/sessions adds five fields to each row for every caller: tokens, keepalive_tokens, keepalive_ping_tokens, used_tokens and tokens_unmeasured_requests. One formatter, sessionTokenCells in savings.js, reuses #988's helpers. Closes #1023. Behavior change: only the one #1023 asks for: on a subscription the Sessions tab shows tokens. Managers, API-key users and hosted mode (#997) keep dollars. Owner's yes, 2026-11-11, in the integrator session: "#1041 (Sessions tab): approved, but merge it after #1042". Data dependence: metadata only (token counts by tier, already stored by #999). No change at any storage level. Reviews: 2 offload reviews (GLM), round 4 (pre-approved by the owner), both approve at 7e454bc. Round 4 reviewed the merge of main after #1042, which kept both sides by hand in dash/ui/savings.js, dash/savings.test.mjs, dash/savingsparts_test.go and docs/dashboard.md. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
On a Claude subscription with enough history, the dashboard learns how the 5-hour limit weighs each token tier, and uses those weights in place of API prices for two figures: the Overview's 5-hour estimate (#988) and the Cache strategy tab's yes/no forecast and range (#1042). - dash/fivehourfit.go: a pure Go fit, one non-negative weight per tier (input, cache read, 5-minute write, 1-hour write, output), from the stored 5-hour share and the billed tokens by tier. Change points remove most whole-percent rounding; spans with outside traffic are dropped by a robust residual test. A tier it cannot learn takes its API price, scaled to the account's spend. - The gate: at least 200 requests, 3 windows and 30 spans, fit error at most 0.25, and a learned cache-read and cache-write weight. - GET /api/me/fivehour-weights serves the fit for the caller's own account, cached 15 minutes. - No real data was available; the fit was tested on synthetic data. Behavior change: members and local proxies on a Claude subscription, only after the fit passes its gate. Old: "estimate at API-price weights". New: "estimate at learned 5-hour weights (from N requests)". Below the gate or on any error, both figures and labels stay as before. Managers, API-key, Bedrock, Vertex and hosted users see no change. No switch: a fit that fails the gate is the off state. Owner's yes, 2026-11-11: "#1068 (Fixes #1047, learned 5-hour weights): approved." Data dependence: metadata only (shares, token counts and the model per row); docs/data-dependence.md row "Decided by: David Amid, #1047 (2026-11-11)". Fixes #1047. Reviews: 5 offload review rounds (GLM). Round 5: both approve at 57d38f7, which is the PR head (a merge of main with an empty remerge-diff). Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]>
Closes #985. Part 2 of #998 for the dashboard. #991, #992 and #999 are in main.
Behavior change. Who: users on a Claude subscription who open the dashboard Overview. Old: every saving shows in dollars. New: every saving shows in tokens, by kind, with a dim estimate of the 5-hour limit share below the total. No dollars show on a subscription. How to turn it off: nothing to turn off. API-key, Bedrock and Vertex users, managers, and hosted users (#997) see no change. The owner decided this on #985 and #998.
Data dependence: metadata only (token counts by tier, the auth kind and the rate-limit numbers). The same at each storage level.
docs/data-dependence.mdhas the row.Summary
A subscription does not bill per token, so dollars mean little to that user. On a subscription the Overview now shows the total and each card in tokens, from the accountant's tier tokens in
/api/stats(#999). The total reads, for example,saved 85.0k wr · 12.0k in · cost 40.0k rd. Below it, dim:≈ 3% of the 5-hour limit (estimate at API-price weights).What changed
dash/ui/savings.js, shared with feat(plugin): status and insights savings show saved tokens on a subscription #989 and feat(mod): subscription band in tokens, this session only #981):wr(5-minute cache write),wr1h(1-hour cache write),rd(cache read),in(fresh input).cost. Tiers are never added into one number.tierText,addTiers,tokenLine,hasTokens.tokenFigure, returns{text, measured}), for every token figure:saved 0 tokens. The server leaves a zero feature out ofby_feature, so a missing feature on a priced period is a zero;tokens_unmeasured_requests> 0, or a server with notokens:not measured.sessionTokenCells) and feat(dash): on a subscription show the Cache strategy tab in tokens (#1022) #1042 (kaTokenLines) can switch to it.tokens.savedandtokens.caused(totalTokens).pingLine), under the total and on the Cache card:Keep-alive pings (not in the total): cost 900 wr · 410.0k rd. The words match feat(plugin): status and insights savings show saved tokens on a subscription #989. A ping is not agent traffic, sokeepalive_ping_tokensis not in the total or in any card's cost. Every screen follows this rule: the band's lean read has no ping tokens.tokens.by_feature(featureTokens):keepalive),cachesplitandttl, one row each, and the pings line.cachesplitstays one entry. With no rows, the list does not show.ended_change).toolfilter. Tool deferral:tooldefer.tokens_unmeasured_requests> 0, a note under the total says how many requests have no token figure.isSubscription):/api/me/limitssayssubscription: true, or a 5-hour window is open. Before, only an open window counted, so a subscription user idle for 5 hours saw dollars. The estimate still needs an open window.min(used% × saved_usd / cost_usd, 100 − used%)for the window, shown after $0.50 of spend and 2% used. It is for the whole account, so it is hidden while a page filter (a session, a time range, a model...) is on. The info text explains the cap, the "would have hit the 5-hour limit" line and the filter rule.saved_uniqueandreplay_tokensare no longer used for the subscription view.docs/dashboard.md: new section "On a subscription, the Overview shows tokens".How it was tested
node --test dash/savings.test.mjs(local): 21 pass, 0 fail. New tests:'';by_featuresplit into the cards; the cards add up to the total, tier by tier; the pings are on their own line and in no cost; a server with notokensgives empty lines, not NaN;subscription: truewith a window that is over shows tokens and no estimate;TestOverviewSubscriptionHeadlineIsWired(Go) checks thatapp.jscallsisSubscription,featureTokensand the token cards, readstokens_unmeasured_requests, and draws the two pings lines.CGO_ENABLED=1 go test -race -count=1 -timeout 30m ./dash/...on the eval box, on 407534d, in 8 foreground runs by first letter: 993 pass, 0 fail, 12 skip (allTest*). The skips are live, demo, node and browser tests.Open questions
🤖 Generated with Claude Code