Skip to content

fix: restore focus after closing file search - #154221

Merged
steipete merged 3 commits into
mainfrom
codex/fix-file-search-focus
Sep 21, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/fix-file-search-focus

Conversation

@steipete

@steipete steipete commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: pressing Escape in a file preview's search field loses keyboard focus when the field disappears.

User Impact

Escape returns focus to Search in file, so keyboard users can reopen search or continue through the file toolbar. File contents and saved drafts are unchanged.

Why This Change Was Made

The file panel already owns search visibility and query cleanup. Escape now uses that close path and synchronously focuses the persistent toolbar button before the input is removed, avoiding delayed focus that could interrupt navigation.

The first CI run also exposed a shared-test locale leak: a separate translation manager left the document in German, while restoring an already-English singleton skipped document synchronization. The existing test cleanup helper now restores the exact language and direction attributes along with locale and persisted preference. Production locale handling and Workboard assertions are unchanged.

The next CI run exposed a model-picker test race: clearing the search moved a model row under the stationary pointer, which opened a tooltip that correctly consumed the next Escape. The test now clicks into search and waits for row tooltips to close before exercising clear-then-dismiss. Picker behavior, Escape precedence, assertions, and deadlines are unchanged.

Evidence

  • Reproduced in real Chrome: search for Unicode text, press Escape, and observe focus fall to the page body; the next Tab reaches View Raw Text.
  • The new Chromium regression fails on the original code with the page body focused (363 ms test execution; 2.85 s Vitest / 4.43 s wrapper). The final file-editor and HTML-preview suites pass all 28 cases in 5.71 s Vitest / 7.34 s wrapper, including keyboard reopening and normal toolbar closure. The passing run retained aggregate timing rather than individual-case timing.
  • UI and owning test types, scoped typed lint, style lint, formatting, docs validation, and diff checks pass. Independent review has no actionable findings.
  • Full build of fece4c4f291a passed in 278.6 s. The task Gateway serves the verified new bundle; live Chrome confirms that Unicode search still finds its match, Escape focuses the toolbar button, Enter reopens a focused empty search field, and Escape restores focus again.
  • Inspected synthetic-only before/after screenshots were delivered in the originating chat and are attached below. CI must pass before landing.

The locale defect reproduces in the exact predecessor-to-Workboard order: four producer cases pass and two clock cases fail with German minute abbreviations. The helper repair passes that unchanged order three times, all 20 standalone regression runs, and 180 related cases. The full original 464-file UI shard passes 7,711 cases with one skip in 199.33 seconds; four newer-main sibling cases are outside this source checkpoint and will run in hosted merge CI.

The model-picker failure reproduces when the naturally hovered row tooltip opens before the second Escape; that key closes the tooltip and leaves the picker open. After moving the pointer into search, all 20 fresh two-case runs pass, followed by three complete 13-case runs and the original 51-file CI shard (264 cases; 313.50 seconds Vitest / 314.98 seconds process). Tooltip-first Escape coverage remains unchanged.

Before Escape dismissed search and left focus on the page body:

Before: Escape leaves no focused control

After Escape returns focus to Search in file, showing its keyboard focus ring:

After: Escape returns focus to Search in file

@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: XS maintainer Maintainer-authored PR labels Sep 21, 2026
@steipete
steipete marked this pull request as ready for review September 21, 2026 00:54
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 20, 2026, 10:53 PM ET / September 21, 2026, 02:53 UTC (Revision 4).

ClawSweeper review

What this changes

Restores keyboard focus after closing file-preview search, documents that behavior, and repairs locale cleanup and pointer positioning in UI tests.

Merge readiness

✅ Ready for maintainer review

The fix remains useful on inspected main. The latest commit addresses the previous review’s test blocker, and no blocking correctness or security findings remain.

Priority: P3
Reviewed head: 808dc2b9f41bae4bca3fb826877064ea4f5fc583

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with convincing visual proof, meaningful regression coverage, and the prior test failure addressed.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected before/after screenshots show the file-panel search button gaining keyboard focus, supported by the captured Chrome run against a rebuilt Gateway bundle exercising Unicode search, Escape, and Enter reopening. The demonstrated production code remains unchanged at this head.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): Inspected before/after screenshots show the file-panel search button gaining keyboard focus, supported by the captured Chrome run against a rebuilt Gateway bundle exercising Unicode search, Escape, and Enter reopening. The demonstrated production code remains unchanged at this head.
Evidence reviewed 8 items Introduced patch: Reviewed the pinned merge-base-to-head delta. Production changes reuse the existing search toggle and synchronously focus a panel-local toolbar button; the remaining changes are documentation and test support.
Still necessary on main: Fetched main still closes search by clearing visibility, query, and match index without restoring focus. No merged replacement was established. The latest-release source object was unavailable locally, so no shipped-fix claim is made.
Inspected visual and live proof: Inspected both downloaded GitHub screenshots: the after image visibly shows the search button’s keyboard focus ring. The captured PR body reports a rebuilt Gateway bundle in Chrome, successful Unicode search, Escape focus restoration, and Enter reopening an empty focused search field. Production files are unchanged between that demonstrated commit and the reviewed head.
Findings None None.
Security None None.

