Try out suspension

This commit is contained in:
Jared Miller 2026-01-30 07:33:18 -05:00
parent 9586925234
commit fd9ec777a3
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C

View file

@ -140,6 +140,20 @@ async function main() {
process.on("SIGINT", cleanup);
process.on("SIGTERM", cleanup);
process.on("SIGCONT", () => {
// Restore terminal state after being resumed from suspension
if (process.stdin.isTTY) {
process.stdin.setRawMode(true);
}
process.stdin.resume();
if (pty) {
// Resume child process
process.kill(pty.pid, "SIGCONT");
// Trigger PTY redraw by sending resize
const { cols, rows } = getTerminalSize();
pty.resize(cols, rows);
}
});
// Spawn PTY only after WebSocket connects
const spawnClaude = () => {
@ -160,6 +174,14 @@ async function main() {
// Forward local stdin to PTY
process.stdin.on("data", (data: Buffer) => {
// ctrl+z in raw mode - suspend child and self
if (data.length === 1 && data[0] === 0x1a) {
if (pty) {
process.kill(pty.pid, "SIGTSTP");
}
process.kill(process.pid, "SIGTSTP");
return;
}
if (pty) {
pty.write(data.toString());
}