Repository navigation
feat(dash): on a subscription the Sessions tab shows tokens (#1023) - #1041
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]>
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]>
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]>
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]>
On a Claude subscription the Sessions tab now shows tokens, not dollars, in its three dollar columns. Managers, API-key users and hosted mode keep dollars. - /api/sessions adds per session: tokens (the accountant figure less the keep-alive rescue), keepalive_tokens (the rescue), keepalive_ping_tokens (what the pings paid), used_tokens (billed input by tier) and tokens_unmeasured_requests. - A second query reads them for the page's sessions only, on a session index. The list's own aggregate does not change. At 20,000 requests: list 103 ms, token read 2.5 ms. - Cost shows Tokens used, Net saved shows Tokens saved, Keep-alive shows the rescue and the pings on a line of their own (pingLine). context-guru's own model calls have no token form. - One formatter: sessionTokenCells reuses tierText, tokenLine and pingLine from savings.js. 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 | fresh | 2 of 2 | 1 of 2 | 15bffe4f0363 |
blocking |
Verdict: blocking
Findings
- dash/ui/app.js:1806 — a subscription card says "not measured" for a feature that was measured and saved 0 tokens
- What fails: a priced window where the preset (or the filter, or the cache) ran and saved 0 tokens, and
tokens_unmeasured_requestsis 0. The card for that part showsnot measured. The hero on the same page showssaved 0 tokensand no "not measured" note. So the card states the opposite of what the page states elsewhere. - Proof:
addFeaturedrops a zero figure fromby_feature(dash/acctokens.go:383-391). So a measured-but-zero part has no entry.featureTokensthen gives a zero flow,tokenLinereturns'', and the fallback at app.js:1806 (tokenLine(flow, compact) || 'not measured') printsnot measured. The dollar path labels the same state$0.00(money(), app.js:1793-1796). The Sessions cells solve this exact problem with the unmeasured count:all ? 'not measured' : 'saved 0'(dash/ui/savings.js,sessionTokenCells). - Fix: apply the
sessionTokenCellsrule to the cards. When the read is full ando.tokens_unmeasured_requestsis 0, showsaved 0. Keepnot measuredfor the unmeasured and pre-#999 cases.
- What fails: a priced window where the preset (or the filter, or the cache) ran and saved 0 tokens, and
Non-blocking
loadOverviewLimits(Overview) andonSubscription(Sessions) each fetch/api/me/limits; they share no request. Also,onSubscriptioncaches a failed fetch for 60 s, so one network blip keeps the Sessions tab on dollars for a minute.- On a subscription,
sort=coststill orders the Sessions tab bySUM(cost_usd), a column the tab no longer shows. The order usually matchesused_tokens, so this is cosmetic. - The golden fixture has no accountant-priced rows, so
sessions.jsonpins the new fields only in their zero shape: all 60 sessions readtokens_unmeasured_requests == turns. The priced path is covered byTestSessionTokens_SplitTheKeepAliveAndKeepThePingsApart. sessionTokensQueryruns for every/api/sessionscaller, subscription or not. The cost is measured and documented (2.5 ms of a 103 ms list,TestSessionTokens_StaysCheapOnALargeWindow), so this is fine as shipped.
What I checked
- Read
CLAUDE.mdanddocs/design.mdfirst. - Read the full diff
7fd26dcd..HEAD(12 files) and the code around each hunk. - Go:
dash/query.go(SessionTokens,sessionTokensQuery,sessionTokens,SessionsOrdered),dash/acctokens.go(less,tokenSumTerms,accTokenTailTerms,accTokensAgg,addFeature), plus the helpers they reuse:withKeepAlive,autoPing,kaSavedSince,pingsBySession,Filter.where,filterFrom.- Column count check: the query selects 27 terms (1 id + 8
tok_total+ 8tok_ka+ 6 tail + 4 used); the scan binds 27. TheflowColumnsorder matchesflowOf. - Ping scoping check: the token ping figure and the dollar
keepalive_ping_usdboth useautoPing(auto pings only, manual pings in neither);used_tokensand the dollarcost_usdboth exclude every ping row. The two views stay consistent. lesscannot go negative:tok_totalis written as components + the four effects, all non-negative, sotok_kais a part of it per row.- Tenant scoping:
sessionTokensruns under the same tenant-scoped filter as the list; ids come from the page rows.
- Column count check: the query selects 27 terms (1 id + 8
/api/me/limits: readdash/limits.goend to end.utilizationis a 0..1 fraction andreset_sis unix seconds;fiveHourSavedPctandfiveHourStartMsuse them correctly.{}and a failed call keep the dollar view. Managers never ask (readsLimits).- JS:
dash/ui/savings.jsanddash/ui/app.jsin full for the changed parts —subscriptionHeadline,fiveHourSavedPct(guards:cost < 0.5,used < 2,saved > 0; cap at100 - used),featureTokens,pingLine,sessionTokenCells,sessionHeaders,loadOverviewLimits(stale-answer guard viasubSeq),onSubscription(60 s cache). Verified the JSON names the UI reads exist on the server structs (tokens,keepalive_ping_tokens,tokens_unmeasured_requests,used_tokens, ...). - The estimate's window stats are fetched unfiltered (
ctl, notapi): correct, because the 5-hour limit is account-wide while the Overview'socan be filtered. - Tests:
dash/sessiontokens_test.go,dash/savingsparts_test.go,dash/savings.test.mjsin full. Checked each wiring-test string againstapp.js/index.html. The mjs test runs throughTestSavingsPartsAddUp(node on PATH). - Golden: sanity-checked all 60 sessions of
testdata/golden/sessions.jsonwith a script — no negative tiers, ping rows excluded fromused_tokens,tokens_unmeasured_requestsconsistent with the fixture having no priced rows. - Docs:
docs/dashboard.md(both new sections, anchor links, the field table) and the newdocs/data-dependence.mdrow. - No Go builds or tests were run (not approved).
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 | fresh | 1 of 2 | 1 of 2 | 15bffe4f0363 |
approve |
Verdict: approve
Findings
None. I found no wrong behavior, no data loss, no broken fail-open path and no security problem.
Non-blocking
- dash/query.go:620 — the doc comment overstates what
keepalive_tokensis.- It says
KeepAliveTokensis "the token form of keepalive_saved_usd". The dollar field is the read-time gated credit (kaSavedSince, dash/keepalive.go:91); the token field is the accountant's own rescue figure (tok_ka_*), with no gate. The two disagree on rows where the legacy rule and the accountant differ (docs/accountant/cg-differences-root-causes.md, causes 9 and 12). - The token figure is the better measurement, and the UI tooltip already calls it "a ceiling". I ask only for a true sentence: say it is the accountant's rescue figure, a different measurement from the gated dollar column.
- It says
- dash/ui/app.js:3103-3107 — the Sessions tab waits for
/api/me/limitsbefore it paints.Promise.all([api('sessions'), onSubscription()])couples the list to the limits call.ctlhas no timeout, so a hung request stalls the whole tab. The Overview loads its limits without awaiting, and its comment states the rule: "a slow or failed read must never blank the savings above it".- A failure is handled (
.catch(() => null)); only a hang exposes this. Fix if desired: paint on the sessions answer, then flip headers and cells when limits answer.
- dash/ui/app.js:3205 — the token Cost cell prints
0where the dollar cell printsn/awith a reason.- The dollar cell uses
usdOrNA, so a session with no reported usage says "cannot say". The token cell printsc.cost || '0', which reads as "used zero tokens". The saved cell beside it says "not measured" in the same case, so the reader has a cue. Low impact.
- The dollar cell uses
- dash/ui/app.js:1754 — the hero legend omits
wr1h.- The line says "by kind: wr cache write, rd cache read, in fresh input", but the figure above it can show
wr1h(the 1-hour cache). The info button explains it. One word missing.
- The line says "by kind: wr cache write, rd cache read, in fresh input", but the figure above it can show
- dash/ui/savings.js:83-96 — the 5-hour estimate ignores the page filter.
- The headline follows the page filter; the estimate reads the unfiltered window (
/api/stats?lean=1&since=<window start>). With a filter on, the two lines describe different scopes. The docs say the estimate is about the window, so this is a design choice. Consider hiding it while a filter is active.
- The headline follows the page filter; the estimate reads the unfiltered window (
What I checked
- Every changed file:
dash/acctokens.go,dash/query.go,dash/savings.test.mjs,dash/savingsparts_test.go,dash/sessiontokens_test.go,dash/testdata/golden/sessions.json,dash/ui/app.js,dash/ui/index.html,dash/ui/savings.js,dash/ui/style.css,docs/dashboard.md,docs/data-dependence.md. - The new SQL, column by column against the scan targets: 1 id + 8
tok_total+ 8tok_ka+ 6 tail + 4 used = 27 columns, and 27 scan targets. TheflowOforder matchesflowColumns.lesscannot go negative:tok_kais a per-row part oftok_total. - The filter path:
withKeepAlive(f)copies the filter,SessionInre-scopes to the page's sessions, andwhere()re-applies tenant and window, so the token figures span the same rows as the dollar figures. Ping rows store zeros in every token column (requestStoredTokenArgs), so the plain sums stay agent-only. - The ping tail uses
autoPing(auto pings only), the same predicate as the dollarkeepalive_ping_usdinpingsBySession. Manual pings are excluded from both. Consistent. - The
used_tokensterms:fresh_input,cache_read,MAX(cache_write - cache_write_1h, 0),cache_write_1hoverkeepalive = 0.cache_write_1hisNOT NULL DEFAULT 0, so no NULL reaches the sums. - The query-cost claim:
idx_requests_sessionandidx_requests_tenant_sessionexist (dash/schema.go:342, 372), andTestSessionTokens_StaysCheapOnALargeWindowasserts the plan and a relative budget. - The arithmetic identities the docs claim:
tokens+keepalive_tokens= the session's/api/statstotals, andKeepAliveTokens= the Overview'sby_feature["keepalive"]— both pinned byTestSessionTokens_SplitTheKeepAliveAndKeepThePingsApart. - The JS decision functions, case by case against their tests in
savings.test.mjs: window liveness and boundaries, the $0.50 / 2% gates, the100 - usedcap, the< 1%form, tier order,featureTokensadding up to the total tier by tier, pings kept out of every cost, and the pre-#999 server shapes (noNaN). - The race guards:
state.subSeqdrops an older limits answer;onSubscriptionshares one request for 60 s;sessionHeaderscaptures the dollar labels before its first flip and restores them. savings.jsloads beforeapp.js(both deferred), so the new globals (PING_LABEL,subscriptionHeadline,sessionTokenCells) exist whenapp.jsruns.- The golden file: regenerated with the new fields, and I cross-checked the ping-token rows against the fixture's ping events.
- Repo rules: data-dependence row added with a decision reference; no proxy or library behavior changes; every display change is inside the dashboard and named by its issue.
…review) - The table paints on the sessions answer, in the last known view. When /api/me/limits answers with another view, it paints again. - A failed limits read is not kept for a minute: the next load asks again. Only a good answer is shared. - The token Cost cell shows n/a with the reason, as the dollar cell, when no turn reported usage. - Costliest first keeps the dollar order on a subscription, labelled "at API prices": one order in tokens would add the tiers. - The keepalive_tokens comment and docs say it is the accountant's own rescue figure, not the gated keepalive_saved_usd. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
|
Round 1 replies. Fixes are in Reviewer 2 (blocking)
Reviewer 1 (approve)
Tests at
|
|
Owner decision (2026-11-10): keep Tokens saved without the keep-alive rescue; the rescue keeps its own column, as in the dollar view. The sessions token query runs for every caller (2.5 ms). Round 2 runs after #988 lands the shared "saved 0 / not measured" rule and this branch merges it. |
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]>
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]>
|
What changed
Tests at
|
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 | 2 of 2 | cf307d4e12ef |
blocking |
Verdict: blocking
Earlier findings
- Mine, round 1 (blocking): a subscription card said "not measured" for a part that saved 0 tokens. Fixed. #988's
tokenFigurelanded in407534d1and the mergecf307d4eapplies it: the cards (app.js:1811), the headline (savings.js,subscriptionHeadline) and the Sessions saved cell all readtokenFigure(flow, scope, fmt). I checked the rule itself: a non-zero flow shows its line; an all-zero flow withtokenspresent andtokens_unmeasured_requests0 readssaved 0 tokens; an all-zero flow with unmeasured requests, or a scope with notokens(a server before #999/#1023), readsnot measured. The mjs tests pin all three cases. - My non-blocking items: the 60 s failure cache is fixed (
onSubscriptiondrops a failed promise, app.js:3092-3096);sort=costis kept with a label and a sound reason (tiers cannot be added) — I accept it; the golden-fixture and query-cost items are noted and owner-decided (comment of 2026-11-10T12:54:25Z). One stays open: see Non-blocking. - Reviewer 1's five items: 1 (comment) fixed in
b2b3d22d, both indash/query.goanddocs/dashboard.md; 2 (tab waits for limits) fixed — the table paints on the sessions answer, then repaints when the limits answer differs, with a load number (sessSeq) that drops an older answer; 3 (Cost cell0vsn/a) fixed viausdOrNA; 4 (hero legendwr1h) fixed for the hero; 5 (estimate vs page filter) fixed —pageFiltered()hides the estimate while a filter or time range narrows the page.
Findings
- dash/ui/app.js:3266 — the keep-alive rescue line says "saved 0" when the rescue was not measured
- What fails: a session whose agent rows were not priced (rows before the accountant, or a fallback) and whose auto pings did run.
keepalive_ping_tokensis measured from the ping rows' own usage, so it is non-empty.keepalive_tokensis 0 (no priced rescue). The keep-alive cell then showssaved 0for the rescue. The saved cell on the same row saysnot measured, because the same session goes throughtokenFigure. One row makes two opposite claims. - Proof:
sessionTokenKeepAlivefalls back toc.keepalive || 'saved 0'(app.js:3266), wherec.keepaliveis a plaintokenLine(savings.js,sessionTokenCells). The PR's own rule says otherwise:docs/dashboard.mdcallstokenFigure"one rule for every screen", and the Overview info text says "saved 0 tokensis a measured zero". Old ping rows carry usage (fresh_input,cache_read) but store zeros in everytok_*column, so the trigger is real on mixed old/new data. - Fix: run the rescue line through the shared rule, like the saved cell:
tokenFigure(s.keepalive_tokens, s, compact).textin place ofc.keepalive || 'saved 0'. Keep then/abranch for "the strategy did not run".
- What fails: a session whose agent rows were not priced (rows before the accountant, or a fallback) and whose auto pings did run.
Non-blocking
sessionTokenCost's title (app.js:3235) and the Sessions "Cost" header (data-sub-titlein index.html) still listwr, rd, inwithoutwr1h, whileused_tokenscan showwr1h. The hero legend got this fix (407534d1); these two spots did not.loadOverviewLimitsandonSubscriptionstill fetch/api/me/limitsseparately on one page visit. The round-1 reply said the shared request goes with the #988 follow-up; #988 merged here without it.
What I checked
- Last review: round 1,
15bffe4f03633e06146f272ceda815412d157b55,2026-11-10T12:34:16Z. - New commits read: 3 —
b2b3d22d"fix(dash): Sessions tab paints without waiting for the limits (#1041 review)",407534d1"fix(dash): one rule for zero against not measured, and round 2 fixes",cf307d4e"Merge feat/dash-subscription; Sessions cells use tokenFigure". - Read in full: 2 reviews, 2 comments, 0 inline comments (from
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt). - New items since my last review:
- Review by reviewer 1 at 12:36:20Z — read; its five non-blocking items checked one by one above.
- Comment at 12:40:49Z (round-1 replies) — each reply checked against the code; "moved to #988" confirmed by the merge.
- Comment at 12:54:25Z (owner decision on the token query cost) — noted; no code to check.
- Comment at 13:17:00Z (
cf307d4emerge note) — verified against the diff.
- Read the full diff
15bffe4f..cf307d4e(6 files) and the final code around each hunk indash/ui/app.js,dash/ui/savings.js,dash/query.go,dash/savingsparts_test.go,dash/savings.test.mjs,docs/dashboard.md. - Checked the merge itself:
cf307d4ehas parentsb2b3d22dand407534d1; the cumulative diff against my round-1 head shows only those two commits' changes, so the merge added nothing on its own. tokenFigure: traced every caller — cards, headline, Sessions saved cell. Found the one caller left out (finding 1).pageFiltered():state.filteris initialized to{}(app.js:213) and never unset, soObject.entriescannot throw. Its filter set matches whatqs()sends, minus tenant, which only chooses whose figures — correct.- The new Sessions paint flow:
subPnever rejects (onSubscriptionreturns a promise with a rejection handler),paint(!!state.sessSub)paints the last known view at once, andseq === state.sessSeqdrops a limits answer from an older load. Checked the failure, hang and no-change cases. onSubscription's failure cache: a rejected promise nullsstate.subLimitsPonly if it is still the current one, and the next call re-asks. Checked the race with a cached good answer.- Tests: read the new mjs cases (
tokenFigure, the headline's filtered parameter, the session zero cases) and the updated wiring strings insavingsparts_test.go; each string was matched against the finalapp.js. - No Go builds or tests were run (not approved).
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 | 2 of 2 | cf307d4e12ef |
approve |
Verdict: approve
Findings
None. Every round-1 finding is fixed or answered, and the new code introduces no defect I can show.
Earlier findings, checked one by one
Mine (round 1, all non-blocking):
keepalive_tokenscomment overstated the figure. Fixed inb2b3d22d. The comment (dash/query.go:620-623) and docs/dashboard.md now say it is the accountant's own rescue figure, a different measurement from the gatedkeepalive_saved_usd, and that the two can disagree. That is the true sentence I asked for.- The Sessions tab waited for
/api/me/limitsbefore it painted. Fixed inb2b3d22d. The table paints on the sessions answer in the last known view (paint(!!state.sessSub)), and repaints when the limits answer differs. A load number (state.sessSeq) drops an older limits answer. I checked the other race too: a stale sessions answer cannot repaint over a newer load, becauserefresh()aborts the previous fetch (state.ac.abort(), app.js:5205) andaborted(err)returns. A failed limits read no longer caches:p.catchclearsstate.subLimitsP, so the next load asks again. - The token Cost cell printed
0where the dollar cell printsn/a. Fixed inb2b3d22d.sessionTokenCostnow routes the no-usage case throughusdOrNAwith the same reason as the dollar cell, gated on the sames.baseline_cost_usdsignal. - The hero legend omitted
wr1h. The author moved it to #988, and #988's commit407534d1is merged in this head: the legend now names "wr1h 1-hour cache write". Fixed. - The 5-hour estimate ignored the page filter. Same: fixed in the merged
407534d1.pageFiltered()(app.js:307-309) covers the time range (hasRange) and everystate.filterkey excepttenant, andsubscriptionHeadlinetakes it asfilteredand hides the estimate. I checked the key set:setFilteris the only writer ofstate.filterand all its keys narrow the figures;tenantpicks whose figures, which the comment states. The info text and docs say the estimate is account-wide and hidden under a filter.
Reviewer 2's round-1 findings:
- A card said "not measured" for a measured zero (blocking). Fixed by the #988 merge (
407534d1, in this head ascf307d4e).tokenFigurein dash/ui/savings.js is now the one rule: a flow with tokens shows its line; an all-zero flow with no unpriced request readssaved 0 tokens; an all-zero flow with unpriced requests, or a server with notokens, readsnot measured. I checked the cause myself:addFeaturedrops zero figures fromby_feature(dash/acctokens.go:383-391), so the missing entry is the zero, and the new rule reads the period'stokens_unmeasured_requeststo tell the two apart. The cards, the headline and the Sessions cells all call it, each with its own scope. - Two separate
/api/me/limitsreads; a failed one cached for 60 s. The caching is fixed (b2b3d22d). The sharing is deferred to a #988 follow-up, and #988 as merged does not do it:loadOverviewLimitsstill makes its own call. I accept the reason — both reads are small, the Sessions one is shared for a minute, and the Overview's call carries its own sequencing (subSeq). Non-blocking, still open. sort=costorders by dollars on a subscription. Kept and labelled, with the author's reason: one token order would have to add the tiers, and the display rule forbids adding tiers. The reason is right — the whole feature refuses to add tiers, and the dollar order is an API-price weighting, the same one the 5-hour estimate uses. The option now reads "Costliest first (at API prices)" (sessionHeaders). Accepted.- The golden fixture pins the new fields only in their zero shape. Noted by the author; the priced path is pinned by
TestSessionTokens_SplitTheKeepAliveAndKeepThePingsApart. Accepted. sessionTokensQueryruns for every caller. The owner decided on 2026-11-10 (PR comment): keep it, 2.5 ms of a 103 ms list. Accepted.
Non-blocking
- The Overview (
loadOverviewLimits) and the Sessions tab (onSubscription) still make separate/api/me/limitsrequests. The author defers the shared request to a #988 follow-up. Both are cheap and the Sessions one is cached for a minute, so this stays a nit. sessionTokenCostusess.baseline_cost_usdas the "usage was reported" signal, exactly as the dollar cell does. A session whose turns all priced to exactly $0.00 of baseline would shown/abeside real token figures. The dollar column behaves the same way, so the two cells agree; noting it only for the record.
What I checked
- Last review: round 1,
15bffe4f03633e06146f272ceda815412d157b55, 2026-11-10T12:36:20Z. - New commits read: 3 —
b2b3d22d(Sessions tab paints without the limits; failed read not kept; Cost cell n/a; costliest labelled; comment fix),407534d1(#988:tokenFigure, estimate hidden under a filter, legend, Cache card, docs),cf307d4e(merge). - 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:
- Reviewer 2's round-1 review (blocking, one finding): re-derived the defect from
addFeatureand checked the fix end to end. - The author's reply comment (12:40): mapped each reply to a commit and verified the claim in the code.
- The owner decision comment (12:54): two decisions, both display-only, both recorded; no action needed.
- The merge comment (13:17): confirmed the merge brings #988's rule to the Sessions cells, and re-ran my own trace of the new rule.
- Reviewer 2's round-1 review (blocking, one finding): re-derived the defect from
- The new code, line by line:
tokenFigure(savings.js): traced every input shape — priced zero, unpriced zero, cost-only flow, lean read, pre-#999 server,undefinedscope — against the mjs tests. The headline now calls it with the period as scope; the cards call it only past thepartialguard; the Sessions cells call it with the session row as scope.subscriptionHeadline's newfilteredargument: old callers (tests) pass nothing, so it defaults off; the one app.js caller passespageFiltered().pageFiltered: checked the writers ofstate.filter(setFilteris the only one) and the range state (state.from/state.tothroughrangeMs).- The reworked
loadSessions: checked both orderings — the sessions answer paints in the last known view; the limits answer repaints only when the view differs and the load number is current; a stale sessions answer is aborted byrefresh().state.sessSubpersists across pagination, so later pages paint in the right view at once. onSubscription: a rejected fetch clears the shared promise (if (state.subLimitsP === p)), so the next load re-asks; the returned chain never rejects.sessionHeadersnow also relabels the sort option; the option exists in index.html (line 605).- The Cache card:
subRowsfiltered and the empty-list case returnsnull; the pings line is computed once; the info text has its own subscription variant.
- The wiring tests (
savingsparts_test.go): matched each new expected string against the final app.js. - The docs (dashboard.md): every claim in the two changed sections matches the code — the zero rule, the hidden estimate, the labelled sort, the paint-without-waiting note, and the corrected
keepalive_tokensdescription. - No Go builds or tests were run (not approved). I traced the mjs test cases by hand instead.
…d 2) - The keep-alive rescue line goes through tokenFigure, scoped to the session. Unpriced rows with pings that ran now read "not measured", not "saved 0". The pings line still shows. n/a stays for a strategy that did not run. - The Tokens used title and header name wr1h. - The Overview and the Sessions tab share one /api/me/limits request (meLimits). The Overview still asks fresh each time; it only joins a request in flight. The Sessions tab reuses a good answer for a minute. A failed answer is not kept. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
|
Round 2 replies. The fixes are in Reviewer 2
Reviewer 1
Tests at
|
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]>
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]>
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 | 358d87916266 |
approve |
Verdict: approve
Findings
None. Both items from my round-2 review are fixed in 358d8791, and the new code introduces no defect I can show.
Earlier findings
- Mine, round 2 (blocking): the keep-alive rescue line said "saved 0" when the rescue was not measured. Fixed.
sessionTokenCellsnow runs the rescue through the shared rule:keepalive: tokenFigure(s.keepalive_tokens, s, fmt).text(savings.js:239). The session row is the scope, so the session's owntokens_unmeasured_requestsdecides betweensaved 0 tokensandnot measured. The plainc.keepalive || 'saved 0'fallback is gone from app.js. Then/abranch now needs both!c.keepaliveRan && !c.pings(app.js:3266), so it still means "the strategy did not run". The dollar cell keeps the same meaning for the same state. The new mjs cases pin both zero outcomes and the quiet session. - Mine, round 2 (non-blocking):
wr1hmissing from the Tokens used title and header. Fixed. The Cost cell title (app.js:3246) and the headerdata-sub-title(index.html:611) both name "wr1h 1-hour cache write", matching the hero legend. - Mine, round 2 (non-blocking): two separate
/api/me/limitsfetches. Fixed.meLimits(maxAgeMs)(app.js:3093) makes one request for both screens.
What I checked
- Last review: round 2,
cf307d4e12efcb86d1d3bfdcf9c41699a9edbffc,2026-11-10T13:22:27Z. - New commits read: 1 —
358d8791"fix(dash): Sessions keep-alive cell follows the zero rule (#1041 round 2)". - Read in full: 4 reviews, 4 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:
- Review by reviewer 1 at 13:22:44Z (round 2, approve) — read; its two non-blocking items match what I saw in the code, and the author's round-2 reply answers both.
- Comment at 13:27:46Z (round-2 replies, tests at
358d8791) — each reply checked against the final code below.
- Read the full diff
cf307d4e..358d8791(6 files) and the final code around each hunk. - The keep-alive fix, end to end:
tokenFigure(s && s.keepalive_tokens, s, fmt)—tokenLinetakes anundefinedflow safely, so a row withoutkeepalive_tokensreadsnot measured, not a crash.keepaliveRan: hasTokens(...)is the "any token in the figure" signal; a session with pings but no measured rescue now shows the measured-or-not line, notn/a.sessionTokenKeepAlive(app.js:3264-3279): the rescue line is plainc.keepalive; the pings line stays separate and still shows the ping cost on its own line.- New mjs cases: unpriced rows plus pings ran → rescue
not measuredand pingscost 9000 rd; all priced, pings ran, no rescue →saved 0 tokens; quiet session →keepaliveRan: false. The deepEqual pin includeskeepalive: 'not measured', keepaliveRan: false.
meLimits(maxAgeMs), case by case:- In flight:
state.limitsAt === nullmarks it, so a second caller joins the same promise. No second request. - Success: the completion stamps
state.limitsAtonly if the promise is still the current one. - Failure:
state.limitsPis nulled only if still current, so the next call asks again. A failure is never cached. - Overview (
meLimits(0)): a completed answer is always older than 0 ms, so each load asks fresh. It only joins a request already in flight, which the reply states. Its rejection is caught (app.js:1936-1945), so a failed read leaves the dollar view. - Sessions (
meLimits(60000)): a good answer is reused for a minute.onSubscriptionchains a rejection handler (app.js:3113), so the returned promise never rejects. - An older answer cannot stamp
limitsAtafter a newer request started: the newer request setstate.limitsPfirst, so the guard fails.
- In flight:
- Wiring strings in
savingsparts_test.go(meLimits(60000),state.limitsP,const limits = await meLimits(0);) match the final app.js. - Docs:
docs/dashboard.mdnow says the rescue goes through the shared zero rule and documents the shared limits request. Both claims match the code. - No Go builds or tests were run (not approved).
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 | 358d87916266 |
approve |
Verdict: approve
Findings
None. Every earlier finding is fixed, answered or closed, and the new commit introduces no defect I can show.
Earlier findings, checked one by one
Mine (round 2, both non-blocking):
- The Overview and the Sessions tab made separate
/api/me/limitsrequests. Fixed in358d8791.meLimits(maxAgeMs)(app.js:3093-3104) is now the one door. A request in flight is shared (limitsAt === null). The Overview passes 0, so each load asks fresh. The Sessions tab passes 60000, so it reuses a good answer for a minute. A failed answer clears the shared promise, and only if it is still the current one, so the next caller asks again. Both callers handle a rejection:loadOverviewLimitshas its try/catch (app.js:1935-1945),onSubscriptionreturnsfalse(app.js:3113). I traced the races: a second Overview load during a flight joins it; a failure after a newer request started cannot clear the newer promise. - A session whose baseline priced to exactly $0.00 shows
n/abeside real token figures. The author noted it and kept the signal, because the dollar cell uses the same one. The two cells agree. Closed.
Reviewer 2's round-2 findings:
- Blocking: the keep-alive rescue line said "saved 0" when the rescue was not measured. Fixed in
358d8791. The rescue line now goes through the shared rule:tokenFigure(s.keepalive_tokens, s, fmt)insessionTokenCells(savings.js:239), with the session row as scope. I traced every shape against the new mjs cases (savings.test.mjs:249-261):- Unpriced rows and pings that ran: the rescue reads
not measured, the pings line still showscost 9000 rd. - Every row priced, pings ran, no rescue:
saved 0 tokens. - Strategy did not run: no rescue tokens and no pings, so the cell keeps its
n/abranch (app.js:3266).
The saved cell and the rescue line now read the same scope, so one row cannot make two opposite claims.
- Unpriced rows and pings that ran: the rescue reads
wr1hwas missing from the Tokens used title and the Cost header. Fixed in358d8791. The cell title (app.js:3246) and the headerdata-sub-title(index.html:611) both name "wr1h 1-hour cache write".
Non-blocking
- A session where the strategy ran, rescued 0 tokens, and the pings billed 0 tokens reads
n/a, "your cache strategy did not run". The row cannot tell that case from not running: both leave no token inkeepalive_tokensorkeepalive_ping_tokens. The trigger needs a ping with zero usage in every kind, which I cannot show on real data. The dollar cell has the same blind spot. For the record only.
What I checked
- Last review: round 2,
cf307d4e12efcb86d1d3bfdcf9c41699a9edbffc, 2026-11-10T13:22:44Z. - New commits read: 1 —
358d8791"fix(dash): Sessions keep-alive cell follows the zero rule (#1041 round 2)" (6 files: savings.js, app.js, index.html, savings.test.mjs, savingsparts_test.go, docs/dashboard.md). - Read in full: 4 reviews, 4 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:
- Reviewer 2's round-2 review (13:22:27Z, blocking): re-derived the defect from
sessionTokenCellsand checked the fix end to end, case by case. - The author's round-2 reply (13:27:46Z): mapped each claim to the code and verified it myself.
- Reviewer 2's round-2 review (13:22:27Z, blocking): re-derived the defect from
- The new code, line by line:
meLimits: traced reuse, in-flight sharing, freshness (maxAgeMs 0 and 60000), failure clearing, and the race between an old failure and a newer request. The returned promise rejects on failure, and both callers catch it, so no unhandled rejection and no blank screen.loadOverviewLimitskeeps itssubSeqguard;onSubscriptionkeeps the manager guard (readsLimits). The oldstate.subLimitsPstate is gone —grepfinds no leftover.sessionTokenCells:keepalivenow carries the rule's text andkeepaliveRancarrieshasTokens(keepalive_tokens). The n/a gate is!c.keepaliveRan && !c.pings. I checked all four combinations of rescue-tokens and pings against the mjs cases.- The wiring tests (
savingsparts_test.go:72-74): matched each expected string against the final app.js (lines 3101, 3113, 1936). - The docs (
docs/dashboard.md): the Keep-alive row and the shared-limits notes match the code.
- No Go builds or tests were run (not approved). I traced the mjs cases by hand instead.
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]>
|
#988 is merged. This branch now has
|
Whitespace only. CI lint failed on gofmt. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
c10bd5e is a gofmt fix only. CI lint failed on
|
Conflicts in dash/ui/savings.js, dash/savings.test.mjs, dash/savingsparts_test.go and docs/dashboard.md. Both sides added a function, a test and a doc section next to each other. Kept both. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Merged origin/main (b9e29f7) into this branch: 7e454bc.
|
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 | fresh | 1 of 2 | 4 of 4 | 7e454bcaae4f |
approve |
Verdict: approve
Findings
None. The four new commits are two merges from main, one merge of the final #988 head, and one gofmt fix. I checked every merge resolution and every earlier fix. Nothing is lost and nothing new breaks.
Earlier findings, checked one by one
All my rounds 1-3 findings and reviewer 2's findings were closed at 358d8791, which I approved. The only question this round: did the merges keep them? They did. I verified each fix in the final code:
- The shared zero rule (
tokenFigure). Present insessionTokenCells(dash/ui/savings.js):keepalive: tokenFigure(s && s.keepalive_tokens, s, fmt).text, with the session row as scope. The cards, the headline and the Sessions saved cell all still call it. meLimits(maxAgeMs). Present (app.js:3077). The Overview passes 0, the Sessions tab 60000. A failed answer clears the shared promise only if still current (app.js:3085).- The Sessions paint flow.
paint(!!state.sessSub)and thesessSeqguard are present (app.js:3217-3218). Then/aCost cell (usdOrNA), thewr1hlabels andkeepaliveRanare all present. - The
keepalive_tokenscomment in dash/query.go and its docs row: unchanged since round 2, still the true sentence.
The new commits
b1e3203a— merge the final #988 head (138324a8). Verified against the first parent (358d8791): the only changes in this PR's files aremain's own (requestColsgainsr.defer_cost_usdandr.sweep_false_expands_warm, with both scan targets added in the same hunk; app.js gains sweep-v3 reason words and a card note). Nothing of this PR's is lost.2b49f80e— mergeorigin/main. Touches none of this PR's files. Trivial for the PR.c10bd5e1— gofmtdash/savingsparts_test.go.git diff -w c10bd5e1^ c10bd5e1is empty, as the author's comment says. Whitespace only.7e454bca— mergeorigin/main(b9e29f74), conflicts resolved by hand. I checked each conflicted file against both parents:dash/ui/savings.js: vs the branch side the merge adds only #1042'skaTokenLines; vsmainit adds only this PR'ssessionTokenCells. Both are inmodule.exports, each defined once.dash/savings.test.mjs: both test blocks kept, each intact.dash/savingsparts_test.go: both wiring tests kept. I ran the string checks myself: all 27 wiring strings from the two tests are present in the final app.js (comments stripped, asstripCommentsdoes).index.htmlhas exactly 3data-sub-label=headers, as the test wants.docs/dashboard.md: both sections kept, each heading appears once.dash/ui/app.jsmerged with no conflict; I read the whole diff since358d8791. The changes aremain's (#1042's Cache-tab token view, #1039's tile removals, #1057's deadkv(), #1040's 80k floor text, sweep-v3 reasons). This PR's functions are untouched.- No conflict markers anywhere at HEAD.
New items since my last review, and what I did
- Comment at 2026-11-10T16:11:33Z (#988 merged in; "only the base moved"). Verified: the merge changes this PR's files only by
main's own hunks (commit 1 above). - Comment at 2026-11-10T16:42:36Z (gofmt only). Verified:
git diff -wis empty. - Comment at 2026-11-11T03:02:43Z (merge
b9e29f74, 4 conflicts, both sides kept). Verified file by file, both directions, as above.
Non-blocking
renderKAVerdictandrenderKADownsidecallkaTokenLines(o, compact)without theledgerNet !== nullguard thatrenderKADecisionhas. This is #1042's own code frommain, not this PR's, andtokenFigurehandles a ledger withouttokens("not measured"), so nothing misbehaves. For the record only.
What I checked
- Last review: round 3,
358d87916266c88ec3c09636ddd53e70e35dfc45,2026-11-10T15:36:43Z. - New commits read: 4 —
b1e3203a"Merge the final #988 head (138324a)",2b49f80e"Merge origin/main into feat/sessions-tab-tokens",c10bd5e1"style(dash): gofmt dash/savingsparts_test.go",7e454bca"Merge origin/main into feat/sessions-tab-tokens". - Read in full: 6 reviews, 7 comments, 0 inline comments (from
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt). - The net PR diff
b9e29f74..HEAD(11 files) and the diff358d8791..HEADon every PR-owned file. dash/query.go: the merged column list and scan targets stay in step (both parents' additions kept, one list, one scan).- The golden fixtures:
maindid not touchsessions.jsonbetween my heads, so the PR's regeneration stands alone.keepalive.jsonhas the fields the new mjs test reads (tokens_unmeasured_requests: 591). - The server side of the merged UI code:
/api/keepalive'stokens,keepalive_ping_tokensandtokens_unmeasured_requestsexist (dash/keepalive.go:304-390). - No Go builds or tests were run (not approved). I ran the wiring-string checks and the fixture reads with node on local files only.
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 | fresh | 2 of 2 | 4 of 4 | 7e454bcaae4f |
approve |
Verdict: approve
Findings
None. The PR's own code is unchanged since the round-3 head, except gofmt whitespace. The new commits only merge main in, and every conflict resolution keeps both sides whole.
Earlier findings
All findings from rounds 1 to 3 stay fixed. I verified each fix survived the merges:
- Round 1 (blocking): a card said "not measured" for a measured zero. Still fixed.
tokenFigure(savings.js:156) is unchanged, and every caller still routes through it. - Round 2 (blocking): the keep-alive rescue line said "saved 0" when not measured. Still fixed.
sessionTokenCells(savings.js:239) still runs the rescue throughtokenFigure, and then/agate insessionTokenKeepAlive(app.js:3250) still needs both no rescue tokens and no pings. - Round 2-3 non-blocking items (
wr1hlabels, one shared/api/me/limitsrequest). Still fixed.meLimits(app.js:3077) and the Cost cell title and headerdata-sub-titleare unchanged. - Reviewer 1's items. All closed in round 3. Reviewer 1's round-3 note (a ran-but-zero session reads
n/a) is unchanged behavior; I have nothing to add.
What I checked
- Last review: round 3,
358d87916266c88ec3c09636ddd53e70e35dfc45,2026-11-10T15:36:38Z. - New commits read: 6 on the PR's own path —
6da75839and138324a8(main into feat/dash-subscription),b1e3203a(final #988 head into this branch),2b49f80e(main into this branch),c10bd5e1(gofmt),7e454bca(mainb9e29f74into this branch). The other 23 commits in358d8791..HEADare main-side, already in the base. - Read in full: 6 reviews, 8 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 them:
- Review by reviewer 1 at 15:36:43Z (round 3, approve) — read; its one note matches the code and stays for the record.
- Comment at 16:11:33Z (#988 merged, main merged in) — verified the merge added nothing on its own for this PR's files.
- Comment at 16:42:36Z (gofmt commit
c10bd5e1) — verifiedgit diff -w c10bd5e1^ c10bd5e1is empty: whitespace only. - Comment at 2026-11-11T03:02:43Z (merge
7e454bca, 4 files in conflict) — checked each resolution below.
- The PR's own content, file by file,
358d8791..HEAD:dash/acctokens.go,dash/sessiontokens_test.go,dash/ui/index.html,dash/testdata/golden/sessions.json: byte-identical to round 3.dash/query.go: only main'srequestColschanges (defer_cost_usd,sweep_false_expands_warm). TheSessionRow,sessionTokensQueryandsessionTokenscode is untouched.dash/ui/savings.js: #1042'skaTokenLinesadded besidesessionTokenCells. Each function is defined once; both are inmodule.exports.sessionTokenCellsitself is unchanged.dash/savings.test.mjs: #1042's two tests added; this PR'ssessionTokenCellstest is unchanged.dash/savingsparts_test.go: gofmt alignment plus #1042'sTestKeepAliveTabSubscriptionTokensAreWired. Thedata-sub-labelcount check still wants 3, andindex.htmlhas exactly 3, all on Sessions headers. Every wiring string in both tests matches the finalapp.js.dash/ui/app.js: all hunks since round 3 sit in main's areas (keep-alive tab, tiles, tools).loadSessions,meLimits,onSubscription,sessionHeadersand the threesessionToken*cell builders are unchanged; I read them in full at HEAD.docs/dashboard.md: additions only since round 3 (#1042's section). This PR's Sessions section is intact, and its anchor link resolves.
- The merge resolution in
7e454bca: parentsc10bd5e1andb9e29f74. Both sides kept in all four conflict files; no function, test or doc section lost. - The helpers
sessionTokensQuerydepends on (withKeepAlive,autoPing,tokenSumTerms,flowColumns,accTokenTailTerms): unchanged by the merges.dash/acctokens.gohas zero diff since round 3. - The golden
sessions.json: all 60 sessions carrytokens,keepalive_tokens,keepalive_ping_tokens,used_tokensandtokens_unmeasured_requests; no negative tier anywhere. - No Go builds or tests were run (not approved). The author's box run at
7e454bca(comment of 03:02:43Z) reports dash green and 34 node tests passing, which matches what I read in the code.
Builds on #988; merge after it.
Closes #1023.
Summary
On a Claude subscription, the Sessions tab now shows tokens, not dollars, in its three dollar columns. Managers, API-key users and hosted mode (#997) keep dollars. The keep-alive pings show on a line of their own and are never added into a cost.
What changed
/api/sessionsadds five fields to each session row, for every caller:tokens: the session's accountant figure (tok_total_*) less the keep-alive rescue. It is the token form ofsaved_usd.keepalive_tokens: the keep-alive rescue (tok_ka_*).tokenspluskeepalive_tokensequals the session's/api/statstokens, tier by tier.keepalive_ping_tokens: what the session's pings paid, in billed tokens by tier.used_tokens: the agent requests' billed input tokens by tier.tokens_unmeasured_requests: the session's agent requests with no token figure.isSubscriptionandreadsLimitstest as feat(dash): on a Claude subscription show saved tokens, with the 5-hour share as an estimate #988):used_tokens, for example1.6k wr · 20.0k rd · 400 in).saved … · cost …). A † marks a session with unmeasured requests.Keep-alive pings (not in the total): cost …on its own line (pingLine,PING_LABELfrom feat(dash): on a Claude subscription show saved tokens, with the 5-hour share as an estimate #988).n/awhen the strategy did not run.data-sub-labelin index.html).sessionTokenCellsin savings.js usestierText,tokenLineandpingLinefrom feat(dash): on a Claude subscription show saved tokens, with the 5-hour share as an estimate #988.Columns with no token form
cg_llm_cost_usd): no token figure on the request row. On a subscription the Tokens used cell leaves them out and its tooltip says so.Query cost
session_id IN (…)). The plan uses a session index; the test asserts it.-race: the list 103 ms, of which the token read 2.5 ms (about 2.4%). With-race: 4.14 s and 99 ms.Data dependence
Metadata only. It sums token numbers the dashboard already stores (#999). No new storage. The same at every storage level.
Behavior change
Only the one the issue asks for: on a subscription the Sessions tab shows tokens. Nothing else changes for managers, API-key users or hosted mode.
How it was tested
go test -race ./dash/..., in two halves:-run '^Test[A-H]': 407 passed, 3 skipped, 0 failed.-run '^Test[^A-H]': ok (598 top-level tests), 0 failed, 479 s.node --test dash/savings.test.mjs dash/navhash.test.mjs: 30 passed, 0 failed. New:a Sessions row in tokens.TestSessionTokens_SplitTheKeepAliveAndKeepThePingsApart: the two parts add up to the session's/api/statstokens; the pings, the unmeasured count and the used tokens match.TestSessionTokens_StaysCheapOnALargeWindow: the query plan uses a session index; the token read stays under a quarter of the list's time.TestSessionsSubscriptionTokensAreWired: the UI wiring (a manager keeps dollars, three cells, three headers).testdata/golden/sessions.json: regenerated. A script checked that the only change is the five new fields on each row.Open questions
🤖 Generated with Claude Code