Add token counts to webview display#47
Merged
ultmaster merged 3 commits intotoken-counterfrom Jul 11, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds token count indicators for individual chat messages and a total token count at the bottom of the webview, along with related CSS updates for styling.
- Introduce a
tokensprop inChatMessagesand render per-message token counts in the header. - Update
Contentto passtokens.perMessagetoChatMessagesand display total tokens. - Enhance CSS with a new font-size variable and styles for
.token-countand.token-total.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/poml-vscode/panel/content.tsx | Added tokens prop to chat components and rendered counts. |
| media/style.css | Defined --poml-font-size-09 and added styles for token displays. |
Comments suppressed due to low confidence (2)
packages/poml-vscode/panel/content.tsx:192
- [nitpick] No tests appear to cover the new per-message token count rendering. Consider adding unit tests to verify
ChatMessagescorrectly displays counts whentokensis provided.
<span className="token-count">{tokens[idx]} tokens</span>
media/style.css:306
- The CSS variable
--poml-paddingis not defined elsewhere; consider using an existing padding variable (e.g.,--poml-padding-02) or define--poml-padding.
margin-left: var(--poml-padding);
media/style.css
Outdated
| margin: 0; | ||
| } | ||
|
|
||
| .chat-message-header .content .name .token-count { |
There was a problem hiding this comment.
The selector includes .content which doesn't exist in the markup. It should be .chat-message-header .name .token-count to correctly target the token-count span.
| <div className="hidden" id="copy-content" data-value={toCopy} /> | ||
| {result} | ||
| {tokens && ( | ||
| <div className="token-total">Total tokens: {tokens.total}</div> |
There was a problem hiding this comment.
[nitpick] For better screen reader support, consider adding an aria-label or visually hidden text to this total token element so it’s announced clearly.
Suggested change
| <div className="token-total">Total tokens: {tokens.total}</div> | |
| <div className="token-total" aria-label={`Total tokens: ${tokens.total}`}>Total tokens: {tokens.total}</div> |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Testing
npm run build-webviewnpm run build-clinpm run lintnpm testpython -m pytest python/testsnpm run generate-component-spechttps://chatgpt.com/codex/tasks/task_e_686e406d2a44832e859df55c19a499f9