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() } }