How this fits together

The Control UI’s file-preview panel owns in-file search and keyboard navigation. Search input updates highlighted matches; closing search should return focus to the persistent toolbar.

flowchart LR
  A[File preview] --> B[Search field]
  B --> C[Highlighted matches]
  B --> D[Escape key]
  D --> E[Close and clear search]
  E --> F[Focus search toolbar button]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +1, Tests +106, Docs 0. Total +107 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 2 5 4 +1
Tests 4 107 1 +106
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 113 6 +107

Review metrics

None.

Technical review

Best possible solution:

Keep search dismissal within the existing panel owner and restore focus synchronously to its persistent toolbar control.

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

Yes: open file-preview search and press Escape; inspected main removes the focused input without selecting a replacement. The supplied Chrome observations corroborate this path; this review did not execute it.

Is this the best way to solve the issue?

Yes: the patch reuses the existing close path and focuses a persistent control before rendering removes the input, avoiding delayed focus theft.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 46e56ca97d44.

Labels

Label justifications:

  • P3: A bounded keyboard-navigation repair improves file-preview accessibility without changing file contents or saved preferences.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): Inspected before/after screenshots show the file-panel search button gaining keyboard focus, supported by the captured Chrome run against a rebuilt Gateway bundle exercising Unicode search, Escape, and Enter reopening. The demonstrated production code remains unchanged at this head.
  • proof: sufficient: Contributor real behavior proof is sufficient. Inspected before/after screenshots show the file-panel search button gaining keyboard focus, supported by the captured Chrome run against a rebuilt Gateway bundle exercising Unicode search, Escape, and Enter reopening. The demonstrated production code remains unchanged at this head.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Inspected before/after screenshots show the file-panel search button gaining keyboard focus, supported by the captured Chrome run against a rebuilt Gateway bundle exercising Unicode search, Escape, and Enter reopening. The demonstrated production code remains unchanged at this head.

Evidence

What I checked:

  • Introduced patch: Reviewed the pinned merge-base-to-head delta. Production changes reuse the existing search toggle and synchronously focus a panel-local toolbar button; the remaining changes are documentation and test support. (ui/src/pages/chat/components/chat-detail-panel.ts:424, 808dc2b9f41b)
  • Still necessary on main: Fetched main still closes search by clearing visibility, query, and match index without restoring focus. No merged replacement was established. The latest-release source object was unavailable locally, so no shipped-fix claim is made. (ui/src/pages/chat/components/chat-detail-panel.ts:420, 46e56ca97d44)
  • Inspected visual and live proof: Inspected both downloaded GitHub screenshots: the after image visibly shows the search button’s keyboard focus ring. The captured PR body reports a rebuilt Gateway bundle in Chrome, successful Unicode search, Escape focus restoration, and Enter reopening an empty focused search field. Production files are unchanged between that demonstrated commit and the reviewed head. (ui/src/pages/chat/components/chat-detail-panel.ts:420, 808dc2b9f41b)
  • Previous blocker addressed: The only change since the previous reviewed head clicks the model-search input and waits for tooltips to close before testing Escape. The existing tooltip owner consumes Escape during capture, supporting the reported failure mechanism. Clear-then-dismiss assertions and deadlines remain intact; the captured body reports successful focused repetitions and the original shard after repair. (ui/src/e2e/chat-model-controls.e2e.test.ts:870, 808dc2b9f41b)
  • Locale isolation repair: The production locale manager can return early when its locale is unchanged, while separate test managers also update document attributes. The shared cleanup helper now restores captured lang and dir attributes, with absent, empty, and explicit-value regression cases; production locale behavior is unchanged. (ui/src/i18n/lib/translate.test-support.ts:27, 808dc2b9f41b)
  • Regression coverage: The browser regression exercises the registered file panel, Unicode matching, Escape focus restoration, Enter reopening, cleared input, and toolbar closure. The body reports failure on original code and 28 passing file-editor/HTML-preview cases afterward. Tests were inspected, not executed during this read-only review. (ui/src/pages/chat/components/chat-sidebar-file-view.browser.test.ts:183, 808dc2b9f41b)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (3 earlier review cycles)
  • reviewed 2026-09-21T01:00:52.148Z sha fece4c4 :: needs changes before merge. :: none
  • reviewed 2026-09-21T01:12:47.121Z sha fece4c4 :: needs changes before merge. :: none
  • reviewed 2026-09-21T01:58:34.670Z sha d37697d :: needs changes before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 21, 2026
@steipete
steipete merged commit d98c70e into main Sep 21, 2026
155 checks passed
@steipete
steipete deleted the codex/fix-file-search-focus branch September 21, 2026 03:06
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
* fix: restore focus after closing file search

* test: restore document locale after isolated managers

* test: position pointer before model-search Escape checks
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 docs Improvements or additions to documentation maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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