Skip to content

Commit 1666dd5

Browse files
committed
feat: Move token statistics to tooltip on price hover
- Wrapped cost badge with StandardTooltip component - Token statistics (input/output/cache) now shown in tooltip - Improved UX by reducing visual clutter while keeping info accessible - Added cursor:default to badge when hovering As suggested by @daniel-lxs in PR #7741
1 parent 7a3faff commit 1666dd5

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

webview-ui/src/components/chat/ChatRow.tsx

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { vscode } from "@src/utils/vscode"
1818
import { removeLeadingNonAlphanumeric } from "@src/utils/removeLeadingNonAlphanumeric"
1919
import { getLanguageFromPath } from "@src/utils/getLanguageFromPath"
2020
import { formatTokenStats } from "@src/utils/formatTokens"
21-
import { Button } from "@src/components/ui"
21+
import { Button, StandardTooltip } from "@src/components/ui"
2222

2323
import { ToolUseBlock, ToolUseBlockHeader } from "../common/ToolUseBlock"
2424
import UpdateTodoListToolBlock from "./UpdateTodoListToolBlock"
@@ -1146,36 +1146,39 @@ export const ChatRowContent = ({
11461146
{title}
11471147
</span>
11481148
<div style={{ display: "flex", alignItems: "center", gap: "8px", flexShrink: 0 }}>
1149-
<VSCodeBadge
1150-
style={{
1151-
opacity: cost !== null && cost !== undefined && cost > 0 ? 1 : 0,
1152-
flexShrink: 0,
1153-
}}>
1154-
${Number(cost || 0)?.toFixed(4)}
1155-
</VSCodeBadge>
1156-
{hasTokenData && (
1157-
<div
1158-
className="flex items-center gap-1"
1149+
{hasTokenData ? (
1150+
<StandardTooltip
1151+
content={
1152+
<div className="flex flex-col gap-1">
1153+
<div className="flex items-center gap-2">
1154+
<span>↑ Input:</span>
1155+
<span className="font-mono">{tokenStats.input}</span>
1156+
</div>
1157+
<div className="flex items-center gap-2">
1158+
<span>↓ Output:</span>
1159+
<span className="font-mono">{tokenStats.output}</span>
1160+
</div>
1161+
</div>
1162+
}
1163+
side="top">
1164+
<VSCodeBadge
1165+
style={{
1166+
opacity:
1167+
cost !== null && cost !== undefined && cost > 0 ? 1 : 0,
1168+
flexShrink: 0,
1169+
cursor: "default",
1170+
}}>
1171+
${Number(cost || 0)?.toFixed(4)}
1172+
</VSCodeBadge>
1173+
</StandardTooltip>
1174+
) : (
1175+
<VSCodeBadge
11591176
style={{
1160-
opacity: hasTokenData ? 1 : 0,
1177+
opacity: cost !== null && cost !== undefined && cost > 0 ? 1 : 0,
11611178
flexShrink: 0,
1162-
whiteSpace: "nowrap",
11631179
}}>
1164-
<span
1165-
style={{
1166-
fontSize: "12px",
1167-
color: "var(--vscode-descriptionForeground)",
1168-
}}>
1169-
{tokenStats.input}
1170-
</span>
1171-
<span
1172-
style={{
1173-
fontSize: "12px",
1174-
color: "var(--vscode-descriptionForeground)",
1175-
}}>
1176-
{tokenStats.output}
1177-
</span>
1178-
</div>
1180+
${Number(cost || 0)?.toFixed(4)}
1181+
</VSCodeBadge>
11791182
)}
11801183
</div>
11811184
</div>

0 commit comments

Comments
 (0)