Add an iPhone client sharing the macOS app's SwiftUI code

This commit is contained in:
Ian Gulliver
2026-10-21 22:00:54 -07:00
parent 57d660c57f
commit 9e81e9107d
46 changed files with 1625 additions and 287 deletions
+11 -2
View File
@@ -1,4 +1,3 @@
import AppKit
import ByreAPI
import SwiftUI
@@ -58,6 +57,7 @@ func createTask(_ projectId: String, _ body: Components.Schemas.TaskCreate, _ st
}
}
#if os(macOS)
@MainActor
func ctrlGo(_ key: String, _ store: Store, _ overlays: Overlays) -> Bool {
if terminalFocused() {
@@ -66,6 +66,7 @@ func ctrlGo(_ key: String, _ store: Store, _ overlays: Overlays) -> Bool {
runGo(key, store, overlays)
return true
}
#endif
private let shortcuts: [(String, [(String, String)])] = [
("Anywhere", [
@@ -157,8 +158,10 @@ final class SwitcherModel {
let imageKey = "switcher:\(UUID().uuidString)"
var text = ""
var selected = 0
var inList = true
var inList = !touchOnly
#if os(macOS)
@ObservationIgnored var pending: NSEvent?
#endif
var workflows: [WorkflowSummary] = []
init(store: Store, overlays: Overlays, anchor: CGRect) {
@@ -422,6 +425,7 @@ private struct SwitcherBox: View {
.shadow(color: Palette.overlayShadow, radius: 14, y: 8)
.onAppear {
DispatchQueue.main.async {
#if os(macOS)
logFocus("switcher before focus")
if model.inList {
overlays.window?.makeFirstResponder(nil)
@@ -431,6 +435,9 @@ private struct SwitcherBox: View {
DispatchQueue.main.async {
logFocus("switcher after focus focused=\(focused)")
}
#else
focused = !model.inList
#endif
}
}
.onChange(of: model.inList) {
@@ -439,10 +446,12 @@ private struct SwitcherBox: View {
.onChange(of: focused) {
if focused {
model.inList = false
#if os(macOS)
if let event = model.pending {
model.pending = nil
NSApp.postEvent(event, atStart: true)
}
#endif
}
}
}