Skip to content

Replay <Static> output when resume re-enters the alternate screen - #1012

Merged
sindresorhus merged 2 commits into
vadimdemedes:masterfrom
costajohnt:fix/resume-replays-static-alt-screen
Sep 21, 2026
Merged

sindresorhus merged 2 commits into
vadimdemedes:masterfrom
costajohnt:fix/resume-replays-static-alt-screen

Conversation

@costajohnt

Copy link
Copy Markdown
Contributor

Fixes #1011. Follow-up to #1005.

endSuspend re-enters the alternate screen and forces a redraw, but the redraw only carries <Static> items new to that frame, so everything rendered before the suspension stays gone until the next full clear. This writes the accumulated static output right after enterAlternativeScreen, the same replay the full-clear path already does on the alternate screen, so the frame lands below the restored rows. The primary screen is unchanged: its static rows survive in scrollback and are never replayed.

One test, for standard and incremental rendering: alternateScreen: true, three static items, one live line, 5 rows, a no-op suspendTerminal(); the terminal reconstructed from the second enterAlternativeScreen on must read S1, S2, S3, live. Fails on master with live alone.

@sindresorhus

Copy link
Copy Markdown
Collaborator

There are two rendering modes this currently gets wrong.

With debug: true, the forced redraw already writes fullStaticOutput + output. Replaying fullStaticOutput when re-entering means every static row is written twice.

With isScreenReaderEnabled: true, fullStaticOutput is never populated because the screen-reader branch returns before the alternate-screen accumulation. I manually reproduced only live after resume, so the original bug still exists in that mode.

…er modes

The debug redraw already writes fullStaticOutput with every frame, so replaying it when re-entering the alternate screen wrote every static row twice. The screen-reader branch returned before the alternate-screen accumulation, so fullStaticOutput stayed empty there and nothing came back after resume. Accumulate in that branch and skip the replay in debug mode.
@sindresorhus
sindresorhus merged commit 9235028 into vadimdemedes:master Sep 21, 2026
2 checks passed
@costajohnt
costajohnt deleted the fix/resume-replays-static-alt-screen branch September 24, 2026 23:54
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.

Resuming from suspend on the alternate screen drops previously rendered <Static> output

2 participants