From e24d332d50fdeac0703bf93b39c04513fd158bd7 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Sat, 8 Aug 2026 14:02:10 +0200 Subject: [PATCH] gui: auto-switch to newly created agent, remove remote field from agent dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit createAgent now returns the new agent ID so the dialog can immediately switch to it. Previously the first agent created required a GUI restart to select. Also removes the Remote field from NewAgentDialog — remote belongs to the session, not the agent. --- gui/NewAgentDialog.qml | 16 ++++------------ gui/ollie9pclient.cpp | 4 +++- gui/ollie9pclient.h | 1 + 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/gui/NewAgentDialog.qml b/gui/NewAgentDialog.qml index 76d5b1f..ca9880d 100644 --- a/gui/NewAgentDialog.qml +++ b/gui/NewAgentDialog.qml @@ -103,16 +103,6 @@ Dialog { } } - RowLayout { - Layout.fillWidth: true - Label { text: "Remote:"; Layout.preferredWidth: 80 } - TextField { - id: remoteField - Layout.fillWidth: true - placeholderText: "user@host:port" - } - } - Component.onCompleted: { if (!ollie.rootBackendsLoaded) ollie.loadRootBackends() if (!ollie.rootAgentsLoaded) ollie.loadRootAgents() @@ -151,12 +141,14 @@ Dialog { var backend = backendCombo.currentText.trim() var model = modelCombo.currentIndex >= 0 ? modelCombo.currentText.trim() : "" var agent = agentCombo.currentText - var remote = remoteField.text.trim() var agentAlias = aliasField.text.trim() - var err = ollie.createAgent(root.targetSessionId, cwd, backend, model, agent, remote, agentAlias) + var newAgentId = ollie.createAgent(root.targetSessionId, cwd, backend, model, agent, "", agentAlias) + var err = ollie.lastError() if (err === "") { + // Success: refresh then switch to the newly created agent. ollie.refreshSessions() + ollie.switchAgent(root.targetSessionId, newAgentId) root.agentCreated() root.close() } else { diff --git a/gui/ollie9pclient.cpp b/gui/ollie9pclient.cpp index 5cfe0fd..b864094 100644 --- a/gui/ollie9pclient.cpp +++ b/gui/ollie9pclient.cpp @@ -587,7 +587,9 @@ QString Ollie9pClient::createAgent(const QString &sessionId, const QString &cwd, qDebug() << "createAgent failed:" << err; return err; } - return QString(); + // Return the new agent's ID (trimmed) so callers can switch to it immediately. + // Format: "agentid\n" + return QString::fromUtf8(result).trimmed(); } bool Ollie9pClient::killAgent(const QString &sessionId, const QString &agentId) diff --git a/gui/ollie9pclient.h b/gui/ollie9pclient.h index 9dc113e..3329ce1 100644 --- a/gui/ollie9pclient.h +++ b/gui/ollie9pclient.h @@ -85,6 +85,7 @@ public: Q_INVOKABLE bool killAgent(const QString &sessionId, const QString &agentId); Q_INVOKABLE bool renameSession(const QString &sessionId, const QString &newName); Q_INVOKABLE bool renameAgent(const QString &sessionId, const QString &agentId, const QString &newName); + Q_INVOKABLE QString lastError() const { return m_9p ? m_9p->lastError() : QString(); } signals: void sessionsChanged();