Skip to content

feat(ui): compact context from the composer usage popover - #188242

Merged
roboclaw-bot merged 6 commits into
mainfrom
openclaw/composer-context-compact-button
Oct 30, 2026
Merged

roboclaw-bot merged 6 commits into
mainfrom
openclaw/composer-context-compact-button

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

The prompt-budget popover beside the composer showed how full the context was but had no way to act on it: compacting meant opening View context and finding the button in the side panel.

User Impact

User impact: the context-usage popover now has a secondary Compact button on its View context row, vertically centered with the link. It stays outlined at every usage level (the context ring already signals the warning), explains why it is unavailable while a run is active, shows progress while compacting, and keeps the popover open so the budget updates in place when the Gateway reports the compacted session.

Why This Change Was Made

The side panel's Compact button becomes one shared control used by both surfaces, so they share one request owner, labels and disabled states instead of two copies. The control also reads the pane's existing compaction status, so a compaction started by the runtime or from the other surface shows as in progress in both places.

How it behaves in each popover state:

State Compact
Viewer cannot compact (no admin scope, catalog session, participation blocked, disconnected) hidden; the row is pixel-identical to main
Normal usage outlined secondary
Fresh usage at or above 85% outlined secondary; the ring stays the warning cue
Approximate (stale) totals outlined secondary
Run active disabled, title "Available when the current run finishes."
Compacting (this request or a pane-tracked compaction) spinner + "Compacting", disabled, aria-busy
Narrow/mobile widths, light/dark, plan-billed sessions same row, above the separator and any quota tray

The popover deliberately stays open after the click: the budget bar, percentage and button emphasis above are where the result shows up.

Notes
  • Copy moved from the lazily loaded chat.sessionDetails.contextCompact* keys to chat.composer.contextUsage.compact*, which the popover already loads eagerly, so the label can never render before its catalog. The unused contextCompact ("Compact session") key goes with them. Foreign locales pick up the new keys through the locale refresh workflow.
  • Shared outlined button styles move to the boot chat stylesheet. The side panel keeps its sizing and its existing filled warning style (it does render filled at 95% on main), now scoped to the panel; its header renders pixel-identical before and after.
  • In the popover the outline is lifted 1px (margin-top: -2px; padding-top: 2px) so it centers on the line it shares with View context: both labels share one baseline and the button box centers on the label (measured in Chromium, asserted in the browser test).
  • The popover row was already 26px tall, so adding the button causes no layout shift.

Evidence

Before → after: 95% fresh usage, dark theme, 1280px. Real Control UI build with a mocked Gateway; synthetic session data.

Before After
Before: the popover offers only View context After: an outlined Compact centered on the View context row
Other states (after)
Normal usage (42%) Stale totals (~95%) Compacting
Outlined Compact at 42% usage Outlined Compact when totals are approximate Disabled Compacting button with spinner while the popover stays open
Light, 95% 390px dark, 95% 390px light, 42%
Light theme with outlined Compact Mobile dark popover with outlined Compact Mobile light popover with outlined Compact

Context panel header with the shared control (pixel-identical to before):

Context panel header with Compact

  • Unit (jsdom): state matrix (hidden, normal, warning, stale, run active, disconnected, pane-tracked compaction), never filled at any usage level, and one request per click while pending, popover open throughout. Existing panel test (busy until the request settles, current callback) still passes on the shared control.
  • Browser (Chromium): at 1280 and 320px with 95% usage, Compact is outlined, shares the View context label baseline, centers on it, and keeps the 26px row; a real click keeps the popover open, shows Compacting, then returns to Compact.
  • Control UI E2E (session-context-breakdown.e2e.test.ts, mocked Gateway, built UI): new scenario opens the popover at 95%, clicks Compact, asserts the sessions.compact request, the disabled Compacting state and an untouched draft, then resolves it and sees 21% while the popover stays open. The existing panel flow passes; its old assertion that the popover had no Compact button was updated.
  • Gates: check:changed on the commit: format, lint (core, UI styles, scripts, test root), tsgo (UI, scripts, core tests, test root), Control UI i18n verify and controller guard pass on the latest commit. On the first commit the dead-export scan failed only on pre-existing unused exports that no changed file referenced on main (reply-tool-authority-inbound.ts, artifact-download-grants.ts, session-html-preview.ts, session-progress-card.ts, participant-colors.ts, motion/spring.ts, chat-composer-width-ref.tsx).
  • CSS budget: check-control-ui-performance-base against 68fbe4ac: total CSS raw +443 B (gzip +40 B), within the fixed ceilings. The first CI run was +656 B and 163 B over; the shared Compact styles were trimmed (no transition, default spinner size, one gap value).
  • No-button parity: with a read-only viewer the popover captures pixel-identical to main.
  • Review: local autoreview (Codex, branch mode, 68fbe4ac → 4c165d51, the full branch including the styling and budget commits, P0–P2): no findings.
  • Gaps: no live Gateway/real-model compaction run (mocked Gateway E2E only). The button is 24px tall, matching the existing View context row rather than a 44px touch target.

Worked on by

Work sessions

roboclaw-bot and others added 2 commits October 30, 2026 10:04
The context-usage popover beside the composer showed the prompt budget
but sent people to the side panel to compact. Move the panel's Compact
control into one shared component and place it on the popover's
View context row, so both surfaces share one request owner, label,
emphasis and disabled states.

Co-authored-by: vyctorbrzezowski <[email protected]>
Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: c4ab4d1a-3ec0-4eba-b99b-d76777b951e8
@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui scripts Repository scripts size: M labels Oct 30, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR adds a shared Compact button to the composer usage popover and Context panel.

