claude-code - 💡(How to fix) Fix VS Code extension: support attaching to running remote/bg sessions as a thin client (like the mobile app)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

The mobile/web client (claude.ai) can attach to a Claude Code session that's actively running as a background agent on a remote machine — multiple thin clients see the same conversation and can submit prompts that run in the existing process. The VS Code extension cannot do the equivalent: clicking a remote session in the sidebar tries to spawn a local Claude process and --resume the session ID, which fails when the bg agent already owns it.

Error Message

Spawning Claude with SDK query function - cwd: /home/dor/HW4, ... resume: dd22af84-... ... Error: Session dd22af84-... is currently running as a background agent (bg). Use claude agents to find and attach to it, or add --fork-session to branch off a copy. ... Error spawning Claude (on channel ...): Error: Claude Code process exited with code 1

Root Cause

The mobile/web client (claude.ai) can attach to a Claude Code session that's actively running as a background agent on a remote machine — multiple thin clients see the same conversation and can submit prompts that run in the existing process. The VS Code extension cannot do the equivalent: clicking a remote session in the sidebar tries to spawn a local Claude process and --resume the session ID, which fails when the bg agent already owns it.

Fix Action

Fix / Workaround

Workarounds today

  • claude agents from a terminal (text UI, not the sidebar)
  • claude.ai web/mobile (works, but not in the IDE)
  • tmux + terminal claude (defeats the purpose of the extension)

Code Example

Spawning Claude with SDK query function - cwd: /home/dor/HW4, ... resume: dd22af84-...
...
Error: Session dd22af84-... is currently running as a background agent (bg).
Use `claude agents` to find and attach to it, or add --fork-session to branch off a copy.
...
Error spawning Claude (on channel ...): Error: Claude Code process exited with code 1
RAW_BUFFERClick to expand / collapse

Summary

The mobile/web client (claude.ai) can attach to a Claude Code session that's actively running as a background agent on a remote machine — multiple thin clients see the same conversation and can submit prompts that run in the existing process. The VS Code extension cannot do the equivalent: clicking a remote session in the sidebar tries to spawn a local Claude process and --resume the session ID, which fails when the bg agent already owns it.

Current behavior

From the extension log when clicking a remote session that has an active bg agent:

Spawning Claude with SDK query function - cwd: /home/dor/HW4, ... resume: dd22af84-...
...
Error: Session dd22af84-... is currently running as a background agent (bg).
Use `claude agents` to find and attach to it, or add --fork-session to branch off a copy.
...
Error spawning Claude (on channel ...): Error: Claude Code process exited with code 1

So the "open remote session" action is really "resume in a new local process," which conflicts with any live bg owner.

Desired behavior

Add an "attach" mode (or make "open" auto-detect): when the selected session is currently held by a bg agent / remote agent, the extension should act as a thin client to that process — same as the mobile app — instead of spawning a new local Claude. Prompts typed in the sidebar should run on the existing process on the remote machine. Closing VS Code should not kill the process.

Use case

Persistent long-running sessions on a remote dev machine (e.g. agent doing a long task, or just leaving Claude attached to a workspace) that I want to revisit from VS Code without losing state when I close my laptop. The mobile app proves the protocol supports multi-client attach; the IDE extension should expose the same path.

Workarounds today

  • claude agents from a terminal (text UI, not the sidebar)
  • claude.ai web/mobile (works, but not in the IDE)
  • tmux + terminal claude (defeats the purpose of the extension)

Environment

  • VS Code extension version: 2.1.145 (linux-x64)
  • Claude Code CLI: bundled with extension
  • Connecting from local VS Code → remote machine via Remote-SSH; bg agent lives on the remote

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING