From 379afd81bf964df6ef6edf1cdd399b0f1fe651b8 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Mon, 3 Aug 2026 11:31:02 +0200 Subject: [PATCH] gui: refresh on agent disconnect instead of showing red When an agent connection drops (killed or server restart), refresh the session model from idx rather than immediately marking the session as disconnected. This avoids a transient red indicator when an agent is killed but the session is still alive. The daemon disconnect handler (server down) still correctly marks everything as disconnected. --- gui/ollie9pclient.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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.