fix(desktop): preserve composer focus during preview automation - #9
Merged
Conversation
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.
Agent-driven browser preview clicks and key presses temporarily move Electron keyboard focus into the guest WebContents. Clicks could leave it there indefinitely—including for hidden or background-thread previews—and press cleanup restored the outer renderer without reliably restoring the composer DOM element.
This restores the previously focused renderer after preview clicks on both success and failure, without overriding a newer user focus choice. The web host also snapshots and restores the exact connected DOM control around click and press operations, while respecting concurrent operations, window blur, and newer pointer/keyboard focus. Other preview operations remain unchanged because they do not transfer native focus.
This incorporates the reviewed upstream fixes from pingdotgg#10982 and pingdotgg#9849, plus applies the DOM focus guard to clicks. Related to pingdotgg#5792 and pingdotgg#10980.
Verified: Preview Manager 90/90 tests; renderer focus guard 10/10 tests; targeted lint and formatting pass (existing warnings only).
Implemented with GPT-5 Codex in T3 Code.