Skip to content

core: resume at the terminal size set while suspended - #2181

Merged
simonklee merged 4 commits into
mainfrom
fix/gh-2158-resume-size
Nov 20, 2026
Merged

simonklee merged 4 commits into
mainfrom
fix/gh-2158-resume-size

Conversation

@simonklee

Copy link
Copy Markdown
Member

A TUI suspended with Ctrl+Z came back after fg at the size it was suspended at when the terminal was resized in
between. A smaller terminal got a broken frame, and on the main screen a taller one lost the shell's last lines under
the first frame. While the job is stopped the shell owns the terminal, so the process gets no SIGWINCH, and fg sends
only SIGCONT. Bun and Node also keep the old process.stdout size until it is refreshed.

resume() now refreshes the size and applies it before the terminal is set up again, so the first frame, the
reserved main-screen rows and the split footer all use it. A size the app set while suspended still wins if the
terminal did not resize. Rust's Host now reads the size before resuming too.

Tested in existing renderer and split-footer suites and in a real pty.

Reported by @bew. Fixes #2158

A process stopped with Ctrl+Z gets no SIGWINCH while its shell owns the
terminal, and fg sends only SIGCONT. resume() never read the size again,
so the renderer came back at the size it was suspended at, and a smaller
terminal got a frame too wide and too tall for it. Bun and Node also keep
the old stdout size until something calls _refreshSize().

resume() now refreshes the process stdout size and applies it before the
first frame. The added lines read that size: nothing else reaches it.

Fixes #2158
The size taken on resume applied after native resume had already set
the terminal up for the old one. On the main screen it reserved rows for
the old height, so a taller resumed frame overwrote the shell's last
lines; in a split footer, output captured while suspended went out under
a first frame at the old width. It also replaced a size the app had set
while suspended with the unchanged terminal size.

resume() now applies the terminal's new size, or else the size requested
while suspended, before the native resume, and only when the terminal
size actually changed. The line that applied a pending size in
finishResume() never ran: the transition was still in flight there.
Host::release() read the terminal size only after the session had
resumed. Native resume reserves main-screen rows for the renderer's
height, so after a resize while released or stopped it reserved rows for
the old height: on a terminal grown from 30 to 40 rows it reserved 29
and the first frame overwrote the shell's last 10 lines. It now reads
and applies the size before the session resumes, as Core does.
Applying the size requested while suspended at resume skipped two things
the normal resize path does. A size the session rejects, such as 0x0,
threw out of resume() and left the renderer suspended; it is now
reported and dropped, and resume continues at the last accepted size.
The flag that marks a pending size as a change stayed set, so a later
request for the same size forced a full repaint; it is now cleared with
the pending size.
@simonklee
simonklee requested a review from kommander as a code owner November 20, 2026 11:17
@simonklee
simonklee merged commit 6651ac9 into main Nov 20, 2026
22 checks passed
@simonklee
simonklee deleted the fix/gh-2158-resume-size branch November 20, 2026 11:43
simonklee added a commit that referenced this pull request Nov 26, 2026
Two models could not reach the Markdown list crash (#2199) or the stale
size after resume (#2181). Each now generates the input its bug needed
and finds the bug with the fix reverted. Builds on the duplicated code
block fix, which the new input found; merge that first.
The Markdown model switches `renderBlock` between four renderers, two of
which take over code blocks; it finds #2199 at seed 985. P7 and P8 now
also skip a line starting with "```" whose info string holds a backtick:
CommonMark makes that no fence, so the run may still close as a code
span while streaming.
The session simulation resizes the terminal while suspended, without a
SIGWINCH, and checks the resumed renderer's size; 31 of 170 rows fail
without the #2181 fix.
CI time grows by about 0.2 s.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(core): a resize that happens while suspended is lost, so the TUI keeps the old dimensions after fg

1 participant