Skip to content

fix(web): restore renderer focus after preview presses - #9849

Closed
0bkevin wants to merge 1 commit into
pingdotgg:mainfrom
0bkevin:fix/5792-renderer-focus
Closed

fix(web): restore renderer focus after preview presses#9849
0bkevin wants to merge 1 commit into
pingdotgg:mainfrom
0bkevin:fix/5792-renderer-focus

Conversation

@0bkevin

@0bkevin 0bkevin commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Preview key presses can leave the host renderer with a connected preview control focused after native focus returns, so the next composer keystroke is lost. This keeps the existing void IPC contract and restores the prior DOM focus only when the document is still focused, the element remains connected, and no newer user focus took ownership.

The change is limited to the web renderer:

  • Wrap the existing preview press bridge call with a DOM focus guard.
  • Recognize native focus transfer separately from newer pointer, keyboard, or programmatic DOM focus.
  • Keep overlapping calls concurrent while preventing an older call from reclaiming focus.
  • Preserve the operation result or rejection when focus restoration fails.

PreviewAutomationHosts is mounted only in Electron (isElectron && previewBridge.automation), so the standalone browser path is unaffected. This is the renderer portion of #9530 and is independent of the desktop native companion PR.

Validation:

  • 10 focused renderer focus tests passed.
  • @t3tools/web typecheck passed.
  • Targeted lint passed with the existing warning at PreviewAutomationHosts.tsx:741.
  • Modeled baseline test failed before the guard and passed with it.
  • No live Electron before/after recording is included yet; the draft remains pending that runtime evidence.
  • During overlaps, the latest-call guard conservatively suppresses stale restoration; this does not claim to resolve every cross-thread focus race.

Refs #5792. Replaces the renderer portion of #9530. Desktop companion: #9848.

Model: GPT-5.6 Luna implementation; GPT-6 review
Harness: Codex in T3 Code

@juliusmarminge

Copy link
Copy Markdown
Member

Superseded by #11354 (fix(desktop): keep preview keystrokes out of the composer), which landed the desktop-side fix for preview automation leaking into the composer (Refs #5792). Closing this renderer focus-restore companion as wash leftover hygiene — reopen if anything unique still needs merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants