gui: fix focus stealing from dialogs during session tree rebuild

buildSessionTree() and updateSessionTree() now save/restore
Window.activeFocusItem instead of only promptInput.activeFocus.
This prevents sessionTreeModel.clear() from pulling focus out of
open modal dialogs (NewSessionDialog, NewAgentDialog).

Also add forceActiveFocus() on dialog open so the first field is
immediately focused.
This commit is contained in:
Levi Neely 2026-08-14 14:27:37 +02:00
parent f136c3e534
commit 0e163f6ee6
3 changed files with 13 additions and 7 deletions

View File

@ -162,5 +162,8 @@ Dialog {
}
}
onOpened: errorLabel.text = ""
onOpened: {
errorLabel.text = ""
dirField.forceActiveFocus()
}
}

View File

@ -75,5 +75,6 @@ Dialog {
errorLabel.text = ""
nameField.text = ""
remoteField.text = ""
nameField.forceActiveFocus()
}
}

View File

@ -102,7 +102,7 @@ ApplicationWindow {
function buildSessionTree() {
// Full rebuild - used on initial load
var hadFocus = promptInput.activeFocus
var focusItem = root.activeFocusItem
sessionTreeModel.clear()
modelCache = {}
var sessions = ollie.sessions
@ -139,8 +139,9 @@ ApplicationWindow {
appendSessionToModel(sess)
}
if (hadFocus)
promptInput.forceActiveFocus()
// Restore focus to whatever had it (handles dialogs, not just promptInput)
if (focusItem && focusItem.visible)
focusItem.forceActiveFocus()
}
// Compute connection color from session data (avoids C++ call)
@ -197,7 +198,7 @@ ApplicationWindow {
function updateSessionTree() {
// Incremental update - diff old vs new
var hadFocus = promptInput.activeFocus
var focusItem = root.activeFocusItem
var sessions = ollie.sessions
// Build lookup of new sessions
@ -232,8 +233,9 @@ ApplicationWindow {
}
}
if (hadFocus)
promptInput.forceActiveFocus()
// Restore focus to whatever had it (handles dialogs, not just promptInput)
if (focusItem && focusItem.visible)
focusItem.forceActiveFocus()
}
function findSessionIndex(sessionId) {