This repository was archived by the owner on May 20, 2026. It is now read-only.
Repository navigation
Add Context Window Widget support for Claude Agent - #3816
Merged
Merged
Conversation
- Add UsageHandler type and methods to IClaudeSessionStateService - Set usage handler in claudeChatSessionContentProvider request handler - Wire up usage reporting in ClaudeStreamingPassThroughEndpoint - Extract usage from AnthropicMessagesProcessor completion and call handler Co-authored-by: TylerLeonhardt <[email protected]>
- Add tests for getUsageHandlerForSession - Add tests for setUsageHandlerForSession - Verify handler preservation across state changes - Verify handler can be called correctly Co-authored-by: TylerLeonhardt <[email protected]>
Copilot
AI
changed the title
[WIP] Add context window widget for Claude agent
Add Context Window Widget support for Claude Agent
Feb 18, 2026
TylerLeonhardt
marked this pull request as ready for review
February 18, 2026 20:55
TylerLeonhardt
enabled auto-merge
February 18, 2026 20:55
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables the Context Window Widget for Claude Agent sessions by wiring up usage data that was already being received from CAPI but not reported to the UI. The implementation uses the session state service as an intermediary to bridge the language model server and the content provider.
Changes:
- Added usage handler mechanism to report token usage from Claude language model server to the UI's context window widget
- Extended session state service to store/retrieve usage handlers per session
- Added comprehensive unit tests for the new usage handler functionality
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/extension/chatSessions/vscode-node/claudeChatSessionContentProvider.ts | Sets and clears usage handler before/after request to report token usage via stream.usage() |
| src/extension/agents/claude/node/claudeSessionStateService.ts | Adds UsageHandler type and getter/setter methods to store handlers per session |
| src/extension/agents/claude/node/claudeLanguageModelServer.ts | Extracts usage from AnthropicMessagesProcessor completion and calls handler when sessionId present |
| src/extension/agents/claude/node/test/claudeSessionStateService.spec.ts | Adds 6 unit tests covering usage handler storage, retrieval, clearing, and event behavior |
Michael Lively (Yoyokrazy)
approved these changes
Feb 18, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Claude sessions receive usage data from CAPI but weren't reporting it to the UI. This wires up the existing usage information to
stream.usage().Implementation
Uses session state service as intermediary to bridge language model server and content provider:
Session State Service
UsageHandlertype:(usage: vscode.ChatResultUsage) => voidContent Provider
stream.usage(usage)Language Model Server
AnthropicMessagesProcessorcompletionpromptTokenDetailsFlow
Testing
claudeSessionStateService.spec.tsOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.