happy icon indicating copy to clipboard operation
happy copied to clipboard

Use with vscode Claude Code native mode?

Open glasser opened this issue 10 months ago • 5 comments

I like to use the VSCode Claude Code extension's native mode. This seems to kind of work with happy if you put it in for the "Claude Process Wrapper" configuration, but it's a bit janky, especially when it prompts for permissions, and around trying to switch back to local mode. Has anyone done this fully successfully?

glasser avatar Jan 15 '26 22:01 glasser

Curious about this as well

jonnycook avatar Jan 29 '26 21:01 jonnycook

looking forward to the release.

walaqi avatar Feb 02 '26 05:02 walaqi

+1 for VSCode extension support!

I'm also very interested in using Happy with the VSCode Claude Code extension.

My use case:

  • Work on VSCode extension during the day at my desk
  • Want to continue the same session from my phone when I'm away
  • Need full session history continuity (--resume equivalent)

The current workaround (VS Code Tunnel) requires my Mac to stay awake, which isn't ideal.

Would love to see native VSCode extension integration!

ruushu avatar Feb 10 '26 01:02 ruushu

+1

cxhttt233 avatar Feb 12 '26 12:02 cxhttt233

Hit this with 2.1.122 Windows extension + [email protected] today. Wanted to share a concrete failure mode and trace in case it helps.

Setup

  • Cursor (VS Code fork) with Anthropic's claude-code extension 2.1.122 (bundles native claude.exe, no cli.js)
  • [email protected] installed globally
  • settings.json: "claudeCode.claudeProcessWrapper": "<path-to-happy.mjs>"

Symptom

Extension spawns happy.mjs via SDK query. happy exits immediately with:

From claude: <ext-dir>\resources\native-binary\claude.exe:1
MZx

SyntaxError: Invalid or unexpected token
    at wrapSafe (node:internal/modules/cjs/loader:1692:18)
    at Module._compile (node:internal/modules/cjs/loader:1735:20)
    at Object..js (node:internal/modules/cjs/loader:1893:10)
    at Module.load (node:internal/modules/cjs/loader:1481:32)
    at Module._load (node:internal/modules/cjs/loader:1300:12)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
    at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
    at node:internal/main/run_main_module:33:47
Node.js v24.12.0

The MZ is the PE header of claude.exe being parsed as JavaScript — i.e. node <path-to-claude.exe> was invoked somewhere.

What's notable

cli-1.1.7 changelog says "detect Claude Code native binary (2.1.113+)", and scripts/claude_version_utils.cjs → runClaudeCli() indeed has an .exe branch that spawns the binary directly (no Node involvement):

const isJsFile = cliPath.endsWith('.js') || cliPath.endsWith('.cjs');
if (isJsFile) {
    import(importUrl);
} else {
    const child = spawn(cliPath, args, { stdio: 'inherit', env: process.env });
}

So happy's own launcher handles native binary correctly. The node <exe> invocation must be happening on a different code path.

Hypothesis

When the extension's wrapper invocation hits happy, happy dispatches to runClaude() (happy CLI default branch, index-q9G4ktSK.mjs:10682) — the full session orchestration, not a transparent pass-through. runClaude ultimately invokes @anthropic-ai/claude-agent-sdk's query() (imported at index-q9G4ktSK.mjs:14, called at :1239). The SDK has its own spawn logic for claude, and I suspect that path still does spawn('node', [claudePath, ...]) unconditionally — which explodes when claudePath is a native .exe.

This would match what @glasser originally described as "a bit janky" — it's not just permission prompts; core invocation breaks on any Windows / macOS arm64 / Linux box with @anthropic-ai/claude-code >= 2.1.113.

Secondary concern

Even setting the MZ error aside: dispatching extension-invoked happy to the full runClaude() orchestration seems wrong — it assumes TTY, interactive auth, daemon ensure, session create, etc. A VS Code extension wrapper invocation is non-interactive and expects claude stream-json protocol on stdio. Maybe wrapper mode warrants a dedicated code path that stays transparent and defers mobile sync to a side-channel?

Environment

Happy to test patches / gather more traces if useful.

Llugaes avatar Apr 30 '26 10:04 Llugaes