mirror of
https://github.com/patriceckhart/zot.git
synced 2026-06-26 21:36:31 +02:00
tui: reset auto-follow baseline on new turn to stop viewport jump
startTurnWithImages clears the previous turn's tool-call overlay and pins scrollOffset to 0. Without also resetting prevChatLen/prevChatCols, the auto-follow guard on the next render sees a synthetic negative delta equal to the number of overlay rows that were cleared, and nudges scrollOffset by that amount. On terminals that mirror zot's chat-pane scroll into their native scrollbar this is visible as a viewport jump the instant the user presses enter on a follow-up prompt. Zero them out in the same locked block so the guard short-circuits on the very next render, the same way it already does on column resize. The legitimate "user scrolled up while content streams in" case is unaffected because prevChatLen is repopulated on that first post-submit render.
This commit is contained in:
parent
1030ae584d
commit
43da5e5249
1 changed files with 11 additions and 1 deletions
|
|
@ -3167,7 +3167,17 @@ func (i *Interactive) startTurnWithImages(parent context.Context, prompt string,
|
|||
i.toolCalls = map[string]*tui.ToolCallView{}
|
||||
i.toolOrder = nil
|
||||
i.scrollOffset = 0 // jump back to the bottom on new turn
|
||||
i.parkedTurn = 0 // starting a turn clears the /jump parked state
|
||||
// Reset the auto-follow baseline so the very next render at
|
||||
// interactive.go:1053 doesn't see a synthetic shrink between
|
||||
// "last frame had the previous turn's tool overlay" and
|
||||
// "this frame had it cleared above". Without this, the guard
|
||||
// reads delta = -(rows in cleared overlay) and decrements
|
||||
// scrollOffset, which on terminals that mirror zot's pane
|
||||
// scroll into the host scrollbar visibly yanks the viewport.
|
||||
// See autofollow_shrink_test.go for the exact arithmetic.
|
||||
i.prevChatLen = 0
|
||||
i.prevChatCols = 0
|
||||
i.parkedTurn = 0 // starting a turn clears the /jump parked state
|
||||
i.parkedTotal = 0
|
||||
i.helpBlock = nil // hide the help block once the user asks something
|
||||
i.mu.Unlock()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue