mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-07-09 17:29:12 +00:00
fix(pi-tui): repaint viewport in place when content collapses above it (#1315)
* fix(pi-tui): repaint viewport in place when content collapses above it When content shrinks past the viewport top while a line above the viewport also changes, the clamped differential path left the render loop empty, cleared deleted lines past the screen bottom, and desynced the cursor anchor — leaving the viewport blank with the input box gone until a full redraw. Repaint the visible viewport in place for that case (no ESC[3J, so the scrollback and the user's scroll position are preserved), and clamp deleted-line clearing to the screen bottom so it can never scroll untracked. * fix(kimi-code): clear the screen fully on session reset The collapse repaint in pi-tui intentionally preserves scrollback, so /new, /clear, and session switches no longer got a clean screen as a side effect of the destructive full redraw — the previous session's text stayed above the welcome banner. Session resets want a pristine screen, so force a destructive full render explicitly instead of relying on the renderer's shrink behavior. * fix(pi-tui): delete kitty images straddling the viewport top on collapse repaint A multi-row kitty image can start above prevViewportTop while its reserved rows are still visible. The collapse repaint's image-delete range started at prevViewportTop and missed the image line carrying the id, leaving a stale overlay that also dropped out of previousKittyImageIds tracking. Widen the range to include such a straddling block. * chore: shorten session reset changeset wording * fix(pi-tui): re-anchor the viewport whenever content shrinks below the screen bottom previousViewportTop only ever grows during normal rendering, so after a shrink the content bottom could hover above the screen bottom, leaving dead rows that nothing repaints. Upstream masked this by frequently doing destructive full redraws, which re-anchored as a side effect; the fork removed those redraws without replacing the re-anchoring. Generalize the collapse repaint into a re-anchor check at the top of the differential path: whenever prevViewportTop exceeds max(0, newLines - height), repaint the visible viewport in place with the tail of the new content. The input area snaps back to the screen bottom, scrollback and the user's scroll position stay intact (no ESC[3J), and the previous collapse branch becomes a defensive destructive fallback. Update the three renderer tests that encoded the old behavior (destructive redraw on shrink, viewport hover after clamped shrink) to assert the re-anchored behavior instead. * fix(kimi-code): full repaint on ctrl+o expansion toggle Expanding tool output shifts content above the viewport; the clamped differential render paints the shifted content through the screen, stacking a duplicate copy below the stale one in scrollback on every toggle. The toggle is a deliberate user action (like /clear), so do a destructive full render instead: scrollback holds exactly one copy and the expanded output stays readable by scrolling up. * chore: simplify user-facing changeset wording
This commit is contained in:
parent
e8ab7ca786
commit
b40bb71399
8 changed files with 362 additions and 18 deletions
5
.changeset/cli-blank-screen-after-shrink.md
Normal file
5
.changeset/cli-blank-screen-after-shrink.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@moonshot-ai/kimi-code": patch
|
||||
---
|
||||
|
||||
Fix TUI rendering bugs that caused the screen to go blank and the input box to disappear.
|
||||
5
.changeset/cli-session-reset-full-clear.md
Normal file
5
.changeset/cli-session-reset-full-clear.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@moonshot-ai/kimi-code": patch
|
||||
---
|
||||
|
||||
Clear the screen fully when starting a new session via /new, /clear, or a session switch.
|
||||
5
.changeset/pi-tui-collapse-repaint.md
Normal file
5
.changeset/pi-tui-collapse-repaint.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@moonshot-ai/pi-tui": patch
|
||||
---
|
||||
|
||||
Re-anchor the viewport with an in-place repaint whenever content shrinks below the screen bottom, and clamp deleted-line clearing to the screen bottom, so large shrinks no longer blank the screen, desync the cursor, or leave the UI hovering above dead rows.
|
||||
Loading…
Add table
Add a link
Reference in a new issue