Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): Claude's commands no longer run Electron apps as Node #29413

Mergedu9g(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/29413/headmerged by maria-rcks View on GitHub

Problem

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 existing mergeClaudeProcessEnvironment test. vp test run src/provider/Drivers/ClaudeHome.test.ts in apps/server fails without the change (the merged env still has ELECTRON_RUN_AS_NODE: "1") and passes with it (4/4).
  • vp fmt --check on 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-port failed 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

    2. Approvability

      Verdict: Approved at 524b33d

      Macroscope'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).
    3. Review in Change Stack →

      No actionable comments were generated in the recent review.

      Recent review info
      Run configuration
      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.ts
      • apps/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_NODE from 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.ts
      mergeClaudeProcessEnvironment deletes ELECTRON_RUN_AS_NODE from 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=1 inheritance in Claude provider shells. This change removes that variable from the base environment.

      Suggested reviewers: t3dotgg, maria-rcks

      Merge Risk: Minimal · up to 524b3

      Claude commands now omit the inherited Electron Node-mode flag without mutating the server environment, with no merge-blocking risk identified.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title clearly and concisely describes the main change: preventing Claude commands from launching Electron apps in Node mode.
      Description checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck 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
    4. Note

      Written by gpt-6.1-sol on behalf of Maria

      Verified in a real dev environment

      verified unchanged head 524b33dedd39c8d09a5c8eb5d5c655547033464d on a linux x64 vm. reproduced first on github/main at f6503f0e717f5d577a897149b4ceeb3d1bf00b3a, in a separate worktree. ran one dev server at a time, with isolated data and ELECTRON_RUN_AS_NODE=1 on both revisions.

      used repo playwright with /usr/bin/google-chrome to 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=9224 failed with bad option and exit code 9.
      • pr: the same environment probe printed null; CLAUDE_CODE_ENTRYPOINT=t3-code and 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 and Electron/44.10.0 user agent. the bounded launches ended with timeout exit 124 as intended.
      • nearby behavior: real codex gpt-6.1-sol turns 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.ts passed all 4 tests through blacksmith-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

      main: claude inherits the flag and electron rejects chromium flags

      pr: claude has no inherited flag and electron opens its debugging port

      actual electron window launched by claude renders the running t3 client

      real claude turn submits, runs shell commands, and streams the launch result

      provider command transcript

      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.

    5. 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 in mergeProviderInstanceEnvironment, 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-6597941402

      The two don't conflict. The branch merges cleanly with #29413, whose delete would then be redundant, so #29413 can land first if you prefer.

    6. maria-rcks merged this6016aac

    7. maria-rcks closed this

Sign in to join this conversation.