Skip to content

Set ELECTRON_RUN_AS_NODE=1 in the --split window command - #46

Open
zenbu-bot[bot] wants to merge 1 commit into
mainfrom
zenbu/issue-36
Open

zenbu-bot[bot] wants to merge 1 commit into
mainfrom
zenbu/issue-36

Conversation

@zenbu-bot

@zenbu-bot zenbu-bot Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Fixes #36

Problem

tode --split right in Ghostty starts the new pane's window process without ELECTRON_RUN_AS_NODE=1. On an x86_64 Mac, Electron Helper then boots Chromium, its GPU process crashes 9 times, and the process exits with code 133 (SIGTRAP).

Cause

windowCommand() in src/launch.ts returns [process.execPath, main.js, "--window", url] and sets no environment. A Ghostty split pane starts with Ghostty's environment, not the caller's. So the export ELECTRON_RUN_AS_NODE=1 in the bin/tode shim does not reach the pane. Without that variable, process.execPath (Electron Helper) starts as a Chromium browser process.

Change

windowCommand() now prefixes the command with /usr/bin/env ELECTRON_RUN_AS_NODE=1. The window process now runs as node in any terminal's split, whatever environment the pane starts with.

Tests

Added test/split-window-env.test.js. It replaces Ghostty with a fake that records the split command, then checks that ELECTRON_RUN_AS_NODE=1 comes before process.execPath. It fails on base and passes with the change. The full suite passes: 129 pass, 0 fail. The demo ran in real Ghostty on an Intel Mac (x86_64). On base, the pane command boots Chromium and exits with code 133. With the change, it runs as node and starts no GPU process.

Evidence

Before:

before.mp4

After:

after.mp4

Test test/split-window-env.test.js before the fix (fails):

---
  duration_ms: 4.171457
  type: 'test'
  location: '/Users/runner/zb/base/test/split-window-env.test.js:27:1'
  failureType: 'testCodeFailure'
  error: 'split command must set ELECTRON_RUN_AS_NODE=1 before /usr/local/Cellar/node@22/22.23.2_1/bin/node, got ["/usr/local/Cellar/node@22/22.23.2_1/bin/node","/Users/runner/zb/base/dist/main.js","--window","http://127.0.0.1:8080/"]'
  code: 'ERR_ASSERTION'
  name: 'AssertionError'
  expected: true
  actual: false
  operator: '=='
  stack: |-
    TestContext.<anonymous> (/Users/runner/zb/base/test/split-window-env.test.js:39:10)
    async Test.run (node:internal/test_runner/test:1054:7)
    async startSubtestAfterBootstrap (node:internal/test_runner/harness:296:3)
  ...
1..1
# tests 1
# suites 0
# pass 0
# fail 1
# cancelled 0
# skipped 0
# todo 0
# duration_ms 342.388123

After (passes):

TAP version 13
# Subtest: --split starts the window process with ELECTRON_RUN_AS_NODE=1
ok 1 - --split starts the window process with ELECTRON_RUN_AS_NODE=1
  ---
  duration_ms: 4.781757
  type: 'test'
  ...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 318.277556
Extra information
Job 41124456218-1
Handler issue.act
Files src/launch.ts, test/split-window-env.test.js
Test command npx tsc -p tsconfig.json > /dev/null; node scripts/write-cjs-boundary.js && node --test "test/*.test.js"
Review Small fix that targets the root cause: the split pane's command now sets ELECTRON_RUN_AS_NODE=1 itself via /usr/bin/env, so it no longer depends on the pane's environment. It works with every terminal backend (quoted or passed as-is), comes with a regression test that fails before and passes after, and the full suite passes. On-hardware Intel Mac confirmation is still outstanding.
Security review This is a small, focused fix: windowCommand now starts the split-pane window process through /usr/bin/env ELECTRON_RUN_AS_NODE=1. The diff also adds one hermetic test that swaps in a fake terminal module; it adds no network, credential, config or install-hook changes.
Sandbox real Mac on GitHub Actions (macos-15-intel: x64, macOS 15.7.9)
Base main@b049d7c
Log GitHub Actions run

@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
tode Ready Ready Preview Oct 30, 2026 9:10pm UTC

Request Review

@zenbu-bot zenbu-bot Bot changed the title Set ELECTRON_RUN_AS_NODE=1 in the --split pane command Set ELECTRON_RUN_AS_NODE=1 in the --split window command Oct 30, 2026

This branch was successfully deployed

1 active deployment
Preview — c22ecb2c Deployed Oct 30, 2026 by vercel[bot]
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.

--split crashes on Intel Mac (windowCommand missing ELECTRON_RUN_AS_NODE)

0 participants