Skip to content

feat(dash): on a subscription the Sessions tab shows tokens (#1023) - #1041

Merged
amiddavid merged 16 commits into
mainfrom
feat/sessions-tab-tokens
Nov 11, 2026
Merged

amiddavid merged 16 commits into
mainfrom
feat/sessions-tab-tokens

Conversation

@amiddavid

Copy link
Copy Markdown
Collaborator

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/sessions adds 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 of saved_usd.
    • keepalive_tokens: the keep-alive rescue (tok_ka_*). tokens plus keepalive_tokens equals the session's /api/stats tokens, 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.
  • Sessions tab, on a subscription (same isSubscription and readsLimits test as feat(dash): on a Claude subscription show saved tokens, with the 5-hour share as an estimate #988):
    • Cost becomes Tokens used (used_tokens, for example 1.6k wr · 20.0k rd · 400 in).
    • Net saved $ becomes Tokens saved (saved … · cost …). A † marks a session with unmeasured requests.
    • Keep-alive net becomes Keep-alive: the rescue on one line, and Keep-alive pings (not in the total): cost … on its own line (pingLine, PING_LABEL from feat(dash): on a Claude subscription show saved tokens, with the 5-hour share as an estimate #988). n/a when the strategy did not run.
    • The headers change with the view (data-sub-label in index.html).
  • One formatter. A new sessionTokenCells in savings.js uses tierText, tokenLine and pingLine from feat(dash): on a Claude subscription show saved tokens, with the 5-hour share as an estimate #988.
  • Docs: docs/dashboard.md (new section "On a subscription, the Sessions tab shows tokens"), docs/data-dependence.md (the Subscription headline row now names the Sessions tab).

Columns with no token form

  • context-guru's own model calls (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.
  • Output tokens are not a tier of the display rule. The Tokens used tooltip gives their count.
  • The cache split has no dollar column on this tab. In tokens it is part of Tokens saved, with the 1-hour head and the ended-change break.

Query cost

  • The list's own aggregate does not change.
  • A second query reads the token figures for the sessions on the page only (session_id IN (…)). The plan uses a session index; the test asserts it.
  • Measured on the box, 20,000 requests, 25 sessions a page, no -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

  • Box, 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, node --test dash/savings.test.mjs dash/navhash.test.mjs: 30 passed, 0 failed. New: a Sessions row in tokens.
  • New Go tests:
    • TestSessionTokens_SplitTheKeepAliveAndKeepThePingsApart: the two parts add up to the session's /api/stats tokens; 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

  • Tokens saved leaves the keep-alive rescue out, to match the dollar columns (the keep-alive has its own column). So a session's Tokens saved is not equal to the Overview total for that session. The two columns add up to it. Is that the wanted split?
  • The token fields are served to every caller, also on the dollar view. A query flag could skip the second query (2.5 ms) when the view shows dollars.

🤖 Generated with Claude Code

…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 amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Verdict: blocking

Findings

  1. 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_requests is 0. The card for that part shows not measured. The hero on the same page shows saved 0 tokens and no "not measured" note. So the card states the opposite of what the page states elsewhere.
    • Proof: addFeature drops a zero figure from by_feature (dash/acctokens.go:383-391). So a measured-but-zero part has no entry. featureTokens then gives a zero flow, tokenLine returns '', and the fallback at app.js:1806 (tokenLine(flow, compact) || 'not measured') prints not 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 sessionTokenCells rule to the cards. When the read is full and o.tokens_unmeasured_requests is 0, show saved 0. Keep not measured for the unmeasured and pre-#999 cases.

Non-blocking

  • loadOverviewLimits (Overview) and onSubscription (Sessions) each fetch /api/me/limits; they share no request. Also, onSubscription caches a failed fetch for 60 s, so one network blip keeps the Sessions tab on dollars for a minute.
  • On a subscription, sort=cost still orders the Sessions tab by SUM(cost_usd), a column the tab no longer shows. The order usually matches used_tokens, so this is cosmetic.
  • The golden fixture has no accountant-priced rows, so sessions.json pins the new fields only in their zero shape: all 60 sessions read tokens_unmeasured_requests == turns. The priced path is covered by TestSessionTokens_SplitTheKeepAliveAndKeepThePingsApart.
  • sessionTokensQuery runs for every /api/sessions caller, 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.md and docs/design.md first.
  • 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 + 8 tok_ka + 6 tail + 4 used); the scan binds 27. The flowColumns order matches flowOf.
    • Ping scoping check: the token ping figure and the dollar keepalive_ping_usd both use autoPing (auto pings only, manual pings in neither); used_tokens and the dollar cost_usd both exclude every ping row. The two views stay consistent.
    • less cannot go negative: tok_total is written as components + the four effects, all non-negative, so tok_ka is a part of it per row.
    • Tenant scoping: sessionTokens runs under the same tenant-scoped filter as the list; ids come from the page rows.
  • /api/me/limits: read dash/limits.go end to end. utilization is a 0..1 fraction and reset_s is unix seconds; fiveHourSavedPct and fiveHourStartMs use them correctly. {} and a failed call keep the dollar view. Managers never ask (readsLimits).
  • JS: dash/ui/savings.js and dash/ui/app.js in full for the changed parts — subscriptionHeadline, fiveHourSavedPct (guards: cost < 0.5, used < 2, saved > 0; cap at 100 - used), featureTokens, pingLine, sessionTokenCells, sessionHeaders, loadOverviewLimits (stale-answer guard via subSeq), 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, not api): correct, because the 5-hour limit is account-wide while the Overview's o can be filtered.
  • Tests: dash/sessiontokens_test.go, dash/savingsparts_test.go, dash/savings.test.mjs in full. Checked each wiring-test string against app.js/index.html. The mjs test runs through TestSavingsPartsAddUp (node on PATH).
  • Golden: sanity-checked all 60 sessions of testdata/golden/sessions.json with a script — no negative tiers, ping rows excluded from used_tokens, tokens_unmeasured_requests consistent with the fixture having no priced rows.
  • Docs: docs/dashboard.md (both new sections, anchor links, the field table) and the new docs/data-dependence.md row.
  • No Go builds or tests were run (not approved).

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

  1. dash/query.go:620 — the doc comment overstates what keepalive_tokens is.
    • It says KeepAliveTokens is "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.
  2. dash/ui/app.js:3103-3107 — the Sessions tab waits for /api/me/limits before it paints.
    • Promise.all([api('sessions'), onSubscription()]) couples the list to the limits call. ctl has 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.
  3. dash/ui/app.js:3205 — the token Cost cell prints 0 where the dollar cell prints n/a with a reason.
    • The dollar cell uses usdOrNA, so a session with no reported usage says "cannot say". The token cell prints c.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.
  4. 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.
  5. 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.

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 + 8 tok_ka + 6 tail + 4 used = 27 columns, and 27 scan targets. The flowOf order matches flowColumns. less cannot go negative: tok_ka is a per-row part of tok_total.
  • The filter path: withKeepAlive(f) copies the filter, SessionIn re-scopes to the page's sessions, and where() 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 dollar keepalive_ping_usd in pingsBySession. Manual pings are excluded from both. Consistent.
  • The used_tokens terms: fresh_input, cache_read, MAX(cache_write - cache_write_1h, 0), cache_write_1h over keepalive = 0. cache_write_1h is NOT NULL DEFAULT 0, so no NULL reaches the sums.
  • The query-cost claim: idx_requests_session and idx_requests_tenant_session exist (dash/schema.go:342, 372), and TestSessionTokens_StaysCheapOnALargeWindow asserts the plan and a relative budget.
  • The arithmetic identities the docs claim: tokens + keepalive_tokens = the session's /api/stats totals, and KeepAliveTokens = the Overview's by_feature["keepalive"] — both pinned by TestSessionTokens_SplitTheKeepAliveAndKeepThePingsApart.
  • The JS decision functions, case by case against their tests in savings.test.mjs: window liveness and boundaries, the $0.50 / 2% gates, the 100 - used cap, the < 1% form, tier order, featureTokens adding up to the total tier by tier, pings kept out of every cost, and the pre-#999 server shapes (no NaN).
  • The race guards: state.subSeq drops an older limits answer; onSubscription shares one request for 60 s; sessionHeaders captures the dollar labels before its first flip and restores them.
  • savings.js loads before app.js (both deferred), so the new globals (PING_LABEL, subscriptionHeadline, sessionTokenCells) exist when app.js runs.
  • 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]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 1 replies. Fixes are in b2b3d22d.

