feat(workspace): per-turn token + cost meter and reasoning blocks #602

Merged
charles merged 1 commit from dev/566 into main 2026-04-30 20:56:41 +00:00
Collaborator

Adds token / cost / duration visibility and extended-thinking display to the workspace transcript.

Test plan

  • Send a foreman chat message; verify the completed assistant bubble shows a footer pill: Xs · Yk+Zk tok · $N.
  • Hover / focus the pill; verify the tooltip shows cache-creation and cache-read tok counts.
  • Session with multiple turns: verify the totals strip appears at the top of the transcript and sums correctly.
  • With an Opus session using extended thinking: verify a collapsible "Reasoning" section appears above the assistant text, default collapsed.
  • Legacy sessions (no meter data): verify no pill renders and no totals strip.

Closes #566

Adds token / cost / duration visibility and extended-thinking display to the workspace transcript. ## Test plan - Send a foreman chat message; verify the completed assistant bubble shows a footer pill: `Xs · Yk+Zk tok · $N`. - Hover / focus the pill; verify the tooltip shows cache-creation and cache-read tok counts. - Session with multiple turns: verify the totals strip appears at the top of the transcript and sums correctly. - With an Opus session using extended thinking: verify a collapsible "Reasoning" section appears above the assistant text, default collapsed. - Legacy sessions (no meter data): verify no pill renders and no totals strip. Closes #566
dev self-assigned this 2026-04-30 20:40:54 +00:00
feat(workspace): per-turn token + cost meter and reasoning blocks (#566)
All checks were successful
qa / dockerfile (pull_request) Successful in 6s
qa / qa (pull_request) Successful in 2m18s
183c672565
- Extend ForemanMessage with meter fields (input/output/cache tokens,
  cost_usd, duration_ms) and optional thinking[] for reasoning blocks
- Persist meter data from the result event when appendMessage is called
  at the end of each foreman chat task
- Extract thinking blocks in sdk-adapter; propagate through AssistantTurn
  and event-log assistant detail
- Transcript: TurnMeter footer pill (duration · tokens · $cost) with
  hover tooltip for cache breakdown; ReasoningBlock collapsible section
  above assistant text; session totals header strip

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dev requested review from reviewer 2026-04-30 20:43:17 +00:00
reviewer approved these changes 2026-04-30 20:47:17 +00:00
reviewer left a comment

CI green (qa + dockerfile). All AC met:

  • Per-turn pill renders on completed assistant bubbles with duration · tokens · cost.
  • Hover/focus tooltip shows cache-creation + cache-read breakdown.
  • Session totals strip sums correctly; hidden on legacy sessions.
  • ReasoningBlock is collapsible, default collapsed.
  • extractAssistantText already filters only type === "text" blocks, so thinking blocks are excluded at source.

Nit (non-blocking): TurnMeter generates tooltipId via Math.random() on every render — the IDs stay in sync within each commit so there's no functional breakage, but useId() is the idiomatic React 18 pattern and avoids needless churn on parent-triggered re-renders.

CI green (`qa` + `dockerfile`). All AC met: - Per-turn pill renders on completed assistant bubbles with duration · tokens · cost. - Hover/focus tooltip shows cache-creation + cache-read breakdown. - Session totals strip sums correctly; hidden on legacy sessions. - `ReasoningBlock` is collapsible, default collapsed. - `extractAssistantText` already filters only `type === "text"` blocks, so thinking blocks are excluded at source. Nit (non-blocking): `TurnMeter` generates `tooltipId` via `Math.random()` on every render — the IDs stay in sync within each commit so there's no functional breakage, but `useId()` is the idiomatic React 18 pattern and avoids needless churn on parent-triggered re-renders.
charles deleted branch dev/566 2026-04-30 20:56:42 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks!602
No description provided.