Sources/OrgstarMobile/OrgstarMobileApp.swift

4752dd3a1e83428b7d3360dbd60184ea42644ead
orgstar/Sources/OrgstarMobile/OrgstarMobileApp.swift

606 lines · 27329 bytes

  1#if os(iOS)
  2import CoreSpotlight
  3import OrgApp
  4import OrgCore
  5import OrgMathJax
  6import SwiftUI
  7import UserNotifications
  8
  9/// Orgstar on iPhone and iPad: the agenda, capture, and the folders they read.
 10@main
 11struct OrgstarMobileApp: App {
 12    @UIApplicationDelegateAdaptor private var delegate: AppDelegate
 13    @State private var model = MobileModel.shared
 14    /// The app's phase: in the background only when every window is.
 15    @Environment(\.scenePhase) private var scenePhase
 16
 17    init() {
 18        PDFExport.mathJaxURL = OrgMathJax.script
 19        RevealExport.library = OrgMathJax.reveal
 20        RevealExport.mathJax = OrgMathJax.script
 21        DiagramBlocks.vizURL = OrgMathJax.viz
 22        DiagramBlocks.mermaidURL = OrgMathJax.mermaid
 23        PythonBlocks.folder = OrgMathJax.pyodide
 24        // Debug builds, and runs from Xcode, whose scheme sets ORGSTAR_PERF.
 25        #if DEBUG
 26        Perf.watchMainThread()
 27        #else
 28        if ProcessInfo.processInfo.environment["ORGSTAR_PERF"] != nil { Perf.watchMainThread() }
 29        #endif
 30        LiveClock.install()
 31        ProStore.shared.start()
 32        ClockTask.titleKey = ClockTitleKey.loadOrCreate()
 33        // Read before the app becomes active and clears it.
 34        _ = UnsavedHeldFiles.atLaunch
 35        // Early, so that the watch's actions are taken when iOS wakes the app for them.
 36        WatchLink.shared.activate(MobileModel.shared)
 37    }
 38
 39    var body: some Scene {
 40        WindowGroup {
 41            if let workspace = model.workspace, let agenda = model.agenda {
 42                RootView(model: model, workspace: workspace, agenda: agenda)
 43                    .environment(model)
 44                    .environment(model.clock)
 45                    .onAppear { delegate.model = model }
 46            } else {
 47                ContentUnavailableView("Can't Open the Index", systemImage: "exclamationmark.triangle", description: Text(model.failure ?? ""))
 48            }
 49        }
 50        // For the clock's idle time: time working in another window isn't time away.
 51        .onChange(of: scenePhase) { _, phase in
 52            if phase == .background { model.clock.wentAway() }
 53        }
 54        .commands { AppMenus(model: model) }
 55    }
 56}
 57
 58/// Reminders show while the app is open too, and open their entry when tapped.
 59final class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate {
 60    @MainActor var model: MobileModel?
 61
 62    func application(_ application: UIApplication, didFinishLaunchingWithOptions options: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
 63        UNUserNotificationCenter.current().delegate = self
 64        return true
 65    }
 66
 67    nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification) async -> UNNotificationPresentationOptions {
 68        // A midnight badge update shows nothing else.
 69        if notification.request.content.badge != nil { return [.badge] }
 70        // A countdown's end shows in the app's own message.
 71        if notification.request.identifier == "sh.krz.orgstar.org-timer" { return [] }
 72        return [.banner, .sound, .list]
 73    }
 74
 75    nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
 76        let info = response.notification.request.content.userInfo
 77        guard let path = info["path"] as? String, let offset = info["offset"] as? Int else { return }
 78        await MainActor.run { model?.openRequest = .offset(path, offset) }
 79    }
 80}
 81
 82/// Files continued from another device, and what Working Copy's syncs come to.
 83private struct HandoffAndSync: ViewModifier {
 84    let model: MobileModel
 85    let open: (HandoffPlace) -> Void
 86    @Binding var message: String?
 87
 88    func body(content: Content) -> some View {
 89        content
 90            .onContinueUserActivity(HandoffPlace.activityType) { activity in
 91                if let place = HandoffPlace(userInfo: activity.userInfo) { open(place) }
 92            }
 93            .onChange(of: model.workingCopy.message) {
 94                guard let text = model.workingCopy.message else { return }
 95                model.workingCopy.message = nil
 96                message = text
 97            }
 98    }
 99}
100
101/// A tab on iPhone, or a row of the sidebar on a regular-width iPad, which also lists search
102/// and each added folder.
103enum AppTab: Hashable { case agenda, search, folders, folder(String), settings }
104
105/// The search screen, pushed from the Agenda and Folders tabs.
106struct SearchRoute: Hashable {}
107
108extension AppTab {
109    /// The tab that shows this on iPhone: search is pushed from Agenda and Folders, and folders
110    /// are listed in Folders.
111    var inTabBar: AppTab {
112        switch self {
113        case .search: .agenda
114        case .folder: .folders
115        default: self
116        }
117    }
118}
119
120extension View {
121    /// Readers pushed for `ReaderRoute`s; Markdown and other text files open in the editor.
122    func readerDestination(workspace: WorkspaceModel, session: DocumentSession) -> some View {
123        navigationDestination(for: ReaderRoute.self) { route in
124            switch route {
125            case .file(let path) where !DocumentSession.isOrgPath(path):
126                EditorSplitScreen(path: path, offset: nil, workspace: workspace, session: session)
127            case .offset(let path, let offset) where !DocumentSession.isOrgPath(path):
128                EditorSplitScreen(path: path, offset: offset, workspace: workspace, session: session)
129            case .heading(let location) where !DocumentSession.isOrgPath(location.path):
130                EditorSplitScreen(path: location.path, offset: location.start, workspace: workspace, session: session)
131            default:
132                ReaderScreen(route: route, workspace: workspace, session: session)
133            }
134        }
135        .navigationDestination(for: EditorRoute.self) { route in
136            EditorSplitScreen(path: route.path, offset: route.offset, workspace: workspace, session: session)
137        }
138        .navigationDestination(for: SearchRoute.self) { _ in
139            SearchScreen(workspace: workspace, session: session)
140        }
141    }
142}
143
144/// A share of files from the share extension.
145struct SharedFiles: Identifiable {
146    let id = UUID()
147    let batch: URL
148}
149
150/// An org-protocol capture, or a plain one.
151struct CaptureRequest: Identifiable {
152    let id = UUID()
153    var template: String?
154    var properties: [String: String] = [:]
155    /// An agenda day (a `Days` number) the entry is scheduled on.
156    var day: Int?
157    /// An org-roam capture, whose templates take the place of capture.toml's.
158    var roam: RoamCapture?
159}
160
161extension CaptureRequest {
162    /// An `org-protocol://capture` link's request.
163    init?(link: String) {
164        guard case .capture(let template, let properties)? = OrgProtocol.parse(link) else { return nil }
165        self.init(template: template, properties: properties)
166    }
167}
168
169struct RootView: View {
170    let model: MobileModel
171    let workspace: WorkspaceModel
172    let agenda: AgendaModel
173    @State private var capture: CaptureRequest?
174    /// The share extension's link whose capture sheet is showing, with its request's id. The link
175    /// stays in the inbox until the sheet is dismissed.
176    @State private var shared: (link: CaptureInbox.Link, request: UUID)?
177    /// Files from the share extension, waiting for the entry to attach them to.
178    @State private var sharedFiles: SharedFiles?
179    @State private var tab = AppTab.agenda
180    @State private var agendaPath = NavigationPath()
181    @State private var hour = 0
182    @State private var showingClockReport = false
183    @State private var showingBoard = false
184    @State private var message: String?
185    @Environment(\.horizontalSizeClass) private var sizeClass
186    @Environment(\.scenePhase) private var scenePhase
187    @AppStorage(OnboardingScreen.doneKey) private var onboarded = false
188    @State private var onboarding = false
189    @State private var whatsNew: ReleaseNotes?
190
191    private var session: DocumentSession { model.session }
192
193    /// Reminders, widgets and Spotlight following the files. Its own view, so that edits redraw
194    /// only it, not the tabs.
195    private struct BackgroundWork: View {
196        let model: MobileModel
197        let workspace: WorkspaceModel
198        let agenda: AgendaModel
199        let active: Bool
200        /// Notifications and badges ask for permission, which onboarding asks for first.
201        let onboarded: Bool
202        let hour: Int
203
204        private var session: DocumentSession { model.session }
205
206        var body: some View {
207            Color.clear
208                // Reminders follow the files, the settings, coming back to the app and the hour.
209                .task(id: ReminderKey(hidden: HiddenFolders.shared.all, files: workspace.files.count, changed: workspace.changedFile?.version, edits: session.editVersion,
210                                      settings: model.settingsVersion, active: active, onboarded: onboarded, hour: hour)) {
211                    guard active, onboarded else { return }
212                    try? await Task.sleep(for: .seconds(1))
213                    // After the agenda's refresh, whose parsed files these share.
214                    while agenda.isComputing, !Task.isCancelled { try? await Task.sleep(for: .milliseconds(100)) }
215                    guard !Task.isCancelled else { return }
216                    await model.updateReminders()
217                    await model.updateWidgets()
218                }
219                // Spotlight follows the files and saved edits.
220                .task(id: SpotlightKey(files: workspace.files.count, changed: workspace.changedFile?.version, saved: session.dirtyPaths.count)) {
221                    await model.spotlight.update(workspace.files)
222                }
223        }
224    }
225
226    private struct SpotlightKey: Equatable {
227        var files: Int
228        var changed: Int?
229        var saved: Int
230    }
231
232    private struct ReminderKey: Equatable {
233        /// The widgets leave out hidden folders.
234        var hidden: Set<String>
235        var files: Int
236        var changed: Int?
237        var edits: Int
238        var settings: Int
239        var active: Bool
240        var onboarded: Bool
241        var hour: Int
242    }
243
244    /// Tabs on iPhone and in a narrow window; a sidebar beside the content on a wider iPad.
245    private var tabs: some View {
246        TabView(selection: Binding { tab.inTabBar } set: { tab = $0 }) {
247            Tab("Agenda", systemImage: "calendar", value: .agenda) { agendaStack }
248            Tab("Folders", systemImage: "folder", value: .folders) { foldersStack }
249            Tab("Settings", systemImage: "gearshape", value: .settings) { settingsStack }
250        }
251        .clockAccessory(model.clock, perform: clock)
252    }
253
254    private var split: some View {
255        NavigationSplitView {
256            AppSidebar(workspace: workspace, selection: $tab)
257        } detail: {
258            Group {
259                switch tab {
260                case .agenda: agendaStack
261                case .search:
262                    NavigationStack {
263                        SearchScreen(workspace: workspace, session: session)
264                            .toolbar { captureButton }
265                            .readerDestination(workspace: workspace, session: session)
266                    }
267                case .folders: foldersStack
268                case .folder(let root):
269                    NavigationStack {
270                        FolderPage(workspace: workspace, session: session, route: FolderRoute(root: root, folder: ""))
271                            .toolbar { searchButton; captureButton }
272                            .readerDestination(workspace: workspace, session: session)
273                            .navigationDestination(for: FolderRoute.self) { FolderPage(workspace: workspace, session: session, route: $0) }
274                    }
275                    .id(root)
276                case .settings: settingsStack
277                }
278            }
279            .safeAreaInset(edge: .bottom) {
280                if let running = model.clock.running {
281                    ClockAccessory(running: running, clock: model.clock, perform: clock).padding(.vertical, 8).background(.bar)
282                }
283            }
284        }
285    }
286
287    private var agendaStack: some View {
288        NavigationStack(path: $agendaPath) {
289            AgendaScreen(workspace: workspace, session: session, agenda: agenda, scheduler: model.scheduler)
290                .equatable()
291                .toolbar { searchButton; captureButton }
292                .readerDestination(workspace: workspace, session: session)
293        }
294    }
295
296    private var foldersStack: some View {
297        NavigationStack {
298            FoldersScreen(workspace: workspace, session: session)
299                .toolbar { searchButton; captureButton }
300                .readerDestination(workspace: workspace, session: session)
301        }
302    }
303
304    private var settingsStack: some View {
305        NavigationStack { SettingsScreen(model: model) }
306    }
307
308    var body: some View {
309        // One view around both layouts, so that what follows runs once, not again when the
310        // window's width class changes.
311        ZStack {
312            if sizeClass == .regular { split } else { tabs }
313        }
314        .tint(model.theme.accentColor)
315        .focusedSceneValue(\.windowActions, WindowActions(
316            show: show, capture: { capture = CaptureRequest() },
317            addFolder: {
318                tab = .folders
319                model.addingFolder = true
320            },
321            board: { showingBoard = true }, flashcards: { model.reviewRequested = true }, clock: clock))
322        .fullScreenCover(isPresented: $showingBoard) {
323            BoardScreen(workspace: workspace, session: session) { showingBoard = false }
324        }
325        .fullScreenCover(isPresented: Binding(get: { model.reviewRequested }, set: { model.reviewRequested = $0 })) {
326            FlashcardScreen(workspace: workspace, session: session) { path, offset in
327                model.reviewRequested = false
328                if let path { model.openRequest = .offset(path, offset) }
329            }
330        }
331        // A removed folder's row goes from the sidebar.
332        .onChange(of: workspace.rootPaths) {
333            if case .folder(let root) = tab, !workspace.rootPaths.contains(root) { tab = .folders }
334        }
335        // Until a folder is added there is nothing for the agenda to show.
336        .onAppear {
337            if workspace.rootPaths.isEmpty { tab = .folders }
338            whatsNew = WhatsNew.pending(firstLaunch: !onboarded)
339            // First launch only; a workspace from before onboarding existed skips it.
340            guard !onboarded else { return }
341            if workspace.rootPaths.isEmpty, ProcessInfo.processInfo.environment["ORGSTAR_ROOT"] == nil {
342                var transaction = Transaction()
343                transaction.disablesAnimations = true
344                withTransaction(transaction) { onboarding = true }
345            } else {
346                onboarded = true
347            }
348        }
349        .fullScreenCover(isPresented: $onboarding) {
350            OnboardingScreen(model: model, workspace: workspace) {
351                onboarding = false
352                onboarded = true
353                if !workspace.rootPaths.isEmpty { tab = .agenda }
354            }
355            .interactiveDismissDisabled()
356        }
357        .sheet(item: $whatsNew) { WhatsNewView(notes: $0) }
358        .modifier(DecryptQuestion())
359        .sheet(item: Bindable(ProAccess.shared).paywall) { ProSheet(feature: $0) }
360        .onChange(of: ProAccess.shared.isUnlocked) {
361            // Calendar and Reminders in the agenda, the widgets and the watch follow Pro.
362            model.reloadConfig()
363            Task { await model.updateWidgets() }
364        }
365        .sheet(item: Binding(get: { model.clockPrompts.pending }, set: { if $0 == nil { model.clockPrompts.answer(nil) } })) { pending in
366            ClockPromptSheet(prompt: pending.prompt) { model.clockPrompts.answer($0) }
367        }
368        // At the top, where the keyboard can't hide it.
369        .message($message, edge: .top)
370        .sheet(isPresented: $showingClockReport) { ClockReportScreen(workspace: workspace) }
371        .onChange(of: model.openRequest) {
372            guard let route = model.openRequest else { return }
373            model.openRequest = nil
374            tab = .agenda
375            agendaPath.append(route)
376        }
377        .onChange(of: model.agendaRequest) {
378            guard let request = model.agendaRequest else { return }
379            model.agendaRequest = nil
380            agenda.mode = .agenda(span: request.count, startOffset: nil)
381            agenda.start = request.start
382            tab = .agenda
383            agendaPath = NavigationPath()
384        }
385        .onChange(of: workspace.changedFile?.version) {
386            // An open file takes in what changed on disk.
387            if let path = workspace.changedFile?.path {
388                session.fileChanged(path)
389                // A clock started or stopped in Emacs or on another device.
390                if path.hasSuffix(".org"), let text = model.clock.sync(session, paths: [path]) { message = text }
391            }
392        }
393        // At launch and as folders load: open clocks in the agenda files.
394        .task(id: workspace.files.count) {
395            guard !workspace.files.isEmpty, let text = model.clock.sync(session, paths: workspace.agendaFilePaths()) else { return }
396            message = text
397        }
398        // Initially too: the capture control may have launched the app.
399        .onChange(of: model.captureRequest?.id, initial: true) {
400            guard let request = model.captureRequest else { return }
401            model.captureRequest = nil
402            capture = request
403        }
404
405        // Another capture took the sheet from a shared one, which stays in the inbox for later.
406        .onChange(of: capture?.id) { _, id in
407            if let id, id != shared?.request { shared = nil }
408        }
409        .sheet(item: $capture, onDismiss: captureDismissed) { request in
410            CaptureScreen(workspace: workspace, session: session, request: request)
411        }
412        .sheet(item: $sharedFiles) { shared in
413            RefileSheet(targets: workspace.refileTargets(openPath: nil, document: nil, settings: RefileSettings(targets: [.init(files: .workspace, spec: .all)])),
414                        title: "Attach to") { target in
415                sharedFiles = nil
416                if let target {
417                    message = session.attach(AttachmentInbox.files(in: shared.batch), to: target.path, at: target.start ?? 0)
418                } else {
419                    message = "The shared files weren't attached"
420                }
421                AttachmentInbox()?.remove(shared.batch)
422                takeShared()
423            }
424        }
425        // After the first frame: removing a pending notification waits on the notification
426        // service, which can take many seconds after the device starts.
427        .task {
428            await Task.yield()
429            model.clock.remindAtEffort(session)
430        }
431        .task {
432            TimerModel.shared.onDone = { message = $0 }
433            if let lost = UnsavedHeldFiles.atLaunch { message = lost }
434            takeShared()
435            // Development: `ORGSTAR_ROOT` adds a folder at launch, as on the Mac.
436            if let root = ProcessInfo.processInfo.environment["ORGSTAR_ROOT"] { try? await workspace.addRoot(URL(fileURLWithPath: root)) }
437            // `ORGSTAR_PASTE_IMAGE`: paste takes this PNG from a pasteboard of the app's own.
438            if let image = ProcessInfo.processInfo.environment["ORGSTAR_PASTE_IMAGE"], let data = try? Data(contentsOf: URL(fileURLWithPath: image)),
439               let pasteboard = UIPasteboard(name: UIPasteboard.Name("orgstar-check"), create: true) {
440                pasteboard.setData(data, forPasteboardType: "public.png")
441                MobileEditor.pasteboard = pasteboard
442            }
443            workspace.startWatching()
444            await workspace.refresh()
445            model.workingCopy.appOpened(roots: workspace.rootPaths, session: session)
446        }
447        .task {
448            while !Task.isCancelled {
449                try? await Task.sleep(for: .seconds(3600))
450                hour += 1
451            }
452        }
453        .background { BackgroundWork(model: model, workspace: workspace, agenda: agenda, active: scenePhase == .active, onboarded: onboarded, hour: hour) }
454        .onContinueUserActivity(CSSearchableItemActionType) { activity in
455            if let path = activity.userInfo?[CSSearchableItemActivityIdentifier] as? String { model.openRequest = .file(path) }
456        }
457        .onChange(of: scenePhase) { _, phase in
458            // Unsaved edits are written before the app may be stopped. A file held for its
459            // passphrase stays in memory; its name is kept so that, if iOS ends the app
460            // meanwhile, the next launch says its edits were lost.
461            if phase == .background {
462                for path in session.dirtyPaths { _ = session.save(path) }
463                UnsavedHeldFiles.record(session.held.keys.filter(session.dirtyPaths.contains).sorted())
464            }
465            if phase == .active { UnsavedHeldFiles.record([]) }
466            // Files and settings synced while away; not every sync tool tells file presenters.
467            guard phase == .active else { return }
468            // iOS has no idle time: time away from the app while a clock ran stands in for it.
469            if let since = model.clock.cameBack(idleMinutes: OrgPreferences.clockIdleTime()) {
470                MobileClock.resolveIdle(since: since, model: model) { message = $0 }
471            }
472            takeShared()
473            model.reloadConfig()
474            model.handoff.update()
475            model.workingCopy.appOpened(roots: workspace.rootPaths, session: session)
476            Task { await workspace.refresh() }
477        }
478        .onOpenURL(perform: handle)
479        .modifier(HandoffAndSync(model: model, open: continueHandoff, message: $message))
480        // The Live Activity follows the clock, wherever it starts or stops.
481        .task {
482            LiveClock.publish(model.clock)
483            await LiveClock.sync(model.clock.running)
484        }
485        .onChange(of: model.clock.running) {
486            LiveClock.publish(model.clock)
487            Task { await LiveClock.sync(model.clock.running) }
488            Task { await model.updateWidgets() }
489        }
490        // A capture dictated on the watch, while the app is open.
491        .onChange(of: model.watchCaptures) { takeShared() }
492    }
493
494    /// What the share extension left, one capture sheet at a time.
495    private func takeShared() {
496        showWaiting()
497        if sharedFiles == nil, let batch = AttachmentInbox()?.batches().first { sharedFiles = SharedFiles(batch: batch) }
498    }
499
500    /// The inbox's oldest capture, unless a capture sheet is showing or being dismissed.
501    private func showWaiting() {
502        guard capture == nil, shared == nil, let inbox = model.inbox else { return }
503        for link in inbox.links() {
504            guard let request = CaptureRequest(link: link.text) else {
505                inbox.remove(link)
506                continue
507            }
508            shared = (link, request.id)
509            capture = request
510            return
511        }
512    }
513
514    /// The shared capture was saved or discarded, so its link goes; then the next one shows.
515    private func captureDismissed() {
516        if let shared { model.inbox?.remove(shared.link) }
517        shared = nil
518        showWaiting()
519    }
520
521    /// A widget's or the Live Activity's link, or an org-protocol URL.
522    private func handle(_ url: URL) {
523        if let callback = WorkingCopy.callback(url) {
524            model.workingCopy.finished(callback, workspace: workspace, session: session)
525        } else if let link = AppLink(url: url) {
526            open(link)
527        } else if let request = CaptureRequest(link: url.absoluteString) {
528            capture = request
529        } else if case .storeLink(let link, let title)? = OrgProtocol.parse(url.absoluteString) {
530            message = StoredLink.add(StoredLink(link: link, description: title), to: &model.storedLinks)
531            UIPasteboard.general.string = link
532        } else if let request = OrgProtocol.parse(url.absoluteString), ProAccess.shared.allows(.roam) {
533            // org-roam-protocol's `roam-ref` and `roam-node`.
534            var actions = RoamActions(session: session, roots: { workspace.rootPaths }, nodes: { try workspace.nodes(overlay: workspace.overlay(session.openDocuments)) },
535                                      show: { message = $0 }, ask: { $1(nil) }, open: { path, offset in model.openRequest = .offset(path, offset) },
536                                      insertLink: { _, _ in }, refresh: { Task { await workspace.refresh() } })
537            actions.capture = { capture = CaptureRequest(roam: $0) }
538            actions.follow(request)
539        } else if url.scheme == "org-protocol" {
540            message = "orgstar handles org-protocol capture and store-link"
541        }
542    }
543
544    /// A file continued from another device, in the editor at the caret's heading or line there.
545    private func continueHandoff(_ place: HandoffPlace) {
546        let match = place.resolve(roots: workspace.rootPaths)
547        guard case .file(let path) = match else { return message = place.problem(match) }
548        let offset = session.text(of: path).map { place.offset(in: $0, settings: session.defaults) } ?? 0
549        tab = .agenda
550        agendaPath.append(EditorRoute(path: path, offset: offset))
551    }
552
553    /// A tab or sidebar row; on iPhone, search is pushed on the agenda.
554    private func show(_ destination: AppTab) {
555        if destination == .search, sizeClass != .regular {
556            tab = .agenda
557            agendaPath.append(SearchRoute())
558        } else {
559            tab = destination
560        }
561    }
562
563    /// A widget's or the Live Activity's link.
564    private func open(_ link: AppLink) {
565        switch link {
566        case .agenda:
567            tab = .agenda
568            agendaPath = NavigationPath()
569        case .entry(let path, let offset):
570            model.openRequest = .offset(path, offset)
571        case .clock:
572            clock("app.clock.goto")
573        case .capture(let template):
574            capture = CaptureRequest(template: template)
575        case .review:
576            model.reviewRequested = true
577        }
578    }
579
580    private func clock(_ id: String) {
581        if id == "app.clock.report" {
582            showingClockReport = true
583        } else {
584            _ = MobileClock.run(id, model: model, workspace: workspace) { message = $0 }
585        }
586    }
587
588    private var searchButton: some ToolbarContent {
589        ToolbarItem(placement: .primaryAction) {
590            NavigationLink(value: SearchRoute()) { Label("Search", systemImage: "magnifyingglass") }
591        }
592    }
593
594    private var captureButton: some ToolbarContent {
595        ToolbarItem(placement: .primaryAction) {
596            Button("Capture", systemImage: "square.and.pencil") { capture = CaptureRequest() }
597        }
598    }
599}
600#else
601/// The iOS app has nothing to run elsewhere.
602@main
603enum OrgstarMobileUnavailable {
604    static func main() { print("orgstar for iOS runs on iPhone and iPad.") }
605}
606#endif
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form