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 <noreply@anthropic.com>
This commit is contained in:
7418andClaude Opus 4.6 committed 2026-03-13 01:28:15 +08:00
1 parent d2bfa4b523
commit 006862a0bb
2 files changed
+19 -16

No files matched your search

+11 -16
View File
@@ -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<string, TerminalInstance>();
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 {
+8
View File
@@ -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',