VS Code extension: automatic selection-attach silently fails (only Ctrl+Esc hint shown)
Description
Automatic selection-attach (highlighting a line in the editor and having it show up as <ide_selection> context in the chat) does not work. The chat input hints at Ctrl+Esc to manually attach a selection, but this used to happen automatically without needing the shortcut.
Environment
- Extension:
anthropic.claude-codev2.1.234 (auto-updated ~24 min before filing, so this is current) - VS Code: 1.133.0, Linux (Ubuntu 24.04.4), Wayland
- Setting:
claudeCode.preferredLocation: "panel"
What I found while debugging
- The auto-attach mechanism is implemented in
extension.js: anonDidChangeTextEditorSelectionlistener builds a selection payload and, after a 300ms debounce, pushes it over a companion WebSocket connection ife.serveris truthy. - That companion connection is alive — confirmed a live lock file under
~/.claude/ide/*.lockwith a listening WebSocket port matching a runningcodeprocess for the workspace window. - Despite that, no
<ide_selection>content ever reaches the model, even immediately after a fresh, non-empty selection, with the file already open and in focus, across multiple test attempts (re-highlighting, closing/reopening the file, reloading the whole VS Code window). - The extension's own log (
~/.config/Code/logs/*/window*/exthost/Anthropic.claude-code/Claude VSCode.log) shows a recurring warning on every session/webview reload:
````
[WARN] claude-vscode notification channel error: Received a response for an unknown message ID: {"jsonrpc":"2.0","result":{},"id":0}; further channel errors are not logged this session
This fired 7 times in one session (once per reload). This looks like a message-ID bookkeeping issue on the same JSON-RPC channel that the selection-push notification would travel over, which would explain the push being silently dropped even though the extension-side code correctly detects and sends it.
- Separately (likely unrelated, noting for completeness):
rg error ... /home/j/.claude/plugins/cache: IO error ... No such file or directory— that directory doesn't exist on this machine.
Steps to reproduce
- Open a workspace in VS Code with the Claude Code extension (panel mode).
- Open a markdown/text file, start or continue a chat session.
- Highlight a non-empty line/selection in the editor.
- Send a message in the chat without using
Ctrl+Esc.
Expected: the highlighted text is automatically attached as <ide_selection> context.
Actual: no selection context is attached; only manual Ctrl+Esc attach (unverified whether that path works, not tested) is suggested by the UI.
Notes
- Reproduced with only one relevant VS Code window newly opened for the workspace, so it's not a stale/orphaned companion-connection or cross-window collision.