diff --git a/gui/ollie9pclient.cpp b/gui/ollie9pclient.cpp index a42b354..7adc160 100644 --- a/gui/ollie9pclient.cpp +++ b/gui/ollie9pclient.cpp @@ -363,7 +363,11 @@ QString Ollie9pClient::readLog() QString Ollie9pClient::readLogForSession(const QString &sessionId, const QString &agentId) { if (sessionId.isEmpty() || agentId.isEmpty()) return {}; - QByteArray out = run9p({"read", "session/" + sessionId + "/agent/" + agentId + "/log"}); + QString sessName = sessionNameForId(sessionId); + if (sessName.isEmpty()) sessName = sessionId; + QString agentName = agentNameForId(sessionId, agentId); + if (agentName.isEmpty()) agentName = agentId; + QByteArray out = run9p({"read", "session/" + sessName + "/agent/" + agentName + "/log"}); return QString::fromUtf8(out); } @@ -412,7 +416,11 @@ bool Ollie9pClient::killSession(const QString &sessionId) stopStreams(); } - QString path = "session/" + sessionId + "/ctl"; + // Resolve the directory name from the immutable session ID + QString sessName = sessionNameForId(sessionId); + if (sessName.isEmpty()) sessName = sessionId; + + QString path = "session/" + sessName + "/ctl"; QProcess proc; proc.start(ninepBin(), {"-a", serverAddr(), "write", path}); proc.waitForStarted(3000); @@ -432,7 +440,9 @@ QString Ollie9pClient::getConfig() QStringList Ollie9pClient::getAgents(const QString &sessionId) { if (sessionId.isEmpty()) return {}; - QByteArray out = run9p({"ls", "session/" + sessionId + "/agent"}); + QString sessName = sessionNameForId(sessionId); + if (sessName.isEmpty()) sessName = sessionId; + QByteArray out = run9p({"ls", "session/" + sessName + "/agent"}); QString raw = QString::fromUtf8(out).trimmed(); if (raw.isEmpty()) return {}; QStringList all = raw.split('\n', Qt::SkipEmptyParts); @@ -596,9 +606,13 @@ bool Ollie9pClient::renameSession(const QString &sessionId, const QString &newNa // Session names are mutable display names, not directory IDs. Writing the // name file also avoids relying on Twstat, which is not implemented by all // 9P frontends. + // Resolve the directory name from the immutable session ID + QString sessName = sessionNameForId(sessionId); + if (sessName.isEmpty()) sessName = sessionId; + QProcess proc; proc.setProgram(bin); - proc.setArguments({"-a", serverAddr(), "write", "session/" + sessionId + "/name"}); + proc.setArguments({"-a", serverAddr(), "write", "session/" + sessName + "/name"}); proc.start(); if (!proc.waitForStarted(3000)) { qDebug() << "renameSession failed to start:" << proc.errorString(); @@ -649,10 +663,16 @@ bool Ollie9pClient::renameAgent(const QString &sessionId, const QString &agentId if (active) stopAgentStreams(); + // Resolve directory names from immutable IDs + QString sessName = sessionNameForId(sessionId); + if (sessName.isEmpty()) sessName = sessionId; + QString agentName = agentNameForId(sessionId, agentId); + if (agentName.isEmpty()) agentName = agentId; + QProcess proc; proc.setProgram(bin); proc.setArguments({"-a", serverAddr(), "write", - "session/" + sessionId + "/agent/" + agentId + "/name"}); + "session/" + sessName + "/agent/" + agentName + "/name"}); proc.start(); if (!proc.waitForStarted(3000)) { qDebug() << "renameAgent failed to start:" << proc.errorString();