gui: auto-switch to newly created agent, remove remote field from agent dialog
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.
This commit is contained in:
parent
70390097b0
commit
e24d332d50
|
|
@ -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: {
|
Component.onCompleted: {
|
||||||
if (!ollie.rootBackendsLoaded) ollie.loadRootBackends()
|
if (!ollie.rootBackendsLoaded) ollie.loadRootBackends()
|
||||||
if (!ollie.rootAgentsLoaded) ollie.loadRootAgents()
|
if (!ollie.rootAgentsLoaded) ollie.loadRootAgents()
|
||||||
|
|
@ -151,12 +141,14 @@ Dialog {
|
||||||
var backend = backendCombo.currentText.trim()
|
var backend = backendCombo.currentText.trim()
|
||||||
var model = modelCombo.currentIndex >= 0 ? modelCombo.currentText.trim() : ""
|
var model = modelCombo.currentIndex >= 0 ? modelCombo.currentText.trim() : ""
|
||||||
var agent = agentCombo.currentText
|
var agent = agentCombo.currentText
|
||||||
var remote = remoteField.text.trim()
|
|
||||||
var agentAlias = aliasField.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 === "") {
|
if (err === "") {
|
||||||
|
// Success: refresh then switch to the newly created agent.
|
||||||
ollie.refreshSessions()
|
ollie.refreshSessions()
|
||||||
|
ollie.switchAgent(root.targetSessionId, newAgentId)
|
||||||
root.agentCreated()
|
root.agentCreated()
|
||||||
root.close()
|
root.close()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -587,7 +587,9 @@ QString Ollie9pClient::createAgent(const QString &sessionId, const QString &cwd,
|
||||||
qDebug() << "createAgent failed:" << err;
|
qDebug() << "createAgent failed:" << err;
|
||||||
return 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)
|
bool Ollie9pClient::killAgent(const QString &sessionId, const QString &agentId)
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ public:
|
||||||
Q_INVOKABLE bool killAgent(const QString &sessionId, const QString &agentId);
|
Q_INVOKABLE bool killAgent(const QString &sessionId, const QString &agentId);
|
||||||
Q_INVOKABLE bool renameSession(const QString &sessionId, const QString &newName);
|
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 bool renameAgent(const QString &sessionId, const QString &agentId, const QString &newName);
|
||||||
|
Q_INVOKABLE QString lastError() const { return m_9p ? m_9p->lastError() : QString(); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sessionsChanged();
|
void sessionsChanged();
|
||||||
|
|
|
||||||
Reference in New Issue