Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): preserve user focus during preview presses #9848

Closed0bkevin(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/9848/headopened View on GitHub

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.ensuring cleanup remains in place for key-up and focus-emulation cleanup.

Scope is limited to apps/desktop/src/preview/Manager.ts and apps/desktop/src/preview/Manager.test.ts. The existing Promise<void> IPC contract is unchanged; this PR contains no web or contracts changes.

Validation:

  • Manager.test.ts: 80 passed
  • The cleanup-time pointer regression applied to the prior PR commit: 79 passed, 1 failed because the old restore guard refocused the previous renderer
  • Desktop typecheck passed with existing Effect suggestions
  • Targeted desktop lint and formatting checks passed

Live 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.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. 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.

    3. juliusmarminge closed this

Sign in to join this conversation.