gui: require explicit agent selection for statewait/chat
- setActiveSessionId now selects only the session; it clears m_agentId and never auto-selects a lone agent. - startStateStream no longer re-resolves or falls back to another agent; it only runs when the explicit active agent still exists. - QML now handles activeAgentId changes explicitly and keeps the right pane blank/disabled when no session or no agent is selected.
This commit is contained in:
parent
56b08d8f8f
commit
22e58b348f
15
gui/main.qml
15
gui/main.qml
|
|
@ -210,7 +210,19 @@ ApplicationWindow {
|
|||
target: ollie
|
||||
function onActiveSessionIdChanged() {
|
||||
chatModel.reset()
|
||||
if (ollie.activeAgentId) {
|
||||
if (ollie.activeSessionId && ollie.activeAgentId) {
|
||||
var log = ollie.readLogForSession(ollie.activeSessionId, ollie.activeAgentId)
|
||||
if (log) {
|
||||
chatModel.appendData(log)
|
||||
chatModel.trimFront(20)
|
||||
}
|
||||
}
|
||||
scrollTimer.start()
|
||||
buildSessionTree()
|
||||
}
|
||||
function onActiveAgentIdChanged() {
|
||||
chatModel.reset()
|
||||
if (ollie.activeSessionId && ollie.activeAgentId) {
|
||||
var log = ollie.readLogForSession(ollie.activeSessionId, ollie.activeAgentId)
|
||||
if (log) {
|
||||
chatModel.appendData(log)
|
||||
|
|
@ -218,7 +230,6 @@ ApplicationWindow {
|
|||
}
|
||||
}
|
||||
scrollTimer.start()
|
||||
// Expand the active session in the tree
|
||||
buildSessionTree()
|
||||
}
|
||||
function onStreamingDone() {
|
||||
|
|
|
|||
|
|
@ -62,25 +62,9 @@ void Ollie9pClient::setActiveSessionId(const QString &id)
|
|||
return;
|
||||
}
|
||||
|
||||
// Discover agents. If exactly one, use it automatically (backward compat).
|
||||
QStringList agents = getAgents(id);
|
||||
if (agents.size() == 1) {
|
||||
m_agentId = agents.first();
|
||||
|
||||
QByteArray stateOut = run9p({"read", agentPath() + "/state"});
|
||||
QString stateStr = QString::fromUtf8(stateOut).trimmed();
|
||||
if (!stateStr.isEmpty())
|
||||
m_activeState = stateStr;
|
||||
}
|
||||
|
||||
emit activeSessionIdChanged();
|
||||
emit activeAgentIdChanged();
|
||||
emit activeStateChanged();
|
||||
|
||||
if (!m_agentId.isEmpty()) {
|
||||
startChatStream();
|
||||
startStateStream();
|
||||
}
|
||||
}
|
||||
|
||||
void Ollie9pClient::refreshSessions()
|
||||
|
|
@ -453,17 +437,10 @@ void Ollie9pClient::startStateStream()
|
|||
// Check if session still exists before starting
|
||||
if (m_activeSessionId.isEmpty() || m_agentId.isEmpty()) return;
|
||||
|
||||
// Verify the current agent directory still exists
|
||||
// The active agent must be explicitly selected. Do not re-resolve
|
||||
// or auto-fallback here; just stop if the selection is no longer valid.
|
||||
QStringList agents = getAgents(m_activeSessionId);
|
||||
if (agents.isEmpty()) {
|
||||
// Session or agent directory gone — don't start
|
||||
return;
|
||||
}
|
||||
if (!agents.contains(m_agentId)) {
|
||||
// Current agent no longer exists — fall back to first available
|
||||
m_agentId = agents.first();
|
||||
emit activeAgentIdChanged();
|
||||
}
|
||||
if (agents.isEmpty() || !agents.contains(m_agentId)) return;
|
||||
|
||||
m_stateProc = new QProcess(this);
|
||||
connect(m_stateProc, &QProcess::readyReadStandardOutput, this, &Ollie9pClient::onStateReadyRead);
|
||||
|
|
|
|||
Reference in New Issue