-
Notifications
You must be signed in to change notification settings - Fork 254
Add token counts to webview display #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add token counts to webview display #47
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 { |
Copilot
AI
Jul 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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> |
Copilot
AI
Jul 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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.
| <div className="token-total">Total tokens: {tokens.total}</div> | |
| <div className="token-total" aria-label={`Total tokens: ${tokens.total}`}>Total tokens: {tokens.total}</div> |
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