-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(pi-tui): keep transcript anchored and render scroll input immediately during streaming #3162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@moonshot-ai/pi-tui": patch | ||
| --- | ||
|
|
||
| Fix janky mouse-wheel scrolling during streaming: render scroll input immediately instead of throttling it, and keep the transcript viewport anchored to the same content when it shrinks mid-turn (fold/trim) so the view no longer snaps to the top. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -390,17 +390,17 @@ export class TuiAltScreen extends TuiBase implements ViewportTUI { | |
|
|
||
| scrollBy(lines: number): void { | ||
| this.getPrimaryScrollView().scrollBy(lines); | ||
| this.requestRender(); | ||
| this.requestImmediateRender(); | ||
| } | ||
|
|
||
| scrollToTop(): void { | ||
| this.getPrimaryScrollView().scrollToStart(); | ||
| this.requestRender(); | ||
| this.requestImmediateRender(); | ||
| } | ||
|
|
||
| scrollToBottom(): void { | ||
| this.getPrimaryScrollView().scrollToEnd(); | ||
| this.requestRender(); | ||
| this.requestImmediateRender(); | ||
| } | ||
|
|
||
| private scrollToPrompt(direction: -1 | 1): void { | ||
|
|
@@ -412,7 +412,7 @@ export class TuiAltScreen extends TuiBase implements ViewportTUI { | |
| for (let row = scrollView.scrollTop + direction; row >= 0 && row < lines.length; row += direction) { | ||
| if (!OSC133_PROMPT_START.test(lines[row] ?? "")) continue; | ||
| scrollView.scrollTo(row); | ||
| this.requestRender(); | ||
| this.requestImmediateRender(); | ||
| return; | ||
| } | ||
| } | ||
|
|
@@ -678,7 +678,7 @@ export class TuiAltScreen extends TuiBase implements ViewportTUI { | |
| const primary = this.getPrimaryScrollView(); | ||
| if (remaining !== 0 && !seen.has(primary)) primary.scrollBy(remaining); | ||
| this.updateScrollbarHover(event.x, event.y); | ||
| this.requestRender(); | ||
| this.requestImmediateRender(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This changes vendored scrolling behavior, but the package's exhaustive local-divergence list was not updated and the added test covers only height anchoring, not the immediate wheel-render path here. Existing alt-screen tests merely wait for an eventual render, so reverting these calls to throttled AGENTS.md reference: packages/pi-tui/AGENTS.md:L3-L7 Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| private parseSgrMouseEvent(data: string): SgrMouseEvent | undefined { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a reader has scrolled into an older turn,
mergeCurrentTurnSteps()can fold the active turn at the bottom, entirely below the viewport.updateLayout()receives only the total height, so subtracting every decrease fromcurrentScrollToptreats that bottom-only shrink as rows removed above and jumps the reader upward byshrink; the same problem occurs whenever a component below the viewport reflows shorter. Preserve the offset unless removal is known to be above a tracked anchor, or pass positional anchor information into this update.Useful? React with 👍 / 👎.