Unverified 提交 7f608d98 authored 作者: wwwillchen-bot's avatar wwwillchen-bot 提交者: GitHub

refactor(TokenBar): improve token display formatting (#2783)

## 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](https://claude.com/claude-code) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2783" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> --------- Co-authored-by: 's avatarWill Chen <willchen90@gmail.com> Co-authored-by: 's avatarClaude Opus 4.5 <noreply@anthropic.com> Co-authored-by: 's avatarclaude[bot] <41898282+claude[bot]@users.noreply.github.com>
上级 fe085225
- text: "/Tokens: \\d+,\\d+ \\d+% of [\\d,.]+[bkmBKM]+ Optimize your tokens with Dyad Pro's Smart Context/" - text: "/Tokens: [\\d,]+ \\d+% Context window: \\d+K Optimize your tokens with Dyad Pro's Smart Context/"
\ No newline at end of file \ No newline at end of file
...@@ -12,7 +12,12 @@ testSkipIfWindows("supabase branch selection works", async ({ po }) => { ...@@ -12,7 +12,12 @@ testSkipIfWindows("supabase branch selection works", async ({ po }) => {
await po.navigation.clickBackButton(); await po.navigation.clickBackButton();
await po.toggleTokenBar(); await po.toggleTokenBar();
// The default branch has a small context. // The default branch has a small context.
await expect(po.page.getByTestId("token-bar")).toContainText("6% of 128K"); await expect(po.page.getByTestId("token-bar")).toContainText("6%");
await expect(po.page.getByTestId("token-bar")).toContainText(
"Context window: 128K",
);
// Move mouse away from the token bar to dismiss tooltip before toggling.
await po.page.mouse.move(0, 0);
// We hide the token bar so we re-open it later to refresh the token count. // We hide the token bar so we re-open it later to refresh the token count.
await po.toggleTokenBar(); await po.toggleTokenBar();
...@@ -24,5 +29,8 @@ testSkipIfWindows("supabase branch selection works", async ({ po }) => { ...@@ -24,5 +29,8 @@ testSkipIfWindows("supabase branch selection works", async ({ po }) => {
// The test branch has a large context (200k tokens) so it'll hit the 100% limit. // The test branch has a large context (200k tokens) so it'll hit the 100% limit.
// This is to make sure we're connecting to the right supabase project for the branch. // This is to make sure we're connecting to the right supabase project for the branch.
await po.toggleTokenBar(); await po.toggleTokenBar();
await expect(po.page.getByTestId("token-bar")).toContainText("100% of 128K"); await expect(po.page.getByTestId("token-bar")).toContainText("100%");
await expect(po.page.getByTestId("token-bar")).toContainText(
"Context window: 128K",
);
}); });
...@@ -54,13 +54,13 @@ export function TokenBar({ chatId }: TokenBarProps) { ...@@ -54,13 +54,13 @@ export function TokenBar({ chatId }: TokenBarProps) {
<div className="px-4 pb-2 text-xs" data-testid="token-bar"> <div className="px-4 pb-2 text-xs" data-testid="token-bar">
<TooltipProvider> <TooltipProvider>
<Tooltip> <Tooltip>
<TooltipTrigger> <TooltipTrigger className="w-full">
<div className="w-full"> <div className="w-full">
<div className="flex justify-between mb-1 text-xs text-muted-foreground"> <div className="flex gap-3 mb-1 text-xs text-muted-foreground">
<span>Tokens: {totalTokens.toLocaleString()}</span> <span>Tokens: {totalTokens.toLocaleString()}</span>
<span>{Math.round(percentUsed)}%</span>
<span> <span>
{Math.round(percentUsed)}% of{" "} Context window: {(contextWindow / 1000).toFixed(0)}K
{(contextWindow / 1000).toFixed(0)}K
</span> </span>
</div> </div>
<div className="w-full h-1.5 bg-muted rounded-full overflow-hidden flex"> <div className="w-full h-1.5 bg-muted rounded-full overflow-hidden flex">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论