Skip to content

fix(vscode): prevent questions from stealing typing focus - #13531

Merged
marius-kilocode merged 1 commit into
mainfrom
fix-question-tool-focus-stealing
Aug 28, 2026
Merged

fix(vscode): prevent questions from stealing typing focus#13531
marius-kilocode merged 1 commit into
mainfrom
fix-question-tool-focus-stealing

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

What Problem This Solves

An open question can move focus from the chat composer to its first answer while a draft is being typed. Further text then misses the composer, and a space can accidentally select that answer.

Why This Change Was Made

The question dock and Agent Manager both schedule question autofocus. The dock only checked whether the webview had focus, while Agent Manager's editable-field guard excluded the chat composer. A repeated question delivery could therefore take focus even though the composer was active.

Check the active text control when each deferred focus callback runs. Keep explicit focus commands and question keyboard navigation unchanged. No question recovery, network, or timing changes are needed.

User Impact

New questions and repeated question deliveries leave active text fields in control. Users can continue writing a draft or custom answer without losing focus. Arrow-key selection and navigation between question pages still work.

Evidence

  • Reproduced in isolated VS Code by replaying the same pending question after typing in the composer. Focus moved to the first answer, the draft lost its suffix, and a typed space selected the answer.
  • Verified the fix in both Agent Manager and the sidebar: new questions during typing, delayed duplicate delivery, three further duplicate deliveries, custom answers, Arrow/Space selection, and next/back question navigation.
  • Both targeted regression cases failed before the fix and passed afterward. The full suite passed with 4,353 tests. Extension compilation, type checks, lint, Knip, and the change-marker guard also passed.

The self-test used deterministic session and question messages in the real webviews, with no credentials or model calls. It verifies UI handling rather than live SSE recovery. Synthetic session IDs produced expected backend Session not found diagnostics. The isolated VS Code instance was cleaned up afterward.

Manual check: leave a question open and type in the bottom composer. Confirm that focus remains there, then select an answer and verify Arrow-key navigation.

Before: the first answer takes focus and the draft is incomplete.

Before the fix, the first answer is focused and accidentally selected while the composer draft is incomplete

After: the composer keeps focus and all text reaches the draft.

After the fix, the composer keeps focus through question updates and no answer is accidentally selected

@kilo-code-bot

kilo-code-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (6 files)
  • .changeset/preserve-question-typing-focus.md
  • packages/kilo-vscode/tests/fixtures/question-dock-disposal.tsx
  • packages/kilo-vscode/tests/unit/agent-manager-focus.test.ts
  • packages/kilo-vscode/tests/unit/question-dock-disposal.test.ts
  • packages/kilo-vscode/webview-ui/agent-manager/focus.ts
  • packages/kilo-vscode/webview-ui/src/components/chat/QuestionDock.tsx

Reviewed by grok-4.6 · Input: 127.4K · Output: 11.8K · Cached: 391.4K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit 8e7ce28 into main Aug 28, 2026
24 checks passed
@marius-kilocode
marius-kilocode deleted the fix-question-tool-focus-stealing branch August 28, 2026 08:39
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