fix(ui): show context indicator even with stale token data (#89662)#95302
Closed
bowenluo718 wants to merge 1 commit into
Closed
Conversation
Fixes openclaw#89662 where the context usage indicator would disappear after sending a message and not reappear until page refresh. The issue was in getContextNoticeViewModel() which returned null when totalTokensFresh was false, completely hiding the indicator even when valid (but potentially stale) token counts were available. Changes: - Reorder validation to check data availability before freshness - Show indicator with stale data (imperfect info > no info) - Only recommend compaction when data is fresh - Add comprehensive unit tests covering stale data scenarios Test plan: - Added 13 unit tests for getContextNoticeViewModel() - Tests cover fresh/stale, low/high usage, edge cases - All tests pass, no regressions in existing functionality
|
Closing this PR because the author has more than 20 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #89662 where the context usage indicator in the webchat UI disappears after sending a message and does not reappear until page refresh.
The root cause was in
getContextNoticeViewModel()which returnednullwhentotalTokensFreshwasfalse, completely hiding the indicator even when valid (but potentially stale) token counts were available. This created a poor user experience where users lost visibility into their context usage during normal conversation flow.This PR reorders the validation logic to check data availability before freshness, ensuring that imperfect information is shown rather than no information at all.
Fixes #89662
Real behavior proof
Behavior addressed: Context indicator disappearing after message send, requiring page refresh to restore visibility.
After-fix evidence:
✅ All 13 unit tests passing covering:
Key test validating the fix:
Git stats:
Observed result after the fix:
Context indicator remains visible after message send, showing token usage percentage even when data may be slightly stale. Users no longer need to refresh the page to restore visibility.
Tests and validation
Risk checklist
Did user-visible behavior change? Yes - indicator now stays visible with stale data instead of disappearing.
Did config, environment, or migration behavior change? No.
Did security, auth, secrets, network, or tool execution behavior change? No.
Highest-risk area: Users might see slightly outdated token counts. Mitigated by: gateway periodic refresh, manual refresh option, conservative compaction recommendations.
Current review state
What is the next action? Maintainer review requested. CI validation pending.