Reviewer 2 (blocking)

  1. app.js:1806, a card says "not measured" for a part that saved 0. Moved to feat(dash): on a Claude subscription show saved tokens, with the 5-hour share as an estimate #988. That line is feat(dash): on a Claude subscription show saved tokens, with the 5-hour share as an estimate #988's code. The main session fixes it there as one shared rule for 0 and "not measured", and the Sessions cells will use the same rule.
  • Two separate /api/me/limits reads, and a failed read cached for 60 s. Fixed in b2b3d22d. onSubscription now keeps only a good answer. After a failed read, the next load asks again. Sharing one request with the Overview's loadOverviewLimits goes with the feat(dash): on a Claude subscription show saved tokens, with the 5-hour share as an estimate #988 follow-up, because that function is feat(dash): on a Claude subscription show saved tokens, with the 5-hour share as an estimate #988's code.
  • sort=cost orders by dollars on a subscription. Kept, and labelled, in b2b3d22d. One token order would have to add the tiers, and the display rule forbids that. The dollar order weights the tiers at API prices, as the 5-hour estimate does. On a subscription the option now reads "Costliest first (at API prices)".
  • The golden fixture pins the new fields only in their zero shape. Noted. TestSessionTokens_SplitTheKeepAliveAndKeepThePingsApart covers the priced path.
  • sessionTokensQuery runs for every caller. Noted. It costs 2.5 ms of a 103 ms list. It is an open question in the PR body.

