gui: fix session switch — emit signals after agent ID discovery

Signals were emitted before m_agentId was set, causing QML's
onActiveSessionIdChanged handler to call readLog() with an empty
agent path. Now: discover agent → emit signals → start streams.
This commit is contained in:
Levi Neely 2026-07-31 20:30:17 +02:00
parent 1ceeeeb39c
commit 4f1c1f7222
1 changed files with 9 additions and 4 deletions

View File

@ -45,12 +45,14 @@ void Ollie9pClient::setActiveSessionId(const QString &id)
m_activeSessionId = id;
m_agentId.clear();
m_activeState = "idle";
emit activeSessionIdChanged();
emit activeStateChanged();
if (id.isEmpty()) return;
if (id.isEmpty()) {
emit activeSessionIdChanged();
emit activeStateChanged();
return;
}
// Discover agent ID
// Discover agent ID BEFORE emitting signals
QByteArray out = run9p({"ls", "session/" + id + "/agent"});
QString agents = QString::fromUtf8(out).trimmed();
if (!agents.isEmpty()) {
@ -59,6 +61,9 @@ void Ollie9pClient::setActiveSessionId(const QString &id)
m_agentId = "0";
}
emit activeSessionIdChanged();
emit activeStateChanged();
startChatStream();
startStateStream();
}