Skip to content

refactor(TokenBar): improve token display formatting#2783

Merged
wwwillchen merged 6 commits intodyad-sh:mainfrom
wwwillchen-bot:agent--1771961786744-1771960889
Feb 26, 2026
Merged

refactor(TokenBar): improve token display formatting#2783
wwwillchen merged 6 commits intodyad-sh:mainfrom
wwwillchen-bot:agent--1771961786744-1771960889

Conversation

@wwwillchen-bot
Copy link
Collaborator

@wwwillchen-bot wwwillchen-bot commented Feb 24, 2026

Summary

  • Refactored the TokenBar's percentage and context window display to use a cleaner flex-based layout
  • Added a centered separator dot between percentage and context window values
  • Improved visual alignment with items-center and consistent spacing

Test plan

  • Open a chat to view the TokenBar component
  • Verify the token percentage and context window display are properly aligned
  • Check that the separator dot appears with correct styling

🤖 Generated with Claude Code


Open with Devin

@wwwillchen
Copy link
Collaborator

@BugBot run

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @wwwillchen-bot, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on improving the user interface and experience of the TokenBar component. The changes aim to present token usage information more clearly and aesthetically by refining the layout and adding visual cues, making the display of percentage and context window values more organized and visually appealing.

Highlights

  • TokenBar Refactoring: Refactored the display of token percentage and context window in the TokenBar component to use a more flexible layout.
  • Separator Dot Added: Introduced a centered separator dot between the token percentage and context window values for improved readability.
  • Visual Alignment Improved: Enhanced visual alignment and consistent spacing of the token display elements using items-center and gap-1.5 utility classes.
Changelog
  • src/components/chat/TokenBar.tsx
    • Refactored the token percentage and context window display to use a flex-based layout.
    • Added a separator dot between the percentage and context window.
    • Applied Tailwind CSS classes for improved alignment and spacing.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 24, 2026

Greptile Summary

This PR refactors the TokenBar component to display token information in a new format. The changes split the percentage and context window into separate spans with gap-3 spacing (instead of justify-between), and update all E2E tests and snapshots accordingly.

Key Changes:

  • Changed token display from "X% of YK" to three separate elements: "Tokens: X", "Y%", "Context window: ZK"
  • Replaced justify-between with gap-3 spacing (items now left-aligned instead of distributed across width)
  • Updated E2E tests to check for new format with separate assertions
  • Added mouse move to dismiss tooltip before toggling in tests
  • Updated ARIA snapshot regex pattern

Note: The PR description mentions adding a "centered separator dot" and items-center class, but these features don't appear in the actual code - only gap-3 spacing was implemented.

Confidence Score: 4/5

  • This PR is safe to merge - straightforward refactoring with properly updated tests
  • The code changes are simple and functional. E2E tests were correctly updated to match the new format. The only concern is that the PR description mentions features (separator dot, items-center) that weren't actually implemented, but this doesn't affect code quality.
  • No files require special attention

Important Files Changed

Filename Overview
src/components/chat/TokenBar.tsx Refactored token display from single line to three separate spans with gap-3 spacing. PR description claims separator dot and items-center were added but they're missing from actual code.
e2e-tests/supabase_branch.spec.ts Updated test expectations to match new token format, split into separate assertions. Added mouse move to dismiss tooltip before toggling.
e2e-tests/snapshots/supabase_branch.spec.ts_supabase-branch-selection-works-1.aria.yml Updated ARIA snapshot regex to match new token display format.

Last reviewed commit: 85b6666

greptile-apps[bot]

This comment was marked as resolved.

@github-actions
Copy link
Contributor

🔍 Dyadbot Code Review Summary

Verdict: ⛔ NO - Do NOT merge

Reviewed by 3 independent agents: Correctness Expert, Code Health Expert, UX Wizard.

Issues Summary

Severity File Issue
🔴 HIGH src/components/chat/TokenBar.tsx:61-65 Text change breaks e2e test assertions
🟢 Low Priority Notes (1 item)
  • Separator dot lacks semantic clarity for screen readers - src/components/chat/TokenBar.tsx:63 - The · separator replaces the word "of", which was more meaningful for assistive technology. Consider adding an aria-label to preserve screen reader clarity.
🚫 Dropped False Positives (0 items)

No false positives to report.

Details

🔴 HIGH: Text change breaks e2e test assertions

