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:
parent
f86c8d3cdc
commit
021436bfbf
|
|
@ -11,7 +11,7 @@
|
||||||
* NativeStreamer - Streaming file reader using ollie-9p subprocess.
|
* NativeStreamer - Streaming file reader using ollie-9p subprocess.
|
||||||
*
|
*
|
||||||
* Uses ollie-9p subprocess for streaming reads (blocking wait files like
|
* 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:
|
* operations, but subprocess is needed for streaming because:
|
||||||
* - Blocking reads in Go can't be interrupted by closing the fid
|
* - Blocking reads in Go can't be interrupted by closing the fid
|
||||||
* - Subprocess can be killed cleanly
|
* - Subprocess can be killed cleanly
|
||||||
|
|
|
||||||
|
|
@ -25,21 +25,9 @@ Ollie9pClient::Ollie9pClient(QObject *parent)
|
||||||
emit chatReceived(QString::fromUtf8(data));
|
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.
|
// 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);
|
m_event = new Lib9pStreamer(Lib9pStreamer::Looping, this);
|
||||||
connect(m_event, &Lib9pStreamer::dataReady, this, [this](const QByteArray &data) {
|
connect(m_event, &Lib9pStreamer::dataReady, this, [this](const QByteArray &data) {
|
||||||
// Events may come in batches separated by newlines
|
// Events may come in batches separated by newlines
|
||||||
|
|
@ -829,7 +817,6 @@ void Ollie9pClient::startActiveAgentStreams()
|
||||||
if (m_activeSessionId.isEmpty() || m_agentId.isEmpty()) return;
|
if (m_activeSessionId.isEmpty() || m_agentId.isEmpty()) return;
|
||||||
|
|
||||||
m_chat->start(agentPath() + "/chat.raw");
|
m_chat->start(agentPath() + "/chat.raw");
|
||||||
m_state->start(agentPath() + "/statewait");
|
|
||||||
|
|
||||||
// Check for pending bypass request on this session
|
// Check for pending bypass request on this session
|
||||||
checkPendingBypass();
|
checkPendingBypass();
|
||||||
|
|
@ -861,7 +848,6 @@ void Ollie9pClient::checkPendingBypass()
|
||||||
void Ollie9pClient::stopAgentStreams()
|
void Ollie9pClient::stopAgentStreams()
|
||||||
{
|
{
|
||||||
if (m_chat) m_chat->stop();
|
if (m_chat) m_chat->stop();
|
||||||
if (m_state) m_state->stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ollie9pClient::stopStreams()
|
void Ollie9pClient::stopStreams()
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
#include "lib9pstreamer.h"
|
#include "lib9pstreamer.h"
|
||||||
|
|
||||||
// 9P-based client for ollie. Uses native libollie9p for all operations.
|
// 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
|
class Ollie9pClient : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -149,8 +149,7 @@ private:
|
||||||
|
|
||||||
// Native streaming readers
|
// Native streaming readers
|
||||||
Lib9pStreamer *m_chat = nullptr; // Guarded — reads agent chat log
|
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 (includes state changes)
|
||||||
Lib9pStreamer *m_event = nullptr; // Looping — reads server event
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OLLIE9PCLIENT_H
|
#endif // OLLIE9PCLIENT_H
|
||||||
Loading…
Reference in New Issue