Skip to content

fix(ui): preserve modal keyboard ownership across shadow roots - #129747

Merged
steipete merged 1 commit into
mainfrom
codex/control-ui-qa-modal-layer-ownership
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/control-ui-qa-modal-layer-ownership

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • Keep Settings open when Escape dismisses a destructive confirmation rendered inside Web Awesome shadow roots.
  • Prevent background chat composers from stealing keyboard focus while either a shadow-root modal or existing light-DOM confirmation is active.
  • Promote the existing modal lifecycle registry into the shared authoritative owner for Settings, chat, and toast stacking; delete the obsolete shadow-blind selector.

Root cause

The native <dialog> used by openclaw-modal-dialog lives two shadow roots below the document. Both Settings Escape handling and chat auto-typing checked document.querySelector('dialog[open]'), which cannot cross those boundaries. Consequently pressing Escape on a nested WhatsApp logout confirmation navigated from /settings/channels to /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:

Before: nested channel confirmation with shadow-root modal ownership bug

After

Escape dismisses only the confirmation while preserving the WhatsApp detail dialog, selected Settings route, QR draft, and unexecuted logout action:

After: Escape keeps the active Settings modal and prevents unintended logout

Verification

  • Pre-fix Settings owner regression fails because Escape is wrongly prevented and navigation is invoked.
  • Pre-fix chat owner regression fails because the background composer steals modal typing focus.
  • Pre-fix Chromium regression independently fails with actual pathname /chat/main instead of /settings/channels.
  • An additional light-DOM confirmation regression failed against the initial registry-only draft and now passes, preventing a sibling regression.
  • 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.
  • Fresh independent Codex review: clean.

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.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Aug 26, 2026
@steipete
steipete marked this pull request as ready for review August 26, 2026 01:42
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 10:05 PM ET / August 26, 2026, 02:05 UTC.

ClawSweeper review

What this changes

The 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 provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep 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
Reviewed head: 6558311b1cf570b6fd55bdbe8ca7a4d217aff4cc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has a coherent lifecycle owner and targeted sibling coverage, with final confidence awaiting current-base refresh and exact-head CI.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This is a maintainer-authored PR; its body nevertheless supplies before/after UI screenshots and an after-fix Chromium scenario command.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored PR; its body nevertheless supplies before/after UI screenshots and an after-fix Chromium scenario command.
Evidence reviewed 5 items Shared owner boundary: The modal component owns lifecycle membership, adding itself when open and removing itself on close or disconnect; Settings and chat consume that shared fact instead of querying into shadow roots.
Sibling behavior retained: Chat still blocks auto-focus for existing light-DOM aria-modal overlays, while toast placement uses the renamed shared registry.
Regression coverage: Focused tests cover registry cleanup, shadow-root Settings Escape, shadow-root chat typing, light-DOM modal typing, and the Chromium WhatsApp logout route preservation scenario.
Findings None None.
Security None None.

Live Verification

Command: 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

Result: FAIL (failed) — step 1 run 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: previous terminal command was still running after 30 seconds: "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"

RUN  v4.1.10 /tmp/clawsweeper-live-proof-129747-6ed1Ej/target

 ❯  ui-e2e  ui/src/e2e/channels-whatsapp-logout.e2e.test.ts (4 tests | 1 failed) 15688ms
     × shows rejected channel configuration saves in the open editor without losing the draft 1409ms
     ✓ confirms the explicit default account and preserves a no-op logout  4202ms
     ✓ rejects a captured custom-account logout after the Gateway reconnects  2404ms
     ✓ preserves standard channel details and the complete Telegram setup wizard  3430ms

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯

 FAIL   ui-e2e  ui/src/e2e/channels-whatsapp-logout.e2e.test.ts › Control UI WhatsApp logout mocked Gateway E2E › shows rejected channel configuration saves in
the open editor without losing the draft
Error: browserContext.newPage: Executable doesn't exist at /tmp/clawsweeper-live-proof-129747-6ed1Ej/profile/cache/ms-playwright/ffmpeg-1011/ffmpeg-linux
╔═════════════════════════════════════════════════════════════════╗
║ Video rendering requires ffmpeg binary.                         ║
║ Downloading it will not affect any of the system-wide settings. ║
║ Please run the following command:                               ║
║                                                                 ║
║     npx playwright install ffmpeg                               ║
║                                                                 ║
║ ‹3 Playwright Team                                              ║
╚═════════════════════════════════════════════════════════════════╝
 ❯ Object.withPage ui/src/e2e/control-ui-e2e-suite.test-support.ts:130:36
    128|       const context = await newBrowserContext(contextOptions);
    129|       try {
    130|         const page = await context.newPage();
       |                                    ^
    131|         return await run({ context, page });
    132|       } finally {
 ❯ ui/src/e2e/channels-whatsapp-logout.e2e.test.ts:29:5

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯


 Test Files  1 failed (1)
      Tests  1 failed | 3 passed (4)
   Start at  02:06:05
   Duration  26.60s (transform 115ms, setup 134ms, import 371ms, tests 15.69s, environment 0ms)


::error file=/tmp/clawsweeper-live-proof-129747-6ed1Ej/target/ui/src/e2e/control-ui-e2e-suite.test-support.ts,title=[ui-e2e] ui/src/e2e/channels-whatsapp-logout
.e2e.test.ts › Control UI WhatsApp logout mocked Gateway E2E › shows rejected channel configuration saves in the open editor without losing the draft,line=130,c
olumn=36::Error: browserContext.newPage: Executable doesn't exist at /tmp/clawsweeper-live-proof-129747-6ed1Ej/profile/cache/ms-playwright/ffmpeg-1011/ffmpeg-li
nux%0A╔═════════════════════════════════════════════════════════════════╗%0A║ Video rendering requires ffmpeg binary.                         ║%0A║ Downloading
it will not affect any of the system-wide settings. ║%0A║ Please run the following command:                               ║%0A║
                                ║%0A║     npx playwright install ffmpeg                               ║%0A║
            ║%0A║ ‹3 Playwright Team                                              ║%0A╚═════════════════════════════════════════════════════════════════╝%0A ❯ O
bject.withPage ui/src/e2e/control-ui-e2e-suite.test-support.ts:130:36%0A ❯ ui/src/e2e/channels-whatsapp-logout.e2e.test.ts:29:5%0A%0A⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
⎯⎯⎯%0ASerialized Error: { log: [] }%0A
[vitest] FAILED (exit 1)
[test] FAILED (exit 1)

Assertions:

  • FAIL expect_output: channels-whatsapp-logout

How this fits together

Control 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]
Loading

Before merge

  • Resolve merge risk (P1) - Current-main comparison could not be completed from this partial clone, and the branch is behind its base with required checks still in progress; rebase and exact-head validation are needed before landing.
  • Complete next step (P2) - The protected maintainer label, unavailable current-main comparison, and incomplete exact-head CI make this a maintainer landing review rather than an automated repair candidate.
Agent review details

Security

None.

PR surface

Source -3, Tests +121, Other 0. Total +118 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 5 11 14 -3
Tests 6 125 4 +121
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 12 137 19 +118

Review metrics

Metric Value Why it matters
Production versus test delta production -3, tests +122 The behavior repair removes more production code than it adds while placing most change volume in focused UI and QA regression coverage.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Rebase onto current main, confirm the modal, chat, toast, QA-fixture, and release-declaration paths remain coherent, then land with exact-head CI green.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best 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.

Labels

Label changes:

  • add P2: This repairs a bounded Control UI interaction regression without evidence of data loss, security exposure, or core-runtime unavailability.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. This is a maintainer-authored PR; its body nevertheless supplies before/after UI screenshots and an after-fix Chromium scenario command.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-authored PR; its body nevertheless supplies before/after UI screenshots and an after-fix Chromium scenario command.

Label justifications:

  • P2: This repairs a bounded Control UI interaction regression without evidence of data loss, security exposure, or core-runtime unavailability.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-authored PR; its body nevertheless supplies before/after UI screenshots and an after-fix Chromium scenario command.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. This is a maintainer-authored PR; its body nevertheless supplies before/after UI screenshots and an after-fix Chromium scenario command.

Evidence

What I checked:

  • Shared owner boundary: The modal component owns lifecycle membership, adding itself when open and removing itself on close or disconnect; Settings and chat consume that shared fact instead of querying into shadow roots. (ui/src/components/modal-dialog.ts:8, 6558311b1cf5)
  • Sibling behavior retained: Chat still blocks auto-focus for existing light-DOM aria-modal overlays, while toast placement uses the renamed shared registry. (ui/src/pages/chat/chat-pane-lifecycle.ts:353, 6558311b1cf5)
  • Regression coverage: Focused tests cover registry cleanup, shadow-root Settings Escape, shadow-root chat typing, light-DOM modal typing, and the Chromium WhatsApp logout route preservation scenario. (ui/src/e2e/channels-whatsapp-logout.e2e.test.ts:207, 6558311b1cf5)
  • Area provenance: Recent history and blame place the current modal and keyboard-owner changes with Peter Steinberger; broader recent Control UI maintenance is also concentrated there. (ui/src/components/modal-dialog.ts:8, 6558311b1cf5)
  • Current-main inspection gap: The partial checkout could read the PR head but could not retrieve current-main/base objects because its promisor remote failed DNS resolution; no current-main implementation or release conclusion is asserted.

Likely related people:

  • steipete: Current-line blame and recent Control UI history attribute the modal/keyboard-owner surface to Peter Steinberger. (role: recent area contributor; confidence: high; commits: 6558311b1cf5, e879376f18c7, 8fe2c1b83ca2; files: ui/src/components/modal-dialog.ts, ui/src/app/app-shell-chrome.ts, ui/src/pages/chat/chat-pane-lifecycle.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase onto current main and confirm the exact head receives green UI and repository checks.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

@steipete
steipete force-pushed the codex/control-ui-qa-modal-layer-ownership branch from 6558311 to fdaa51c Compare August 26, 2026 02:25
@openclaw-barnacle openclaw-barnacle Bot removed scripts Repository scripts extensions: qa-lab labels Aug 26, 2026
@steipete
steipete merged commit 72adefb into main Aug 26, 2026
111 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant