diff --git a/gui/ollie9pclient.cpp b/gui/ollie9pclient.cpp index ea39c56..94c0b41 100644 --- a/gui/ollie9pclient.cpp +++ b/gui/ollie9pclient.cpp @@ -189,6 +189,7 @@ void Ollie9pClient::setAgentConnected(const QString &key, bool connected) const bool cached = m_agentConnected.value(key, false); m_agentConnected[key] = connected; bool modelChanged = false; + bool foundInModel = false; // Update the in-memory model without starting another round of probes. for (QVariant &value : m_sessions) { QVariantMap session = value.toMap(); @@ -196,6 +197,7 @@ void Ollie9pClient::setAgentConnected(const QString &key, bool connected) for (QVariant &agentValue : agents) { QVariantMap agent = agentValue.toMap(); if (agentKey(session["id"].toString(), agent["id"].toString()) == key) { + foundInModel = true; if (agent.value("connected").toBool() != connected) modelChanged = true; agent["connected"] = connected; @@ -205,6 +207,9 @@ void Ollie9pClient::setAgentConnected(const QString &key, bool connected) session["agents"] = agents; value = session; } + // Ignore stale disconnects for agents no longer in the model (killed). + if (!foundInModel && !connected) + return; if (cached != connected || modelChanged) emit sessionsChanged(); } @@ -245,7 +250,9 @@ void Ollie9pClient::reconcileAgentConnections() } }); connect(connection, &NinePConnection::disconnected, this, [this, key]() { - setAgentConnected(key, false); + // Agent may have been killed — refresh to get authoritative state + // rather than showing a transient red indicator. + refreshSessions(); }); // Use immutable IDs in path — aliases in the 9P namespace resolve // these to the correct session/agent regardless of display name.