fix(server): Claude's commands no longer run Electron apps as Node #29413
main fromrefs/pull/29413/head·merged by maria-rcks View on GitHubProblem#
The desktop app runs the server as Node through Electron with ELECTRON_RUN_AS_NODE=1. mergeClaudeProcessEnvironment copies the host environment into the Claude process, so every command Claude runs inherits that variable. Any Electron app started from a Claude session then runs as plain Node and exits.
Reproduce on macOS with the desktop app (0.0.45, and the same code is on main): in a Claude thread, ask Claude to run env | grep ELECTRON (prints ELECTRON_RUN_AS_NODE=1). Then ask it to start the app's own binary with a Chromium flag:
"/Applications/T3 Code (Alpha).app/Contents/MacOS/T3 Code (Alpha)" --remote-debugging-port=9224
It exits right away with Node's error:
/Applications/T3 Code (Alpha).app/Contents/MacOS/T3 Code (Alpha): bad option: --remote-debugging-port=9224
The same happens for VS Code, Cursor, Slack or any other Electron app started from a Claude command.
Change#
mergeClaudeProcessEnvironment drops ELECTRON_RUN_AS_NODE with the launching Claude session's variables. The terminal manager already drops it (TERMINAL_ENV_BLOCKLIST), and so do externalLauncher and the ACP cgroup wrapper. This brings the Claude process in line.
Claude itself doesn't need it. A native claude binary ignores it, and the SDK runs a cli.js entry with node, not the Electron binary. The Claude history worker, which does run through the Electron binary, still sets the variable itself in runClaudeWorker.
Scope and approval#
A very small, focused fix for an obvious bug: one environment variable dropped in one place, matching how the terminal manager and the external launcher already treat it. No behavior changes beyond commands run by Claude no longer inheriting the variable.
Verification#
- Added
ELECTRON_RUN_AS_NODE: "1"to the host env in the existingmergeClaudeProcessEnvironmenttest.vp test run src/provider/Drivers/ClaudeHome.test.tsinapps/serverfails without the change (the merged env still hasELECTRON_RUN_AS_NODE: "1") and passes with it (4/4). vp fmt --checkon both files passes.- Found it in the desktop app (0.0.45): a Claude thread's shell had
ELECTRON_RUN_AS_NODE=1, and relaunching the app from it with--remote-debugging-portfailed with the error above. With the variable unset (env -u ELECTRON_RUN_AS_NODE), the same command started the app with the debug port. - Not checked: a desktop build from this branch. The fix is in the server's env construction, which the unit test covers.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved at
524b33dMacroscope's review found this PR approvable — Claude-launched Electron apps no longer inherit the server’s Node-only runtime flag. The change is limited to child-process environments and preserves explicit instance overrides and the worker’s required flag.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: ac8dce0
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
59c19500-93c1-4271-854f-fad40565ba19
Commits-
Reviewing files that changed from the base of the PR and between ac8dce0cc3abd8a337f2d806b5082a6834b9b81a and 524b33dedd39c8d09a5c8eb5d5c655547033464d.
Files selected for processing: 2-
apps/server/src/provider/Drivers/ClaudeHome.test.tsapps/server/src/provider/Drivers/ClaudeHome.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
Walkthrough
-
The Claude process environment merge now removes
ELECTRON_RUN_AS_NODEfrom the base environment. The test fixture includes the flag, while the expected merged environments remain unchanged.Changes: Claude process environment
Layer / File(s) Summary Remove Electron run-as-Node flag
apps/server/src/provider/Drivers/ClaudeHome.ts,apps/server/src/provider/Drivers/ClaudeHome.test.tsmergeClaudeProcessEnvironmentdeletesELECTRON_RUN_AS_NODEfrom the base environment. The test fixture includes the flag, and the expected merged environments remain unchanged.Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix
Possibly related issues
- Issue 26966 reports the same
ELECTRON_RUN_AS_NODE=1inheritance in Claude provider shells. This change removes that variable from the base environment.
Suggested reviewers:
t3dotgg,maria-rcks - Issue 26966 reports the same
Merge Risk:
Minimal · up to524b3-
Claude commands now omit the inherited Electron Node-mode flag without mutating the server environment, with no merge-blocking risk identified.
Pre-merge checks:
4-
Check name Status Explanation Title check The title clearly and concisely describes the main change: preventing Claude commands from launching Electron apps in Node mode. Description check The description includes all required sections. It clearly explains the problem, change, scope and approval rationale, focused verification results, and the desktop build that was not checked. Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request.
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
Note
Written by
gpt-6.1-solon behalf of MariaVerified in a real dev environment#
verified unchanged head
524b33dedd39c8d09a5c8eb5d5c655547033464don a linux x64 vm. reproduced first ongithub/mainatf6503f0e717f5d577a897149b4ceeb3d1bf00b3a, in a separate worktree. ran one dev server at a time, with isolated data andELECTRON_RUN_AS_NODE=1on both revisions.used repo playwright with
/usr/bin/google-chrometo add a real git project, create threads, and submit real provider turns. no mocks, fixtures, or replay provider.- main: a real claude haiku 5.5 Bash command printed
ELECTRON_RUN_AS_NODE=1. launching electron 44.10.0 with--remote-debugging-port=9224failed withbad optionand exit code 9. - pr: the same environment probe printed
null;CLAUDE_CODE_ENTRYPOINT=t3-codeand README access still worked. the server retained its own flag. claude launched the same electron binary with chromium flags and opened the debugging port. a follow-up launch opened the running t3 web client in an electron window; i independently connected to that port and inspected its rendered pairing page andElectron/44.10.0user agent. the bounded launches ended with timeout exit 124 as intended. - nearby behavior: real codex
gpt-6.1-solturns completed on both revisions, reading README and checking git status. claude continued in the original thread, then the app forked that conversation and completed another real claude turn with inherited history, working shell commands, and the flag still absent. vp test run apps/server/src/provider/Drivers/ClaudeHome.test.tspassed all 4 tests throughblacksmith-check. existing head CI checks are green. no source changes or push were needed.
short transcript from actual provider tool results:
main shell: {"ELECTRON_RUN_AS_NODE":"1","CLAUDE_CODE_ENTRYPOINT":"t3-code","DISPLAY":":0"} electron: bad option: --remote-debugging-port=9224 EXIT_CODE=9 pr shell: {"ELECTRON_RUN_AS_NODE":null,"CLAUDE_CODE_ENTRYPOINT":"t3-code","DISPLAY":":0"} electron: DevTools listening on ws://127.0.0.1:9224/devtools/browser/... independent inspection: T3 Code (Dev), http://localhost:5733/pair, Electron/44.10.0 fork shell: {"flag":null,"entrypoint":"t3-code"} git status --short: clean


Not verified#
packaged t3 desktop builds, macos/windows launch behavior, and native ios/android clients. this vm exercises the real server/provider path with the desktop runtime flag explicitly inherited; it does not replace checking a packaged desktop build. local/remote relay and tunnel connections were not exercised.
- main: a real claude haiku 5.5 Bash command printed
Note
🤖 Claude Opus 5.5 responding on behalf of AJ (@ajbarryiii)
Is a Claude-only fix the approach you want here, or would a general one be better? #29413 fixes the Claude path correctly, but Codex agent shells keep
ELECTRON_RUN_AS_NODE=1, and from the code so do ACP agents.In a VM with a packaged AppImage built from main, a managed Codex agent's shell still had the variable, and an Electron app started from it exited with
bad option: --no-sandbox. #26966 reports the same on macOS. #16679 removes the variable for every provider inmergeProviderInstanceEnvironment, but on its own it breaks managed Codex: Codex runs T3's own binary as its token command, and that command relied on inheriting the variable. A small launcher for that one command fixes it. The details, VM results for main, #16679 + main and the fixed branch are here: https://github.com/pingdotgg/t3code/issues/26966#issuecomment-6597941402The two don't conflict. The branch merges cleanly with #29413, whose
deletewould then be redundant, so #29413 can land first if you prefer.maria-rcks merged this6016aac
maria-rcks closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes