VS Code extension: automatic selection-attach silently fails (only Ctrl+Esc hint shown)

Status Open
Maintainer reply None cached
Activity 0 comments · opened Aug 18, 2026

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-code v2.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

  1. The auto-attach mechanism is implemented in extension.js: an onDidChangeTextEditorSelection listener builds a selection payload and, after a 300ms debounce, pushes it over a companion WebSocket connection if e.server is truthy.
  2. That companion connection is alive — confirmed a live lock file under ~/.claude/ide/*.lock with a listening WebSocket port matching a running code process for the workspace window.
  3. 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).
  4. 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.

  1. 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

  1. Open a workspace in VS Code with the Claude Code extension (panel mode).
  2. Open a markdown/text file, start or continue a chat session.
  3. Highlight a non-empty line/selection in the editor.
  4. 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.

View original on GitHub ↗