fix: fix PTY test failures — stdin double-processing, raw mode exit hang, fixture JSX

Three runtime bugs and fixture issues fixed:

1. stdin registered both "readable" and "data" handlers, causing double input
   processing in real PTY. Now only uses "data" handler (works for both real
   TTY and fake PassThrough streams).

2. dispose() didn't call stdin.unref() after restoring raw mode, keeping the
   event loop alive and causing raw mode exit tests to hang.

3. PTY fixtures used JSX syntax which tsx compiles without vue-jsx plugin,
   producing non-function slot values. Converted to h() with function slots.

Also: term.ts now passes rows arg to node-pty for viewport-dependent tests,
and exit-double-raw-mode fixture uses __READY__ protocol.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yunfei He
2026-05-27 01:28:29 +08:00
parent 8befc0d0de
commit d8dde1438d
12 changed files with 83 additions and 84 deletions
+1 -1
View File
@@ -882,7 +882,6 @@ function createStdinController(
if (typeof stdin.ref === "function") stdin.ref();
if (typeof (stdin as any).setEncoding === "function") (stdin as any).setEncoding("utf8");
appCtx.setRawMode(true);
stdin.on("readable", handleReadable);
stdin.on("data", handleData);
}
state.refs++;
@@ -939,6 +938,7 @@ function createStdinController(
if (state.refs === 0 && state.prevRaw !== null) {
appCtx.setRawMode(state.prevRaw);
state.prevRaw = null;
if (typeof stdin.unref === "function") stdin.unref();
inputParser.reset();
}
}