Skip to content

fix: prevent context token indicator flickering#5811

Merged
kevinvandijk merged 7 commits intoKilo-Org:mainfrom
wombatepiclandingstudio:fix-context-token-flickering
Feb 12, 2026
Merged

fix: prevent context token indicator flickering#5811
kevinvandijk merged 7 commits intoKilo-Org:mainfrom
wombatepiclandingstudio:fix-context-token-flickering

Conversation

@wombatepiclandingstudio
Copy link
Contributor

Summary

Fixed a bug where the context token indicator would flicker to 0% when a new API request started.

The Bug

The loop in consolidateTokenUsage.ts was breaking on placeholder messages (messages without token data) instead of continuing to search for the last complete message with valid token data.

The Fix

Moved the break statement inside the if (hasTokenData) block so the loop only breaks when valid token data is found. If a placeholder is encountered, it now continues to check previous messages.

Files Changed

  • packages/core/src/message-utils/consolidateTokenUsage.ts - Fixed the loop logic
  • .changeset/fix-context-flickering.md - Changelog entry

Testing

This fix addresses the failing tests in src/shared/__tests__/getApiMetrics-context-indicator.spec.ts which document this exact issue.

Fixed a bug where the context token indicator would flicker to 0% when
a new API request started. The issue occurred because the loop would
break on placeholder messages without valid token data instead of
continuing to search for the last complete message with token data.

Affected: packages/core/src/message-utils/consolidateTokenUsage.ts
@changeset-bot
Copy link

changeset-bot bot commented Feb 11, 2026

🦋 Changeset detected

Latest commit: 22fc3a4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kilo-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Collaborator

@kevinvandijk kevinvandijk left a comment

Choose a reason for hiding this comment

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

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants