From 95d6da75f66fbf5459a55c180ed4e61ae214331c Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Sat, 1 Aug 2026 10:23:24 +0200 Subject: [PATCH] fix scroll: use named Timer instead of Timer.singleShot (scope issue) --- gui/main.qml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/gui/main.qml b/gui/main.qml index 6bbb14f..cbc2164 100644 --- a/gui/main.qml +++ b/gui/main.qml @@ -59,12 +59,21 @@ ApplicationWindow { palette.disabled.light: theme.lightColor palette.disabled.shadow: theme.shadowColor + // Deferred scroll timer — fires once after model changes settle + Timer { + id: scrollTimer + interval: 0 + repeat: false + onTriggered: chatView.positionViewAtEnd() + } + Component.onCompleted: { var log = ollie.readLog() if (log) { chatModel.appendData(log) chatModel.trimFront(30) } + scrollTimer.start() } Connections { @@ -76,6 +85,7 @@ ApplicationWindow { chatModel.appendData(log) chatModel.trimFront(30) } + scrollTimer.start() } function onStreamingDone() { chatModel.appendData("\n[info]\nsession ended\n") @@ -313,23 +323,15 @@ ApplicationWindow { boundsBehavior: Flickable.StopAtBounds onCountChanged: { - if (count > 0) { - var idx = count - 1 - Timer.singleShot(0, function() { - positionViewAtIndex(idx, ListView.End) - }) - } + if (count > 0) + scrollTimer.start() } Connections { target: chatModel function onDataChanged() { - if (chatView.atYEnd && chatView.count > 0) { - var idx = chatView.count - 1 - Timer.singleShot(0, function() { - chatView.positionViewAtIndex(idx, ListView.End) - }) - } + if (chatView.atYEnd && chatView.count > 0) + scrollTimer.start() } }