gui: remove per-agent statewait stream, use server event bus

The server event stream already delivers state change events for all
agents. Removed the redundant per-agent statewait streamer - now agent
switching has no teardown/startup overhead for state monitoring.

- Removed m_state streamer entirely
- State updates come via event stream's session.{sid}.agent.{aid}.state events
- Only chat stream needs per-agent setup/teardown
This commit is contained in:
Levi Neely 2026-10-06 12:11:14 +02:00
parent f86c8d3cdc
commit 021436bfbf
3 changed files with 5 additions and 20 deletions

View File

@ -11,7 +11,7 @@
* NativeStreamer - Streaming file reader using ollie-9p subprocess.
*
* Uses ollie-9p subprocess for streaming reads (blocking wait files like
* chat, statewait, event). The native library is used for request/response
* chat, event). The native library is used for request/response
* operations, but subprocess is needed for streaming because:
* - Blocking reads in Go can't be interrupted by closing the fid
* - Subprocess can be killed cleanly

View File

@ -25,21 +25,9 @@ Ollie9pClient::Ollie9pClient(QObject *parent)
emit chatReceived(QString::fromUtf8(data));
});
// State stream — guarded, reads agent statewait. Auto-restarts until
// session/agent is deselected or daemon disconnects (guard returns false).
m_state = new Lib9pStreamer(Lib9pStreamer::Guarded, this);
m_state->setGuard([this]() {
return m_daemonConnected && !m_activeSessionId.isEmpty() && !m_agentId.isEmpty();
});
connect(m_state, &Lib9pStreamer::dataReady, this, [this](const QByteArray &data) {
QString state = QString::fromUtf8(data).trimmed();
if (!state.isEmpty()) {
m_activeState = state;
emit activeStateChanged();
}
});
// Event stream — looping, reads server event for session/agent events.
// This single stream handles all state changes across all agents — no
// teardown/startup overhead on agent switch.
m_event = new Lib9pStreamer(Lib9pStreamer::Looping, this);
connect(m_event, &Lib9pStreamer::dataReady, this, [this](const QByteArray &data) {
// Events may come in batches separated by newlines
@ -829,7 +817,6 @@ void Ollie9pClient::startActiveAgentStreams()
if (m_activeSessionId.isEmpty() || m_agentId.isEmpty()) return;
m_chat->start(agentPath() + "/chat.raw");
m_state->start(agentPath() + "/statewait");
// Check for pending bypass request on this session
checkPendingBypass();
@ -861,7 +848,6 @@ void Ollie9pClient::checkPendingBypass()
void Ollie9pClient::stopAgentStreams()
{
if (m_chat) m_chat->stop();
if (m_state) m_state->stop();
}
void Ollie9pClient::stopStreams()

View File

@ -12,7 +12,7 @@
#include "lib9pstreamer.h"
// 9P-based client for ollie. Uses native libollie9p for all operations.
// Streaming files (chat, statewait, event) use Lib9pStreamer threads.
// Streaming files (chat, event) use Lib9pStreamer threads.
class Ollie9pClient : public QObject
{
Q_OBJECT
@ -149,8 +149,7 @@ private:
// Native streaming readers
Lib9pStreamer *m_chat = nullptr; // Guarded — reads agent chat log
Lib9pStreamer *m_state = nullptr; // Guarded — reads agent statewait
Lib9pStreamer *m_event = nullptr; // Looping — reads server event
Lib9pStreamer *m_event = nullptr; // Looping — reads server event (includes state changes)
};
#endif // OLLIE9PCLIENT_H