Reviewer 1 (approve)

  1. query.go:620, keepalive_tokens comment. Fixed in b2b3d22d. The comment and docs/dashboard.md now say it is the accountant's own rescue figure (tok_ka_*). It is a different measurement from keepalive_saved_usd, the legacy credit that is checked on read, so the two can disagree.
  2. The Sessions tab waits for /api/me/limits. Fixed in b2b3d22d. The limits read starts beside the sessions read. The table paints on the sessions answer, in the last known view. When the limits answer gives another view, the table paints again. A load number stops an older answer from repainting a newer load.
  3. The token Cost cell prints 0 where the dollar cell prints n/a. Fixed in b2b3d22d. It uses usdOrNA with the same reason as the dollar cell when no turn reported usage.
  4. The hero legend has no wr1h. Moved to feat(dash): on a Claude subscription show saved tokens, with the 5-hour share as an estimate #988 (follow-up).
  5. The 5-hour estimate does not follow the page filter. Moved to feat(dash): on a Claude subscription show saved tokens, with the 5-hour share as an estimate #988 (follow-up).

Tests at b2b3d22d

  • Node, savings.test.mjs and navhash.test.mjs: 30 passed, 0 failed.
  • Box, go vet ./dash/: clean.
  • Box, -race, the affected tests (TestSessionTokens|TestSessionsSubscription|TestSavingsParts|TestGoldenEndpoints|TestOverviewSubscription|TestAccTokens|TestUI|TestJS|TestCSP|TestSessions): 25 passed, 2 skipped (no node on the box), 0 failed.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

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]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

cf307d4e merges #988 (head 407534d1) and moves the Sessions cells to its shared rule.

