gui: add double-click to rename agent nodes in tree view

This commit is contained in:
Levi Neely 2026-08-01 18:17:13 +02:00
parent 74d346418d
commit 363b2e95ed
3 changed files with 44 additions and 5 deletions

View File

@ -155,7 +155,7 @@ ApplicationWindow {
function startRename(index) {
var item = sessionTreeModel.get(index)
if (item.type === "session") {
if (item.type === "session" || item.type === "agent") {
renamingIndex = index
renamingText = item.displayName
}
@ -165,9 +165,15 @@ ApplicationWindow {
if (renamingIndex < 0) return
var item = sessionTreeModel.get(renamingIndex)
var newName = renamingText.trim()
if (newName !== "" && newName !== item.id) {
if (ollie.renameSession(item.id, newName)) {
sessionTreeModel.set(renamingIndex, { id: newName, displayName: newName })
if (newName !== "" && newName !== item.displayName) {
if (item.type === "session") {
if (ollie.renameSession(item.id, newName)) {
sessionTreeModel.set(renamingIndex, { id: newName, displayName: newName })
}
} else if (item.type === "agent") {
if (ollie.renameAgent(item.parentId, item.agentId, newName)) {
sessionTreeModel.set(renamingIndex, { agentId: newName, displayName: newName })
}
}
}
renamingIndex = -1
@ -556,7 +562,7 @@ ApplicationWindow {
}
}
onDoubleClicked: {
if (type === "session") {
if (type === "session" || type === "agent") {
startRename(parent.modelIndex)
}
}

View File

@ -322,6 +322,38 @@ bool Ollie9pClient::renameSession(const QString &sessionId, const QString &newNa
return true;
}
bool Ollie9pClient::renameAgent(const QString &sessionId, const QString &agentId, const QString &newName)
{
if (sessionId.isEmpty() || agentId.isEmpty() || newName.isEmpty()) return false;
QString bin = ollie9pBin();
if (bin.isEmpty()) {
qDebug() << "renameAgent: ollie-9p not found, cannot rename";
return false;
}
QProcess proc;
proc.setProgram(bin);
proc.setArguments({"-a", serverAddr(), "mv",
"session/" + sessionId + "/agent/" + agentId,
"session/" + sessionId + "/agent/" + newName});
proc.start();
proc.waitForFinished(5000);
if (proc.exitCode() != 0) {
qDebug() << "renameAgent failed:" << QString::fromUtf8(proc.readAllStandardError()).trimmed();
return false;
}
if (m_activeSessionId == sessionId && m_agentId == agentId) {
m_agentId = newName;
emit activeAgentIdChanged();
}
refreshSessions();
return true;
}
// --- Root data loading (lazy) ---
void Ollie9pClient::ensureRootDataLoaded()

View File

@ -67,6 +67,7 @@ public:
Q_INVOKABLE QStringList getAvailableModels(const QString &backend) const;
Q_INVOKABLE bool createSession(const QString &cwd, const QString &name, const QString &backend, const QString &model, const QString &agent, const QString &remote);
Q_INVOKABLE bool renameSession(const QString &sessionId, const QString &newName);
Q_INVOKABLE bool renameAgent(const QString &sessionId, const QString &agentId, const QString &newName);
signals:
void sessionsChanged();