Fix terminal first responder restoration after workspace switches
Closed
AU
1mo ago+281+281+012345678901234567890123456789-17-17-01234567890123456789
Summary
- add a regression test that reproduces workspace-switch focus loss when the returning terminal is still zero-sized on the first restore attempt
- keep retrying terminal first-responder restoration for a short bounded window while workspace visibility, layout, and pane selection settle
- stop retrying once the intended terminal surface owns first responder again
Verification
- ./scripts/reload.sh --tag issue1122-focus
Fixes #1122
Summary by cubic
Fixes terminal keyboard focus loss after workspace switches by adding a bounded, delayed retry that reapplies first responder only after the returning terminal is visible, active, and sized. No-op visible/active updates no longer rearm the retry budget.
- Bug Fixes
- Implemented automatic first-responder retry (30ms delay, up to 8 tries). Budget arms only on state changes (window key, visible/active flips, pane/tab selection), clears on success, and retries on hidden/zero-size, stale/inactive target, or
makeFirstResponderfailure. - Added
TerminalWorkspaceSwitchFocusTestscovering deferred-geometry recovery and ensuring no-op visible/active updates don’t reset the budget.
- Implemented automatic first-responder retry (30ms delay, up to 8 tries). Budget arms only on state changes (window key, visible/active flips, pane/tab selection), clears on success, and retries on hidden/zero-size, stale/inactive target, or
Summary by CodeRabbit
- Bug Fixes
- Improved focus handling for terminal views during workspace switches by introducing a bounded automatic retry so terminals reliably regain focus after hidden, tiny, or deferred geometry restores.
- Tests
- Added automated tests validating focus restoration after workspace switches and confirming redundant visibility/active updates do not rearm the retry budget.