fix(desktop): preserve user focus during preview presses - #9848
Closed
0bkevin wants to merge 2 commits into
Closed
Conversation
This was referenced Sep 5, 2026
2 tasks
Member
|
Superseded by #11354 (fix(desktop): keep preview keystrokes out of the composer), which landed the Manager/PreviewKeyboard fix for preview automation interfering with the composer (Refs #5792). Closing this desktop focus-restore companion as wash leftover hygiene — reopen if anything unique still needs merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Desktop preview key presses temporarily focus the guest WebContents so native keyboard events reach the preview. Cleanup must not restore a stale renderer after the preview window loses focus or after a user takes control, which could steal focus back from the user.
This desktop-only change snapshots the existing per-tab control epoch before focus transfer and rechecks it immediately before native focus restoration. The previous renderer is restored only while the app window is focused and the preview guest still owns focus. A human event during key dispatch or while key-up cleanup is in flight therefore prevents refocus. The existing
Effect.ensuringcleanup remains in place for key-up and focus-emulation cleanup.Scope is limited to
apps/desktop/src/preview/Manager.tsandapps/desktop/src/preview/Manager.test.ts. The existingPromise<void>IPC contract is unchanged; this PR contains no web or contracts changes.Validation:
Manager.test.ts: 80 passedLive Electron before/after recording remains pending. This PR covers native desktop focus restoration and does not claim to fix DOM or composer focus behavior by itself.
Refs #5792. Replaces the desktop portion of #9530.
Implemented GPT-5.6 Luna; reviewed GPT-6 via Codex harness in T3 Code.