Example: A session has used 95,000 of 100,000 context tokens.

  • Before: The usage popover offers View context; manual compaction requires opening the panel.
  • After: The popover offers a highlighted Compact button and remains open while usage updates.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful, focused UI work with directly inspected screenshots, but two diff-related exact-head checks remain broken.
Proof confidence 🐚 platinum hermit (4/6) This maintainer-authored PR is outside the ordinary contributor proof gate; inspected built-UI screenshots establish the visible change, while click, busy-state and result-update evidence uses the mocked Gateway.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Users inspecting context pressure must open a separate panel to compact their session.
Reason: The maintainer-authored direction makes an existing action easier to reach while sharing its control and retaining current access policy.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep open: this maintainer-authored feature reuses the existing compaction path, but the added mobile browser scenario and CSS asset budget fail on the reviewed head.

Priority: P3
Reviewed head: 3a28f26a2b0dc0149f9228cd2af49afde186617e

Before merge

  • Repair the added 320px browser scenario (P2) - On the reviewed head, the newly added Chromium case at 320px times out here because isPainted(open) && isPainted(compact) remains false. This fails checks-ui (3/3) before the click, busy-state and settlement assertions execute. Repair the fixture or the underlying geometry based on the failing capture, preserving the narrow-width visibility contract; the available annotation does not establish which control is obscured.
  • Keep the shared Compact styles within the CSS asset budget (P2) - The added shared styles and action row push the reviewed build past the enforced total raw CSS budget: control-ui-performance reports 1560.5 KiB against 1560.2 KiB. Its base-comparison checker already accommodates an over-budget base, so this is rejected growth from the candidate rather than an inherited failure. Consolidate or reduce the added rules while retaining both surfaces' appearance instead of raising the budget.

Findings

  • [P2] Repair the added 320px browser scenario — ui/src/pages/chat/chat-composer-context.browser.test.ts:177
  • [P2] Keep the shared Compact styles within the CSS asset budget — ui/src/styles/chat/layout.css:1052-1060

Tests

  • Missing end-to-end proof: The supplied interaction flow uses a mocked Gateway; no live Gateway/model compaction run is recorded.
Agent review details

How this fits together

The Control UI projects session usage and pane lifecycle state into the composer; Compact invokes the existing session-action callback and /compact command, which sends sessions.compact through the session owner.

flowchart LR
  A[Session usage and lifecycle] --> B[Composer popover]
  A --> C[Context panel]
  B --> D[Shared Compact control]
  C --> D
  D --> E[Pane session action]
  E --> F[Existing compact command]
  F --> G[Gateway session owner]
Loading

Technical review

Best possible solution:

Keep the shared control and existing mutation owner, repair the mobile scenario, and reduce the added CSS enough to pass the existing asset budget.

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

The missing popover action is confirmed in current main and the before screenshot; this is an intentional feature addition rather than a reproduced upstream bug.

Is this the best way to solve the issue?

Extracting the panel control for two consumers is a focused implementation that preserves the existing request and authorization owners.

Full review comments:

  • [P2] Repair the added 320px browser scenario — ui/src/pages/chat/chat-composer-context.browser.test.ts:177
    On the reviewed head, the newly added Chromium case at 320px times out here because isPainted(open) && isPainted(compact) remains false. This fails checks-ui (3/3) before the click, busy-state and settlement assertions execute. Repair the fixture or the underlying geometry based on the failing capture, preserving the narrow-width visibility contract; the available annotation does not establish which control is obscured.
    Confidence: 0.98
  • [P2] Keep the shared Compact styles within the CSS asset budget — ui/src/styles/chat/layout.css:1052-1060
    The added shared styles and action row push the reviewed build past the enforced total raw CSS budget: control-ui-performance reports 1560.5 KiB against 1560.2 KiB. Its base-comparison checker already accommodates an over-budget base, so this is rejected growth from the candidate rather than an inherited failure. Consolidate or reduce the added rules while retaining both surfaces' appearance instead of raising the budget.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 063e5c23fe9e.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm --dir ui test src/pages/chat/chat-composer-context.browser.test.ts
  • pnpm --dir ui test src/pages/chat/chat-composer-context.test.ts src/pages/chat/components/chat-details-session.test.ts
  • pnpm ui:check-performance:base
  • pnpm check:changed

What I checked:

PR surface

Source +99, Tests +195, Other -7. Total +287 across 16 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 10 172 73 +99
Tests 5 207 12 +195
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 8 -7
Total 16 380 93 +287

Labels

Label changes:

  • add P3: This is a convenience improvement to an existing manual compaction workflow.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P3: This is a convenience improvement to an existing manual compaction workflow.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish.
  • 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.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 30, 2026, 6:30 AM ET / 10:30 UTC.

roboclaw-bot and others added 4 commits October 30, 2026 13:38
The composer popover's Compact stays outlined at every usage level; the
context ring already carries the warning. The side panel keeps its own
filled warning treatment, now scoped to the panel. In the popover the
outline is lifted 1px so it centers on the line it shares with
View context while both labels keep one baseline.

Co-authored-by: vyctorbrzezowski <[email protected]>
Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: e94d8122-5fa2-4e93-baf9-9a853184ec8e
Trim the shared Compact styles (no transition, default spinner size, one
gap value) so total Control UI CSS stays under its fixed raw ceiling.
The browser layout test now registers the View context label it
measures; it had measured the raw i18n key, which overflowed the 320px
popover with wider fallback fonts. Centering allows WebKit's whole-pixel
text boxes.

Co-authored-by: vyctorbrzezowski <[email protected]>
Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: bf45dd1a-a5b8-43da-9033-a33ee4577904
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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: M 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