Skip to content

fix(webchat): keep context indicator visible with stale token data#89772

Merged
steipete merged 3 commits into
openclaw:mainfrom
bladin:fix/89662-context-indicator-bug
Jul 6, 2026
Merged

fix(webchat): keep context indicator visible with stale token data#89772
steipete merged 3 commits into
openclaw:mainfrom
bladin:fix/89662-context-indicator-bug

Conversation

@bladin

@bladin bladin commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #89662.

What Problem This Solves

The Control UI hid the context-usage indicator as soon as a run made the cached total stale. That removed useful orientation during a response, but treating stale totals as current would also risk false warning styling and an inappropriate Compact action after the session had already compacted.

Why This Change Was Made

The view model now separates whether a finite cached total can be displayed from whether that total is fresh enough to drive actions. A stale finite total remains visible as approximate, while warning state and Compact remain gated on fresh usage. Missing or invalid totals stay hidden.

User Impact

During an active response, users keep an approximate context indicator instead of seeing it disappear. Stale data cannot trigger warning colors or offer Compact; fresh totals preserve the existing threshold and action behavior.

Evidence

  • Focused view-model tests cover stale finite, missing, invalid, fresh-warning, and fresh-compact states.
  • Real-Chromium Control UI E2E injects cached usage, starts a run, verifies the approximate marker remains visible, and verifies Compact is absent.
  • Sanitized AWS Crabbox run run_9f30d3d15aa1 passed all 8 focused view-model tests.
  • Sanitized AWS Crabbox run run_b5f0e5398cea passed all 23 chat-flow.e2e.test.ts browser scenarios, including the new stale-context case.
  • Exact-head sanitized AWS Crabbox run run_f637a2d3b9b3 passed all 8 focused view-model tests and all 23 chat-flow.e2e.test.ts browser scenarios on 59a4d3549d9fd9979d51edf78856611e28a2bad9.
  • Fresh autoreview found no accepted/actionable defects.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 3, 2026
@clawsweeper

clawsweeper Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 6, 2026, 1:30 AM ET / 05:30 UTC.

Summary
The branch updates the Control UI chat context notice so stale finite session totals render as approximate ~ usage without warning or Compact behavior, adds focused unit and mocked browser E2E coverage, and adds a changelog entry.

PR surface: Source +4, Tests +60, Docs +1. Total +65 across 4 files.

Reproducibility: yes. Source inspection shows current main hides the notice when totalTokensFresh is false, and the linked issue provides a matching send-message user path; I did not run a live browser reproduction.

Review metrics: 1 noteworthy metric.

  • Release-owned changelog edits: 1 added. Normal PR changelog edits bypass the release-owned changelog generation path and should be noticed before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #89662
Summary: This PR is the active implementation candidate for the canonical disappearing Control UI context indicator bug; related stale-token and token-meter work overlaps but does not supersede it.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🦞 diamond lobster
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add after-fix proof from a real setup, such as a short recording, terminal output, linked artifact, or redacted logs.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body cites focused tests, a mocked Chromium Control UI E2E, and Crabbox run IDs, but it does not include redacted real Control UI proof such as a screenshot, recording, live output, or logs from the changed send-message flow. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Mantis proof suggestion
A short web UI chat proof would directly show the visible context indicator behavior that mocked tests do not prove. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis web UI chat proof: verify that the chat context indicator remains visible with approximate stale token usage after sending a message and no Compact action is shown.

Risk before merge

  • [P1] The PR body now cites mocked browser E2E and Crabbox test run IDs, but it still does not show redacted real Control UI behavior proof from an actual send-message flow.
  • [P1] The branch edits CHANGELOG.md even though release generation owns changelog entries, so merging it can create release-note drift or conflict.

Maintainer options:

  1. Remove changelog and add real UI proof (recommended)
    Before merge, keep the release-note context in the PR body or squash message, drop the CHANGELOG.md line, and attach redacted real Control UI proof.
  2. Accept mocked proof only
    Maintainers could intentionally accept the mocked E2E and Crabbox test evidence, but that would bypass the external-PR real behavior proof gate.

Next step before merge

  • [P1] Continue normal maintainer review; ClawSweeper found no patch-correctness issue.

Security
Cleared: The diff is limited to Control UI rendering, tests, and changelog text with no dependency, workflow, secret, permission, network, code-execution, or supply-chain change.

Review details

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection shows current main hides the notice when totalTokensFresh is false, and the linked issue provides a matching send-message user path; I did not run a live browser reproduction.

Is this the best way to solve the issue?

Yes for the runtime shape. Displaying stale finite totals as approximate while suppressing warning and Compact is the narrow fix, and current session reconciliation preserves omitted stale totals; the remaining gaps are proof and release-owned changelog cleanup.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 06fbd84d2b1a.

Label changes

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦞 diamond lobster.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P2: The PR targets a visible but non-blocking Control UI context indicator regression with limited blast radius.
  • merge-risk: 🚨 other: Merging as-is would carry a release-owned changelog edit and still lacks real Control UI behavior proof beyond mocked tests.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body cites focused tests, a mocked Chromium Control UI E2E, and Crabbox run IDs, but it does not include redacted real Control UI proof such as a screenshot, recording, live output, or logs from the changed send-message flow. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +4, Tests +60, Docs +1. Total +65 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 13 9 +4
Tests 2 73 13 +60
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 87 22 +65

What I checked:

