Skip to content

TUI renders with wrong dimensions after suspend/resume if terminal was resized while suspended #599

@aliou

Description

@aliou

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:

  1. When process is suspended (SIGTSTP), Node.js cannot receive signals
  2. SIGWINCH (window change signal) sent by OS during resize is lost
  3. On resume, process.stdout.columns and process.stdout.rows still hold stale values
  4. TUI renders with wrong dimensions, causing display corruption

Fix (two parts):

  1. terminal.ts: In ProcessTerminal.start(), send SIGWINCH to ourselves to refresh cached dimensions:

    process.kill(process.pid, "SIGWINCH");
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions