diff --git a/gui/main.qml b/gui/main.qml index 705bca3..9b526c2 100644 --- a/gui/main.qml +++ b/gui/main.qml @@ -533,9 +533,15 @@ ApplicationWindow { MouseArea { anchors.fill: parent - acceptedButtons: Qt.LeftButton + acceptedButtons: Qt.LeftButton | Qt.RightButton hoverEnabled: false onClicked: { + if (mouse.button === Qt.RightButton) { + if (type === "session") { + sessionCtxMenu.popup() + } + return + } if (renamingIndex >= 0) return if (type === "session") { toggleExpand(parent.modelIndex) @@ -548,6 +554,20 @@ ApplicationWindow { startRename(parent.modelIndex) } } + + Menu { + id: sessionCtxMenu + MenuItem { + text: "Kill" + icon.color: "#f44336" + onClicked: { + var item = sessionTreeModel.get(parent.parent.parent.modelIndex) + if (item && item.type === "session") + ollie.killSession(item.id) + ollie.refreshSessions() + } + } + } } contentItem: RowLayout { diff --git a/gui/ollie9pclient.cpp b/gui/ollie9pclient.cpp index 86aa215..372f1ee 100644 --- a/gui/ollie9pclient.cpp +++ b/gui/ollie9pclient.cpp @@ -160,6 +160,21 @@ bool Ollie9pClient::kill() return proc.exitCode() == 0; } +bool Ollie9pClient::killSession(const QString &sessionId) +{ + if (sessionId.isEmpty()) return false; + QStringList agents = getAgents(sessionId); + if (agents.isEmpty()) return false; + QString path = "session/" + sessionId + "/agent/" + agents.first() + "/ctl"; + QProcess proc; + proc.start(ninepBin(), {"-a", serverAddr(), "write", path}); + proc.waitForStarted(3000); + proc.write("kill"); + proc.closeWriteChannel(); + proc.waitForFinished(3000); + return proc.exitCode() == 0; +} + QString Ollie9pClient::getConfig() { if (m_activeSessionId.isEmpty()) return {}; diff --git a/gui/ollie9pclient.h b/gui/ollie9pclient.h index 9c71951..fb38b10 100644 --- a/gui/ollie9pclient.h +++ b/gui/ollie9pclient.h @@ -57,6 +57,7 @@ public: Q_INVOKABLE bool submit(const QString &prompt); Q_INVOKABLE bool interrupt(); Q_INVOKABLE bool kill(); + Q_INVOKABLE bool killSession(const QString &sessionId); Q_INVOKABLE QString getConfig(); Q_INVOKABLE QStringList getAgents(const QString &sessionId); Q_INVOKABLE void setActiveAgentId(const QString &agentId);