Repository navigation
feat(chat): show per-turn token usage capsule - #1818
Merged
Merged
Conversation
added 2 commits
October 22, 2026 18:07
Completed assistant turns now show the model, average generation speed, and total tokens on one quiet row. Hovering or focusing the capsule reveals cache-read, input, and output counts without opening the composer inspector, while the composer remains the last-request occupancy authority. The capsule aggregates every parent assistant message in the visual turn, so its total answers what the round consumed rather than what the newest request occupied. Subagent spend stays out of the per-message usage contract.
The session reference UI test transpiles the real shared transcript module and asserts every dependency is stubbed. Importing the new capsule broke that fixture graph, so the fixture now provides a capsule stub and the breakdown helper Mock.
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Completed assistant turns now render one quiet usage capsule immediately to the right of the existing model badge:
Semantics
input + output + cacheRead + cacheWritesummed across the visual turn's parent assistant messages. Reasoning tokens are already insideoutput; subagent spend stays out.calculateTokenRate; estimated interrupted-response output is prefixed with the existing approximately marker.Files
apps/desktop/src/features/chat/transcript/TurnUsageCapsule.tsx(new component)apps/desktop/src/features/chat/transcript/{AssistantTurn,shared}.tsxapps/desktop/src/lib/{context-usage,context-inspector-position}.tsapps/desktop/src/styles/messages.csspackages/i18n/src/locales/*(9 shipped locales)docs/spec/04-ux/{08-component-spec,10-workbuddy-benchmark-ux}.md+ zh-CN mirrorsdocs/spec/06-delivery/04-e2e-test-plan.mdE2E-060d + zh-CN mirrorapps/desktop/test/{context-usage,context-inspector-position,turn-usage-capsule}.test.mjsValidation
corepack pnpm --filter @pi-desktop/desktop typecheck— passcorepack pnpm lint— pass (Biome + style-token gate)node --teston the three touched test files — 38 pass, 0 failcorepack pnpm build:js— passnode docs/scripts/check-locales.mjs— 86 pairs verifiednode docs/scripts/check-docs.mjs— 583 pages verifiedcorepack pnpm check:pr-base— origin/main is an ancestor of the headverify:ui:*E2E was not run; this is a renderer-only surface and the user did not request UI E2E.