What changed

  • Reviewer 2's blocking finding is resolved. The Overview card at app.js ~1806 said "not measured" for a part that saved 0. feat(dash): on a Claude subscription show saved tokens, with the 5-hour share as an estimate #988 fixed it in 407534d1 with one shared rule, tokenFigure(flow, scope, fmt).
  • The Sessions Tokens saved cell now uses tokenFigure. The session row is the scope, so tokens_unmeasured_requests is the session's own count. Before, the cell had its own zero rule.
    • An all-zero figure on a session with every request priced reads saved 0 tokens.
    • An all-zero figure with any unpriced request reads not measured. So does a row with no tokens (a server from before dash: Sessions tab shows dollars on a subscription #1023).
    • The † (some requests unmeasured) shows only on a figure the rule calls measured.
  • Node tests and docs/dashboard.md follow the shared rule.

Tests at cf307d4e

  • Node, savings.test.mjs and navhash.test.mjs: 32 passed, 0 failed.
  • Box, go vet ./dash/: clean.
  • Box, -race, the affected tests: 24 passed, 2 skipped (they need node, which the box does not have), 0 failed.
  • Correction to my round-1 reply: the same set was 24 passed and 2 skipped there too, not 25 passed.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 2 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 tokenFigure landed in 407534d1 and the merge cf307d4e applies it: the cards (app.js:1811), the headline (savings.js, subscriptionHeadline) and the Sessions saved cell all read tokenFigure(flow, scope, fmt). I checked the rule itself: a non-zero flow shows its line; an all-zero flow with tokens present and tokens_unmeasured_requests 0 reads saved 0 tokens; an all-zero flow with unmeasured requests, or a scope with no tokens (a server before #999/#1023), reads not measured. The mjs tests pin all three cases.
  • My non-blocking items: the 60 s failure cache is fixed (onSubscription drops a failed promise, app.js:3092-3096); sort=cost is 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 in dash/query.go and docs/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 cell 0 vs n/a) fixed via usdOrNA; 4 (hero legend wr1h) fixed for the hero; 5 (estimate vs page filter) fixed — pageFiltered() hides the estimate while a filter or time range narrows the page.

Findings

  1. 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_tokens is measured from the ping rows' own usage, so it is non-empty. keepalive_tokens is 0 (no priced rescue). The keep-alive cell then shows saved 0 for the rescue. The saved cell on the same row says not measured, because the same session goes through tokenFigure. One row makes two opposite claims.
    • Proof: sessionTokenKeepAlive falls back to c.keepalive || 'saved 0' (app.js:3266), where c.keepalive is a plain tokenLine (savings.js, sessionTokenCells). The PR's own rule says otherwise: docs/dashboard.md calls tokenFigure "one rule for every screen", and the Overview info text says "saved 0 tokens is a measured zero". Old ping rows carry usage (fresh_input, cache_read) but store zeros in every tok_* 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).text in place of c.keepalive || 'saved 0'. Keep the n/a branch for "the strategy did not run".

Non-blocking

  • sessionTokenCost's title (app.js:3235) and the Sessions "Cost" header (data-sub-title in index.html) still list wr, rd, in without wr1h, while used_tokens can show wr1h. The hero legend got this fix (407534d1); these two spots did not.
  • loadOverviewLimits and onSubscription still fetch /api/me/limits separately 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 (cf307d4e merge note) — verified against the diff.
  • Read the full diff 15bffe4f..cf307d4e (6 files) and the final code around each hunk in dash/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: cf307d4e has parents b2b3d22d and 407534d1; 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.filter is initialized to {} (app.js:213) and never unset, so Object.entries cannot throw. Its filter set matches what qs() sends, minus tenant, which only chooses whose figures — correct.
  • The new Sessions paint flow: subP never rejects (onSubscription returns a promise with a rejection handler), paint(!!state.sessSub) paints the last known view at once, and seq === state.sessSeq drops a limits answer from an older load. Checked the failure, hang and no-change cases.
  • onSubscription's failure cache: a rejected promise nulls state.subLimitsP only 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 in savingsparts_test.go; each string was matched against the final app.js.
  • No Go builds or tests were run (not approved).

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 2 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):

  1. keepalive_tokens comment overstated the figure. Fixed in b2b3d22d. 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 gated keepalive_saved_usd, and that the two can disagree. That is the true sentence I asked for.
  2. The Sessions tab waited for /api/me/limits before it painted. Fixed in b2b3d22d. 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, because refresh() aborts the previous fetch (state.ac.abort(), app.js:5205) and aborted(err) returns. A failed limits read no longer caches: p.catch clears state.subLimitsP, so the next load asks again.
  3. The token Cost cell printed 0 where the dollar cell prints n/a. Fixed in b2b3d22d. sessionTokenCost now routes the no-usage case through usdOrNA with the same reason as the dollar cell, gated on the same s.baseline_cost_usd signal.
  4. The hero legend omitted wr1h. The author moved it to #988, and #988's commit 407534d1 is merged in this head: the legend now names "wr1h 1-hour cache write". Fixed.
  5. 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 every state.filter key except tenant, and subscriptionHeadline takes it as filtered and hides the estimate. I checked the key set: setFilter is the only writer of state.filter and all its keys narrow the figures; tenant picks 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:

  1. A card said "not measured" for a measured zero (blocking). Fixed by the #988 merge (407534d1, in this head as cf307d4e). tokenFigure in dash/ui/savings.js is now the one rule: a flow with tokens shows its line; an all-zero flow with no unpriced request reads saved 0 tokens; an all-zero flow with unpriced requests, or a server with no tokens, reads not measured. I checked the cause myself: addFeature drops zero figures from by_feature (dash/acctokens.go:383-391), so the missing entry is the zero, and the new rule reads the period's tokens_unmeasured_requests to tell the two apart. The cards, the headline and the Sessions cells all call it, each with its own scope.
  2. Two separate /api/me/limits reads; 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: loadOverviewLimits still 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.
  3. sort=cost orders 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.
  4. 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.
  5. sessionTokensQuery runs 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/limits requests. 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.
  • sessionTokenCost uses s.baseline_cost_usd as the "usage was reported" signal, exactly as the dollar cell does. A session whose turns all priced to exactly $0.00 of baseline would show n/a beside 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 addFeature and 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.
  • 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, undefined scope — against the mjs tests. The headline now calls it with the period as scope; the cards call it only past the partial guard; the Sessions cells call it with the session row as scope.
    • subscriptionHeadline's new filtered argument: old callers (tests) pass nothing, so it defaults off; the one app.js caller passes pageFiltered().
    • pageFiltered: checked the writers of state.filter (setFilter is the only one) and the range state (state.from/state.to through rangeMs).
    • 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 by refresh(). state.sessSub persists 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.
    • sessionHeaders now also relabels the sort option; the option exists in index.html (line 605).
    • The Cache card: subRows filtered and the empty-list case returns null; 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_tokens description.
  • 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]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 2 replies. The fixes are in 358d8791.

