From 5384c83a0f3261233a0dae6fc2aa0e3d3901a472 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Wed, 21 Oct 2026 22:38:16 -0700 Subject: [PATCH] =?UTF-8?q?Focus=20the=20project=20dashboard=20when=20?= =?UTF-8?q?=E2=8C=98P=20opens=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mac/Sources/Byre/Dialogs.swift | 1 + mac/Sources/Byre/Project.swift | 13 +++++++++++++ mac/Sources/Byre/Switcher.swift | 2 ++ 3 files changed, 16 insertions(+) diff --git a/mac/Sources/Byre/Dialogs.swift b/mac/Sources/Byre/Dialogs.swift index 2896bc4..4cfe9e2 100644 --- a/mac/Sources/Byre/Dialogs.swift +++ b/mac/Sources/Byre/Dialogs.swift @@ -51,6 +51,7 @@ final class Overlays { var switcher: SwitcherModel? var leftTab = LeftTab.lead var leadFocus = 0 + var projectFocus = false @ObservationIgnored var pickerFrame: CGRect = .zero @ObservationIgnored var menuHover = false var paneFrame: CGRect = .zero diff --git a/mac/Sources/Byre/Project.swift b/mac/Sources/Byre/Project.swift index 9aec1a4..fcedbeb 100644 --- a/mac/Sources/Byre/Project.swift +++ b/mac/Sources/Byre/Project.swift @@ -8,8 +8,10 @@ private let refreshKinds: Set = ["task.merged", "project.created"] struct ProjectView: View { @Environment(Store.self) private var store + @Environment(Overlays.self) private var overlays @ViewState private var todos: [String: Result] = [:] @ViewState private var off: (() -> Void)? + @FocusState private var focused: Bool var body: some View { ScrollView { @@ -23,6 +25,17 @@ struct ProjectView: View { } } .frame(maxWidth: .infinity, maxHeight: .infinity) + .focusable() + .focusEffectDisabled() + .focused($focused) + .onChange(of: overlays.projectFocus, initial: true) { + if overlays.projectFocus { + overlays.projectFocus = false + DispatchQueue.main.async { + focused = true + } + } + } .onAppear { off = store.events.add { ev in if refreshKinds.contains(ev.kind), let projectId = ev.projectId { diff --git a/mac/Sources/Byre/Switcher.swift b/mac/Sources/Byre/Switcher.swift index 1304073..a44787f 100644 --- a/mac/Sources/Byre/Switcher.swift +++ b/mac/Sources/Byre/Switcher.swift @@ -19,6 +19,7 @@ func runGo(_ key: String, _ store: Store, _ overlays: Overlays) { overlays.switcher?.close() store.sheet = nil if let project = store.focusedProject() ?? store.projects.first { + overlays.projectFocus = true store.focusProject(project.id) } case "l": @@ -279,6 +280,7 @@ final class SwitcherModel { go(task.id) case .project(let p): close() + overlays.projectFocus = true store.focusProject(p.id) case .newTask(let p): create(p.id, .init())