feat(extension): show session cost in the context popover - #4751
Merged
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryRe-reviewed after new commits added assistant-streaming-id tracking ( Files Reviewed (12 files)
Previous Review Summary (commit a3a3322)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit a3a3322)Status: No Issues Found | Recommendation: Merge Executive SummaryReviewed the session-cost tracking feature (in-memory atom, gateway usage parsing, and context-popover UI) with high confidence and found no correctness, security, or reliability issues in the changed lines. Files Reviewed (12 files)
Reviewed by claude-sonnet-5 · Input: 24 · Output: 8.6K · Cached: 539.2K Review guidance: REVIEW.md from base branch |
iscekic
enabled auto-merge (squash)
July 24, 2026 15:59
pandemicsyn
approved these changes
Jul 24, 2026
# Conflicts: # apps/extension/entrypoints/sidepanel/agent-chat-atoms.ts # apps/extension/entrypoints/sidepanel/agent-chat-panel.tsx # apps/extension/src/shared/agent-chat-atoms.test.ts
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.
Summary
Shows the running total session cost next to context usage in the browser extension side panel. The existing
ContextDonutpopover gains a Session cost row (under the token summary, above "Compact now"), formatted$X.XXXXidentical to the mobile app'sformatCost.usage.costfrom the gateway chat-completions stream; no backend changes.usageSchemaacceptscost: z.number().nullish(): a chunk with nocostorcost: nullcontributes $0 and never breaksprompt_tokensparsing (free models, where the gateway strips cost fields, correctly read$0.0000).onUsage(a tool-round turn sums multiple completions), accumulated into a per-conversation in-memory jotai atom with the same lifecycle ascontextUsageAtomFamily(kept across close, evicted on delete and sign-out, reset on reload).Test plan
pnpm --filter kilo-extension verify— typecheck, lint, format:check, 230 vitest tests (new: stream-client cost parsing present/missing/null, runner per-completion forwarding incl. in-turn tool-round order, atom eviction/sign-out lifecycle,formatSessionCost/addSessionCostedge cases).pnpm --filter kilo-extension e2e:chrome— 53 passed; new E2E proves empty$0.0000state, in-turn tool-round accumulation ($0.0130), cross-turn accumulation ($0.0140), unchanged donut aria-label, and cost surviving manual compaction ($0.0123).pnpm --filter kilo-extension build/build:firefox/e2e:firefox— green (existing scenarios; the new row has Chrome-only E2E, matching the existing context-usage coverage).