Repository navigation
feat(ui): compact context from the composer usage popover - #188242
Conversation
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
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. What this changesThis 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.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete 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 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 063e5c23fe9e. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +99, Tests +195, Other -7. Total +287 across 16 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 30, 2026, 6:30 AM ET / 10:30 UTC. |
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
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:
mainaria-busyThe popover deliberately stays open after the click: the budget bar, percentage and button emphasis above are where the result shows up.
Notes
chat.sessionDetails.contextCompact*keys tochat.composer.contextUsage.compact*, which the popover already loads eagerly, so the label can never render before its catalog. The unusedcontextCompact("Compact session") key goes with them. Foreign locales pick up the new keys through the locale refresh workflow.main), now scoped to the panel; its header renders pixel-identical before and after.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).Evidence
Before → after: 95% fresh usage, dark theme, 1280px. Real Control UI build with a mocked Gateway; synthetic session data.
Other states (after)
Context panel header with the shared control (pixel-identical to before):
session-context-breakdown.e2e.test.ts, mocked Gateway, built UI): new scenario opens the popover at 95%, clicks Compact, asserts thesessions.compactrequest, 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.check:changedon 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 onmain(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).check-control-ui-performance-baseagainst68fbe4ac: 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).main.68fbe4ac→4c165d51, the full branch including the styling and budget commits, P0–P2): no findings.Worked on by
Work sessions