Likely related people:

  • clawSean: Introduced the current page-module and session reconciliation structure that now owns both the context notice helper and stale session-row merge path. (role: recent current-path contributor; confidence: high; commits: d84aabf642c3; files: ui/src/pages/chat/components/chat-composer.ts, ui/src/lib/sessions/reconcile.ts)
  • Peter Steinberger: Earlier split the context notice helper coverage and added the current PR's mocked browser E2E and changelog commit. (role: helper extraction and branch test contributor; confidence: high; commits: 7c862da6a1de, d155d578ebde, 09b34b410d34; files: ui/src/pages/chat/components/chat-composer.ts, ui/src/pages/chat/chat-composer.test.ts, ui/src/e2e/chat-flow.e2e.test.ts)
  • Vincent Koc: Shared the chat token formatter used by the context notice display path and appears in recent history for this formatting surface. (role: adjacent token-format contributor; confidence: medium; commits: 45f935887769; files: ui/src/ui/chat/context-notice.ts, ui/src/ui/chat/token-format.ts)
  • Tak Hoffman: Changed the Control UI notice to use current session context usage, which is the display value this stale-token patch preserves. (role: context-usage source contributor; confidence: medium; commits: 6db6e117df9d; files: ui/src/ui/views/chat.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (2 earlier review cycles)
  • reviewed 2026-06-21T12:18:23.565Z sha 4388ea0 :: needs real behavior proof before merge. :: [P1] Preserve stale totals before rendering the notice | [P2] Cover stale rows that no longer include totals | [P2] Align the stale-token docs and marker convention
  • reviewed 2026-06-30T05:19:43.410Z sha 4388ea0 :: needs real behavior proof before merge. :: [P1] Preserve stale totals before rendering the notice | [P2] Cover stale rows that no longer include totals | [P2] Align the stale-token marker with docs and /usage

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 3, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Jun 11, 2026
@steipete steipete self-assigned this Jul 6, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 6, 2026
@steipete
steipete force-pushed the fix/89662-context-indicator-bug branch from 4388ea0 to f67e1cc Compare July 6, 2026 05:09
bladin and others added 3 commits July 6, 2026 01:24
The context usage indicator was disappearing after sending a message because
totalTokensFresh was set to false during the run, even though we had valid
token count data from before the message was sent.

Changes:
- Modified getContextNoticeViewModel to show the indicator even when
  totalTokensFresh is false, as long as totalTokens is non-zero
- Added isStale flag to indicate when token data is not fresh
- Applied subtle visual styling for stale data (lighter colors, 5% opacity)
- Added "(updating)" suffix to the percentage text and title when stale
- Updated tests to verify the new behavior

Fixes openclaw#89662
@steipete
steipete force-pushed the fix/89662-context-indicator-bug branch from f67e1cc to 59a4d35 Compare July 6, 2026 05:24
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 6, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 6, 2026
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Maintainer refactor and land-ready verification complete.

  • Separated stale displayability from fresh actionability: stale finite context remains approximate, while warnings and Compact remain fresh-only.
  • Exact head: 59a4d3549d9fd9979d51edf78856611e28a2bad9.
  • Sanitized AWS Crabbox: provider aws, lease cbx_5f2b529bfaf8, run run_f637a2d3b9b3.
  • Exact remote command: pnpm test ui/src/pages/chat/chat-composer.test.ts ui/src/e2e/chat-flow.e2e.test.ts after Playwright Chromium installation.
  • Result: 8/8 focused assertions and 23/23 real-Chromium chat-flow scenarios passed, including approximate stale usage with no warning or Compact action.
  • Fresh autoreview: no accepted/actionable findings. Native review artifacts: validated, READY FOR /prepare-pr.
  • Hosted CI is green after rerunning one unrelated gateway admission-race test; the rerun passed and the changed surface is only the Control UI view model and browser regression.
  • Known proof gaps: none for the changed context-indicator behavior.

Thank you @bladin for the original report and implementation direction.

@steipete
steipete merged commit 00f5df2 into openclaw:main Jul 6, 2026
145 of 149 checks passed
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 6, 2026
…penclaw#89772)

* fix(webchat): keep context indicator visible with stale token data

The context usage indicator was disappearing after sending a message because
totalTokensFresh was set to false during the run, even though we had valid
token count data from before the message was sent.

Changes:
- Modified getContextNoticeViewModel to show the indicator even when
  totalTokensFresh is false, as long as totalTokens is non-zero
- Added isStale flag to indicate when token data is not fresh
- Applied subtle visual styling for stale data (lighter colors, 5% opacity)
- Added "(updating)" suffix to the percentage text and title when stale
- Updated tests to verify the new behavior

Fixes openclaw#89662

* test(ui): cover stale context indicator behavior

* docs(changelog): note Control UI fix

---------

Co-authored-by: 黑承亮0668000844 <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
…penclaw#89772)

* fix(webchat): keep context indicator visible with stale token data

The context usage indicator was disappearing after sending a message because
totalTokensFresh was set to false during the run, even though we had valid
token count data from before the message was sent.

Changes:
- Modified getContextNoticeViewModel to show the indicator even when
  totalTokensFresh is false, as long as totalTokens is non-zero
- Added isStale flag to indicate when token data is not fresh
- Applied subtle visual styling for stale data (lighter colors, 5% opacity)
- Added "(updating)" suffix to the percentage text and title when stale
- Updated tests to verify the new behavior

Fixes openclaw#89662

* test(ui): cover stale context indicator behavior

* docs(changelog): note Control UI fix

---------

Co-authored-by: 黑承亮0668000844 <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Context indicator disappears after sending message and count mismatch

2 participants