fix: make find escape behavior consistent
Merged
LA
6mo ago+720+720+012345678901234567890123456789-124-124-012345678901234567890123456789
Summary
- Make Escape close terminal find even when the query is non-empty.
- Restore browser web-view focus after hiding browser find.
- Add an E2E regression for terminal and browser find Escape behavior.
Testing
- python3 scripts/swift_file_length_budget.py --budget .github/swift-file-length-budget.tsv
- git diff --check
- ./scripts/reload.sh --tag task-cmd-f-escape-find-consistency
Issues
- Reported in chat: terminal and browser Cmd+F Escape behavior differed.
Summary by cubic
Escape now consistently closes and clears Find in terminal and browser. Reopening restores the last query and caret/selection across refocus, pane handoffs, and field remounts.
-
Bug Fixes
- Terminal: Plain Escape closes Find when terminal owns focus (
cmuxCloseFocusedTerminalFindForEscape); surface ESC fallback clears Find (IME‑safe) and restores focus. Cmd+F seeds fromlastSearchNeedleviastartOrFocusTerminalSearch(initialNeedle:). Selection is remembered before pane‑focus shortcuts and restored on refocus/remount (before any key replay); field editor ownership is tracked for stability. - Browser:
startFindseeds fromlastSearchNeedleand select‑all only when a recovered query is non‑empty.hideFindrestores WebView focus only if Find had focus. Caret/selection are persisted across editor reuse and focus handoffs viaFindSelectionTrackingTextField; Escape stores selection before closing.
- Terminal: Plain Escape closes Find when terminal owns focus (
-
Tests
- E2E cover Escape close‑and‑clear with focus restore, query recovery on reopen, and preserving caret/selection on repeated Cmd+F, pane handoff, and field remount; waits for the field before assertions; responder snapshot data exposed for UI assertions.
Summary by CodeRabbit
-
Bug Fixes
- Escape now reliably closes Find and clears the query in both terminal and browser panes.
- Dismissal more reliably restores focus to page/terminal as expected and avoids spurious selection resets.
- Terminal Escape behavior tightened for consistent focus routing.
-
New Features
- Previous search text is preserved and restored when reopening Find; repeated open preserves prior selection instead of replacing it.
- Find text selection is preserved across edits and focus changes.
-
Tests
- UI tests added validating Escape behavior and selection/restore across panes.