Skip to content

fix(vscode): restore live context usage on v2 - #3098

Open
LCZcn96 wants to merge 1 commit into
MoonshotAI:mainfrom
LCZcn96:fix/vscode-context-usage-v2
Open

fix(vscode): restore live context usage on v2#3098
LCZcn96 wants to merge 1 commit into
MoonshotAI:mainfrom
LCZcn96:fix/vscode-context-usage-v2

Conversation

@LCZcn96

@LCZcn96 LCZcn96 commented Aug 19, 2026

Copy link
Copy Markdown

Related Issue

Fixes #3059

Problem

After the VS Code extension switched to the v2 engine, the context-window usage indicator could disappear or remain frozen. v2 status updates carried contextTokens and maxContextTokens, but the legacy VS Code Webview contract was not receiving a derived context_usage value. Re-entering a session also dropped the value because announceStatus() did not forward the status snapshot's context usage.

What changed

  • Derive context_usage in the VS Code event adapter when v2 status events omit the ratio but provide a valid token pair.
  • Restore contextUsage in the v2 Node SDK status snapshot so downstream consumers receive the combined status contract.
  • Forward context_usage when a session announces its current status to an attaching Webview.
  • Preserve explicit ratios and omit derived ratios when the context capacity is invalid.
  • Add regression tests for live v2 status mapping, invalid capacities, SDK snapshots, and attach status.

Verification

  • I have read the CONTRIBUTING document.
  • I have linked a related issue.
  • I have added tests that prove the fix works.
  • Ran the gen-changesets skill; added a patch changeset for @moonshot-ai/kimi-code.
  • No documentation update is needed.

Tests run with Node v24.15.0 and pnpm 10.33.0:

  • VS Code targeted tests: 4 files, 114 passed
  • Node SDK session wiring tests: 3 passed
  • VS Code typecheck: passed
  • Node SDK typecheck: passed

@changeset-bot

changeset-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f4fbbb9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VS Code extension 0.7.0 (agent-core-v2): TodoList card no longer shows items when expanded; context usage % frozen

1 participant