Commit 6236c2f7de

6236c2f7de7b4f3c92176353e4a33e66b9181766

parent: 173b70c8c8

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-14 03:50 UTC

Welcome sheet on first launch; iOS opens on Folders until a folder exists

With no folder added, the Mac shows a sheet once: choose a folder, or make
org/notes.org in iCloud Drive (when iCloud Drive is on) and add it, and
pick the key preset. Get Started… in the empty window opens it again. On
iOS the Agenda tab has nothing to show without a folder, so the app starts
on Folders until one is added.

Closes #72

Layout: unified · split

Sources/Orgstar/ContentView.swift +19 −5
@@ -32,6 +32,8 @@ struct ContentView: View {
3232 @State private var keymap = KeymapPreset.emacs.keymap
3333 @AppStorage("tagsColumn") private var tagsColumn = -77
3434 @AppStorage("headingAfterSubtree") private var headingAfterSubtree = false
35 /// The welcome sheet has been shown once; it comes back only through the empty state.
36 @AppStorage("welcomeShown") private var welcomeShown = false
3537 @AppStorage("splitLine") private var splitLine = false
3638 @AppStorage("alphabeticalLists") private var alphabeticalLists = true
3739 @AppStorage("fillColumn") private var fillColumn = 80
@@ -171,11 +173,13 @@ struct ContentView: View {
171173 }
172174 }
173175 } else {
174 ContentUnavailableView(
175 workspace.roots.isEmpty ? "Add a folder of org files" : "Choose a file",
176 systemImage: "doc.text",
177 description: Text(workspace.roots.isEmpty ? "File ▸ Add Folder… (⇧⌘O)" : "Or press ⌘P to open one by name.")
178 )
176 ContentUnavailableView {
177 Label(workspace.roots.isEmpty ? "Add a folder of org files" : "Choose a file", systemImage: "doc.text")
178 } description: {
179 Text(workspace.roots.isEmpty ? "File ▸ Add Folder… (⇧⌘O)" : "Or press ⌘P to open one by name.")
180 } actions: {
181 if workspace.roots.isEmpty { Button("Get Started…") { commands.showingWelcome = true } }
182 }
179183 }
180184 }
181185
@@ -299,6 +303,10 @@ struct ContentView: View {
299303 clock.remindAtEffort(session)
300304 commands.knownTags = { [index = workspace.index] in (try? index.tags()) ?? [] }
301305 commands.mainWindowOpen = true
306 if workspace.roots.isEmpty, !welcomeShown {
307 welcomeShown = true
308 commands.showingWelcome = true
309 }
302310 if let stale = window { commands.store.windows.removeAll { $0 === stale } }
303311 // The session's first pane the first time; a new one showing the focused buffer
304312 // when the window opens again.
@@ -336,6 +344,12 @@ struct ContentView: View {
336344 commands.editor?.perform(ReplaceBlockLines(edit: request.edit, content: content))
337345 }
338346 }
347 .sheet(isPresented: $commands.showingWelcome) {
348 WelcomeView(workspace: workspace, chooseFolder: {
349 // After the sheet closes, so the picker can present.
350 DispatchQueue.main.async { commands.showingFolderPicker = true }
351 }, open: { selectedFile = $0 })
352 }
339353 .sheet(isPresented: $commands.showingPalette) {
340354 PaletteView(commands: commands) { id in
341355 commands.showingPalette = false
Sources/Orgstar/OrgstarApp.swift +2
@@ -12,6 +12,8 @@ import UserNotifications
1212final class AppCommands {
1313 var showingQuickOpen = false
1414 var showingFolderPicker = false
15 /// The first-launch sheet, while no folder has been added.
16 var showingWelcome = false
1517 var focusSearch = false
1618 var showingConflict = false
1719 var showingPalette = false
Sources/Orgstar/WelcomeView.swift added +75
@@ -0,0 +1,75 @@
1import OrgApp
2import OrgCore
3import SwiftUI
4
5/// The first launch, with no folder added: add a folder or start one, and pick the keys.
6struct WelcomeView: View {
7 let workspace: WorkspaceModel
8 /// Opens the folder picker once the sheet has closed.
9 let chooseFolder: () -> Void
10 /// Shows the file the sheet made.
11 let open: (String) -> Void
12 @AppStorage("keymap") private var preset = KeymapPreset.emacs
13 @State private var error: String?
14 @Environment(\.dismiss) private var dismiss
15
16 /// iCloud Drive's folder, when iCloud Drive is on for this user.
17 static var iCloudDrive: URL? {
18 let url = FileManager.default.homeDirectoryForCurrentUser
19 .appendingPathComponent("Library/Mobile Documents/com~apple~CloudDocs")
20 return FileManager.default.fileExists(atPath: url.path) ? url : nil
21 }
22
23 var body: some View {
24 VStack(alignment: .leading, spacing: 14) {
25 Text("Welcome to orgstar").font(.title2.bold())
26 Text("orgstar edits a folder of plain-text org files in place. Add the folder your notes are in, or start a new one. Nothing is copied or moved, and you can add more folders later with File ▸ Add Folder….")
27 Picker("Keys", selection: $preset) {
28 ForEach(KeymapPreset.allCases, id: \.self) { Text($0.title).tag($0) }
29 }
30 Text(presetNote).font(.callout).foregroundStyle(.secondary)
31 if let error { Text(error).foregroundStyle(.red) }
32 HStack {
33 Button("Not Now") { dismiss() }
34 Spacer()
35 if let drive = Self.iCloudDrive {
36 Button("New Folder in iCloud Drive") { start(in: drive.appendingPathComponent("org")) }
37 .help("Makes org/notes.org in iCloud Drive and adds the folder")
38 }
39 Button("Choose Folder…") {
40 dismiss()
41 chooseFolder()
42 }
43 .keyboardShortcut(.defaultAction)
44 }
45 }
46 .padding(20)
47 .frame(width: 480)
48 }
49
50 private var presetNote: String {
51 switch preset {
52 case .emacs: "Org's own bindings: C-c C-t cycles TODO, C-c C-s schedules, M-RET makes a heading."
53 case .mac: "Standard Mac editing keys, with Org commands on ⌃⌘: ⌃⌘T cycles TODO, ⌃⌘S schedules."
54 case .doom: "Modal editing as in Doom Emacs, with SPC as the leader: SPC m t cycles TODO."
55 }
56 }
57
58 /// Makes `folder` with a notes file in it, adds it, and opens the file.
59 private func start(in folder: URL) {
60 Task {
61 do {
62 let file = folder.appendingPathComponent("notes.org")
63 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
64 if !FileManager.default.fileExists(atPath: file.path) {
65 try "* Inbox\n".write(to: file, atomically: true, encoding: .utf8)
66 }
67 try await workspace.addRoot(folder)
68 open(file.standardizedFileURL.path)
69 dismiss()
70 } catch {
71 self.error = error.localizedDescription
72 }
73 }
74 }
75}
Sources/OrgstarMobile/OrgstarMobileApp.swift +2
@@ -190,6 +190,8 @@ struct RootView: View {
190190 }
191191 }
192192 .clockAccessory(model.clock, perform: clock)
193 // Until a folder is added there is nothing for the agenda to show.
194 .onAppear { if workspace.rootPaths.isEmpty { tab = .folders } }
193195 .sheet(item: Binding(get: { model.clockPrompts.pending }, set: { if $0 == nil { model.clockPrompts.answer(nil) } })) { pending in
194196 ClockPromptSheet(prompt: pending.prompt) { model.clockPrompts.answer($0) }
195197 }
docs/manual/guide/01-files-and-folders.org +1 −1
@@ -46,7 +46,7 @@ orgstar does not open a single folder like a project. You add any number of fold
4646
4747** Adding a folder
4848
49Choose File ▸ Add Folder… (=⇧⌘O=), or click =+= at the bottom of the sidebar, and pick a folder. orgstar indexes it in the background; the toolbar shows a progress indicator while it works.
49Choose File ▸ Add Folder… (=⇧⌘O=), or click =+= at the bottom of the sidebar, and pick a folder. The first time orgstar opens with no folder, a welcome sheet offers the same, or a new =org= folder in iCloud Drive with a =notes.org= in it, and the choice of keys; Get Started… in the empty window opens the sheet again. orgstar indexes it in the background; the toolbar shows a progress indicator while it works.
5050
5151orgstar keeps a bookmark to each folder, so a folder you move or rename in Finder is followed. If a folder can't be found at launch, orgstar reports =Can't find the folder PATH.= Adding a folder that is already in the sidebar does nothing.
5252
docs/manual/guide/14-ios.org +1 −1
@@ -4,7 +4,7 @@
44
55* Overview
66
7The app has three tabs:
7The app has three tabs, and opens on Folders until a folder has been added:
88
99- Agenda :: the agenda over your folders, with capture.
1010- Folders :: the folders of org files you added. Each shows its subfolders and org files; tap a subfolder to open it.
docs/manual/quickstart.org +5 −1
@@ -4,7 +4,11 @@
44
55* Add a folder
66
7Choose File ▸ Add Folder… (=⇧⌘O=) and pick the folder that holds your org files.
7The first time orgstar opens with no folder, a welcome sheet offers to choose a folder,
8to make one (=org= in iCloud Drive, with a =notes.org= to start on), and the keys to use. Get
9Started… in the empty window opens it again.
10
11Otherwise, choose File ▸ Add Folder… (=⇧⌘O=) and pick the folder that holds your org files.
812It appears in the sidebar, and orgstar indexes every org file under it for search,
913the agenda and links. You can add several folders. Nothing is copied or moved.
1014