Skip to content

fix(tui): preserve native scrollback on terminal resize - #3124

Open
joinmouse wants to merge 1 commit into
MoonshotAI:mainfrom
joinmouse:fix/tui-preserve-scrollback-on-resize
Open

fix(tui): preserve native scrollback on terminal resize#3124
joinmouse wants to merge 1 commit into
MoonshotAI:mainfrom
joinmouse:fix/tui-preserve-scrollback-on-resize

Conversation

@joinmouse

Copy link
Copy Markdown

Related Issue

Related Issue

Fixes #3116

#3116

Problem

Resizing the terminal window could clear the native scrollback buffer and change the user's current scroll position.

This was especially noticeable when the user had scrolled away from the input area: resizing either the terminal width or height could unexpectedly move the
viewport to the top of the conversation.

What changed

  • Preserve native terminal scrollback during terminal resize.
  • Keep height changes on the differential rendering path instead of performing a full redraw.
  • On width changes, clear and redraw only the active viewport rather than clearing scrollback or replaying the entire transcript.
  • Preserve the existing full-redraw behavior for explicit render resets and Kitty image handling.
  • Add regression tests covering:
    • Height changes without clearing scrollback.
    • Width changes without duplicating transcript history.
    • Width changes while the user is manually scrolled away from the prompt.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dc82089

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/pi-tui Patch
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e91eef7dad

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/pi-tui/src/tui-main-screen.ts Outdated
@joinmouse
joinmouse force-pushed the fix/tui-preserve-scrollback-on-resize branch from e91eef7 to 7e7a846 Compare August 20, 2026 09:20
@HelloWorldU

Copy link
Copy Markdown

We should not change current behaviors as it may lead to regression

@joinmouse
joinmouse force-pushed the fix/tui-preserve-scrollback-on-resize branch from 7e7a846 to dc82089 Compare August 21, 2026 09:07
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.

滚动位置问题

2 participants