Skip to content

Focus PTYTerminal on creation from ShellV2 menu#2265

Merged
KCarretto merged 2 commits intomainfrom
copilot/focus-pty-terminal-on-click
Apr 17, 2026
Merged

Focus PTYTerminal on creation from ShellV2 menu#2265
KCarretto merged 2 commits intomainfrom
copilot/focus-pty-terminal-on-click

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

Clicking the PTY menu option in ShellV2 creates the terminal tab but leaves keyboard focus on the HeadlessUI Menu button. The terminal only received focus later when the WebSocket onopen fired—if at all, since HeadlessUI's focus restoration could race against it.

  • Added a deferred term.focus() immediately after term.open() in PtyTerminal's mount effect, matching the pattern already used by handleNewPortal for the same HeadlessUI focus-restoration issue
term.open(termRef.current);
fitAddon.fit();
termInstance.current = term;

// Deferred so HeadlessUI menu finishes restoring focus first.
setTimeout(() => term.focus(), 0);

Agent-Logs-Url: https://github.com/spellshift/realm/sessions/ad51667f-d58a-4d57-af22-4bf198d73ec0

Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>
@KCarretto KCarretto merged commit da3e670 into main Apr 17, 2026
6 of 8 checks passed
@KCarretto KCarretto deleted the copilot/focus-pty-terminal-on-click branch April 17, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants