Revert "gui: verify agent directory before starting statewait/chat streams"

This reverts commit dbbcc07934.
This commit is contained in:
Levi Neely 2026-08-01 20:59:08 +02:00
parent dbbcc07934
commit 9f51a2181b
1 changed files with 14 additions and 31 deletions

View File

@ -437,19 +437,13 @@ void Ollie9pClient::ensureRootDataLoaded()
void Ollie9pClient::startChatStream() void Ollie9pClient::startChatStream()
{ {
if (m_chatProc) return; if (m_chatProc) return;
if (m_activeSessionId.isEmpty() || m_agentId.isEmpty()) return; if (m_activeSessionId.isEmpty() || m_agentId.isEmpty()) return;
m_chatProc = new QProcess(this);
// Verify the agent directory exists before opening a blocking read connect(m_chatProc, &QProcess::readyReadStandardOutput, this, &Ollie9pClient::onChatReadyRead);
QString ap = agentPath(); connect(m_chatProc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
QByteArray verify = run9p({"stat", ap}); this, &Ollie9pClient::onChatFinished);
if (verify.isEmpty()) return; // directory gone m_chatProc->start(ninepBin(), {"-a", serverAddr(), "read", agentPath() + "/chat"});
m_chatProc = new QProcess(this);
connect(m_chatProc, &QProcess::readyReadStandardOutput, this, &Ollie9pClient::onChatReadyRead);
connect(m_chatProc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, &Ollie9pClient::onChatFinished);
m_chatProc->start(ninepBin(), {"-a", serverAddr(), "read", ap + "/chat"});
} }
void Ollie9pClient::startStateStream() void Ollie9pClient::startStateStream()
@ -459,16 +453,6 @@ void Ollie9pClient::startStateStream()
// Check if session still exists before starting // Check if session still exists before starting
if (m_activeSessionId.isEmpty() || m_agentId.isEmpty()) return; if (m_activeSessionId.isEmpty() || m_agentId.isEmpty()) return;
// Verify the agent directory still exists before opening a blocking read
QString ap = agentPath();
QByteArray verify = run9p({"stat", ap});
if (verify.isEmpty()) {
// Directory gone — don't start spamming
m_agentId.clear();
emit activeAgentIdChanged();
return;
}
// Verify the current agent directory still exists // Verify the current agent directory still exists
QStringList agents = getAgents(m_activeSessionId); QStringList agents = getAgents(m_activeSessionId);
if (agents.isEmpty()) { if (agents.isEmpty()) {
@ -481,11 +465,11 @@ void Ollie9pClient::startStateStream()
emit activeAgentIdChanged(); emit activeAgentIdChanged();
} }
m_stateProc = new QProcess(this); m_stateProc = new QProcess(this);
connect(m_stateProc, &QProcess::readyReadStandardOutput, this, &Ollie9pClient::onStateReadyRead); connect(m_stateProc, &QProcess::readyReadStandardOutput, this, &Ollie9pClient::onStateReadyRead);
connect(m_stateProc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), connect(m_stateProc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, &Ollie9pClient::onStateFinished); this, &Ollie9pClient::onStateFinished);
m_stateProc->start(ninepBin(), {"-a", serverAddr(), "read", ap + "/statewait"}); m_stateProc->start(ninepBin(), {"-a", serverAddr(), "read", agentPath() + "/statewait"});
} }
void Ollie9pClient::stopStreams() void Ollie9pClient::stopStreams()
@ -545,9 +529,8 @@ void Ollie9pClient::onStateFinished(int, QProcess::ExitStatus)
{ {
m_stateProc->deleteLater(); m_stateProc->deleteLater();
m_stateProc = nullptr; m_stateProc = nullptr;
// Restart to pick up the next state change — statewait is a blocking // Do NOT restart — statewait is only started when the user
// read that returns once and closes the FD. // explicitly selects an agent via setActiveSessionId or switchAgent.
startStateStream();
} }
void Ollie9pClient::startEventStream() void Ollie9pClient::startEventStream()