fix: correct context badge count to sum actual items instead of injection objects (#2)

This commit is contained in:
Psypeal Gwai 2026-02-21 01:15:55 -08:00
parent 4ec272758c
commit 6e9c6219b2
2 changed files with 15 additions and 4 deletions

View file

@ -215,6 +215,17 @@ export const ContextBadge = ({
[newTaskCoordinationInjections] [newTaskCoordinationInjections]
); );
// Compute actual item counts (not injection-object counts) for accurate badge display
const toolOutputCount = useMemo(
() => newToolOutputInjections.reduce((sum, inj) => sum + inj.toolCount, 0),
[newToolOutputInjections]
);
const taskCoordinationCount = useMemo(
() => newTaskCoordinationInjections.reduce((sum, inj) => sum + inj.breakdown.length, 0),
[newTaskCoordinationInjections]
);
const userMessageTokens = useMemo( const userMessageTokens = useMemo(
() => newUserMessageInjections.reduce((sum, inj) => sum + inj.estimatedTokens, 0), () => newUserMessageInjections.reduce((sum, inj) => sum + inj.estimatedTokens, 0),
[newUserMessageInjections] [newUserMessageInjections]
@ -478,7 +489,7 @@ export const ContextBadge = ({
{newToolOutputInjections.length > 0 && ( {newToolOutputInjections.length > 0 && (
<PopoverSection <PopoverSection
title="Tool Outputs" title="Tool Outputs"
count={newToolOutputInjections.length} count={toolOutputCount}
tokenCount={toolOutputTokens} tokenCount={toolOutputTokens}
> >
{newToolOutputInjections.map((injection) => {newToolOutputInjections.map((injection) =>
@ -501,7 +512,7 @@ export const ContextBadge = ({
{newTaskCoordinationInjections.length > 0 && ( {newTaskCoordinationInjections.length > 0 && (
<PopoverSection <PopoverSection
title="Task Coordination" title="Task Coordination"
count={newTaskCoordinationInjections.length} count={taskCoordinationCount}
tokenCount={taskCoordinationTokens} tokenCount={taskCoordinationTokens}
> >
{newTaskCoordinationInjections.map((injection) => {newTaskCoordinationInjections.map((injection) =>

View file

@ -836,13 +836,13 @@ function computeContextStats(params: ComputeContextStatsParams): ContextStats {
newCounts.mentionedFiles++; newCounts.mentionedFiles++;
break; break;
case 'tool-output': case 'tool-output':
newCounts.toolOutputs++; newCounts.toolOutputs += (injection).toolCount;
break; break;
case 'thinking-text': case 'thinking-text':
newCounts.thinkingText++; newCounts.thinkingText++;
break; break;
case 'task-coordination': case 'task-coordination':
newCounts.taskCoordination++; newCounts.taskCoordination += (injection).breakdown.length;
break; break;
case 'user-message': case 'user-message':
newCounts.userMessages++; newCounts.userMessages++;