diff --git a/gui/main.qml b/gui/main.qml index f952671..3d9a27c 100644 --- a/gui/main.qml +++ b/gui/main.qml @@ -210,7 +210,19 @@ ApplicationWindow { target: ollie function onActiveSessionIdChanged() { chatModel.reset() - if (ollie.activeAgentId) { + if (ollie.activeSessionId && ollie.activeAgentId) { + var log = ollie.readLogForSession(ollie.activeSessionId, ollie.activeAgentId) + if (log) { + chatModel.appendData(log) + chatModel.trimFront(20) + } + } + scrollTimer.start() + buildSessionTree() + } + function onActiveAgentIdChanged() { + chatModel.reset() + if (ollie.activeSessionId && ollie.activeAgentId) { var log = ollie.readLogForSession(ollie.activeSessionId, ollie.activeAgentId) if (log) { chatModel.appendData(log) @@ -218,7 +230,6 @@ ApplicationWindow { } } scrollTimer.start() - // Expand the active session in the tree buildSessionTree() } function onStreamingDone() { diff --git a/gui/ollie9pclient.cpp b/gui/ollie9pclient.cpp index 7df9d43..5490009 100644 --- a/gui/ollie9pclient.cpp +++ b/gui/ollie9pclient.cpp @@ -62,25 +62,9 @@ void Ollie9pClient::setActiveSessionId(const QString &id) return; } - // Discover agents. If exactly one, use it automatically (backward compat). - QStringList agents = getAgents(id); - if (agents.size() == 1) { - m_agentId = agents.first(); - - QByteArray stateOut = run9p({"read", agentPath() + "/state"}); - QString stateStr = QString::fromUtf8(stateOut).trimmed(); - if (!stateStr.isEmpty()) - m_activeState = stateStr; - } - emit activeSessionIdChanged(); emit activeAgentIdChanged(); emit activeStateChanged(); - - if (!m_agentId.isEmpty()) { - startChatStream(); - startStateStream(); - } } void Ollie9pClient::refreshSessions() @@ -453,17 +437,10 @@ void Ollie9pClient::startStateStream() // Check if session still exists before starting if (m_activeSessionId.isEmpty() || m_agentId.isEmpty()) return; - // Verify the current agent directory still exists + // The active agent must be explicitly selected. Do not re-resolve + // or auto-fallback here; just stop if the selection is no longer valid. QStringList agents = getAgents(m_activeSessionId); - if (agents.isEmpty()) { - // Session or agent directory gone — don't start - return; - } - if (!agents.contains(m_agentId)) { - // Current agent no longer exists — fall back to first available - m_agentId = agents.first(); - emit activeAgentIdChanged(); - } + if (agents.isEmpty() || !agents.contains(m_agentId)) return; m_stateProc = new QProcess(this); connect(m_stateProc, &QProcess::readyReadStandardOutput, this, &Ollie9pClient::onStateReadyRead);