From 006862a0bb35b2c7ada3a5e1a567edb7ab0afd0d Mon Sep 17 00:00:00 2001 From: 7418 <7418@openclaw.ai> Date: Fri, 13 Mar 2026 01:28:15 +0800 Subject: [PATCH] fix: esbuild compiles JSDoc `node-pty` into `node - pty;` causing startup crash Root cause: esbuild 0.27.3 misparses `node-pty` inside JSDoc comments as a code expression `node - pty` (subtraction). This produces a bare `ReferenceError: node is not defined` at app.asar/dist-electron/main.js:35 on startup. Fixes: - terminal-manager.ts: replace JSDoc block with line comments and remove all literal `node-pty` strings (reference docs/handover instead) - build-electron.mjs: clean dist-electron/ before every build to prevent stale artifact contamination in app.asar Co-Authored-By: Claude Opus 4.6 --- electron/terminal-manager.ts | 27 +++++++++++---------------- scripts/build-electron.mjs | 8 ++++++++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/electron/terminal-manager.ts b/electron/terminal-manager.ts index 6c5264d..c4833d2 100644 --- a/electron/terminal-manager.ts +++ b/electron/terminal-manager.ts @@ -12,21 +12,16 @@ interface TerminalInstance { cwd: string; } -/** - * TerminalManager — manages terminal processes. - * - * KNOWN LIMITATION: Uses child_process.spawn with stdio: 'pipe' instead of - * a real PTY (node-pty). This means: - * - resize() is a no-op (COLUMNS/LINES env vars are set at creation only) - * - Full-screen programs (vim, htop) won't render correctly - * - readline line-editing may behave differently - * - * TODO: Upgrade to node-pty for full PTY support. Requires: - * 1. npm install node-pty - * 2. scripts/after-pack.js: add node-pty to rebuild list - * 3. electron-builder.yml: add "**/node-pty/**" to asarUnpack - * 4. scripts/build-electron.mjs: add node-pty to esbuild externals - */ +// TerminalManager — manages terminal processes. +// +// KNOWN LIMITATION: Uses child_process.spawn with stdio: 'pipe' instead of +// a real PTY. This means: +// - resize() is a no-op (COLUMNS/LINES env vars are set at creation only) +// - Full-screen programs (vim, htop) won't render correctly +// - readline line-editing may behave differently +// +// TODO: Upgrade to a real PTY library for full support. See +// docs/handover/git-terminal-layout.md for the 4-step upgrade path. export class TerminalManager { private terminals = new Map(); private onData: ((id: string, data: string) => void) | null = null; @@ -94,7 +89,7 @@ export class TerminalManager { // eslint-disable-next-line @typescript-eslint/no-unused-vars resize(id: string, _cols: number, _rows: number): void { // With spawn (non-PTY), resize is a no-op. - // Would use pty.resize() with node-pty. + // Would use pty.resize() with a real PTY library. } kill(id: string): void { diff --git a/scripts/build-electron.mjs b/scripts/build-electron.mjs index 61a2a3d..bc9c105 100644 --- a/scripts/build-electron.mjs +++ b/scripts/build-electron.mjs @@ -24,6 +24,14 @@ function resolveStandaloneSymlinks() { } async function buildElectron() { + // Clean dist-electron/ before every build to prevent stale artifacts + // from leaking into app.asar (caused v0.34 crash on upgrade). + if (fs.existsSync('dist-electron')) { + fs.rmSync('dist-electron', { recursive: true }); + console.log('Cleaned dist-electron/'); + } + fs.mkdirSync('dist-electron', { recursive: true }); + const shared = { bundle: true, platform: 'node',