diff --git a/src/cli.ts b/src/cli.ts index 10d0060..8dcd2b1 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -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()); }