I have a working fix here, but not super confident of it as I can't tell if it has subtle side effects on other tui things. Opus issue summary below + Video repro
Issue Summary
Problem:
When the user suspends pi with Ctrl+Z, resizes the terminal, then resumes with fg, the TUI renders with the old (pre-suspend) dimensions instead of the new terminal size.
Root Cause:
- When process is suspended (SIGTSTP), Node.js cannot receive signals
- SIGWINCH (window change signal) sent by OS during resize is lost
- On resume,
process.stdout.columns and process.stdout.rows still hold stale values
- TUI renders with wrong dimensions, causing display corruption
Fix (two parts):
-
terminal.ts: In ProcessTerminal.start(), send SIGWINCH to ourselves to refresh cached dimensions:
process.kill(process.pid, "SIGWINCH");
-
tui.ts: Add forceClear flag to ensure screen is cleared on resume even when previousWidth is reset to 0:
requestRender(true) sets forceClear = true
doRender() checks needsClear = widthChanged || forceClear and clears screen if true