Skip to content

agent: Ensure context meter updates when context is cleared #30320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

captaindpt
Copy link
Contributor

Addresses an issue where the agent context token meter in the panel toolbar (showing usage like "X / Y tokens") failed to update its count after the user cleared the current context via the context editor UI. While the meter updated correctly when adding items, clearing them left the display showing the old count.

The root cause was traced to the ContextStore::clear method in crates/agent/src/context_store.rs. This method correctly cleared the internal data structures holding the context items but neglected to call cx.notify() to inform listeners of the state change. Consequently, the UI components responsible for displaying the token count were not triggered to re-render with the new (presumably lower) count.

This PR fixes the issue by adding the missing cx.notify() call to the ContextStore::clear method. This ensures listeners are notified when the context set is cleared, allowing the token meter UI to update correctly.

Release Notes:

  • Fixed an issue where the agent context token meter did not update when the context was cleared.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label May 8, 2025
@maxdeviant maxdeviant changed the title fix(agent): Ensure context meter updates when context is cleared agent: Ensure context meter updates when context is cleared May 8, 2025
@captaindpt captaindpt force-pushed the bugfix/agent-clear-context-meter branch from 1db8592 to d23cad2 Compare May 8, 2025 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant