From b68b72b31f7e515e049334121c61aeff16f80c9c Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Sat, 1 Aug 2026 20:13:53 +0200 Subject: [PATCH] fix(gui): use eventwait data directly, remove focus-stealing timer - onEventReadyRead() now parses the eventwait data directly instead of discarding it and re-reading session/idx - Removed the 2-second refresh timer that was stealing focus from the prompt text area on every tick --- gui/main.qml | 11 ----------- gui/ollie9pclient.cpp | 28 ++++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/gui/main.qml b/gui/main.qml index 34959c7..f7761f7 100644 --- a/gui/main.qml +++ b/gui/main.qml @@ -90,17 +90,6 @@ ApplicationWindow { onTriggered: chatView.positionViewAtEnd() } - // Periodic session list refresh — fallback for missed events - Timer { - id: refreshTimer - interval: 2000 - repeat: true - running: true - onTriggered: { - ollie.refreshSessions() - } - } - // Session ID to kill — set on right-click, consumed by context menu property string killTargetSessionId: "" diff --git a/gui/ollie9pclient.cpp b/gui/ollie9pclient.cpp index 5b1039e..3f76bfb 100644 --- a/gui/ollie9pclient.cpp +++ b/gui/ollie9pclient.cpp @@ -536,10 +536,30 @@ void Ollie9pClient::startEventStream() void Ollie9pClient::onEventReadyRead() { - // Consume the data to prevent readyRead from firing again - m_eventProc->readAllStandardOutput(); - // Session index changed (create/delete/rename). Refresh. - refreshSessions(); + // eventwait returned the full session index — use it directly + QByteArray data = m_eventProc->readAllStandardOutput(); + QString raw = QString::fromUtf8(data).trimmed(); + + m_sessions.clear(); + if (!raw.isEmpty()) { + for (const QString &line : raw.split('\n')) { + QStringList parts = line.split('\t'); + if (parts.size() >= 2) { + QVariantMap session; + session["id"] = parts[0]; + session["state"] = parts[1]; + session["model"] = parts.size() > 2 ? parts[2] : ""; + session["agent"] = parts.size() > 3 ? parts[3] : ""; + m_sessions.append(session); + } + } + } + emit sessionsChanged(); + + // Auto-select first session if none active + if (m_activeSessionId.isEmpty() && !m_sessions.isEmpty()) { + setActiveSessionId(m_sessions.first().toMap()["id"].toString()); + } } void Ollie9pClient::onEventFinished(int, QProcess::ExitStatus)