Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion dashboard/src/pages/Chat/components/ContextWindowRing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ export default function ContextWindowRing({
] as ContextUsageBreakdown["segments"])
: display.segments;
const segmentTotal = segments.reduce((sum, item) => sum + item.tokens, 0);
// Segments are harness-side estimates and run short of the provider's input
// total; the bar already normalizes them onto ``displayUsed``. Scale the
// legend by the same factor so the listed parts sum to the header figure
// instead of silently falling short of it.
const scaleToUsed = (tokens: number) =>
segmentTotal > 0 ? Math.round((displayUsed * tokens) / segmentTotal) : tokens;

const popoverContent = (
<div className={styles.contextUsagePanel}>
Expand Down Expand Up @@ -278,7 +284,7 @@ export default function ContextWindowRing({
{t(`chat.contextWindow.segments.${segment.key}`)}
</span>
<span className={styles.contextUsageLegendValue}>
~{formatTokenK(segment.tokens)}
~{formatTokenK(scaleToUsed(segment.tokens))}
</span>
</li>
))}
Expand Down
Loading