Start the task switcher focused on its list

This commit is contained in:
Ian Gulliver
2026-10-21 10:50:13 -07:00
parent fab6ce5831
commit 761b9ced6a
2 changed files with 20 additions and 4 deletions
+13 -2
View File
@@ -79,6 +79,7 @@ private let shortcuts: [(String, [(String, String)])] = [
("Task switcher", [
("Tab", "Switch between the text and the list"),
("↑ ↓", "Move the highlight, in the list"),
("Typing, ⌘V", "Jump from the list to the text"),
("Enter", "Pick the highlighted row"),
("Shift+Enter", "New line in the first message"),
("name: message", "Start the task in the project whose name starts with name"),
@@ -154,7 +155,8 @@ final class SwitcherModel {
let imageKey = "switcher:\(UUID().uuidString)"
var text = ""
var selected = 0
var inList = false
var inList = true
@ObservationIgnored var pending: NSEvent?
var workflows: [WorkflowSummary] = []
init(store: Store, overlays: Overlays, anchor: CGRect) {
@@ -317,6 +319,7 @@ final class SwitcherModel {
} catch {
overlays.openSwitcher(store)
if let s = overlays.switcher {
s.inList = false
s.setText(typed)
store.images.restore(s.imageKey, imgs)
}
@@ -418,7 +421,11 @@ private struct SwitcherBox: View {
.onAppear {
DispatchQueue.main.async {
logFocus("switcher before focus")
focused = true
if model.inList {
overlays.window?.makeFirstResponder(nil)
} else {
focused = true
}
DispatchQueue.main.async {
logFocus("switcher after focus focused=\(focused)")
}
@@ -430,6 +437,10 @@ private struct SwitcherBox: View {
.onChange(of: focused) {
if focused {
model.inList = false
if let event = model.pending {
model.pending = nil
NSApp.postEvent(event, atStart: true)
}
}
}
}