Repository navigation
fix(ui): preserve modal keyboard ownership across shadow roots - #129747
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 10:05 PM ET / August 26, 2026, 02:05 UTC. ClawSweeper reviewWhat this changesThe PR tracks active Control UI modal components centrally so Settings Escape handling and chat typing do not act behind shadow-root dialogs, while retaining light-DOM modal protection. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open for maintainer review. The shared modal registry is a coherent owner-boundary repair and the branch includes focused regression coverage, but the checkout could not retrieve current-main objects and exact-head CI is still running. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherControl UI settings and chat keyboard handlers receive document-level events, while Web Awesome dialogs render their native dialogs inside shadow roots. The modal component publishes whether it is open; Settings, chat focus routing, and toast stacking consume that state. flowchart LR
A[Keyboard event] --> B[Settings or chat handler]
C[Modal component] --> D[Active modal registry]
D --> B
B --> E[Modal keeps ownership]
E --> F[Settings route or chat composer]
D --> G[Toast stacking]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -3, Tests +121, Other 0. Total +118 across 12 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Rebase onto current main, confirm the modal, chat, toast, QA-fixture, and release-declaration paths remain coherent, then land with exact-head CI green. Do we have a high-confidence way to reproduce the issue? Yes, at source level: the focused tests construct a shadow-root modal and exercise the Settings and chat keyboard handlers; the PR body also specifies a Chromium WhatsApp logout route scenario, though it was not runnable in this read-only review. Is this the best way to solve the issue? Yes, based on the reviewed branch: the modal component is the lifecycle owner and its registry replaces a document selector that cannot cross its shadow roots, while the light-DOM sibling path remains explicit. AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against c841a9958abc. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
6558311 to
fdaa51c
Compare
|
Merged via squash.
|
Summary
Root cause
The native
<dialog>used byopenclaw-modal-dialoglives two shadow roots below the document. Both Settings Escape handling and chat auto-typing checkeddocument.querySelector('dialog[open]'), which cannot cross those boundaries. Consequently pressing Escape on a nested WhatsApp logout confirmation navigated from/settings/channelsto/chat/main, while ordinary keystrokes inside confirmations focused the underlying chat composer.The modal component already maintained an authoritative lifecycle registry for toast stacking. This refactor generalizes that existing registry, publishes membership on open/close/disconnect, and consumes the same fact in Settings and chat. Existing light-DOM
[aria-modal='true']popovers retain their own documented focus protection, and DOM-free toast imports remain unchanged. Production code is net negative.Before
Pressing Escape on the nested logout confirmation incorrectly exits Settings entirely; focused owner tests prove chat also steals typing focus:
After
Escape dismisses only the confirmation while preserving the WhatsApp detail dialog, selected Settings route, QR draft, and unexecuted logout action:
Verification
/chat/maininstead of/settings/channels.node scripts/run-vitest.mjs ui/src/app/app-host-native-shell.test.ts ui/src/components/modal-dialog.test.ts ui/src/lib/toast.test.ts— 49 tests pass, covering owner membership, reconnect/disconnect cleanup, Settings Escape, and nested toast layering.node scripts/run-vitest.mjs ui/src/pages/chat/chat-pane.test.ts— 36 tests pass, including both shadow-root and light-DOM keyboard ownership.OPENCLAW_CAPTURE_UI_PROOF=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/channels-whatsapp-logout.e2e.test.ts— all four real Chromium scenarios pass.OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1 pnpm check:changed— shared core-test/UI typechecks, formatting, lint, i18n, and architecture gates pass.Risk
Low: modal lifecycle/presentation only; no approval authorization, destructive action, configuration, persistence, or Gateway protocol changes. Existing navigation-drawer precedence, approval-overlay guards, light-DOM confirmations, toast stacking, and DOM-free toast loading are preserved.