Repository navigation
refactor(ui): share segmented control rendering - #140699
Conversation
|
🦞👀 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 maintainer review before merge. Reviewed September 7, 2026, 2:25 PM ET / 18:25 UTC. ClawSweeper reviewWhat this changesShares segmented selector rendering and styling across Settings, Usage, Config, Activity, and Chat while preserving their existing button and radio interactions. Merge readiness✅ Ready for maintainer review The prior selected-background finding is resolved, and no additional blocking defect was found. This maintainer-requested consolidation remains distinct from current main and is ready for the normal landing gates. Priority: P3 Review scores
Verification
How this fits togetherControl UI selectors receive page options, selected values, and callbacks. The shared renderer displays those choices and forwards user selections to the existing page handlers. flowchart LR
A[Page options and selected value] --> B[Shared selector renderer]
B --> C{Control mode}
C --> D[Settings radios]
C --> E[Native buttons]
F[Shared visual styles] --> D
F --> E
D --> G[Existing page callbacks]
E --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +58, Tests +137. Total +195 across 16 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep one selector rendering and styling owner while retaining the established radio, native-button, disabled, and focus contracts. Do we have a high-confidence way to reproduce the issue? Not applicable to the refactor itself. The earlier light-theme defect has a focused browser regression and a source-level repair; this review did not execute it. Is this the best way to solve the issue? Yes. Extending the existing shared renderer removes competing page implementations while preserving their distinct contracts, and the maintainer has accepted the documented size tradeoff. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fae6778b125c. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
Preserve radio and native-button keyboard and callback contracts, per-option gates, same-value activation, and exact visual variants. Proposed buttons mode adds 53 production lines; keep as draft for maintainer decision. Proof: node scripts/run-vitest.mjs ui/src/pages/chat/components/chat-context-window-control.test.ts ui/src/pages/config/view.browser.test.ts ui/src/pages/usage ui/src/pages/activity (318 cases); 29 mocked E2E cases, exact computed-style parity, UI build/performance, and Codex autoreview pass.
Keep the shared segmented selection visible over generic light-theme button backgrounds at rest and on hover. Preserve the existing light-theme border color. Proof: 31 mocked Gateway e2e cases pass, including a light-theme regression that failed before the repair. Codex autoreview is clean through P2.
73540fb to
f27f00b
Compare
|
Merged via squash.
|
* refactor(ui): share segmented control rendering Preserve radio and native-button keyboard and callback contracts, per-option gates, same-value activation, and exact visual variants. Proposed buttons mode adds 53 production lines; keep as draft for maintainer decision. Proof: node scripts/run-vitest.mjs ui/src/pages/chat/components/chat-context-window-control.test.ts ui/src/pages/config/view.browser.test.ts ui/src/pages/usage ui/src/pages/activity (318 cases); 29 mocked E2E cases, exact computed-style parity, UI build/performance, and Codex autoreview pass. * fix(ui): preserve selected usage accents in light mode Keep the shared segmented selection visible over generic light-theme button backgrounds at rest and on hover. Preserve the existing light-theme border color. Proof: 31 mocked Gateway e2e cases pass, including a light-theme regression that failed before the repair. Codex autoreview is clean through P2.
Maintainer decision
Landed by maintainer decision: one owner for segmented controls outweighs the +53 production lines.
This refactor preserves the existing interactions by adding an explicit
buttonsmode torenderSettingsSegmented. Existing Settings callers keep Web Awesome radios; Usage, Config, Activity, and the multi-option Chat context selector keep native buttons. Radio callbacks retain their element argument, while native callbacks retain their value-only contract.The maintainer accepts this additional component mode and one CSS owner despite +53 production lines (+329/-276). Preserving the distinct focus, disabled, transition, and visual contracts did not produce the survey's anticipated line reduction. Standardizing the interactions is outside this proposal. No user configuration option is added. The maintainer has authorized landing after validation.
What Problem This Solves
Exclusive-value selectors repeat page-local rendering and styling across Usage, Config, Activity, and Chat, despite an existing shared Settings control. This maintainer-requested proposal centralizes their owner while retaining current behavior.
Why This Change Was Made
The shared renderer handles per-option disabling, current-value activation, compact labels, and event containment.
settings-controls.cssowns the neutral, accent, primary, and compact treatments; the corresponding page-specific chrome is removed. The Usage Reset button remains an ordinary action, and Chat's binary context switch remains unchanged.User Impact
No intended appearance, keyboard, selection, callback, or focus change. No public SDK export, wire format, persisted data, dependency, or user configuration change.
Evidence
Closeout validation on the rebased candidate:
falserestores the prior value).rgb(250, 249, 247)instead of the expected accent fill, and passes after it. Cost and Tokens remain selected at rest and on hover in both themes. The fix adds five production lines; final production delta is +58.pnpm buildpassed in 9m 36.6s. Finalpnpm ui:check-performancepassed: startup JavaScript 350757 B gzip in 8 requests, below the unchanged 350953 B enforcement limit (350377 B baseline plus its existing allowances); startup CSS 44972 B gzip. No baseline was edited.node scripts/check-changed.mjspassed, including typechecks, all three dead-export scans, and lint. Exact-head hosted CI is green forf27f00bf04e0a83c0b68f7b44cebcedbd1d17b3b. Native review,OPENCLAW_TESTBOX=1prepare, and merge completed. Landed as517e9935ff9f3c978ae1b3aafc4bf24f01196ec2, verified as an ancestor of freshly fetchedorigin/main. The first merge request received HTTP 405 because main moved; one investigated native recovery merged the same prepared head. No CI rerun, admin bypass, or baseline change was used.Original proposal evidence follows; the new light-theme proof supplements the earlier captures:
node scripts/run-vitest.mjs ui/src/pages/chat/components/chat-context-window-control.test.ts ui/src/pages/config/view.browser.test.ts ui/src/pages/usage ui/src/pages/activity.node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runneronconfig-controls-visual,usage-cost-analysis,activity-session-refresh, andchat-flow.models-reasoningE2E files, including the existing forced-colors proof.pnpm ui:build, andpnpm ui:check-performancepass. Startup JS is 346199 B gzip in 8 requests, below the untouched 350377 B baseline. Startup CSS is 44279 B gzip.git diff --checkpasses.node scripts/check-changed.mjspasses, including both typecheck lanes, dead-export scans, and style checks. This original local proof predates closeout; completed full-build and native hosted-gate validation is recorded above.An initial focused run reported three Activity session-snapshot teardown errors after its 252 assertions passed. Subsequent complete runs had no teardown errors; no loader, timeout, or mock relaxation was made. An existing Config browser assertion also caught callback arity during implementation; the native callback contract was corrected instead of weakening the assertion.
Visual proof covers 16 surfaces and 37 options/actions: zero differences across 5500 computed-style values, 500 geometry values, 375 pseudo-element values, and 1298 semantic/state values. Ten of fourteen screenshot pairs are pixel-identical; the other four contain 46 differing edge pixels total (maximum channel delta 5), without a measured style or geometry difference. The comparison records those differences rather than masking them.
All 28 full captures were inspected and contain only synthetic fixtures (Synthetic Viewer, fabricated usage/config data, and public GPT-5.5). The browser and Gateway are isolated mocks. The screenshot comparisons cover normal colors; forced colors additionally use the existing E2E test and source review.
Light-theme selected Usage regression proof
Fresh captures use an isolated mocked Gateway, empty synthetic Usage data, and no real account or session data. All nine new captures were inspected. The first image shows the defect before repair; the following images show the restored Cost selection at rest and on hover.