Skip to content

feat(ui): show context usage details#100264

Merged
steipete merged 7 commits into
mainfrom
codex/context-usage-popover
Jul 5, 2026
Merged

feat(ui): show context usage details#100264
steipete merged 7 commits into
mainfrom
codex/context-usage-popover

Conversation

@steipete

@steipete steipete commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Control UI chat composer shows context pressure as a compact ring, but opening that control did not reveal the numbers behind it. Users had to infer the current context window and could not see the latest run's token split or active model in place.

Why This Change Was Made

The context ring now opens a keyboard-accessible details panel with the fresh context snapshot, latest-run input/output tokens, and active model. The panel uses the existing session-list data, preserves the compact recommendation path, closes on Escape or outside interaction, and becomes a viewport sheet on narrow or short-landscape screens.

The Control UI mock server also loads the external UI package aliases used by production, keeping live visual verification on the real route. AI-assisted with Codex; two fresh autoreview passes were completed, with the final pass reporting no actionable findings.

User Impact

Users can click the composer context ring to understand current context usage without leaving chat. The same panel stays readable on desktop, portrait mobile, and short landscape layouts.

Evidence

  • Blacksmith Testbox tbx_01kwrrh4nm6b1857st4y4s1cx2: pnpm test ui/src/pages/chat/chat-composer.test.ts — 8/8 passed.
  • Blacksmith Testbox tbx_01kwrrh4nm6b1857st4y4s1cx2: pnpm test ui/src/e2e/chat-flow.e2e.test.ts — 20/20 passed, including open/dismiss usage coverage.
  • Blacksmith Testbox tbx_01kwrrh4nm6b1857st4y4s1cx2: pnpm ui:i18n:check and pnpm ui:build — passed.
  • Existing-profile Chrome live proof: desktop panel rendered; 844×390 landscape panel remained fully inside the viewport; Escape dismissed it.
  • Fresh Codex autoreview after fixes: no accepted/actionable findings.
  • The broader changed gate completed this PR's typechecks and UI lint, then hit an unrelated existing packages/speech-core/node_modules/openclaw lint fan-out; exact-head hosted CI remains the merge gate.
  • Desktop and short-landscape screenshots are attached as visual evidence.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui scripts Repository scripts size: L maintainer Maintainer-authored PR labels Jul 5, 2026
@steipete

steipete commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Visual evidence

Existing-profile Chrome proof: desktop and 844×390 short-landscape layouts.

openclaw-context-usage-desktop openclaw-context-usage-landscape

@clawsweeper

clawsweeper Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed July 5, 2026, 8:49 AM ET / 12:49 UTC.

Summary
The branch adds a Control UI chat-composer context usage details panel with localized labels, responsive styling, mock-server aliasing, and focused UI/E2E coverage.

Reproducibility: yes. for the blocking interaction bug from source: clicks inside the static popover body bubble to the composer focus handler and do not match the interactive guard. I did not run a live touch/mobile repro in this read-only review.

Review metrics: 2 noteworthy metrics.

  • Release-owned file changes: 1 added CHANGELOG.md entry. CHANGELOG.md is release-owned, so this direct entry should be removed before merge.
  • Current-main review surface: 69 unique files vs 323 displayed files. The PR base is stale; this helps maintainers separate the actual UI/i18n diff from already-landed current-main overlap.

Stored data model
Persistent data-model change detected: persistent cache schema: ui/src/i18n/.i18n/ru.tm.jsonl, persistent cache schema: ui/src/i18n/.i18n/th.tm.jsonl, persistent cache schema: ui/src/i18n/.i18n/tr.tm.jsonl, persistent cache schema: ui/src/i18n/.i18n/uk.tm.jsonl, persistent cache schema: ui/src/i18n/.i18n/vi.tm.jsonl, persistent cache schema: ui/src/i18n/.i18n/zh-CN.tm.jsonl, and 6 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster ✨ media proof bonus
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

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

Rank-up moves:

  • Prevent popover body interactions from focusing the composer and cover that path with focused UI proof.
  • Remove the manual CHANGELOG.md entry.

