The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): a node-pty layout without its macOS spawn-helper is an incomplete native tree
kshitijk4poor1f6d8b6ba84f
diff --git a/apps/desktop/scripts/stage-native-deps.mjs b/apps/desktop/scripts/stage-native-deps.mjsindex a018923fb61..34cb4929892 100644--- a/apps/desktop/scripts/stage-native-deps.mjs+++ b/apps/desktop/scripts/stage-native-deps.mjs@@ -741,7 +741,20 @@ export function nativeTreeComplete(out, platform, arch) {if (native && ['darwin', 'linux', 'win32'].includes(platform)) {required.push(hudModifierBinaryRelativePath(platform, arch))}- return required.every(relative => existsSync(join(out, relative)))+ return required.every(relative => existsSync(join(out, relative))) && nodePtyComplete(join(out, 'node-pty'), platform)+}++// node-pty loads pty.node from the first of these that has one (lib/utils.js loadNativeModule), and+// on macOS spawns through the spawn-helper beside it (lib/unixTerminal.js): a layout with the+// binding but not the helper loads fine and fails on the first terminal.+function nodePtyComplete(pty, platform) {+ const layout = ['build/Release', 'build/Debug', ...readdirSafe(join(pty, 'prebuilds')).map(name => `prebuilds/${name}`)]+ .find(dir => existsSync(join(pty, dir, 'pty.node')))+ return !!layout && (platform !== 'darwin' || existsSync(join(pty, layout, 'spawn-helper')))+}++function readdirSafe(dir) {+ try { return readdirSync(dir).sort() } catch { return [] }}/**diff --git a/apps/desktop/scripts/stage-native-deps.test.mjs b/apps/desktop/scripts/stage-native-deps.test.mjsindex ca94fad871e..3a2b475f5ad 100644--- a/apps/desktop/scripts/stage-native-deps.test.mjs+++ b/apps/desktop/scripts/stage-native-deps.test.mjs@@ -718,9 +718,12 @@ test('a native tree missing a piece this host could stage is incomplete; unfixabconst tmp = fs.mkdtempSync(join(os.tmpdir(), 'native-complete-'))const put = relative => { fs.mkdirSync(path.dirname(join(tmp, relative)), { recursive: true }); fs.writeFileSync(join(tmp, relative), '') }try {+ // Without a loadable node-pty binding no target is complete.+ put('get-windows/lib/windows.js')+ assert.equal(nativeTreeComplete(tmp, 'win32', 'arm64'), false)+ put('node-pty/prebuilds/any-target/pty.node')// A cross-target pack (here: win32 packed off Windows) never builds the HUD helper.const crossWin = (arch) => nativeTreeComplete(tmp, 'win32', arch)- put('get-windows/lib/windows.js')if (process.platform !== 'win32') {assert.equal(crossWin('x64'), false) // x64 can still get its prebuilt bindingassert.equal(crossWin('arm64'), true) // arm64 has no prebuild: nothing a host fix adds@@ -732,6 +735,15 @@ test('a native tree missing a piece this host could stage is incomplete; unfixabput('get-windows/main')assert.equal(nativeTreeComplete(tmp, 'darwin', process.arch), false) // HUD helper did not buildput('native/darwin-universal/hud-modifier-monitor')+ // node-pty's binding without the spawn-helper beside it fails on the first terminal.+ assert.equal(nativeTreeComplete(tmp, 'darwin', process.arch), false)+ put('node-pty/prebuilds/any-target/spawn-helper')+ assert.equal(nativeTreeComplete(tmp, 'darwin', process.arch), true)+ // A locally built binding wins over the prebuild (node-pty's own search order), so its+ // directory must carry the helper too.+ put('node-pty/build/Release/pty.node')+ assert.equal(nativeTreeComplete(tmp, 'darwin', process.arch), false)+ put('node-pty/build/Release/spawn-helper')assert.equal(nativeTreeComplete(tmp, 'darwin', process.arch), true)}if (process.platform === 'linux') {