gui: update eventwait to use new global /eventwait with structured events

- Changed path from session/eventwait to /eventwait (global, not per-session)
- Use ollie-9p instead of plan9port 9p for the read
- Changed from parsing full session index to just calling refreshSessions()
  on any event (the event format is now structured deltas, but the GUI
  is kept simple with a full index refresh)
This commit is contained in:
Levi Neely 2026-08-02 10:25:10 +02:00
parent cd7bb9e272
commit bfac41b2ae
1 changed files with 14 additions and 31 deletions

View File

@ -523,42 +523,25 @@ void Ollie9pClient::startEventStream()
connect(m_eventProc, &QProcess::readyReadStandardOutput, this, &Ollie9pClient::onEventReadyRead);
connect(m_eventProc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, &Ollie9pClient::onEventFinished);
m_eventProc->start(ninepBin(), {"-a", serverAddr(), "read", "session/eventwait"});
m_eventProc->start(ollie9pBin(), {"-a", serverAddr(), "read", "eventwait"});
}
void Ollie9pClient::onEventReadyRead()
{
// eventwait returned the full session index — use it directly
QByteArray data = m_eventProc->readAllStandardOutput();
// Don't trim — trailing tabs are significant fields
QString raw = QString::fromUtf8(data);
QByteArray data = m_eventProc->readAllStandardOutput();
QString raw = QString::fromUtf8(data);
if (raw.isEmpty()) return;
m_sessions.clear();
QSet<QString> seen;
if (!raw.isEmpty()) {
for (const QString &line : raw.split('\n', Qt::SkipEmptyParts)) {
QStringList parts = line.split('\t');
// Skip lines where the first field (session name) is empty
if (parts.isEmpty() || parts[0].isEmpty()) continue;
QString sid = parts[0];
if (seen.contains(sid)) continue; // already added (multi-agent)
seen.insert(sid);
QVariantMap session;
session["id"] = sid;
session["state"] = parts.size() > 1 ? parts[1] : "";
session["cwd"] = parts.size() > 2 ? parts[2] : "";
session["backend"] = parts.size() > 3 ? parts[3] : "";
session["model"] = parts.size() > 4 ? parts[4] : "";
session["agent"] = parts.size() > 5 ? parts[5] : "";
m_sessions.append(session);
}
}
emit sessionsChanged();
// Auto-select first session if none active
if (m_activeSessionId.isEmpty() && !m_sessions.isEmpty()) {
setActiveSessionId(m_sessions.first().toMap()["id"].toString());
}
// Events come as lines: "<scope> <action> <path>"
// S new session/{name}
// A new session/{name}/agent/{aid}
// S kill session/{name}
// A kill session/{name}/agent/{aid}
// S rename session/{old} session/{new}
// A rename session/{name}/agent/{old} session/{name}/agent/{new}
//
// For simplicity, refresh the full session index on any event.
refreshSessions();
}
void Ollie9pClient::onEventFinished(int, QProcess::ExitStatus)