gui: fix scrolling to follow content

Use onContentHeightChanged with a re-entry guard to scroll as content
renders. Works for both initial log load and streaming responses.

- followTail tracks user preference (updated on scroll end)
- scrollingNow prevents recursive positionViewAtEnd calls
This commit is contained in:
Levi Neely 2026-08-07 18:51:20 +02:00
parent cde0284bad
commit 4b21deec14
1 changed files with 8 additions and 12 deletions

View File

@ -467,7 +467,6 @@ ApplicationWindow {
chatModel.trimFront(20)
}
}
// Ensure we have the latest session list
ollie.refreshSessions()
buildSessionTree()
}
@ -476,7 +475,7 @@ ApplicationWindow {
target: ollie
function onActiveSessionIdChanged() {
chatModel.reset()
chatView.shouldAutoScroll = true // Reset scroll state on session switch
chatView.followTail = true
if (ollie.activeSessionId && ollie.activeAgentId) {
var log = ollie.readLogForSession(ollie.activeSessionId, ollie.activeAgentId)
if (log) {
@ -487,7 +486,7 @@ ApplicationWindow {
}
function onActiveAgentIdChanged() {
chatModel.reset()
chatView.shouldAutoScroll = true // Reset scroll state on agent switch
chatView.followTail = true
if (ollie.activeSessionId && ollie.activeAgentId) {
var log = ollie.readLogForSession(ollie.activeSessionId, ollie.activeAgentId)
if (log) {
@ -883,21 +882,18 @@ ApplicationWindow {
boundsBehavior: Flickable.StopAtBounds
visible: ollie.daemonConnected && ollie.activeAgentId !== ""
// Auto-scroll state: true = follow new content, false = user scrolled up
property bool shouldAutoScroll: true
property bool followTail: true
property bool scrollingNow: false
onContentHeightChanged: {
// Content grew — scroll to end if we're following
if (shouldAutoScroll && contentHeight > height) {
if (followTail && !scrollingNow && contentHeight > 0) {
scrollingNow = true
positionViewAtEnd()
scrollingNow = false
}
}
onMovementEnded: {
// User finished scrolling — update auto-scroll based on position
// atYEnd is true when scrolled to bottom
shouldAutoScroll = atYEnd
}
onMovementEnded: followTail = atYEnd
delegate: ChatBlockDelegate {
width: chatView.width - 8