agent: Ensure context meter updates when context is cleared #30320
+5
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 incrates/agent/src/context_store.rs
. This method correctly cleared the internal data structures holding the context items but neglected to callcx.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 theContextStore::clear
method. This ensures listeners are notified when the context set is cleared, allowing the token meter UI to update correctly.Release Notes: