Add assistant turn stats footer#2601
Conversation
Show compact assistant turn stats with model, elapsed time, token count, throughput, TTFT, and tool-call count when those fields are available. Derive Codex timing from response boundaries so completed throughput does not use tiny final delta gaps as the denominator. Closes pingdotgg#2518
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This PR introduces a new user-facing feature (assistant turn stats footer) with new UI components, business logic, backend timing infrastructure, and schema changes spanning multiple layers. The scope and new capability warrant human review. You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e433872. Configure here.



Summary
Closes #2518.
Verification
cd apps/server && bun run test -- src/orchestration/Layers/ProviderRuntimeIngestion.test.tscd apps/server && bun run test -- src/orchestration/Layers/ProviderRuntimeIngestion.test.ts src/orchestration/Layers/ProjectionPipeline.test.tscd apps/web && bun run test -- src/lib/turnStats.test.ts src/lib/contextWindow.test.tsbun fmtbun lint(passes with existing warnings only)bun typecheckbun run testgit diff --checkLive smoke
http://localhost:5733/[data-assistant-turn-stats="true"]footer rendered with16 tokens,66.7 tok/sec, andTime-to-first: 7.2 secdurationMs: 240,timeToFirstTokenMs: 7216, andlastOutputTokens: 16, so completed TPS is not using the old sub-10ms final-delta denominatorNote
Medium Risk
Touches provider ingestion/projection and token-usage normalization, which can affect persisted thread metadata and any downstream metrics/UX. Changes are well-covered by new targeted tests but involve timing/edge-case logic across providers.
Overview
Adds a compact per-assistant-message stats footer in the chat timeline (model/effort, elapsed, token count, throughput, TTFT, tool-call count), derived for the latest completed assistant turn and omitted when metrics are missing.
To make these stats stable across reloads, provider ingestion now derives Codex generation
durationMsandtimeToFirstTokenMsfrom assistant stream boundaries (excluding approval/user-input gaps) and merges them intocontext-window.updatedactivities only when the provider doesn’t supply valid timings; the contracts schema is extended to includetimeToFirstTokenMs, and Codex token-usage events now carry/propagateturnId.Also fixes a projection edge case where
thread.session-setwithactiveTurnId: nullwould clearlatestTurnId, and adjusts proposed plan export filenames to beplan-*.md(without double-prefixing).Reviewed by Cursor Bugbot for commit 69658e2. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add assistant turn stats footer to chat timeline
TurnStatsFootercomponent to assistant messages displaying model, token count, throughput, time-to-first-token, and tool call count when available.deriveLatestAssistantTurnStatsandbuildLatestAssistantTurnStatsMapin turnStats.ts to compute human-readable stats from turn timing, context window snapshots, and activities.turnIdandproviderRefs.providerTurnIdto emittedthread.token-usage.updatedruntime events in the Codex adapter; events without payload are now dropped.ProjectionPipeline.tsto preservelatestTurnIdwhen a session update setsactiveTurnIdto null.buildProposedPlanMarkdownFilenameoutput withplan-unless the name already starts withplan.Macroscope summarized 69658e2.