The PR changes the displayed text from "6% of 128K" to "6% · 128K" (with the word "of" replaced by a dot separator). However, e2e-tests/supabase_branch.spec.ts lines 15 and 27 assert:

await expect(po.page.getByTestId("token-bar")).toContainText("6% of 128K");
await expect(po.page.getByTestId("token-bar")).toContainText("100% of 128K");

These e2e tests will fail because the text content no longer contains "of".

Fix: Update the e2e test assertions to match the new format, or keep the "of" text visible (e.g., visually hidden for screen readers).


Generated by Dyadbot multi-agent code review

github-actions[bot]

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

@github-actions github-actions bot added the needs-human:review-issue ai agent flagged an issue that requires human review label Feb 24, 2026
@wwwillchen
Copy link
Collaborator

@BugBot run

@wwwillchen wwwillchen added merge-when-ready merges PR if all checks passes (triggered by CI finish) and removed needs-human:review-issue ai agent flagged an issue that requires human review labels Feb 25, 2026
greptile-apps[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@github-actions github-actions bot added the needs-human:review-issue ai agent flagged an issue that requires human review label Feb 25, 2026
wwwillchen and others added 3 commits February 25, 2026 17:01
Refactored the percentage and context window display to use a cleaner
layout with flex alignment and a centered separator dot.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@wwwillchen
Copy link
Collaborator

@BugBot run

@wwwillchen-bot wwwillchen-bot added cc:request and removed needs-human:review-issue ai agent flagged an issue that requires human review labels Feb 26, 2026
github-actions bot and others added 2 commits February 26, 2026 01:20
- Update supabase_branch E2E snapshot to match new "Context window: YK"
  format instead of old "X% of YK" format

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The w-full TooltipTrigger causes the base-ui tooltip (delay=0) to appear
instantly when the dropdown menu closes and the mouse lands on the trigger.
Move mouse away before the second toggleTokenBar() to dismiss it.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

✅ Claude Code completed successfully

Summary

  • Fixed 5 review comments (all from trusted bot reviewers)
  • Updated ARIA snapshot for new TokenBar text format
  • Fixed E2E test failure: tooltip blocking toggleTokenBar() click

Review Comments Addressed

Thread Author Resolution
E2E test format breakage (outdated) greptile-apps Resolved - E2E tests already updated, fixed ARIA snapshot
Text change breaks E2E assertions github-actions Resolved - ARIA snapshot updated to match new format
Accessibility: dot separator gemini-code-assist Resolved (not valid) - dot separator was already removed
E2E test breaking change greptile-apps Resolved - same as above
Preserve token text contract chatgpt-codex-connector Resolved - ARIA snapshot updated

CI Fixes

Check Status Resolution
e2e-tests (shard 2/2) Fixed Tooltip intercepting pointer events on auxiliary-actions-menu - added mouse.move(0,0) to dismiss tooltip
template-create-nextjs Not fixable Network error ("socket hang up") - unrelated to PR
claude-review N/A Review bot action, not a code check
Details

ARIA Snapshot Fix:
Updated e2e-tests/snapshots/supabase_branch.spec.ts_supabase-branch-selection-works-1.aria.yml regex from old format (X% of YK) to new format (X% Context window: YK).

E2E Tooltip Fix:
The w-full class on TooltipTrigger combined with base-ui's delay=0 tooltip causes the tooltip to appear instantly when the dropdown menu closes and the mouse lands on the trigger area. Added page.mouse.move(0, 0) before the second toggleTokenBar() call to dismiss the tooltip.


Workflow run

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 95e3439f8b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wwwillchen
Copy link
Collaborator

@BugBot run

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85b66660c3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions
Copy link
Contributor

🔍 Dyadbot Code Review Summary

Verdict: ✅ YES - Ready to merge

Reviewed by 3 independent agents: Correctness Expert, Code Health Expert, UX Wizard.

Issues Summary

Severity File Issue
🟡 MEDIUM src/components/chat/TokenBar.tsx:59 Layout clusters items left instead of spreading across bar width
🟢 Low Priority Notes (1 item)
  • Standalone percentage less scannable - src/components/chat/TokenBar.tsx:61 - The old "6% of 128K" was a self-contained phrase; the new separate "6%" and "Context window: 128K" require the reader to mentally connect the two values.
🚫 Dropped False Positives (4 items)
  • Hardcoded English strings bypass i18n - Dropped: TokenBar.tsx doesn't use the i18n system; the old code also hardcoded strings directly. The stale tokenPercentUsed locale key is a pre-existing issue, not a regression from this PR.
  • Imprecise test assertion toContainText('6%') - Dropped: Already flagged by existing comment from chatgpt-codex-connector[bot].
  • Bare percentage lacks screen reader context - Dropped: The container content reads sequentially as "Tokens: 8,192 6% Context window: 128K" which is understandable.
  • Mouse move tooltip workaround in e2e test - Dropped: Standard e2e test pattern, well-documented with a clear comment.

Generated by Dyadbot multi-agent code review

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Multi-agent review: 1 issue found

@github-actions
Copy link
Contributor

🎭 Playwright Test Results

❌ Some tests failed

OS Passed Failed Flaky Skipped
🍎 macOS 232 3 5 6

Summary: 232 passed, 3 failed, 5 flaky, 6 skipped

Failed Tests

🍎 macOS

  • rebuild.spec.ts > rebuild app
    • Error: expect(locator).toMatchAriaSnapshot(expected) failed
  • select_component.spec.ts > select component next.js
    • Error: expect(locator).toBeVisible() failed
  • template-create-nextjs.spec.ts > create next.js app
    • Error: expect(locator).toBeVisible() failed

📋 Re-run Failing Tests (macOS)

Copy and paste to re-run all failing spec files locally:

npm run e2e \
  e2e-tests/rebuild.spec.ts \
  e2e-tests/select_component.spec.ts \
  e2e-tests/template-create-nextjs.spec.ts

⚠️ Flaky Tests

🍎 macOS

  • context_manage.spec.ts > manage context - smart context (passed after 1 retry)
  • edit_custom_models.spec.ts > edit custom model (passed after 1 retry)
  • local_agent_auto.spec.ts > local-agent - auto model (passed after 1 retry)
  • logs_server.spec.ts > system messages UI shows server logs with correct type (passed after 1 retry)
  • setup_flow.spec.ts > Setup Flow > setup banner shows correct state when node.js is installed (passed after 1 retry)

📊 View full report

@github-actions
Copy link
Contributor

✅ Claude Code completed successfully

Summary

  • Fixed 3 review comments (2 duplicate + 1 unique)
  • No actionable CI failures (3 failed E2E tests are pre-existing flaky tests also failing on main)
Details

Review Comments Addressed

  1. Tightened E2E assertion (e2e-tests/supabase_branch.spec.ts:15): Changed toContainText("6%") to toContainText(/\b6%/) to prevent false substring matches (e.g., 16%, 60%). Also applied to 100% assertion. (Threads by chatgpt-codex-connector x2)
  2. Restored justify-between layout (src/components/chat/TokenBar.tsx:59): Replaced gap-3 with justify-between so token labels spread across the full bar width, matching the progress bar below. Per Principle Make node.js setup have a more explicit error state #6: Delightful. (Thread by github-actions)

CI Check Analysis

  • Flakiness.io: External service, not actionable
  • e2e-tests shard 2/2: 3 failed tests (rebuild.spec.ts, select_component.spec.ts, template-create-nextjs.spec.ts) are pre-existing flaky failures also present on main branch — unrelated to TokenBar changes

Workflow run

@github-actions
Copy link
Contributor

🤖 Claude Code Review Summary

PR Confidence: 4/5

All review comments addressed and resolved; the only remaining risk is pre-existing flaky E2E tests unrelated to this PR.

Unresolved Threads

No unresolved threads

Resolved Threads

Issue Rationale Link
Loose substring match in E2E assertion (toContainText("6%") could match 16%, 60%) Fixed with word boundary regex /\b6%/ and /\b100%/ View, View
Layout clusters labels left with gap-3 instead of spreading across bar width Restored justify-between to match progress bar width. Per Principle #6: Delightful — visual alignment should feel intentional. View
Product Principle Suggestions

No suggestions — principles were clear enough for all decisions.


🤖 Generated by Claude Code

@github-actions github-actions bot added cc:done needs-human:review-issue ai agent flagged an issue that requires human review and removed cc:pending labels Feb 26, 2026
@wwwillchen wwwillchen merged commit 7f608d9 into dyad-sh:main Feb 26, 2026
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cc:done cc:request merge-when-ready merges PR if all checks passes (triggered by CI finish) needs-human:review-issue ai agent flagged an issue that requires human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants