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