Skip to content

feat: display token usage in footers and show unclamped context usage with warning when limit exceeded (#317977)#319165

Open
Neizan93 wants to merge 3 commits into
microsoft:mainfrom
Neizan93:feature/chat-token-usage-317977
Open

feat: display token usage in footers and show unclamped context usage with warning when limit exceeded (#317977)#319165
Neizan93 wants to merge 3 commits into
microsoft:mainfrom
Neizan93:feature/chat-token-usage-317977

Conversation

@Neizan93
Copy link
Copy Markdown

@Neizan93 Neizan93 commented May 30, 2026

Proposed Changes

This PR addresses issue #317977 by adding detailed token usage metrics to response footers and enhancing context usage visibility when limit thresholds are crossed.

1. Response Token Usage Badge

  • Injected ILanguageModelsService into the chat list renderer to check for metadata (costs and pricing categories).
  • Added a dynamically updated badge in each response footer displaying total tokens and estimated credit costs.
  • Configured a detailed delayed Markdown hover tooltip presenting a breakdown of prompt tokens, completion tokens, and their respective unit costs.

2. Unclamped Context Usage & Limit Warning

  • Removed the Math.min(100, ...) clamping on the bottom-right context usage circular widget and the details popup panel so actual percentage values above 100% can be visualized when limits are exceeded.
  • Added dynamic warning text toggling to show "Context limit exceeded. Some older messages or context may be omitted." when context usage is >= 100%.

Copilot AI review requested due to automatic review settings May 30, 2026 20:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates chat UI token/context usage display and improves notification toast removal with fade-out behavior.

Changes:

  • Show token usage (and optional cost) in the chat response footer with hover details.
  • Allow context usage percentages to display above 100% and refine warning messaging near/exceeding limits.
  • Add fade-out animation for notification toasts and defer removal until transition completes.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatContextUsageWidget.ts Adds dev fallback model metadata; shows percentages >100% in label/ARIA
src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatContextUsageDetails.ts Shows >100% usage in details label; updates warning text by threshold
src/vs/workbench/contrib/chat/browser/widget/media/chat.css Adds styling/visibility rules for new footer token-usage element
src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts Renders token usage + cost in footer with hover tooltip; injects language model service
src/vs/workbench/browser/parts/notifications/notificationsToasts.ts Implements toast fade-out and defers removal; adds pending-removal tracking
src/vs/workbench/browser/parts/notifications/media/notificationsToasts.css Adds CSS fade-out transition and reduced-motion override

Comment thread src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts Outdated
Comment thread src/vs/workbench/browser/parts/notifications/notificationsToasts.ts Outdated
@Neizan93 Neizan93 force-pushed the feature/chat-token-usage-317977 branch from 6f0ac74 to 65008cf Compare May 30, 2026 20:45
@Neizan93 Neizan93 requested a review from Copilot May 30, 2026 20:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts
@Neizan93 Neizan93 force-pushed the feature/chat-token-usage-317977 branch from 65008cf to aad1dcd Compare May 30, 2026 20:57
@Neizan93 Neizan93 requested a review from Copilot May 30, 2026 20:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

Comment thread src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts Outdated
Comment thread src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts Outdated
Comment thread src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts
Comment thread src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts
Comment thread src/vs/workbench/contrib/chat/browser/widget/media/chat.css
Comment thread src/vs/workbench/contrib/chat/browser/widget/media/chat.css
@Neizan93 Neizan93 force-pushed the feature/chat-token-usage-317977 branch from aad1dcd to b4cddc5 Compare May 30, 2026 21:13
@Neizan93 Neizan93 force-pushed the feature/chat-token-usage-317977 branch from b4cddc5 to a0f20ef Compare May 30, 2026 21:16
@Neizan93 Neizan93 requested a review from Copilot May 30, 2026 21:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts
Comment thread src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts Outdated
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.

4 participants