[BUG] Selection context not passed to Claude in DevContainer environment

Resolved 💬 9 comments Opened Dec 16, 2025 by NetverseSocial Closed Feb 14, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When running Claude Code inside a VS Code DevContainer, the selection context feature does not work. The extension shows the selected lines in the UI ("15 lines sel..." at bottom of input), but the context is not passed to Claude when sending a message.

Claude responds with: "I don't see any code context or file selection in your message. It seems like you may have tried to share or select some code, but it didn't come through."

What works:

  • Claude Code CLI in terminal (claude command)
  • - VS Code extension sidebar panel
  • - - Diff viewing (edits show as VS Code diffs)
  • - - - Edit approval flow
  • - - - - @filename references
  • - - - - - File reading/writing

What doesn't work:

  • Selection auto-context (main issue)
  • - Cmd+Esc keyboard shortcut
  • - - Active tab auto-context

What Should Happen?

When code is selected in the editor and a message is sent via the Claude Code sidebar panel, Claude should receive the selected code as context and respond with understanding of that selection.

The extension UI correctly shows "15 lines sel..." at the bottom of the input, indicating it detects the selection. This context should be transmitted to Claude's backend.

Error Messages/Logs

VS Code Developer Console (Cmd+Shift+I → Console):

ERR chatParticipant must be declared in package.json: claude-code


Extension Host logs:

[Extension Host] Created lock file at /home/node/.claude/ide/39497.lock
[Extension Host] Set CLAUDE_CODE_SSE_PORT=39497 in terminal environment (in-memory)
[Extension Host] Set ENABLE_IDE_INTEGRATION=true in terminal environment (in-memory)


Claude Code extension logs (from "Claude Code: Show Logs"):

2025-12-16 07:20:17.110 [info] Claude code extension is now active?
2025-12-16 07:20:17.110 [info] MCP Server running on port 33449 (localhost only)

Steps to Reproduce

  1. Create a devcontainer with Claude Code installed globally via npm

devcontainer.json:

{
  "name": "Claude Code",
  "build": { "dockerfile": "Dockerfile" },
  "mounts": [
    "source=${localWorkspaceFolder}/claude-home/.claude,target=/home/node/.claude,type=bind"
  ],
  "remoteUser": "node",
  "customizations": {
    "vscode": { "extensions": ["anthropic.claude-code"] }
  }
}

Dockerfile:

FROM node:20-slim
RUN apt-get update && apt-get install -y git curl && rm -rf /var/lib/apt/lists/*
RUN npm install -g @anthropic-ai/claude-code
WORKDIR /workspace
RUN mkdir -p /home/node/.claude && chown -R node:node /workspace /home/node
USER node
CMD ["/bin/bash"]
  1. Open folder in VS Code → "Reopen in Container"
  2. 3. Wait for container to build and Claude Code extension to activate
  3. 4. Open any file (e.g., test.js)
  4. 5. Select some code (e.g., 15 lines)
  5. 6. Open Claude Code sidebar panel
  6. 7. Notice "15 lines sel..." appears at bottom of input field
  7. 8. Type a message like "Can you refactor this?" and send

Expected: Claude responds with understanding of the selected code
Actual: Claude responds saying it doesn't see any code selection

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.70

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

Analysis:

The chatParticipant must be declared in package.json: claude-code error suggests the extension isn't properly registering as a VS Code chat participant when running in DevContainer/remote environments.

The extension CAN see the selection (UI shows "15 lines sel...") but cannot pass it to the Claude backend. This indicates the selection detection works but the chat participant registration fails in remote contexts.

Environment verified inside container:

which code  # /vscode/vscode-server/bin/.../code
env | grep VSCODE  # All IPC sockets present
env | grep TERM  # TERM_PROGRAM=vscode

Workaround:
Use @filename references instead of selection context:

@test.js refactor this code

Tested with:

  • Docker Desktop 4.54.0
  • - VS Code 1.107.0
  • - - node:20-slim base image
  • - - - Claude Subscription Max (OAuth)

View original on GitHub ↗

This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