Skip to content

Preserve terminal scrollback when growing the TUI viewport - #45271

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/1dbfc30bb6997dcc2738ec6b2f42d35c786124de
Sep 13, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/1dbfc30bb6997dcc2738ec6b2f42d35c786124de

Conversation

@copyberry

@copyberry copyberry Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

Preserve terminal scrollback when growing the TUI viewport

Why

Scrolling with CSI S can discard history rows in QTermWidget and xterm.js when the viewport grows.

What changed

Use newlines at the bottom of the history scroll region for ScrollbackStrategy::Standard, preserving the composer and restoring the cursor and full-screen scroll region afterward. Fall back to full-screen scrolling when only one history row exists, since DECSTBM requires two distinct rows. Skip scrolling when there are no history rows or no rows to scroll.

Testing

Add regression tests for composer and cursor preservation, scroll-region restoration, emitted newline sequences, single-row scrollback preservation, and no-op growth. Snapshot visible geometry for growth by one, three, and four rows.

## Why

Scrolling with `CSI S` can discard history rows in QTermWidget and xterm.js when the viewport grows.

## What changed

Use newlines at the bottom of the history scroll region for `ScrollbackStrategy::Standard`, preserving the composer and restoring the cursor and full-screen scroll region afterward. Fall back to full-screen scrolling when only one history row exists, since `DECSTBM` requires two distinct rows. Skip scrolling when there are no history rows or no rows to scroll.

## Testing

Add regression tests for composer and cursor preservation, scroll-region restoration, emitted newline sequences, single-row scrollback preservation, and no-op growth. Snapshot visible geometry for growth by one, three, and four rows.

GitOrigin-RevId: 1dbfc30bb6997dcc2738ec6b2f42d35c786124de
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/1dbfc30bb6997dcc2738ec6b2f42d35c786124de branch from 1ffb7cf to 44b9011 Compare September 13, 2026 18:15
@copyberry
copyberry Bot merged commit 44b9011 into main Sep 13, 2026
1 check passed
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/1dbfc30bb6997dcc2738ec6b2f42d35c786124de branch September 13, 2026 18:15
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 13, 2026

This branch was previously deployed

1 inactive deployment
issue-triage — 44b90116 Deployed Sep 13, 2026 by MaddMind via Identify potential duplicates (open issues fallback) #45266
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants