gui: stop state stream when session is killed; don't restart if session gone
This commit is contained in:
parent
363b2e95ed
commit
374349622e
|
|
@ -163,6 +163,12 @@ bool Ollie9pClient::kill()
|
|||
bool Ollie9pClient::killSession(const QString &sessionId)
|
||||
{
|
||||
if (sessionId.isEmpty()) return false;
|
||||
|
||||
// If killing the active session, shut down its streams first
|
||||
if (sessionId == m_activeSessionId) {
|
||||
stopStreams();
|
||||
}
|
||||
|
||||
QString path = "session/" + sessionId + "/ctl";
|
||||
QProcess proc;
|
||||
proc.start(ninepBin(), {"-a", serverAddr(), "write", path});
|
||||
|
|
@ -396,15 +402,21 @@ void Ollie9pClient::startChatStream()
|
|||
void Ollie9pClient::startStateStream()
|
||||
{
|
||||
if (m_stateProc) return;
|
||||
|
||||
// Check if session still exists before starting
|
||||
if (m_activeSessionId.isEmpty()) return;
|
||||
|
||||
// Re-discover agent ID — directory may have been renamed
|
||||
QByteArray out = run9p({"ls", "session/" + m_activeSessionId + "/agent"});
|
||||
QString agents = QString::fromUtf8(out).trimmed();
|
||||
if (!agents.isEmpty()) {
|
||||
QString newId = agents.split('\n').first().trimmed();
|
||||
if (newId != m_agentId) {
|
||||
m_agentId = newId;
|
||||
emit activeAgentIdChanged();
|
||||
}
|
||||
if (agents.isEmpty()) {
|
||||
// Session or agent directory gone — don't start
|
||||
return;
|
||||
}
|
||||
QString newId = agents.split('\n').first().trimmed();
|
||||
if (newId != m_agentId) {
|
||||
m_agentId = newId;
|
||||
emit activeAgentIdChanged();
|
||||
}
|
||||
|
||||
m_stateProc = new QProcess(this);
|
||||
|
|
|
|||
Reference in New Issue