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();