Reviewer 2

  1. Blocking: the keep-alive rescue line said "saved 0" when the rescue was not measured. Fixed in 358d8791.
    • The rescue line now uses the shared rule, tokenFigure(s.keepalive_tokens, s, fmt), with the session row as scope (in sessionTokenCells).
    • The n/a branch stays for "the strategy did not run": no rescue tokens and no pings.
    • New node cases:
      • Unpriced rows and pings that ran: the rescue reads not measured, and the pings line still shows cost 9000 rd.
      • Every row priced, pings ran, no rescue: the rescue reads saved 0 tokens.
  • wr1h was missing from the Tokens used title and header. Fixed in 358d8791. The cell title and the header data-sub-title in index.html both name "wr1h 1-hour cache write".
  • Two separate /api/me/limits fetches. Fixed in 358d8791. A new meLimits(maxAgeMs) makes one request for both screens.
    • The Overview calls meLimits(0). It joins a request already in flight, and it still asks for a fresh answer on each load, so its freshness does not change.
    • The Sessions tab calls meLimits(60000). It reuses a good answer for up to a minute.
    • A failed answer is not kept.

Reviewer 1

  • Separate limits requests (nit). Fixed in 358d8791, as above.
  • n/a on a session whose baseline is exactly $0.00. Noted. The token cell uses the same signal as the dollar cell, so the two cells agree.

