anthropics / anthropics/claude-code
VS Code extension: agent file-read preview tabs (✻ [Claude Code]) steal keyboard focus from the tab the user is typing in
- Ngôn ngữ chính
- Python
- Star
- 145k
- Fork
- 23.1k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
## Environment
- Claude Code VS Code extension 2.1.235 (also present in 2.1.233/2.1.234 bundles)
- VS Code 1.133.0, Windows 11
## Problem
While a Claude Code session is working, the extension surfaces the files the agent is reading in a `✻ [Claude Code] …` preview tab. Each time that preview opens or updates, the tab is shown via `showTextDocument(doc, { preview: true })` with **no `preserveFocus` option** — which defaults to taking focus. The preview tab therefore activates itself and moves keyboard focus, in whatever window the session lives in.
When the user is meanwhile typing (or dictating) into a *different* tab in that same window — including answering an `AskUserQuestion` prompt in another Claude Code chat — the caret is yanked out of their input mid-sentence, with no user action.
Verified with an element-level UIA focus trace: focus left an `AskUserQuestion` "Other" input and landed on the freshly re-revealed `✻ [Claude Code]` preview tab while a second session's agent read through several files, with zero clicks in the interval.
## Where
In the bundled `extension.js`, the readonly branch of the `openContent` flow creates the `/temp/readonly/…` virtual document and shows it with:
```js
d = await dp.workspace.openTextDocument(g), await dp.window.showTextDocument(d, { preview: !0 })
```
— no `preserveFocus`, so it defaults to `false` and steals focus on every reveal. (The editable branch of the same function *does* pass `{ preview: !1, preserveFocus: !0 }`, so the fix is precedented three lines down.)
## Suggested fix
Pass `preserveFocus: true` on the agent-driven preview reveals in the `openContent` path so the preview stays passive; user-initiated opens (clicking a file link in chat) can keep taking focus.
This is the file-tab cousin of the focus-jump issue fixed in 2.1.218 ("Fixed focus jumping between open Claude tabs on its own when a window with several Claude panels is restored or reloaded") and of the `preserveFocus` inconsistency reported for diff-opens in #77979 — same class, different call site.
## Impact
Scales with multi-session use: anyone running a working session and an interactive chat in one window hits this every time the worker reads files while they type. It is especially painful mid-`AskUserQuestion`, where the stolen caret can silently swallow a typed/dictated answer.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Open the bundled extension.js and inspect the readonly branch of the openContent flow, where /temp/readonly/ documents are shown, then compare it with the editable branch three lines later. Reproduce the issue with one session reading files while typing in another tab; done means agent-driven previews no longer steal focus while user-initiated opens retain their existing behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, vscode
- Lĩnh vực
- desktop-dev, developer-experience
- Loại issue
- Lỗi
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 88/100