gui: use rdwr (not write) for session/new and agent/new

This commit is contained in:
Levi Neely 2026-08-01 18:50:19 +02:00
parent 153b40cbc7
commit c4d6f2a1b9
1 changed files with 8 additions and 7 deletions

View File

@ -268,14 +268,14 @@ bool Ollie9pClient::createSession(const QString &cwd, const QString &name, const
{
if (cwd.isEmpty()) return false;
// Step 1: Create the session (name only)
// Step 1: Create the session (name only) using rdwr (write then read back result)
QString sessName = name;
{
QProcess proc;
QStringList args = {"-a", serverAddr(), "write", "session/new"};
QStringList args = {"-a", serverAddr(), "rdwr", "session/new"};
proc.start(ninepBin(), args);
proc.waitForStarted(3000);
QString input = "name=" + sessName;
QString input = "name=" + sessName + "\n";
proc.write(input.toUtf8());
proc.closeWriteChannel();
proc.waitForFinished(5000);
@ -286,13 +286,13 @@ bool Ollie9pClient::createSession(const QString &cwd, const QString &name, const
qDebug() << "createSession (step 1) failed:" << err;
return false;
}
// Read the returned session name (may be auto-generated)
// Read the returned session name (auto-generated if blank)
QByteArray out = proc.readAllStandardOutput().trimmed();
if (!out.isEmpty())
sessName = QString::fromUtf8(out);
}
// Step 2: Create the agent within the session
// Step 2: Create the agent within the session using rdwr
{
QStringList agentArgs;
agentArgs << "cwd=" + cwd;
@ -303,10 +303,11 @@ bool Ollie9pClient::createSession(const QString &cwd, const QString &name, const
if (!agentAlias.isEmpty()) agentArgs << "agent_alias=" + agentAlias;
QProcess proc;
QStringList args = {"-a", serverAddr(), "write", "session/" + sessName + "/agent/new"};
QStringList args = {"-a", serverAddr(), "rdwr", "session/" + sessName + "/agent/new"};
proc.start(ninepBin(), args);
proc.waitForStarted(3000);
proc.write(agentArgs.join(" ").toUtf8());
QString input = agentArgs.join(" ") + "\n";
proc.write(input.toUtf8());
proc.closeWriteChannel();
proc.waitForFinished(5000);