[feat] add remaining token counter in the chat view #4253
Closed
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.
Description
This PR introduces a new feature that displays the remaining token counts for chat, user, and enhanced token types in the chat view. This enhancement aims to provide users with real-time visibility into their token usage, helping them manage their token allocation more effectively.
Changes
TokenCounter
class to expose a new method,getRemainingTokens()
, which returns an object containing the remaining token counts for each token type.SimpleChatPanelProvider
to:TokenCounter
instance after building the prompt.postMessage
method.PromptInfo
andTokenCounter
instances.'remainingTokens'
message type to the extension-webview communication protocol to facilitate the transfer of token counts.TokenIndicators
component that displays the remaining token counts in the chat view UI.TokenIndicators
component into theChat
component, populating it with the token counts received from the extension.TokenIndicators
component to ensure a visually appealing and intuitive user experience.Benefits
Screenshots
Checklist
Please review this PR and provide any feedback or suggestions for improvement. Let me know if you have any questions or concerns.
Test plan
TokenCounter
and propagated to the webview.TokenIndicators
component renders properly and displays the expected token counts.