Issue #10567: Record token usage and optionally display for turn/session/history#10568
Issue #10567: Record token usage and optionally display for turn/session/history#10568benjschiller wants to merge 2 commits intocontinuedev:mainfrom
Conversation
…on/history usage surfacing
|
All contributors have signed the CLA ✍️ ✅ |
There was a problem hiding this comment.
3 issues found across 31 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="core/protocol/passThrough.ts">
<violation number="1" location="core/protocol/passThrough.ts:114">
P2: IntelliJ PASS_THROUGH_TO_WEBVIEW is missing the new "ideSettingsUpdate" message type added to CORE_TO_WEBVIEW_PASS_THROUGH, so JetBrains clients won’t receive this update.</violation>
</file>
<file name="core/util/history.ts">
<violation number="1" location="core/util/history.ts:43">
P2: list() now hydrates usage for every session with synchronous disk reads before applying limit/offset, causing O(n) blocking I/O even when only a small slice is requested.</violation>
</file>
<file name="core/llm/index.ts">
<violation number="1" location="core/llm/index.ts:360">
P2: `_logEnd` now trusts numeric usage token counts, but upstream usage parsing normalizes missing values to 0. When prompt/completion counts are absent, this bypasses `countTokens` and records 0 tokens, undercounting batching/logging.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| "didCloseFiles", | ||
| "toolCallPartialOutput", | ||
| "freeTrialExceeded", | ||
| "ideSettingsUpdate", |
There was a problem hiding this comment.
P2: IntelliJ PASS_THROUGH_TO_WEBVIEW is missing the new "ideSettingsUpdate" message type added to CORE_TO_WEBVIEW_PASS_THROUGH, so JetBrains clients won’t receive this update.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At core/protocol/passThrough.ts, line 114:
<comment>IntelliJ PASS_THROUGH_TO_WEBVIEW is missing the new "ideSettingsUpdate" message type added to CORE_TO_WEBVIEW_PASS_THROUGH, so JetBrains clients won’t receive this update.</comment>
<file context>
@@ -111,4 +111,5 @@ export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] =
"didCloseFiles",
"toolCallPartialOutput",
"freeTrialExceeded",
+ "ideSettingsUpdate",
];
</file context>
There was a problem hiding this comment.
- Added
"ideSettingsUpdate"to IntelliJPASS_THROUGH_TO_WEBVIEWto match core passthrough updates. - File:
extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt
|
I have read the CLA Document and I hereby sign the CLA |
|
Checking if there's anything else I need to do. I believe the failing CI checks were not due to the PR |
RomneyDa
left a comment
There was a problem hiding this comment.
@benjschiller some merge conflicts popped up but otherwise might take a while to review. The main concern is it touches many providers and the UI. A smaller set of targeted PRs e.g. usage per provider, then UI could go through quicker.
note removing as any type casting is also a soft requirement for new code, applies to many files in this PR.
you got it @RomneyDa , I'll work on that this week. I'll clean up the typing too, that's AI slop and tbh I didn't notice it because I usually work in Python. I can at least break this into separate backend + frontend PRs. I need to noodle on breaking up the backend changes per provider, since there's some model changes that touch many providers |
Description
Address issue #10567
Adds token usage persistence/display improvements in VS Code Chat + History with a single display setting and turn/session/history granularity.
I used codex to help me to do this cause my typescript is is rusty. This is my first PR for continue, so please let me know anything I can do to conform better to your flow! Open to adding support for JetBrains if desired.
Main changes:
continue.showTokenUsagewith values:neverhistorysession(history + session)turn(history + session + turn)ideSettingsUpdateso UI updates immediately without manual window reload.message.usagein session history)session.usage)sessions.jsonmetadata (BaseSessionMetadata.usage)Scope notes:
AI Code Review
@continue-reviewChecklist
Screen recording or screenshot
Turn + session token usage display

History token usage display

help->stats (added consistency warning)

new config option

Tests
Manual testing: ran extension in debug mode and checked that features appear and work as expected
Automated testing below
Updated tests:
core/llm/openaiTypeConverters.test.tsgui/src/redux/slices/sessionSlice.test.tsLocal checks run:
npm run format:check(repo root)cd core && npx tsc --noEmitcd core && npm run lintcd core && npm run vitestcd gui && npx tsc --noEmitcd gui && npm run lintcd gui && npm testcd binary && npx tsc --noEmitcd extensions/vscode && npm run write-build-timestampcd extensions/vscode && npx tsc --noEmitcd extensions/vscode && npm run lintcd extensions/vscode && npm run vitestnode ./scripts/build-packages.jscd extensions/vscode && npm run e2e:compilepackages/*(withnpm ciwhere needed)Note:
cd core && npm testhad an environment-specific network failure in this local machine (ENOTFOUNDto Sentry host inllm/countTokens.test.ts), not tied to this feature logic.Continue Tasks: ✅ 1 no changes — View all
Summary by cubic
Adds per-turn, per-session, and history token usage tracking with a single display setting in VS Code, updated live without reload. Addresses Issue #10567.
New Features
Bug Fixes
Migration
Written for commit a4aaf9d. Summary will update on new commits.