From 4b21deec1439a5f990cfcdbb46cdac9dadd75fd2 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Fri, 7 Aug 2026 18:51:20 +0200 Subject: [PATCH] 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 --- gui/main.qml | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/gui/main.qml b/gui/main.qml index 2a83f01..31812f4 100644 --- a/gui/main.qml +++ b/gui/main.qml @@ -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