Skip to content

fix(daemon): strip ELECTRON_RUN_AS_NODE from spawned PTY env - #2415

Merged
nwparker merged 1 commit into
stablyai:mainfrom
AIEPhoenix:fix/strip-electron-run-as-node-from-daemon-pty
May 22, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
AIEPhoenix:fix/strip-electron-run-as-node-from-daemon-pty

Conversation

@AIEPhoenix

@AIEPhoenix AIEPhoenix commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The daemon process is forked from Electron with ELECTRON_RUN_AS_NODE=1 so the forked daemon runs as plain Node and avoids Electron display/GPU initialization around node-pty startup.
  • That flag was leaking into daemon-backed terminal shells because createPtySubprocess spreads the daemon process env into the PTY child env.
  • This strips the daemon-internal flag at the daemon -> PTY boundary before pty.spawn, while keeping the daemon process itself unchanged.

Fixes #2414.

Security / compatibility review

  • Security: this reduces parent-process env leakage into user shells. It does not add a new trust boundary, command path, or dependency.
  • Explicit child env is scrubbed too. Renderer/main callers have no legitimate reason to seed ELECTRON_RUN_AS_NODE into an interactive user shell, and preserving it would keep the reported Electron-as-Node footgun open.
  • Cross-platform: the variable has the same Electron meaning on macOS, Linux, and Windows, so the scrub is intentionally platform-agnostic.
  • SSH: the change is limited to daemon-backed local PTY subprocess creation. It does not inject host-local paths into SSH PTYs or change SSH relay env handling.

Validation

  • Regression test fails before the fix with expected '1' to be undefined.
  • pnpm exec vitest run --config config/vitest.config.ts src/main/daemon/pty-subprocess.test.ts
  • pnpm run typecheck:node
  • pnpm exec oxlint src/main/daemon/pty-subprocess.ts src/main/daemon/pty-subprocess.test.ts
  • Live createPtySubprocess harness with parent ELECTRON_RUN_AS_NODE=1 prints ORCA_REPRO:unset from the spawned shell.
  • pnpm test (893 files passed, 1 skipped; 9349 tests passed, 10 skipped)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Terminal sessions inherit ELECTRON_RUN_AS_NODE=1 from the daemon process

2 participants