Terminal jumps to top when scrolling up during generation
What version of Kimi Code is running?
0.23.1
Which open platform/subscription were you using?
Kimi Code (OAuth)
Which model were you using?
No response
What platform is your computer?
Linux 6.19.14-108.fc42.x86_64 x86_64 unknown (Fedora)
What issue are you seeing?
When generation is in progress, scrolling up slightly in the terminal to view previous messages causes the terminal to jump all the way to the top instead of staying near the intended position.
What steps can reproduce the bug?
- Start a generation that produces multiple terminal messages.
- While the generation is still running, scroll up slightly in the terminal to view previous messages.
- Observe that the terminal jumps all the way to the top instead of staying near the scroll position.
What is the expected behavior?
No response
Additional information
No response
0.23.3 has the same issue too. Fixes from earlier versions didn’t work at all.
0.28.1 has the same issue too.
same issue
Same here, reproducible on our side.
Environment:
- kimi-code v0.31.1
- Windows 11, Git Bash (MINGW64, via Windows Terminal)
- Session in goal mode, which fires continuation turns roughly every 40 s; each turn appends new output
Reproduction:
- Run a session with continuously streaming output (goal mode or any long generation).
- Scroll up with mouse wheel / Shift+PageUp to read earlier content.
- As soon as new output arrives, the viewport jumps — not to the bottom (latest output), but all the way to the top of the session (oldest content). This makes it impossible to read anything older while the session is active.
Expected: the viewport keeps its scroll anchor when the user has scrolled up (new content grows below, out of view); auto-follow only resumes when the user scrolls back to the bottom. Jumping to the oldest content is doubly wrong — even a plain "snap to bottom on new output" would lose less context.
Frequency: 100% reproducible here while output is streaming.
Follow-up from the same session: the symptom has escalated — the viewport now jumps to the top even without any scroll input. While goal mode streams a new turn roughly every 40 s, the view spontaneously re-anchors to the oldest content; the user does not touch wheel/keys at all. So this is not only "scroll position lost on new output" — under continuous output the TUI actively repositions the viewport to the top on its own, making the session effectively unreadable until output stops. Same environment as above (v0.31.1, Windows 11, Git Bash via Windows Terminal).
Thanks for the detailed report — confirming this is still not fixed on the latest version.
Reproduction data:
- Version: 0.33.0 (2026-08-05), default agent-core-v2 engine
- Platform: Linux
- Trigger: While a long response is streaming, scroll up in the transcript to read earlier messages. The viewport jumps away from the current position (to the top of the transcript / back to the newest message) at both stream start and stream end.
Frequency: Reproduces consistently with a long streaming turn.
Note: The 0.22.0 changelog lists "Fix the transcript jumping to the top when scrolling up through history during streaming output" — this scenario appears to have regressed or was never fully fixed.
Happy to attach a debug ZIP (kimi export) if it helps triage.
Confirming this bug on the latest version — and adding a data point: it reproduces in every terminal I've tried on this machine, with the VS Code integrated terminal being the worst offender.
Environment
- OS: Windows 11 Pro, Build 26200 (10.0.26200)
- Kimi Code: 0.42.0
- Node: v24.19.0
- Windows Terminal: 1.24.11911.0
- VS Code: 1.137.0
- Shells tested: PowerShell 5.1.26100.9444, Git Bash (MINGW64, git 2.55.0.windows.4), VS Code integrated terminal
What I'm seeing
Same symptom as the OP: while a task is streaming output, scrolling up with the mouse wheel (or Shift+PageUp) to read earlier messages causes the viewport to jump all the way to the top of the session instead of staying near the intended position.
Additional observations from my side:
- Not terminal-specific. It reproduces in Windows Terminal (PowerShell and Git Bash profiles) and in the VS Code integrated terminal — so this is unlikely to be a quirk of one terminal emulator.
- VS Code integrated terminal triggers it most often. In long sessions with lots of tool output, nearly every scroll-up attempt during generation yanks the view back to the top. External terminals trigger it too, just at a lower probability.
- Severity scales with session length / output rate. Short, quiet sessions are mostly fine; long sessions with frequent streaming turns make the transcript effectively unreadable until generation stops.
Impact
This significantly hurts day-to-day usability: there is no reliable way to review earlier output while the agent is working, which is exactly when you want to check what it just did. Happy to test any fix build or capture logs/recordings if that helps — just let me know what to collect.
Adding another data point — this still reproduces on the latest version, and in our case it happens without any scroll input at all.
Environment
- Kimi Code: 2.3.2 (
kimi --version) - OS: Windows 11 (build 26300), MINGW64 / Git Bash 3.6.3, running inside the Kimi Code desktop harness (bash at
C:\Program Files\Git\bin\bash.exe) - Also observed: Windows Terminal + standalone
kimiCLI sessions on the same machine
Symptom
While the AI is streaming output (long generations, many tool calls, or goal-mode continuation turns), the entire terminal viewport spontaneously jumps to the very top of the scrollback — the scrollbar re-anchors to the oldest content. No wheel/keyboard scroll from the user; the jump is triggered purely by streamed output, with some probability per update rather than every time.
Observations
- Frequency correlates with output volume: long streaming responses and rapid successive tool results make it much more likely.
- Once jumped, the view stays at the top; later streamed output does not pull it back down to the live region, so the user must manually scroll down to see new content.
- The full-redraw path mentioned in #3257 (
CSI 2J/CSI H/CSI 3J) would explain both symptoms: it clears the screen and re-anchors the terminal's scroll position, which terminals expose as "jumped to top".
Happy to capture a terminal recording or debug logs if that helps narrow down which redraw path is taken during streaming.
Sharing a measurement that may help narrow this down: we patched out the ESC[3J in the full-redraw path and it reduces but does not eliminate the jump.
What we changed
pi-tui's full render emits ESC[2J ESC[H ESC[3J when clear is set:
const fullRender = (clear) => {
...
if (clear) {
output.append(this.deleteKittyImages(this.previousKittyImageIds));
output.append("\x1B[2J\x1B[H\x1B[3J");
}
ESC[3J wipes the terminal's scrollback, so anything the user had scrolled up to is destroyed and the viewport lands at the top of what is left — which in regular mode is the top of the session. We removed the ESC[3J (keeping ESC[2J ESC[H), which is the same effect as the requestRender(true, { clearScrollback: false }) change proposed in #2296.
Result
- The "jump to the top of the session" becomes much rarer but still happens occasionally, so there is at least one further cause.
- Multimodal models are unaffected; the patch only touches the redraw path.
Hypotheses we ruled out
We went through the bundle for other reset paths in the primary transcript scroll view and found none:
ScrollView.scrollToStart()(the method that setscurrentScrollTop = 0) has zero callers in the shipped bundle.fitBodyLines()— which doesfollowTail = true; scrollTop = 0— belongs toBtwPanelComponent(the/btwside panel), not the main transcript.viewportTop = 0does not appear at all.
The primary transcript is a ScrollView(content, { follow: "end", primary: true, overscroll: "chain", scrollbar: "auto" }). Its followingEnd flag is correctly cleared when the user scrolls up (scrollTo recomputes nextFollowingEnd = this.followEnd && next === maxScrollTop), so the view does stop following. What we cannot find is what moves the terminal's viewport, as opposed to the app's scroll offset — in regular mode the transcript is painted into the terminal's normal buffer, so the two are easy to confuse.
Questions
- In
regularmode, does the app write the transcript into the terminal's normal buffer whileoverscroll: "chain"also lets the wheel chain to the terminal? If so, a redraw that clears the screen (ESC[2J) and re-homes the cursor would drop the terminal's own scroll position even withoutESC[3J— which would match "less frequent, but still there". - Is there a known path where the transcript's
contentHeightshrinks (a collapsed block being replaced by its summary) and the scroll offset is therefore clamped back to the top?
Environment: kimi-code 2.3.3, Windows Terminal 1.x on WSL2, tui_mode = "regular".
Minimal reproduction on 2.8.1
Environment
- Kimi Code 2.8.1
- Linux x86_64
- Regular TUI mode
@xterm/headless5.5.0
I reproduced the viewport reset through the public TuiMainScreen renderer without involving a model or a specific terminal application.
- Render 30 lines in a 40x10 terminal.
- Scroll the native terminal viewport up by 12 rows. Its
viewportYis 8. - Change line 3 and append line 30 in the next frame.
Actual behavior
The viewport jumps to viewportY=0. The redraw emits ESC[2J ESC[H ESC[3J, so the native scrollback and the user's reading position are lost.
Expected behavior
The native viewport and the text being read stay unchanged. New content can grow below the viewport without forcing auto-follow.
The trigger is the firstChanged < prevViewportTop branch in packages/pi-tui/src/tui-main-screen.ts. It calls fullRender(true) for above-viewport edits, including in-place updates and growing frames that can be handled without clearing scrollback.
I tested a local opt-in patch that handles safe above-viewport changes differentially. Resize, visible shrinks, and Kitty image cases retain the existing full-redraw behavior. The regression test fails before the patch with 0 !== 8 and passes after it. The full pi-tui suite passes with 1273 passed and 2 skipped, and typechecks, repository lint, native build, and native smoke tests pass.