Mantis proof suggestion
A short browser proof after the interaction fix would materially verify the visible popover behavior on desktop and short landscape viewports. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis visual task: verify the Control UI context ring opens a readable details panel, popover-body taps do not focus the composer, and Escape dismisses it on desktop and short landscape viewports.

Risk before merge

  • [P1] The stale PR base still makes GitHub display unrelated current-main overlap; final review should use the merge result or current-main two-dot diff.
  • [P1] The visible panel proof does not cover tapping or scrolling inside the popover body on touch/mobile after the focus fix.

Maintainer options:

  1. Decide the mitigation before merge
    Keep the Control UI details panel, absorb or exempt popover-body interactions from composer focus, remove the manual CHANGELOG.md line, and rerun the focused UI/i18n proof.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • The remaining blockers are narrow mechanical repairs on the PR branch, not product or ownership decisions.

Security
Cleared: The current-main unique diff does not add dependency, workflow, secret, lockfile, or production code-execution surface; no concrete security or supply-chain concern was found.

Review findings

  • [P2] Treat popover body as composer chrome — ui/src/pages/chat/components/chat-composer.ts:1336
  • [P3] Drop the release-owned changelog entry — CHANGELOG.md:29
Review details

Best possible solution:

Keep the Control UI details panel, absorb or exempt popover-body interactions from composer focus, remove the manual CHANGELOG.md line, and rerun the focused UI/i18n proof.

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

Yes for the blocking interaction bug from source: clicks inside the static popover body bubble to the composer focus handler and do not match the interactive guard. I did not run a live touch/mobile repro in this read-only review.

Is this the best way to solve the issue?

No as currently implemented. The details panel is the right UI owner boundary, but it needs the popover-body focus fix and release-owned changelog cleanup before it is the best merge shape.

Full review comments:

  • [P2] Treat popover body as composer chrome — ui/src/pages/chat/components/chat-composer.ts:1336
    The popover is rendered as a static <section> inside .agent-chat__input, whose click handler focuses the textarea unless the target matches COMPOSER_CHROME_INTERACTIVE_SELECTOR. Tapping or scrolling the readout body can focus the composer and bring the keyboard over the sheet; stop propagation on the popover body or make the whole open details surface count as composer chrome.
    Confidence: 0.89
  • [P3] Drop the release-owned changelog entry — CHANGELOG.md:29
    CHANGELOG.md is owned by release generation, and this PR already carries the release-note context in its body. Keeping this manual entry creates release churn, so remove it and leave the context for the PR body or squash message.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.87

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 601b80c5f4c1.

Label changes

Label justifications:

  • P2: This is a normal-priority user-facing Control UI feature PR with a concrete interaction blocker before merge.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (screenshot): The inspected screenshots directly show the after-fix visible panel on desktop and short landscape, with PR comments also listing live Chrome and Testbox proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The inspected screenshots directly show the after-fix visible panel on desktop and short landscape, with PR comments also listing live Chrome and Testbox proof.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The inspected screenshots directly show the after-fix visible panel on desktop and short landscape, with PR comments also listing live Chrome and Testbox proof.
Evidence reviewed

Acceptance criteria:

  • [P1] pnpm test ui/src/pages/chat/chat-composer.test.ts.
  • [P1] pnpm test ui/src/e2e/chat-flow.e2e.test.ts.
  • [P1] pnpm ui:i18n:check.
  • [P1] pnpm ui:build.
  • [P1] git diff --check.

What I checked:

Likely related people:

  • Vincent Koc: Git blame on current main attributes the existing context-ring view model, styling, chat details selector, and composer focus guard to 53bd4dd. (role: current-main feature introducer; confidence: medium; commits: 53bd4dde6c00; files: ui/src/pages/chat/components/chat-composer.ts, ui/src/styles/chat/layout.css, ui/src/pages/chat/chat-page.ts)
  • steipete: Recent merged PR history shows work on the same Control UI composer surface in e7808db, and this branch builds on that area. (role: recent area contributor; confidence: high; commits: e7808dbe6003, 56ee340a279b; files: ui/src/pages/chat/components/chat-composer.ts, ui/src/styles/chat/layout.css)
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 (4 earlier review cycles)
  • reviewed 2026-07-05T10:14:21.356Z sha 56ee340 :: found issues before merge. :: [P2] Regenerate the new locale strings before merge
  • reviewed 2026-07-05T10:39:09.734Z sha ceb90c6 :: needs changes before merge. :: [P2] Stop popover clicks from focusing the composer | [P3] Drop the release-owned changelog entry
  • reviewed 2026-07-05T11:14:38.218Z sha 3918e48 :: needs changes before merge. :: [P2] Treat popover clicks as composer chrome | [P3] Drop the release-owned changelog entry
  • reviewed 2026-07-05T11:29:05.102Z sha 44b94b8 :: needs changes before merge. :: [P2] Treat popover body as composer chrome | [P3] Drop the release-owned changelog entry

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 5, 2026
@steipete

steipete commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the i18n finding in 6cfae71: all five chat.composer.contextUsage.* labels now have generated translations and translation-memory entries for every supported locale, and every locale metadata file reports zero fallbackKeys.

Fresh exact-head proof on Blacksmith Testbox tbx_01kwrrh4nm6b1857st4y4s1cx2:

  • pnpm ui:i18n:check — 20/20 locales clean, zero fallbacks
  • pnpm test test/scripts/control-ui-i18n.test.ts — 7/7 passed
  • pnpm ui:build — passed
  • Fresh autoreview — clean, no accepted/actionable findings

The prior desktop and short-landscape Chrome proof remains attached in #100264 (comment). Exact-head hosted CI is running now.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6cfae7195a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

</svg>
<span class="context-ring__pct">${model.pct}%</span>
</summary>
<section class="context-usage__popover" aria-label=${t("chat.composer.contextUsage.title")}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Stop popover clicks from focusing the composer

When the context sheet is open, tapping or trying to scroll inside this non-interactive <section> bubbles to the .agent-chat__input click-to-focus handler, and none of the popover's static div/dl content matches COMPOSER_CHROME_INTERACTIVE_SELECTOR. On touch/mobile this can focus the textarea and bring up the keyboard over the very sheet the user is trying to read, so the popover should absorb clicks/pointer events or be treated as interactive by the composer chrome handler.

Useful? React with 👍 / 👎.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: android App: android gateway Gateway runtime agents Agent runtime and tooling size: XL and removed size: L labels Jul 5, 2026
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Jul 5, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ceb90c64cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return;
}
selectedDecision = decision;
allowDecisionArmed = decision !== "deny";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Require confirmation after selecting allow decisions

When an approval offers both deny and an allow choice, the selector starts on Deny, and moving the highlight to allow-once/allow-always triggers onSelectionChange; this line sets allowDecisionArmed before the user has seen or acknowledged the confirmation text, so the very first Enter on the allow option resolves the approval. The two-Enter guard still works for allow-only prompts, but it is bypassed for the common allow/deny approval prompts, including the default decision set.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 5, 2026
@clawsweeper

clawsweeper Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@steipete
steipete force-pushed the codex/context-usage-popover branch from b1a41a9 to e0bbe17 Compare July 5, 2026 13:04
@openclaw-barnacle openclaw-barnacle Bot removed docs Improvements or additions to documentation channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web app: android App: android gateway Gateway runtime cli CLI command changes commands Command implementations docker Docker and sandbox tooling agents Agent runtime and tooling channel: qqbot extensions: qa-lab extensions: codex extensions: copilot labels Jul 5, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e0bbe17ac2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread CHANGELOG.md

### Changes

- **Control UI context usage:** show context-window progress, latest-run input/output tokens, and the active model when the chat context ring is opened.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Remove this normal PR entry from CHANGELOG

This feature commit adds a manual release note to CHANGELOG.md, but the repo guide says CHANGELOG.md is release-only and normal PRs/direct fixes should carry release-note context in the PR body or squash message instead. This is also inserted into the versioned 2026.7.1 section rather than Unreleased, so merging it rewrites a finalized release section and can make generated release notes duplicate or misattribute this change.

Useful? React with 👍 / 👎.

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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant