Skip to content

fix(ui): stop modal autofocus steal after the open animation - #115168

Merged
steipete merged 2 commits into
mainfrom
steipete/mystifying-sammet-581cb2
Jul 28, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/mystifying-sammet-581cb2

Conversation

@steipete

@steipete steipete commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The checks-ui-e2e lane flaked repeatedly on 2026-07-28 (runs 30351573136, 30358455220 attempts 1-4), each time failing exactly one of 104 files, a different test each attempt. Two distinct causes:

  1. Modal autofocus steal (product bug). workboard-status-persistence.e2e.test.ts failed with the Notes text typed into the Title field (title: "Persisted renamed cardEdited notes survive reopening.", notes: "Original notes"). workboard.e2e.test.ts fills the same Edit-card dialog and has flaked identically on other runs.
  2. 1-second expect.poll deadline. Vitest's expect.poll defaults to a 1s timeout; the lane's ~70 polls await real Chromium renders. On loaded runners a route change or list update regularly stalls past 1s, producing rolling one-off failures (external-session-catalogs, new-session-page.workspace-memory, session-management.archive, sidebar-customization — all "Matcher did not succeed in time").

Why This Change Was Made

Modal fix: openclaw-modal-dialog focused the slotted [autofocus] target twice — once from the scheduled wa-show hook and again on wa-after-show, which fires only after the open animation completes. If focus had already moved to another field inside the dialog (user click, autofill, or Playwright fill, which focuses + selects in page context and then delivers text through the browser input pipeline), the late refocus stole focus mid-fill and the text landed in the autofocus input at its caret — exactly the concatenation the CI diff shows. handleAfterShow now skips the refocus when document.activeElement is already a slotted descendant (excluding the host itself, which is what activeElement reports while native dialog chrome holds focus). Fixes every dialog consumer at the owner boundary instead of patching individual tests with waits.

Poll budget: the ui-e2e project config now sets expect: { poll: { interval: 100, timeout: 15_000 } }. Correctness in these tests is the eventual UI state, so a larger deadline only trades failure latency for stability — genuine regressions still fail, 14 seconds later. This mirrors Playwright's own auto-wait budgets (its locator waits in the same suite already use 10-30s).

User Impact

Users who click or tab into another field while a dialog's open animation is still settling no longer lose focus (and keystrokes) back to the autofocus field. CI: closes the Workboard edit-dialog corruption flake and the rolling 1s-poll timeout flake class in checks-ui-e2e.

Evidence

  • Regression test "keeps focus on a field the user selected when the show animation settles" fails on the previous code (1 failed / 8 passed) and passes with the fix (9 passed).
  • node scripts/run-vitest.mjs ui/src/components/modal-dialog.test.ts — 9 passed.
  • node scripts/run-vitest.mjs ui/src/pages/workboard/workboard-status-persistence.e2e.test.ts ui/src/pages/workboard/workboard.e2e.test.ts — 5 passed (Chromium).
  • CI-flaked poll tests pass locally: external-session-catalogs.e2e.test.ts (1 passed), new-session-page.workspace-memory.e2e.test.ts (7 passed).
  • node scripts/check-changed.mjs -- ui/src/components/modal-dialog.ts ui/src/components/modal-dialog.test.ts — 0 warnings, 0 errors (delegated Testbox).
  • Codex autoreview (gpt-5.6-sol, xhigh) on both changes: clean, no actionable findings (0.94 / 0.98).

Companion investigation: the second flake in the original report (model-catalog-visibility.test.ts 120s timeout in agentic-agents-core-models, run 30346551462 attempt 1 at 09:35 UTC) was already fixed by #115139 (merged 10:37 UTC the same day) — synthetic transport tests cold-loading the real OpenAI/Azure provider plugin pushed serial model-catalog tests over the 120s limit. No further change needed for that one.

@steipete
steipete marked this pull request as ready for review July 28, 2026 11:51
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XS maintainer Maintainer-authored PR labels Jul 28, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 28, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 28, 2026, 8:25 AM ET / 12:25 UTC.

ClawSweeper review

What this changes

The PR prevents the shared web modal component from refocusing its autofocus field after the open animation when a user has already selected another field.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

This PR appears to be a focused, correct repair for the shared modal focus race, and the contributor’s refreshed terminal trace supplies after-fix browser and component-test evidence. It remains open because the maintainer label requires an explicit maintainer merge decision rather than automated cleanup.

Priority: P2
Reviewed head: 970619425402bcbaf4aa06ab5f3a95bcf9429086

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow owner-boundary fix with a deterministic regression test and focused after-fix browser evidence; it is ready for normal maintainer review.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The contributor posted an after-fix terminal trace for the deterministic component regression and the two affected Chromium Workboard suites; redact-sensitive runtime details are not involved in this proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The contributor posted an after-fix terminal trace for the deterministic component regression and the two affected Chromium Workboard suites; redact-sensitive runtime details are not involved in this proof.
Evidence reviewed 5 items Focused implementation: At PR head 970619425402bcbaf4aa06ab5f3a95bcf9429086, the dialog’s after-show focus handler returns when the active element is an in-dialog descendant rather than the dialog host, preserving focus already moved by the user or input automation.
Regression coverage: The PR adds a focused regression test that moves focus to the notes textarea, dispatches wa-after-show, and asserts that focus remains on that textarea.
After-fix behavior proof: The contributor’s July 28, 2026 PR comment reports the new modal test passing and reruns both affected Chromium Workboard suites on the refreshed branch, including the edit/reopen persistence case that previously showed typed notes in the title field.
Findings None None.
Security None None.

How this fits together

OpenClaw’s web UI uses a shared modal wrapper around Web Awesome dialogs; Workboard and other UI surfaces place their form controls inside it. Dialog-show events select an autofocus target, and this change preserves a user’s later in-dialog focus choice after the open animation settles.

flowchart LR
  A[Modal consumer opens dialog] --> B[Shared modal wrapper]
  B --> C[Web Awesome show events]
  C --> D[Autofocus selection]
  D --> E{Focus already in dialog?}
  E -- No --> F[Focus autofocus field]
  E -- Yes --> G[Preserve selected field]
  F --> H[User edits form]
  G --> H
Loading

Before merge

  • Complete next step (P2) - No mechanical repair is identified; the remaining action is normal maintainer approval on the current head because the PR carries the protected maintainer label.
Agent review details

Security

None.

PR surface

Source +8, Tests +17. Total +25 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 8 0 +8
Tests 1 17 0 +17
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 25 0 +25

Review metrics

None.

Technical review

Best possible solution:

Merge the shared-dialog guard once a maintainer confirms the final head and required checks, retaining the regression test so future animation timing changes cannot reintroduce focus theft.

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

Yes, at source level: the added regression test deterministically focuses the notes field before wa-after-show and asserts that the late callback does not steal it. The contributor also supplied passing Chromium runs for both affected Workboard paths.

Is this the best way to solve the issue?

Yes. Guarding the shared modal owner boundary is preferable to adding timing waits or test-specific workarounds in each dialog consumer, because it protects user-selected focus across all consumers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4f6fc38a2204.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The contributor posted an after-fix terminal trace for the deterministic component regression and the two affected Chromium Workboard suites; redact-sensitive runtime details are not involved in this proof.
  • 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. Sufficient (terminal): The contributor posted an after-fix terminal trace for the deterministic component regression and the two affected Chromium Workboard suites; redact-sensitive runtime details are not involved in this proof.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The patch addresses intermittent user input landing in the wrong form field and a related Workboard browser-test flake, with a limited web-UI blast radius.
  • 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. Sufficient (terminal): The contributor posted an after-fix terminal trace for the deterministic component regression and the two affected Chromium Workboard suites; redact-sensitive runtime details are not involved in this proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The contributor posted an after-fix terminal trace for the deterministic component regression and the two affected Chromium Workboard suites; redact-sensitive runtime details are not involved in this proof.

Evidence

What I checked:

  • Focused implementation: At PR head 970619425402bcbaf4aa06ab5f3a95bcf9429086, the dialog’s after-show focus handler returns when the active element is an in-dialog descendant rather than the dialog host, preserving focus already moved by the user or input automation. (ui/src/components/modal-dialog.ts:176, 970619425402)
  • Regression coverage: The PR adds a focused regression test that moves focus to the notes textarea, dispatches wa-after-show, and asserts that focus remains on that textarea. (ui/src/components/modal-dialog.test.ts:80, 970619425402)
  • After-fix behavior proof: The contributor’s July 28, 2026 PR comment reports the new modal test passing and reruns both affected Chromium Workboard suites on the refreshed branch, including the edit/reopen persistence case that previously showed typed notes in the title field. (2dc590d7d151)
  • Current-head CI evidence: The supplied PR check state reports completed success for checks-ui, the dedicated real-behavior-proof check, lint/type/guard checks, and build artifacts; the remaining broad checks are still running rather than failing. (970619425402)
  • Related CI-flake separation: The PR body identifies the separate model-catalog timeout as already resolved by merged fix: stop model transport tests from stalling CI #115139, leaving this branch scoped to the modal-focus race. (a20c5550c874)

Likely related people:

  • steipete: Authored this focused modal repair and the separately merged same-day CI-flake repair, so they are the clearest available routing candidate in the supplied history; broader modal ownership was not established from the available provenance. (role: recent contributor to the adjacent CI-stability work; confidence: low; commits: 970619425402, a20c5550c874; files: ui/src/components/modal-dialog.ts, ui/src/components/modal-dialog.test.ts)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-07-28T11:55:37.690Z sha 385e923defe5548912ebcc82247114703caad191 :: needs real behavior proof before merge. :: none

@steipete
steipete force-pushed the steipete/mystifying-sammet-581cb2 branch from 385e923 to 2dc590d Compare July 28, 2026 12:13
@steipete

Copy link
Copy Markdown
Contributor Author

Applied both rank-up moves at head 2dc590d7d1512b923f5a378991a814148c11acb9 (rebased onto current main at f0bf74b).

Focused terminal trace — modal focus stays on the user-selected field after wa-after-show:

node scripts/run-vitest.mjs ui/src/components/modal-dialog.test.ts -- --reporter=verbose
✓ opens a labelled modal dialog with an optional description 97ms
✓ focuses the dialog container first 56ms
✓ focuses slotted autofocus content 54ms
✓ keeps focus on a field the user selected when the show animation settles 57ms
✓ delegates native modality and light dismissal to Web Awesome 53ms
✓ emits modal-cancel on Escape 55ms
✓ emits modal-cancel when the backdrop is clicked 51ms
✓ restores focus when closed and removed 72ms
✓ reopens the same dialog element after reconnect 72ms
Tests  9 passed (9)

The regression test dispatches wa-after-show while the notes textarea is focused and asserts document.activeElement stays on it; with the guard reverted the same test fails (1 failed / 8 passed), reproducing the CI corruption deterministically.

Targeted Workboard browser checks rerun on the refreshed head (Chromium):

node scripts/run-vitest.mjs ui/src/pages/workboard/workboard-status-persistence.e2e.test.ts ui/src/pages/workboard/workboard.e2e.test.ts -- --reporter=verbose
✓ workboard.e2e: persists Workboard create, edit, running move, lifecycle sync, reload, and read-only state 5499ms
✓ workboard.e2e: keeps card titles visible when a column overflows its height 975ms
✓ workboard.e2e: filters persisted boards and keeps the selection in the URL 1156ms
✓ workboard-status-persistence.e2e: preserves an execution-owned session when editing a linked Workboard card 1677ms
✓ workboard-status-persistence.e2e: persists edit/reopen fields and does not bounce a dragged linked card from stale lifecycle 2301ms
Tests  5 passed (5)

@steipete
steipete force-pushed the steipete/mystifying-sammet-581cb2 branch from 2dc590d to 9706194 Compare July 28, 2026 12:19
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 28, 2026
@steipete
steipete force-pushed the steipete/mystifying-sammet-581cb2 branch from 9706194 to 8133833 Compare July 28, 2026 14:13
@steipete
steipete merged commit b3fc995 into main Jul 28, 2026
99 checks passed
@steipete
steipete deleted the steipete/mystifying-sammet-581cb2 branch July 28, 2026 14:39
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 28, 2026
* origin/main:
  fix: preserve skill proposals across apply crashes and workspace moves (#114535)
  fix(qa): run maturity Docker scenarios through the aggregate scheduler (#114447)
  refactor(cli): unify configured model rows onto the shared row pipeline (#115239)
  fix(ui): stop modal autofocus steal after the open animation (#115168)
  fix(process): preserve long supervisor timeout deadlines (#115230)
  fix(slack): preserve pasted inbound tables (#115163)
  fix(codex): restore trajectory capture for canonical session targets (#115220)
  refactor(qa): make scenario selection taxonomy-owned (#114055)
  feat(plugins): match shared models across vendor-namespaced catalog ids (#115210)
vincentkoc added a commit to christian-lallo/openclaw that referenced this pull request Jul 28, 2026
* origin/main: (150 commits)
  fix: preserve skill proposals across apply crashes and workspace moves (openclaw#114535)
  fix(qa): run maturity Docker scenarios through the aggregate scheduler (openclaw#114447)
  refactor(cli): unify configured model rows onto the shared row pipeline (openclaw#115239)
  fix(ui): stop modal autofocus steal after the open animation (openclaw#115168)
  fix(process): preserve long supervisor timeout deadlines (openclaw#115230)
  fix(slack): preserve pasted inbound tables (openclaw#115163)
  fix(codex): restore trajectory capture for canonical session targets (openclaw#115220)
  refactor(qa): make scenario selection taxonomy-owned (openclaw#114055)
  feat(plugins): match shared models across vendor-namespaced catalog ids (openclaw#115210)
  fix(ios): forgetting a paired gateway does nothing (openclaw#114083)
  test(ui): share pauseVirtualClock e2e helper and de-flake marquee hover-delay asserts (openclaw#115203)
  fix(docs): preserve pure fenced translation chunks (openclaw#115204)
  fix: keep shared web and TUI chats synchronized under load (openclaw#115191)
  fix(auto-reply): require a directed turn for the no-visible-reply fallback
  fix(auto-reply): attest source-routed message-tool sends via the dedupe route matcher
  fix(auto-reply): attest message-tool source replies in every delivery mode and gate eligibility on resolved settlement
  fix(auto-reply): bound turn-ledger settlement and treat started sends as conservatively visible
  fix(auto-reply): abort-aware fallback settlement and straggler drain in turn ledger
  fix(auto-reply): keep turn-ledger types module-local
  test(auto-reply): fix type-check errors in turn-ledger corner tests
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
…w#115168)

* fix(ui): stop modal autofocus steal after the open animation

* test(ui-e2e): give expect.poll a CI-realistic deadline
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
* origin/main:
  fix: preserve skill proposals across apply crashes and workspace moves (openclaw#114535)
  fix(qa): run maturity Docker scenarios through the aggregate scheduler (openclaw#114447)
  refactor(cli): unify configured model rows onto the shared row pipeline (openclaw#115239)
  fix(ui): stop modal autofocus steal after the open animation (openclaw#115168)
  fix(process): preserve long supervisor timeout deadlines (openclaw#115230)
  fix(slack): preserve pasted inbound tables (openclaw#115163)
  fix(codex): restore trajectory capture for canonical session targets (openclaw#115220)
  refactor(qa): make scenario selection taxonomy-owned (openclaw#114055)
  feat(plugins): match shared models across vendor-namespaced catalog ids (openclaw#115210)
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: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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