diff --git a/gui/ollie9pclient.cpp b/gui/ollie9pclient.cpp index 5490009..28cb7db 100644 --- a/gui/ollie9pclient.cpp +++ b/gui/ollie9pclient.cpp @@ -196,7 +196,12 @@ QStringList Ollie9pClient::getAgents(const QString &sessionId) void Ollie9pClient::setActiveAgentId(const QString &agentId) { + if (m_agentId == agentId) return; + stopStreams(); m_agentId = agentId; + m_activeState = "idle"; + emit activeAgentIdChanged(); + emit activeStateChanged(); } void Ollie9pClient::switchAgent(const QString &sessionId, const QString &agentId) @@ -218,6 +223,7 @@ void Ollie9pClient::switchAgent(const QString &sessionId, const QString &agentId emit activeAgentIdChanged(); emit activeStateChanged(); + // switchAgent is the ONLY path that starts per-agent streams. startChatStream(); startStateStream(); } @@ -504,7 +510,9 @@ void Ollie9pClient::onStateFinished(int, QProcess::ExitStatus) { m_stateProc->deleteLater(); m_stateProc = nullptr; - startStateStream(); + // Reopen only for the current explicit agent selection. + if (!m_activeSessionId.isEmpty() && !m_agentId.isEmpty()) + startStateStream(); } void Ollie9pClient::startEventStream()