Tests at 358d8791

  • Node, savings.test.mjs and navhash.test.mjs: 32 passed, 0 failed.
  • Box, go vet ./dash/: clean.
  • Box, -race, the affected tests (TestSessionTokens|TestSessionsSubscription|TestSavingsParts|TestGoldenEndpoints|TestOverviewSubscription|TestAccTokens|TestUI|TestJS|TestCSP|TestSessions): 24 passed, 2 skipped (they need node, which the box does not have), 0 failed.

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 amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 2 of 2 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. sessionTokenCells now 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 own tokens_unmeasured_requests decides between saved 0 tokens and not measured. The plain c.keepalive || 'saved 0' fallback is gone from app.js. The n/a branch 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): wr1h missing from the Tokens used title and header. Fixed. The Cost cell title (app.js:3246) and the header data-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/limits fetches. 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) — tokenLine takes an undefined flow safely, so a row without keepalive_tokens reads not 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, not n/a.
    • sessionTokenKeepAlive (app.js:3264-3279): the rescue line is plain c.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 measured and pings cost 9000 rd; all priced, pings ran, no rescue → saved 0 tokens; quiet session → keepaliveRan: false. The deepEqual pin includes keepalive: 'not measured', keepaliveRan: false.
  • meLimits(maxAgeMs), case by case:
    • In flight: state.limitsAt === null marks it, so a second caller joins the same promise. No second request.
    • Success: the completion stamps state.limitsAt only if the promise is still the current one.
    • Failure: state.limitsP is 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. onSubscription chains a rejection handler (app.js:3113), so the returned promise never rejects.
    • An older answer cannot stamp limitsAt after a newer request started: the newer request set state.limitsP first, so the guard fails.
  • Wiring strings in savingsparts_test.go (meLimits(60000), state.limitsP, const limits = await meLimits(0);) match the final app.js.
  • Docs: docs/dashboard.md now 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 amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 1 of 2 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):

  1. The Overview and the Sessions tab made separate /api/me/limits requests. Fixed in 358d8791. 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: loadOverviewLimits has its try/catch (app.js:1935-1945), onSubscription returns false (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.
  2. A session whose baseline priced to exactly $0.00 shows n/a beside 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:

  1. 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) in sessionTokenCells (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 shows cost 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/a branch (app.js:3266).
      The saved cell and the rescue line now read the same scope, so one row cannot make two opposite claims.
  2. wr1h was missing from the Tokens used title and the Cost header. Fixed in 358d8791. The cell title (app.js:3246) and the header data-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 in keepalive_tokens or keepalive_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 sessionTokenCells and 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.
  • 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.
    • loadOverviewLimits keeps its subSeq guard; onSubscription keeps the manager guard (readsLimits). The old state.subLimitsP state is gone — grep finds no leftover.
    • sessionTokenCells: keepalive now carries the rule's text and keepaliveRan carries hasTokens(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]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

#988 is merged. This branch now has main merged in. The approval of 358d879 still counts.

Whitespace only. CI lint failed on gofmt.

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

Copy link
Copy Markdown
Collaborator Author

c10bd5e is a gofmt fix only. CI lint failed on dash/savingsparts_test.go.

  • The commit adds spaces before one trailing // comment in a test, to align it as gofmt wants.
  • git diff -w c10bd5e1^ c10bd5e1 is empty: no change except whitespace.
  • approval-still-valid.sh 1041 358d8791 prints CHANGED, because the spaces are on a code line, not a comment line.

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]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Merged origin/main (b9e29f7) into this branch: 7e454bc.

  • Conflicts, resolved by hand (4 files). feat(dash): on a subscription show the Cache strategy tab in tokens (#1022) #1042 and this PR each added a function, a test and a doc section at the same place. Both sides kept, no logic changed.
    • dash/ui/savings.js: sessionTokenCells and kaTokenLines side by side, and both in module.exports.
    • dash/savings.test.mjs: both new tests kept.
    • dash/savingsparts_test.go: TestSessionsSubscriptionTokensAreWired and TestKeepAliveTabSubscriptionTokensAreWired kept, each with its own check loop. The index.html header-count check stays with the Sessions test.
    • docs/dashboard.md: both sections kept. dash/ui/app.js merged with no conflict.
  • Semantic check: each of the two functions is defined once. go vet ./... and gofmt -l dash clean.
  • Tests (box, -race): dash ok (both halves). node --test dash/*.test.mjs: 34 pass.
  • CI: first run failed on the known load flake TestRegistrationRateLimitedPerIP. The rerun of the failed job passed. CodeQL and Docs green.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session fresh 1 of 2 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 in sessionTokenCells (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 the sessSeq guard are present (app.js:3217-3218). The n/a Cost cell (usdOrNA), the wr1h labels and keepaliveRan are all present.
  • The keepalive_tokens comment in dash/query.go and its docs row: unchanged since round 2, still the true sentence.

The new commits

  1. b1e3203a — merge the final #988 head (138324a8). Verified against the first parent (358d8791): the only changes in this PR's files are main's own (requestCols gains r.defer_cost_usd and r.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.
  2. 2b49f80e — merge origin/main. Touches none of this PR's files. Trivial for the PR.
  3. c10bd5e1 — gofmt dash/savingsparts_test.go. git diff -w c10bd5e1^ c10bd5e1 is empty, as the author's comment says. Whitespace only.
  4. 7e454bca — merge origin/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's kaTokenLines; vs main it adds only this PR's sessionTokenCells. Both are in module.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, as stripComments does). index.html has exactly 3 data-sub-label= headers, as the test wants.
    • docs/dashboard.md: both sections kept, each heading appears once.
    • dash/ui/app.js merged with no conflict; I read the whole diff since 358d8791. The changes are main's (#1042's Cache-tab token view, #1039's tile removals, #1057's dead kv(), #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 -w is 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

  • renderKAVerdict and renderKADownside call kaTokenLines(o, compact) without the ledgerNet !== null guard that renderKADecision has. This is #1042's own code from main, not this PR's, and tokenFigure handles a ledger without tokens ("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 diff 358d8791..HEAD on 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: main did not touch sessions.json between my heads, so the PR's regeneration stands alone. keepalive.json has the fields the new mjs test reads (tokens_unmeasured_requests: 591).
  • The server side of the merged UI code: /api/keepalive's tokens, keepalive_ping_tokens and tokens_unmeasured_requests exist (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 amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session fresh 2 of 2 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 through tokenFigure, and the n/a gate in sessionTokenKeepAlive (app.js:3250) still needs both no rescue tokens and no pings.
  • Round 2-3 non-blocking items (wr1h labels, one shared /api/me/limits request). Still fixed. meLimits (app.js:3077) and the Cost cell title and header data-sub-title are 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 — 6da75839 and 138324a8 (main into feat/dash-subscription), b1e3203a (final #988 head into this branch), 2b49f80e (main into this branch), c10bd5e1 (gofmt), 7e454bca (main b9e29f74 into this branch). The other 23 commits in 358d8791..HEAD are 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) — verified git diff -w c10bd5e1^ c10bd5e1 is 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's requestCols changes (defer_cost_usd, sweep_false_expands_warm). The SessionRow, sessionTokensQuery and sessionTokens code is untouched.
    • dash/ui/savings.js: #1042's kaTokenLines added beside sessionTokenCells. Each function is defined once; both are in module.exports. sessionTokenCells itself is unchanged.
    • dash/savings.test.mjs: #1042's two tests added; this PR's sessionTokenCells test is unchanged.
    • dash/savingsparts_test.go: gofmt alignment plus #1042's TestKeepAliveTabSubscriptionTokensAreWired. The data-sub-label count check still wants 3, and index.html has exactly 3, all on Sessions headers. Every wiring string in both tests matches the final app.js.
    • dash/ui/app.js: all hunks since round 3 sit in main's areas (keep-alive tab, tiles, tools). loadSessions, meLimits, onSubscription, sessionHeaders and the three sessionToken* 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: parents c10bd5e1 and b9e29f74. Both sides kept in all four conflict files; no function, test or doc section lost.
  • The helpers sessionTokensQuery depends on (withKeepAlive, autoPing, tokenSumTerms, flowColumns, accTokenTailTerms): unchanged by the merges. dash/acctokens.go has zero diff since round 3.
  • The golden sessions.json: all 60 sessions carry tokens, keepalive_tokens, keepalive_ping_tokens, used_tokens and tokens_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

dash: Sessions tab shows dollars on a subscription

1 participant