fix context menu: kill target session, not active one

Right-click now stores the target session ID in a root-level
property (killTargetSessionId) before popping the menu, avoiding
unreliable QML parent chain traversal that could resolve to the
wrong delegate.
This commit is contained in:
Levi Neely 2026-08-01 17:08:22 +02:00
parent 0706a052f4
commit ada6dc1feb
1 changed files with 8 additions and 3 deletions

View File

@ -90,6 +90,9 @@ ApplicationWindow {
onTriggered: chatView.positionViewAtEnd() onTriggered: chatView.positionViewAtEnd()
} }
// Session ID to kill — set on right-click, consumed by context menu
property string killTargetSessionId: ""
// Session tree model — flat list with level info // Session tree model — flat list with level info
ListModel { ListModel {
id: sessionTreeModel id: sessionTreeModel
@ -538,6 +541,9 @@ ApplicationWindow {
onClicked: function(mouse) { onClicked: function(mouse) {
if (mouse.button === Qt.RightButton) { if (mouse.button === Qt.RightButton) {
if (type === "session") { if (type === "session") {
var item = sessionTreeModel.get(parent.modelIndex)
if (item)
root.killTargetSessionId = item.id
sessionCtxMenu.popup() sessionCtxMenu.popup()
} }
return return
@ -561,9 +567,8 @@ ApplicationWindow {
text: "Kill" text: "Kill"
icon.color: "#f44336" icon.color: "#f44336"
onClicked: { onClicked: {
var item = sessionTreeModel.get(parent.parent.parent.modelIndex) if (root.killTargetSessionId)
if (item && item.type === "session") ollie.killSession(root.killTargetSessionId)
ollie.killSession(item.id)
ollie.refreshSessions() ollie.refreshSessions()
} }
} }