Skip to content

fix(vscode): restore chat prompt focus after window reactivation - #14142

Merged
marius-kilocode merged 2 commits into
Kilo-Org:mainfrom
mondalaci:fix/14139-restore-prompt-focus
Sep 15, 2026
Merged

marius-kilocode merged 2 commits into
Kilo-Org:mainfrom
mondalaci:fix/14139-restore-prompt-focus

Conversation

@mondalaci

Copy link
Copy Markdown
Contributor

What

Restore the chat prompt caret when returning to VS Code if the prompt was focused before the window was deactivated (sidebar and Open in Tab).

Fixes #14139

Why

Alt-Tab (or any OS window switch) blurs the webview textarea. VS Code restores workbench focus to the webview, but not the inner input, so keystrokes are lost. Cursor already restores this correctly.

How

  • Remember whether the prompt held focus, without treating Alt-Tab blur as “user left the chat”
  • When the webview is focused again, focus the textarea once
  • After VS Code settles, send a single restoreInput if needed; only show()/reveal() the host if the webview never got focus
  • Do not steal focus from the editor, other text controls, popups, or Agent Manager terminals

Tests

  • Unit tests for the host latch and webview hold
  • Manual: focus the prompt, Alt-Tab away and back — typing goes to the prompt; focusing the editor first does not steal back to the prompt

Keep the prompt focused across Alt-Tab when it held focus before the VS Code window was deactivated, without stealing focus from the editor.
@marius-kilocode

Copy link
Copy Markdown
Collaborator

I can't reproduce, seems to be only os specific.

Keep both the prompt focus hold and hasTextSelection when resolving the add/add conflicts in PromptInput.tsx and focus.ts.

@marius-kilocode marius-kilocode left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix and for the clear write-up on the OS focus behavior. I merged main into the branch to clear the conflicts in PromptInput.tsx and focus.ts, keeping both createHold and hasTextSelection. Enabling auto-merge now.

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.

Chat input loses focus when the VS Code window is deactivated and does not regain it on return

2 participants