Public: anyone can read this; the crew can change it.
An imported session's steps carry their tokens and the page shows them, where the file holds them #18372
Merged 4h 1m ago, live in production
An imported session's trace page now shows tokens on each model step line, and the total is the sum of those steps. The new tests pass, and so do the existing trace and imported-page tests I ran. bun x tsc --noEmit and the design lint came back clean.
-
Reviews
ApprovedClean. The readers already put per-message usage on each step (a reply split across records is counted once, malformed values give 0). This pull adds the missing piece: the page shows each step's tokens in an inline span, and the text step line carries them. The only values rendered are numbers the server built, so there is nothing to escape. The API already answered per-step tokens and totals, and the new tests cover it. There is no new script, no new CSS and no new dependency. The docs move 'tokens per step' out of Not yet. Imported traces have no screen under src/tui/, so there is no terminal side to add. One nit, not blocking: the tokens span has a
trace-tokensclass with no rule behind it, so it is only a hook. -
Checks
shipped production is serving it deploy be10e7a
-
History
- No look for the imported trace page 2345ec6
- Name the look page for the imported trace's step tokens 3b4af8d
- Rewrap comments e147368
- An imported session's steps show their tokens on the page and in the raw line, where the file holds them 4333f51
- An imported session opens at /traces/<id> as the same tree and time strip a crew run has (#18366) 90fb1bc
- /traces lists Talk and imported traces with a kind facet, and the terminal's kind key is tested (#18365) c5e780a
- Issues: a route to assign an issue to a person or an agent (#18285) 69ce311
- The loopback-only look test stops failing checks: the missing prerequisite is named and provided, or the check skips by name (#18362) be7c1a3
- A Codex rollout file imports as a trace, beside Claude Code sessions (#18360) 8900ff3
- Every bare "No …" empty state is drawn from src/core/empty_words.ts, and the OWN_WORDS count table is deleted (#18355) e036110
- A map file over 600 KB is served in parts instead of failing the whole 3D view (#18350) b6d2692
- The terminal and the Apple app's API offer no captain (#18353) 9a9ebf0
- The lane-stopped card carries a Merge action for each green pull waiting on a person (#18348) 67ae93f
- Talk no longer lists, selects or routes to the captain on the web (#18346) 7406da3
- Publishing an app from the tab forge mints the visitor principal, and only then (#18243) 64017fd
- A server's page shows whether its map answers, with the reason, before anyone opens the 3D view (#18349) bca1c31
- The Apple app can list and answer the actions Talk is holding for a person (#18342) 8a995aa
- The Apple app can read the game door, lock it and open a write window, through one JSON route (#18341) 37d7870
- The game map says which way it failed: not listening, too large, too slow or refused by BlueMap (#18347) f1e92e5
- Full suite red: test/spawn-move-cell-sizes.test.ts (#18340) 6034a7d
3 earlier comments · 1 event
An imported session's trace page now shows tokens on each model step line, and the total is the sum of those steps. The new tests pass, and so do the existing trace and imported-page tests I ran. bun x tsc --noEmit and the design lint came back clean. I did not run the full suite, and I haven't tried the page on a preview. After the last push the gate still prints a "look pages" warning for src/web/pages/trace.ts. It asks for a "Looks:" or "No look:" line, and I didn't add one, so a reviewer decides.
- Readers: the Claude Code and Codex readers already read per-message usage onto each step. A reply split across several records is counted once. A file with no usage, or with a malformed value, still gives 0 and "not recorded in this file".
- API:
GET /api/v1/traces/<id>for an imported id already answered per-step tokens and the totals, so there is no change there. - Page:
stepNodeinsrc/web/pages/trace.tsadds one inline span per step that has tokens, for example5 in, 7 cached, 9 out. It uses no new script or CSS and sits in the existing summary line. - Raw-step text: the text of a step's raw-lines route (
stepLineinsrc/trace/read.ts) appends the same figures. Crew runs hold no per-step tokens, so their pages are unchanged. - Docs:
docs/features/traces.mdno longer lists tokens per step under "Not yet" for imports. - Tests: the new
test/trace-imported-tokens.test.tshas fixtures for a Claude Code session with usage (per-step and total figures) and one without. It also covers malformed usage on both readers, a Codextoken_countlanding on the reply before it, the page, and the API. - Terminal:
forge tracealready printed per-step tokens and totals, and the terminal screens use the sharedstepLine. Imported traces have no screen undersrc/tui/yet, so the commit says "No door". - Not done: cost per step or per import stays "not recorded in this file", since prices change and I won't guess.
- Truncation: the total comes from the stored row, so for a session longer than 20,000 steps it can exceed the visible steps. The page already says it is cut.
- Reuse: I reused
stepTime,stepLine, the existing token fields andtotalsOf. The only new function is the smallstepTokens.
Try: open /traces/<id> for an imported session whose file has usage.
[{"go":"/traces/<id of an imported Claude Code session with usage>","look":"each model step line, and the Tokens fact above the tree","expect":"a step shows `N in, N cached, N out` beside its time; the Tokens fact is the sum; a session without usage still reads `not recorded in this file`"}]<!-- look-pages e1473681fc88 --> Look pages for e147368, from the gate:
look pages (none): this pull changes src/web/pages/trace.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 28 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
<!-- look-pages 3b4af8de01ed --> Look pages for 3b4af8d, from the gate:
look pages (none): "Looks: /traces/:id" is not a page of app.looks in forge.json; this pull changes src/web/pages/trace.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 28 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
An imported session's steps now show their tokens on /traces/<id> and in the text step line, where the file holds them. Replies split across records count once, and malformed values give 0. Only server-built numbers are rendered, so nothing needs escaping.
Feedback addressed: the look-pages gate refused Looks: /traces/:id because that route is not a page of app.looks in forge.json. The last commit, 2345ec6e6, replaces it with No look: …. It says an imported session's trace needs an import by a signed-in owner, and no app.looks page has one. test/trace-imported-tokens.test.ts reads the page instead.
Checks: that test file passes, 6 tests, and scripts/gate.ts runs clean. I didn't re-run bun x tsc --noEmit or the other three tests the check names (both doors, duplicate import, module-level state, first-view budget). The change adds no imports, no module-level state and no new page weight beyond one inline span per step.
Tooling: the clone I was given went missing mid-session. The working tree is now at 18367.broken-1796542835685, with nothing uncommitted and origin/scout/18367-an-imported-session-s-steps-carry-their already at 2345ec6e6, so I didn't push again. I ran those checks from that directory.
Left out: I did not add CSS for trace-tokens. The sentinel noted it has no rule behind it and is only a hook, and a style would be new design surface. Imported traces have no terminal screen under src/tui/, and forge trace already prints per-step tokens, so there is no terminal side to add.
Try it: import a Claude Code session whose file has usage, open /traces/<id>, and each model step shows its tokens.
An imported session's trace page now shows tokens on each model step line, and the total is the sum of those steps. The new tests pass, and so do the existing trace and imported-page tests I ran.
bun x tsc --noEmitand the design lint came back clean. I did not run the full suite, and I haven't tried the page on a preview. After the last push the gate still prints a "look pages" warning forsrc/web/pages/trace.ts. It asks for a "Looks:" or "No look:" line, and I didn't add one, so a reviewer decides.GET /api/v1/traces/<id>for an imported id already answered per-step tokens and the totals, so there is no change there.stepNodeinsrc/web/pages/trace.tsadds one inline span per step that has tokens, for example5 in, 7 cached, 9 out. It uses no new script or CSS and sits in the existing summary line.stepLineinsrc/trace/read.ts) appends the same figures. Crew runs hold no per-step tokens, so their pages are unchanged.docs/features/traces.mdno longer lists tokens per step under "Not yet" for imports.test/trace-imported-tokens.test.tshas fixtures for a Claude Code session with usage (per-step and total figures) and one without. It also covers malformed usage on both readers, a Codextoken_countlanding on the reply before it, the page, and the API.forge tracealready printed per-step tokens and totals, and the terminal screens use the sharedstepLine. Imported traces have no screen undersrc/tui/yet, so the commit says "No door".stepTime,stepLine, the existing token fields andtotalsOf. The only new function is the smallstepTokens.Try: open
/traces/<id>for an imported session whose file has usage.Closes #18367