Commit 60adec1bc8

60adec1bc8a6672594f2ee4a4dfbb14b00825fbf

parent: b9d4cf5485

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-17 16:08 UTC

iOS: Overdue section, entry sheet, onboarding

- Agenda: today's overdue entries, missed habits included, form their own
  section above today. Rows carried from an earlier day show how late they
  are (2d ago) instead of their old time of day.
- Tapping an agenda entry opens a sheet for its title, TODO state,
  priority, scheduled date, deadline, tags and notes. Changes run the
  editor's commands on a copy of the file, with undo and redo, and are
  written back as one edit on Done (ReplaceChangedText). More > Open in
  File shows it in the reader. OrgCore gains EntryFields, SetHeadingTitle
  and SetEntryNotes.
- First launch without folders shows onboarding: welcome, folder,
  notifications, Calendar events, Reminders. Notification and badge
  requests wait until it's done; existing workspaces skip it.

Layout: unified · split

Sources/OrgApp/DocumentSession.swift +9
@@ -198,6 +198,15 @@ public final class DocumentSession {
198198 return state.isEditable ? state.text : nil
199199 }
200200
201 /// A copy of `path`'s text and tree, its buffer's when it's open, for changes made apart
202 /// and written back with `ReplaceChangedText`.
203 public func copy(of path: String) -> DocumentState? {
204 if let entry = entry(path) { return entry.buffer.document }
205 guard let bytes = try? fileSystem.read(URL(fileURLWithPath: path)) else { return nil }
206 let state = loaded(bytes, path: path)
207 return state.isEditable ? state : nil
208 }
209
201210 /// The buffer's name as uniquify writes it (`post-forward-angle-brackets`): the file name,
202211 /// with as many of its folders as tell it apart from other open files of the same name.
203212 public func bufferName(_ path: String) -> String {
Sources/OrgCore/Commands/EntryFields.swift added +147
@@ -0,0 +1,147 @@
1import Foundation
2
3/// An entry's heading parts, planning and notes, as a form edits them. The notes are the text
4/// after the planning line, drawers and clock lines, up to the next heading, without trailing
5/// blank lines.
6public struct EntryFields: Equatable, Sendable {
7 public var todo: String?
8 /// The cookie's letter or number: `A`, `10`.
9 public var priority: String?
10 public var title: String
11 public var tags: [String]
12 /// The timestamps' text without brackets: `2026-10-17 Sat 18:00 +1w`.
13 public var scheduled: String?
14 public var deadline: String?
15 public var notes: String
16
17 public init(todo: String?, priority: String?, title: String, tags: [String], scheduled: String?, deadline: String?, notes: String) {
18 self.todo = todo
19 self.priority = priority
20 self.title = title
21 self.tags = tags
22 self.scheduled = scheduled
23 self.deadline = deadline
24 self.notes = notes
25 }
26
27 /// The fields of the entry whose heading is at or before `offset`; nil before the first heading.
28 public static func read(_ text: String, at offset: Int, settings: OrgSettings) -> EntryFields? {
29 let buffer = EmacsBuffer(text, point: offset, settings: settings)
30 guard (try? buffer.backToHeading()) != nil, let match = buffer.lookingAt(buffer.complexHeadingPattern) else { return nil }
31 func group(_ i: Int) -> String? { match[i].map { buffer.substring($0.lowerBound, $0.upperBound) } }
32 let notes = buffer.notesRange()
33 return EntryFields(
34 todo: group(2),
35 priority: group(3).map { String($0.dropFirst(2).dropLast()) },
36 title: group(4) ?? "",
37 tags: group(5).map { $0.split(separator: ":").map(String.init) } ?? [],
38 scheduled: buffer.planningValue(.scheduled),
39 deadline: buffer.planningValue(.deadline),
40 notes: buffer.substring(notes.lowerBound, notes.upperBound)
41 )
42 }
43}
44
45extension EmacsBuffer {
46 /// The notes of the entry at point: from past its meta-data to before the trailing blanks
47 /// of the entry's text.
48 func notesRange() -> Range<Int> {
49 saveExcursion {
50 let end = entryEnd
51 endOfMetaDataFull()
52 let start = min(point, end)
53 point = end
54 skipBackward([32, 9, 10, 13])
55 return start..<max(start, point)
56 }
57 }
58}
59
60/// Replaces the title of the entry's heading, keeping its keyword, priority and tags.
61public struct SetHeadingTitle: OrgCommand {
62 let text: String
63 public init(title: String) { text = title }
64 public var id: String { "org.heading.set-title" }
65 public var title: String { "Set Heading Title" }
66 public func applies(in context: EditContext) -> Bool { entryHeading(at: context.caret, in: context.tree) != nil }
67 public func run(in context: EditContext) -> CommandStep {
68 guard entryHeading(at: context.caret, in: context.tree) != nil else { return .failed("Before first headline") }
69 // A heading is one line.
70 let new = text.split(whereSeparator: \.isNewline).joined(separator: " ").trimmingCharacters(in: .whitespaces)
71 return commitBuffer(context) { buffer in
72 try buffer.saveExcursion {
73 try buffer.backToHeading()
74 guard let match = buffer.lookingAt(buffer.complexHeadingPattern) else { return }
75 if let old = match[4] {
76 buffer.replace(old, with: new)
77 } else if !new.isEmpty {
78 buffer.point = (1...3).compactMap { match[$0]?.upperBound }.max()!
79 buffer.insert(" " + new)
80 }
81 buffer.alignTags(onLineAt: buffer.point)
82 }
83 }
84 }
85}
86
87/// Replaces the entry's notes (see `EntryFields.notes`).
88public struct SetEntryNotes: OrgCommand {
89 let notes: String
90 public init(notes: String) { self.notes = notes }
91 public var id: String { "org.entry.set-notes" }
92 public var title: String { "Set Notes" }
93 public func applies(in context: EditContext) -> Bool { entryHeading(at: context.caret, in: context.tree) != nil }
94 public func run(in context: EditContext) -> CommandStep {
95 guard entryHeading(at: context.caret, in: context.tree) != nil else { return .failed("Before first headline") }
96 var new = notes
97 while new.last?.isWhitespace == true { new.removeLast() }
98 return commitBuffer(context) { buffer in
99 buffer.saveExcursion {
100 let old = buffer.notesRange()
101 if !old.isEmpty {
102 // An emptied note takes its line break with it.
103 let end = new.isEmpty && buffer.character(at: old.upperBound) == 10 ? old.upperBound + 1 : old.upperBound
104 buffer.replace(old.lowerBound..<end, with: new)
105 } else if !new.isEmpty {
106 buffer.point = old.lowerBound
107 if !buffer.bolp { buffer.insert("\n") }
108 buffer.insert(new + "\n")
109 }
110 }
111 }
112 }
113}
114
115/// Writes the changes made on a copy of the text back as one edit: the span between what the
116/// two texts share at their start and end, when the text there still reads as it did.
117public struct ReplaceChangedText: OrgCommand {
118 public let edit: TextEdit
119 let expected: String
120
121 /// Nil when the texts are the same.
122 public init?(from old: String, to new: String) {
123 let a = Array(old.utf16)
124 let b = Array(new.utf16)
125 let shorter = min(a.count, b.count)
126 var prefix = 0
127 while prefix < shorter, a[prefix] == b[prefix] { prefix += 1 }
128 var suffix = 0
129 while suffix < shorter - prefix, a[a.count - 1 - suffix] == b[b.count - 1 - suffix] { suffix += 1 }
130 while prefix > 0, prefix < a.count, UTF16.isTrailSurrogate(a[prefix]) { prefix -= 1 }
131 while suffix > 0, UTF16.isTrailSurrogate(a[a.count - suffix]) { suffix -= 1 }
132 guard a.count != b.count || prefix != a.count else { return nil }
133 edit = TextEdit(range: prefix..<(a.count - suffix), replacement: String(decoding: b[prefix..<(b.count - suffix)], as: UTF16.self))
134 expected = String(decoding: a[prefix..<(a.count - suffix)], as: UTF16.self)
135 }
136
137 public var id: String { "org.replace-changed-text" }
138 public var title: String { "Replace Changed Text" }
139 public func applies(in context: EditContext) -> Bool { true }
140 public func run(in context: EditContext) -> CommandStep {
141 let text = context.text as NSString
142 guard edit.range.upperBound <= text.length, text.substring(with: NSRange(edit.range)) == expected else {
143 return .failed("The entry changed; nothing was saved.")
144 }
145 return .commit(EditResult(baseRevision: context.revision, edits: [edit], selection: nil, effects: []))
146 }
147}
Sources/OrgDocument/CaptureEntry.swift +8 −5
@@ -24,14 +24,17 @@ public struct CaptureEntry: Sendable, Equatable {
2424 scheduled = heading.scheduled
2525 deadline = heading.deadline
2626 keywords = tree.settings.todoSequences.flatMap { $0.active.map(\.name) + $0.done.map(\.name) }
27 let range = tree.settings.priorities
27 priorities = Self.priorities(tree.settings.priorities)
28 }
29
30 /// The priorities from `range.highest` to `range.lowest`: `A`, `B`, `C`, or numbers.
31 public static func priorities(_ range: Priorities) -> [String] {
2832 if let high = Int(range.highest), let low = Int(range.lowest), high <= low {
29 priorities = (high...low).map(String.init)
33 return (high...low).map(String.init)
3034 } else if let high = range.highest.unicodeScalars.first?.value, let low = range.lowest.unicodeScalars.first?.value, high <= low {
31 priorities = (high...low).compactMap(Unicode.Scalar.init).map { String(Character($0)) }
32 } else {
33 priorities = []
35 return (high...low).compactMap(Unicode.Scalar.init).map { String(Character($0)) }
3436 }
37 return []
3538 }
3639
3740 /// `text` after `command` runs on its first heading with `answers`, or nil when the command
Sources/OrgPresentation/AgendaRows.swift +11 −8
@@ -46,7 +46,7 @@ public struct AgendaEvent: Sendable, Equatable, Identifiable {
4646///
4747/// The gutter holds the time (`08:00`, `13:50–14:30`) or, untimed, a short status:
4848/// deadlines `Due today`, `Due in 2d`, `3d late`, `Due` (on a day other than today);
49/// scheduled `Scheduled`, `4d ago`; habits `Habit`; timestamps, diary sexps and
49/// scheduled `Scheduled`, `4d ago`; habits `Habit`, `1d ago` when missed; timestamps, diary sexps and
5050/// calendar events `All day`; ranges `Day 2/5`; log mode `Closed`, `Clocked`, `State`; TODO
5151/// and match lists nothing. Ages use `AgendaAge.compact`.
5252public struct AgendaRow: Sendable, Equatable, Identifiable {
@@ -102,9 +102,11 @@ public struct AgendaRow: Sendable, Equatable, Identifiable {
102102 /// Nil for the time grid and the current-time line.
103103 public init?(item: AgendaItem, day: Int, today: Int) {
104104 if item.kind == .timeGrid || item.kind == .currentTime { return nil }
105 let timed = item.timeOfDay.map { start in (start, Self.endTime(item.time)) }
106105 let planning = item.planningDay
107106 let late = planning.map { $0 < today } ?? false
107 // Carried to today from an earlier day, where its time no longer applies.
108 let carried = late && day == today
109 let timed = carried ? nil : item.timeOfDay.map { start in (start, Self.endTime(item.time)) }
108110 var icon: Icon?
109111 var status: Status = .normal
110112 var untimed = ""
@@ -121,13 +123,14 @@ public struct AgendaRow: Sendable, Equatable, Identifiable {
121123 }
122124 status = late ? .overdue : day == today ? .dueSoon : .normal
123125 case .scheduled, .pastScheduled:
126 let on = planning ?? day
127 let ago = String(localized: "\(AgendaAge.compact(day - on)) ago", bundle: .main)
124128 if item.habit != nil {
125129 icon = .habit
126 untimed = String(localized: "Habit", bundle: .main)
130 untimed = carried ? ago : String(localized: "Habit", bundle: .main)
127131 } else {
128132 icon = .scheduled
129 let on = planning ?? day
130 untimed = on < day ? String(localized: "\(AgendaAge.compact(day - on)) ago", bundle: .main) : String(localized: "Scheduled", bundle: .main)
133 untimed = on < day ? ago : String(localized: "Scheduled", bundle: .main)
131134 }
132135 status = late ? .overdue : .normal
133136 case .timestamp, .sexp:
@@ -325,8 +328,8 @@ public enum AgendaRows {
325328 ///
326329 /// - Days with no rows are left out unless `showAllDates` (`org-agenda-show-all-dates`);
327330 /// today always stays.
328 /// - Today's past-scheduled entries and past deadlines (not habits) go in `overdue`,
329 /// oldest date first, Org's order among the same date.
331 /// - Today's past-scheduled entries, habits and past deadlines go in `overdue`, oldest
332 /// date first, Org's order among the same date.
330333 /// - Other rows keep the agenda's order (timed by time, then untimed by urgency, habits
331334 /// after other entries at the same time).
332335 /// All-day events come first, timed events go among the timed entries by start time,
@@ -349,7 +352,7 @@ public enum AgendaRows {
349352 if item.kind == .timeGrid, let time = item.timeOfDay { grid.append((rows.count, time)) }
350353 if item.kind == .currentTime { showsNow = true }
351354 guard keep(item), let row = AgendaRow(item: item, day: day.day, today: today) else { continue }
352 if day.day == today, item.habit == nil, let planning = row.planningDay, planning < today {
355 if day.day == today, let planning = row.planningDay, planning < today {
353356 overdue.append(row)
354357 } else {
355358 rows.append(row)
Sources/OrgstarMobile/AgendaScreen.swift +34 −10
@@ -50,6 +50,8 @@ struct AgendaScreen: View, Equatable {
5050 @State private var bulkArchiving = false
5151 @State private var bulkPlanning: BulkPlanning?
5252 @State private var showingBoard = false
53 /// The entry open in its sheet.
54 @State private var editing: AgendaItem?
5355
5456 /// A marked entry: its heading line, to find it again.
5557 private struct Mark: Hashable {
@@ -110,6 +112,7 @@ struct AgendaScreen: View, Equatable {
110112 } else if case .agenda = agenda.mode {
111113 let _ = model.settingsVersion
112114 ForEach(Perf.measure("agenda.groups") { agenda.groups(showAllDates: OrgPreferences.agendaShowAllDates(), filter: filter) }) { group in
115 overdue(group)
113116 Section {
114117 day(group)
115118 } header: {
@@ -122,6 +125,7 @@ struct AgendaScreen: View, Equatable {
122125 if block.isAgenda {
123126 Section { } header: { Text(block.header).font(.headline) }
124127 ForEach(agenda.groups(block, showAllDates: OrgPreferences.agendaShowAllDates(), filter: filter)) { group in
128 overdue(group)
125129 Section {
126130 day(group)
127131 } header: {
@@ -272,6 +276,13 @@ struct AgendaScreen: View, Equatable {
272276 .navigationBarTitleDisplayMode(.inline)
273277 }
274278 }
279 .sheet(item: $editing) { item in
280 EntrySheet(item: item, workspace: workspace, session: session) { saved, open in
281 editing = nil
282 if saved { tick += 1 }
283 if let open { model.openRequest = .offset(open.path, open.offset) }
284 }
285 }
275286 .sheet(item: $refiling) { item in
276287 RefileSheet(targets: workspace.refileTargets(openPath: session.path, document: session.document)) { target in
277288 refiling = nil
@@ -401,29 +412,39 @@ struct AgendaScreen: View, Equatable {
401412
402413 // MARK: - Days
403414
404 private func day(_ group: AgendaDayGroup) -> some View {
405 Group {
406 if group.isToday, !group.overdue.isEmpty {
415 /// Today's entries from earlier days, in a section of their own above today's.
416 @ViewBuilder
417 private func overdue(_ group: AgendaDayGroup) -> some View {
418 if group.isToday, !group.overdue.isEmpty {
419 Section {
420 if overdueExpanded {
421 ForEach(group.overdue) { item in Deferred { row(item, day: group.day) } }
422 }
423 } header: {
407424 Button {
408425 withAnimation { overdueExpanded.toggle() }
409426 } label: {
410427 HStack(spacing: 6) {
411 Image(systemName: "chevron.right")
412 .font(.caption.weight(.semibold))
413 .rotationEffect(.degrees(overdueExpanded ? 90 : 0))
414428 Text("Overdue").font(.subheadline.weight(.semibold))
415429 Text("\(group.overdue.count)").font(.subheadline.monospacedDigit())
416430 Spacer()
431 Image(systemName: "chevron.right")
432 .font(.caption.weight(.semibold))
433 .rotationEffect(.degrees(overdueExpanded ? 90 : 0))
417434 }
418435 .foregroundStyle(themed(theme.statusColor(.overdue, dark: isDark), .red))
419436 .contentShape(Rectangle())
420437 }
421438 .buttonStyle(.plain)
422 if overdueExpanded {
423 ForEach(group.overdue) { item in Deferred { row(item, day: group.day) } }
424 }
439 .textCase(nil)
440 .accessibilityValue(overdueExpanded ? "Expanded" : "Collapsed")
425441 }
426 if group.isEmpty {
442 }
443 }
444
445 private func day(_ group: AgendaDayGroup) -> some View {
446 Group {
447 if group.rows.isEmpty {
427448 Text("Nothing scheduled").font(.subheadline).foregroundStyle(.secondary)
428449 }
429450 // One view per element, so the list counts its rows without building them.
@@ -658,6 +679,9 @@ struct AgendaScreen: View, Equatable {
658679 } else {
659680 AgendaRowView(row: row, day: day, theme: theme, dark: isDark).opacity(0.5)
660681 }
682 } else if let item = row.item, item.path != nil, item.headingLine != nil, item.headingOffset != nil {
683 Button { editing = item } label: { AgendaRowView(row: row, day: day, theme: theme, dark: isDark) }
684 .tint(.primary)
661685 } else if let item = row.item, let path = item.path, let offset = item.headingOffset ?? item.markerOffset {
662686 NavigationLink(value: ReaderRoute.offset(path, offset)) { AgendaRowView(row: row, day: day, theme: theme, dark: isDark) }
663687 } else if let event = row.event {
Sources/OrgstarMobile/CaptureScreen.swift +2 −2
@@ -361,7 +361,7 @@ private struct EntryFields: View {
361361}
362362
363363/// A date and, when switched on, a time; the answer as a date prompt takes it.
364private struct DateTimeSheet: View {
364struct DateTimeSheet: View {
365365 let title: String
366366 let initial: Date
367367 let done: (String?) -> Void
@@ -393,7 +393,7 @@ private struct DateTimeSheet: View {
393393}
394394
395395/// Tags to toggle, from the file and the workspace, and new ones typed in.
396private struct TagsSheet: View {
396struct TagsSheet: View {
397397 let choices: [String]
398398 let done: ([String]?) -> Void
399399 @State private var selected: [String]
Sources/OrgstarMobile/EntrySheet.swift added +315
@@ -0,0 +1,315 @@
1#if os(iOS)
2import OrgApp
3import OrgCore
4import OrgDocument
5import OrgPresentation
6import SwiftUI
7
8/// An agenda entry's title, state, priority, dates, tags and notes, changed by the editor's
9/// commands on a copy of its file and written back as one edit on Done.
10struct EntrySheet: View {
11 let item: AgendaItem
12 let workspace: WorkspaceModel
13 let session: DocumentSession
14 /// Whether anything was written, and the entry to show in its file.
15 let done: (_ saved: Bool, _ open: (path: String, offset: Int)?) -> Void
16 @Environment(MobileModel.self) private var model
17 @Environment(\.colorScheme) private var colorScheme
18 @State private var draft: DocumentState?
19 @State private var original = ""
20 @State private var offset = 0
21 @State private var title = ""
22 @State private var notes = ""
23 /// Changes on the copy that undo may take back, and those redo may bring back: the copy of
24 /// an open file has the editor's history too.
25 @State private var steps = 0
26 @State private var undone = 0
27 @State private var problem: String?
28 @State private var prompt: PendingPrompt?
29 @State private var planning: Planning?
30 @State private var choosingTags = false
31 @State private var confirmingDiscard = false
32
33 private enum Planning: String, Identifiable {
34 case scheduled = "Scheduled", deadline = "Deadline"
35 var id: String { rawValue }
36 }
37
38 private struct PendingPrompt: Identifiable {
39 let id = UUID()
40 let prompt: Prompt
41 let reply: (String?) -> Void
42 }
43
44 private var fields: EntryFields? {
45 draft.flatMap { EntryFields.read($0.text, at: offset, settings: $0.tree.settings) }
46 }
47
48 private var hasChanges: Bool {
49 guard let draft, let fields else { return false }
50 return draft.text != original || title != fields.title || trimmed(notes) != fields.notes
51 }
52
53 private var isDark: Bool { colorScheme == .dark }
54
55 var body: some View {
56 NavigationStack {
57 Group {
58 if let fields, let draft {
59 form(fields, settings: draft.tree.settings)
60 } else if let problem {
61 ContentUnavailableView("Can't open the entry", systemImage: "exclamationmark.triangle", description: Text(problem))
62 } else {
63 ProgressView()
64 }
65 }
66 .navigationBarTitleDisplayMode(.inline)
67 .toolbar {
68 ToolbarItemGroup(placement: .topBarLeading) {
69 Button("Cancel", systemImage: "xmark") {
70 if hasChanges { confirmingDiscard = true } else { done(false, nil) }
71 }
72 Button("Undo", systemImage: "arrow.uturn.backward", action: undo).disabled(steps == 0)
73 Button("Redo", systemImage: "arrow.uturn.forward", action: redo).disabled(undone == 0)
74 }
75 ToolbarItem(placement: .primaryAction) {
76 Menu("More", systemImage: "ellipsis") {
77 Button("Open in File", systemImage: "doc.text") { save(open: true) }
78 }
79 .disabled(draft == nil)
80 }
81 ToolbarItem(placement: .confirmationAction) {
82 Button("Done", systemImage: "checkmark") { save() }.disabled(draft == nil)
83 }
84 }
85 .confirmationDialog("Discard your changes?", isPresented: $confirmingDiscard, titleVisibility: .visible) {
86 Button("Discard Changes", role: .destructive) { done(false, nil) }
87 }
88 }
89 .presentationDragIndicator(.visible)
90 .interactiveDismissDisabled(hasChanges)
91 .task { load() }
92 .sheet(item: $prompt) { pending in
93 PromptSheet(prompt: pending.prompt) { answer in
94 prompt = nil
95 pending.reply(answer)
96 }
97 }
98 .sheet(item: $planning) { which in
99 let stamp = which == .scheduled ? fields?.scheduled : fields?.deadline
100 DateTimeSheet(title: which.rawValue, initial: stamp.flatMap(Self.timestamp).map(Self.date) ?? Calendar.current.startOfDay(for: Date())) { answer in
101 planning = nil
102 if let answer { run(SetPlanning(deadline: which == .deadline), ["date": answer]) }
103 }
104 }
105 .sheet(isPresented: $choosingTags) {
106 TagsSheet(selected: fields?.tags ?? [], choices: (try? workspace.index.tags()) ?? []) { tags in
107 choosingTags = false
108 guard let tags, let old = fields?.tags else { return }
109 for tag in old where !tags.contains(tag) { run(ToggleTag(tag: tag, on: false)) }
110 for tag in tags where !old.contains(tag) { run(ToggleTag(tag: tag, on: true)) }
111 }
112 }
113 }
114
115 private func form(_ fields: EntryFields, settings: OrgSettings) -> some View {
116 ScrollView {
117 VStack(alignment: .leading, spacing: 12) {
118 TextField("Title", text: $title, axis: .vertical)
119 .font(.title3.weight(.semibold))
120 ScrollView(.horizontal, showsIndicators: false) {
121 HStack(spacing: 8) {
122 stateChip(fields, settings: settings)
123 priorityChip(fields, settings: settings)
124 dateChip(.scheduled, fields.scheduled)
125 dateChip(.deadline, fields.deadline)
126 }
127 }
128 Button {
129 choosingTags = true
130 } label: {
131 chip(fields.tags.isEmpty ? "Tags" : fields.tags.joined(separator: " "), systemImage: "tag", color: fields.tags.isEmpty ? .secondary : .accentColor)
132 }
133 if let problem {
134 Text(problem).font(.footnote).foregroundStyle(.red)
135 }
136 }
137 .padding()
138 .frame(maxWidth: .infinity, alignment: .leading)
139 .background(Color.accentColor.opacity(0.08))
140 Divider()
141 TextEditor(text: $notes)
142 .font(.body)
143 .scrollDisabled(true)
144 .scrollContentBackground(.hidden)
145 .frame(minHeight: 240)
146 .overlay(alignment: .topLeading) {
147 if notes.isEmpty {
148 Text("Add notes").foregroundStyle(.tertiary).padding(.top, 8).padding(.leading, 5).allowsHitTesting(false)
149 }
150 }
151 .padding(.horizontal)
152 }
153 .scrollDismissesKeyboard(.interactively)
154 }
155
156 private func stateChip(_ fields: EntryFields, settings: OrgSettings) -> some View {
157 let keywords = settings.todoSequences.flatMap { $0.active.map(\.name) + $0.done.map(\.name) }
158 let color = fields.todo.flatMap { todo in
159 model.theme.todoColor(todo, isDone: settings.todoSequences.contains { $0.done.contains { $0.name == todo } }, dark: isDark)?.swiftUI
160 } ?? .secondary
161 return Menu {
162 ForEach(keywords, id: \.self) { keyword in
163 Button(keyword) { run(SetTodo(keyword: keyword)) }
164 }
165 Button("None") { run(SetTodo(keyword: nil)) }
166 } label: {
167 chip(fields.todo ?? "No State", color: color)
168 }
169 }
170
171 @ViewBuilder
172 private func priorityChip(_ fields: EntryFields, settings: OrgSettings) -> some View {
173 let priorities = CaptureEntry.priorities(settings.priorities)
174 if !priorities.isEmpty {
175 let color = fields.priority.flatMap { model.theme.priorityColor($0, dark: isDark)?.swiftUI } ?? .secondary
176 Menu {
177 ForEach(priorities, id: \.self) { priority in
178 Button("Priority \(priority)") { run(SetPriority(), ["priority": priority]) }
179 }
180 Button("None") { run(SetPriority(), ["priority": " "]) }
181 } label: {
182 chip(fields.priority.map { "#" + $0 } ?? "#", color: color)
183 }
184 .accessibilityLabel(fields.priority.map { "Priority \($0)" } ?? "No priority")
185 }
186 }
187
188 private func dateChip(_ which: Planning, _ value: String?) -> some View {
189 let stamp = value.flatMap(Self.timestamp)
190 let prefix = which == .scheduled ? "S: " : "D: "
191 return Menu {
192 Button("Today") { set(which, days: 0, keeping: stamp) }
193 Button("Tomorrow") { set(which, days: 1, keeping: stamp) }
194 Button("In a Week") { set(which, days: 7, keeping: stamp) }
195 Button("Pick Date…") { planning = which }
196 if value != nil {
197 Button("Remove", role: .destructive) { run(RemovePlanning(deadline: which == .deadline)) }
198 }
199 } label: {
200 chip(stamp.map { prefix + Self.text($0) } ?? (which == .scheduled ? "Schedule" : "Deadline"),
201 systemImage: which == .scheduled ? "calendar" : "flag", color: stamp == nil ? .secondary : .accentColor)
202 }
203 }
204
205 private func chip(_ text: String, systemImage: String? = nil, color: Color) -> some View {
206 HStack(spacing: 4) {
207 if let systemImage { Image(systemName: systemImage) }
208 Text(text).lineLimit(1)
209 }
210 .font(.subheadline.weight(.medium))
211 .foregroundStyle(color)
212 .padding(.horizontal, 12)
213 .padding(.vertical, 7)
214 .background(color.opacity(0.14), in: Capsule())
215 }
216
217 // MARK: - Changes
218
219 private func load() {
220 guard draft == nil else { return }
221 guard let path = item.path, let line = item.headingLine, let near = item.headingOffset,
222 let at = session.locateHeading(path: path, line: line, near: near), let copy = session.copy(of: path),
223 let fields = EntryFields.read(copy.text, at: at, settings: copy.tree.settings) else {
224 problem = "The entry changed or its file can't be read."
225 return
226 }
227 (draft, original, offset, title, notes) = (copy, copy.text, at, fields.title, fields.notes)
228 }
229
230 /// Runs `command` at the heading on the copy, asking what it asks.
231 private func run(_ command: any OrgCommand, _ answers: [String: String] = [:]) {
232 guard var copy = draft else { return }
233 do {
234 switch try copy.run(command, selection: [offset..<offset], answers: answers, options: session.options) {
235 case .commit:
236 problem = nil
237 guard copy.text != draft?.text else { return }
238 draft = copy
239 steps += 1
240 undone = 0
241 case .prompt(let request):
242 prompt = PendingPrompt(prompt: request) { answer in
243 if let answer { run(command, answers.merging([request.key: answer]) { $1 }) }
244 }
245 case .failed(let text):
246 problem = text
247 case .external(let request):
248 problem = MobileEditor.unavailable(request, title: command.title)
249 }
250 } catch {
251 problem = "\(error)"
252 }
253 }
254
255 private func undo() {
256 guard steps > 0, var copy = draft, copy.undo() != nil else { return }
257 draft = copy
258 steps -= 1
259 undone += 1
260 }
261
262 private func redo() {
263 guard undone > 0, var copy = draft, copy.redo() != nil else { return }
264 draft = copy
265 undone -= 1
266 steps += 1
267 }
268
269 /// `days` from today, at the time `stamp` has.
270 private func set(_ which: Planning, days: Int, keeping stamp: Timestamp?) {
271 var day = Calendar.current.date(byAdding: .day, value: days, to: Calendar.current.startOfDay(for: Date())) ?? Date()
272 if let hour = stamp?.start.hour {
273 day = Calendar.current.date(bySettingHour: hour, minute: stamp?.start.minute ?? 0, second: 0, of: day) ?? day
274 }
275 run(SetPlanning(deadline: which == .deadline), ["date": QuestionField.stamp(day, withTime: stamp?.start.hour != nil)])
276 }
277
278 /// The title and notes onto the copy, and the copy written back to the file.
279 private func save(open: Bool = false) {
280 guard let path = item.path, let fields else { return }
281 if title != fields.title { run(SetHeadingTitle(title: title)) }
282 if trimmed(notes) != fields.notes { run(SetEntryNotes(notes: notes)) }
283 guard let draft else { return }
284 var saved = false
285 if let command = ReplaceChangedText(from: original, to: draft.text) {
286 if case .failed(let text) = session.perform(command, path: path, at: offset, expect: nil) {
287 problem = text
288 return
289 }
290 saved = true
291 }
292 done(saved, open ? (path, offset) : nil)
293 }
294
295 private func trimmed(_ text: String) -> String {
296 var text = text
297 while text.last?.isWhitespace == true { text.removeLast() }
298 return text
299 }
300
301 private static func timestamp(_ value: String) -> Timestamp? { Timestamp.parse("<" + value + ">") }
302
303 private static func date(_ stamp: Timestamp) -> Date {
304 let p = stamp.start
305 return Calendar.current.date(from: DateComponents(year: p.year, month: p.month, day: p.day, hour: p.hour, minute: p.minute)) ?? Date()
306 }
307
308 /// `Sat 17 Oct`, with the time when it has one.
309 private static func text(_ stamp: Timestamp) -> String {
310 let day = date(stamp).formatted(.dateTime.weekday(.abbreviated).day().month(.abbreviated))
311 guard let hour = stamp.start.hour else { return day }
312 return day + String(format: " %02d:%02d", hour, stamp.start.minute ?? 0)
313 }
314}
315#endif
Sources/OrgstarMobile/MobileModel.swift +2 −1
@@ -321,7 +321,8 @@ final class MobileModel {
321321 /// that only changes the badge.
322322 private func updateBadge(_ counts: [Int]) async {
323323 let center = UNUserNotificationCenter.current()
324 guard await badgesEnabled(asking: true) else { return }
324 // Onboarding asks first.
325 guard await badgesEnabled(asking: UserDefaults.standard.bool(forKey: OnboardingScreen.doneKey)) else { return }
325326 try? await center.setBadgeCount(counts.first ?? 0)
326327 center.removePendingNotificationRequests(withIdentifiers: (1..<AgendaSnapshot.dayCount).map(Self.badgeID))
327328 let today = Calendar.current.startOfDay(for: Date())
Sources/OrgstarMobile/OnboardingScreen.swift added +192
@@ -0,0 +1,192 @@
1#if os(iOS)
2import OrgApp
3import OrgCore
4import SwiftUI
5import UserNotifications
6
7/// First launch: what the app does, the folder of org files, and the permissions each
8/// optional feature needs, asked for one at a time and only when the user chooses to.
9struct OnboardingScreen: View {
10 /// Set once onboarding is done or skipped for a workspace that had folders already.
11 static let doneKey = "onboarded"
12
13 let model: MobileModel
14 let workspace: WorkspaceModel
15 let finish: () -> Void
16 @State private var step = Step.welcome
17 @State private var importing = false
18 @State private var problem: String?
19
20 private enum Step: Int, CaseIterable {
21 case welcome, folder, notifications, calendar, reminders
22 }
23
24 var body: some View {
25 VStack(spacing: 0) {
26 Group {
27 switch step {
28 case .welcome: welcome
29 case .folder: folder
30 case .notifications: notifications
31 case .calendar: calendar
32 case .reminders: reminders
33 }
34 }
35 .frame(maxWidth: 500, maxHeight: .infinity)
36 .padding(.horizontal, 28)
37 .transition(.asymmetric(insertion: .move(edge: .trailing), removal: .move(edge: .leading)).combined(with: .opacity))
38 .id(step)
39 HStack(spacing: 8) {
40 ForEach(Step.allCases, id: \.self) { s in
41 Circle().fill(s == step ? Color.accentColor : Color.secondary.opacity(0.3)).frame(width: 7, height: 7)
42 }
43 }
44 .accessibilityElement(children: .ignore)
45 .accessibilityLabel("Step \(step.rawValue + 1) of \(Step.allCases.count)")
46 .padding(.bottom, 12)
47 }
48 .tint(model.theme.accentColor)
49 .fileImporter(isPresented: $importing, allowedContentTypes: [.folder]) { result in
50 guard case .success(let url) = result else { return }
51 // Kept for the bookmark; WorkspaceRoot resolves it with access again at launch.
52 _ = url.startAccessingSecurityScopedResource()
53 Task {
54 do {
55 try await workspace.addRoot(url)
56 problem = nil
57 next()
58 } catch {
59 problem = "Can't add \(url.lastPathComponent): \(error.localizedDescription)"
60 }
61 }
62 }
63 }
64
65 private var welcome: some View {
66 page(symbol: "star.fill", title: "Welcome to orgstar", text: "Your org files on iPhone, in the folders where they already are.") {
67 VStack(alignment: .leading, spacing: 18) {
68 feature("calendar", "The agenda", "Scheduled entries, deadlines and TODOs from all your files.")
69 feature("hand.tap", "Tap to edit", "Change an entry's state, dates, tags and notes in place. Swipe to finish or reschedule.")
70 feature("square.and.pencil", "Capture", "Your capture templates, from the app, the share sheet, widgets and the watch.")
71 }
72 .padding(.top, 8)
73 } actions: {
74 primary("Continue") { next() }
75 }
76 }
77
78 private var folder: some View {
79 page(symbol: "folder.fill", title: "Choose your org folder",
80 text: "Pick the folder that holds your org files, in iCloud Drive or another provider. orgstar reads and writes them there; nothing is copied.") {
81 if let problem { Text(problem).font(.footnote).foregroundStyle(.red).multilineTextAlignment(.center) }
82 } actions: {
83 primary("Choose Folder") { importing = true }
84 secondary("Later") { next() }
85 }
86 }
87
88 private var notifications: some View {
89 page(symbol: "bell.badge.fill", title: "Notifications",
90 text: "orgstar can notify you before timed entries, as Org's appointment reminders do, and show today's overdue count on its icon.") {
91 EmptyView()
92 } actions: {
93 primary("Allow Notifications") {
94 Task {
95 _ = try? await UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge])
96 next()
97 }
98 }
99 secondary("Not Now") {
100 // Off, so the agenda doesn't ask later; Settings turns it back on.
101 model.set("reminders", to: .bool(false))
102 next()
103 }
104 }
105 }
106
107 private var calendar: some View {
108 page(symbol: "calendar.badge.clock", title: "Calendar events",
109 text: "Show events from Calendar among your agenda's entries. You can choose which calendars in Settings.") {
110 EmptyView()
111 } actions: {
112 primary("Show Calendar Events") {
113 Task {
114 if await model.calendarEvents.requestAccess() { model.set("calendarEvents", to: .bool(true)) }
115 next()
116 }
117 }
118 secondary("Not Now") { next() }
119 }
120 }
121
122 private var reminders: some View {
123 page(symbol: "checklist", title: "Reminders app",
124 text: "Show incomplete reminders with a due date from the Reminders app in your agenda, read-only.") {
125 EmptyView()
126 } actions: {
127 primary("Show Reminders") {
128 Task {
129 if await model.reminderLists.requestAccess() { model.set("agendaReminders", to: .bool(true)) }
130 next()
131 }
132 }
133 secondary("Not Now") { next() }
134 }
135 }
136
137 private func next() {
138 guard let following = Step(rawValue: step.rawValue + 1) else {
139 model.reloadConfig()
140 finish()
141 return
142 }
143 withAnimation(.snappy) { step = following }
144 }
145
146 // MARK: - Layout
147
148 private func page<Content: View, Actions: View>(
149 symbol: String, title: LocalizedStringKey, text: LocalizedStringKey,
150 @ViewBuilder content: () -> Content, @ViewBuilder actions: () -> Actions
151 ) -> some View {
152 VStack(spacing: 20) {
153 Spacer(minLength: 24)
154 Image(systemName: symbol)
155 .font(.system(size: 44, weight: .semibold))
156 .foregroundStyle(Color.accentColor)
157 .frame(width: 96, height: 96)
158 .background(Color.accentColor.opacity(0.12), in: Circle())
159 .accessibilityHidden(true)
160 Text(title).font(.title.bold()).multilineTextAlignment(.center)
161 Text(text).font(.body).foregroundStyle(.secondary).multilineTextAlignment(.center)
162 content()
163 Spacer(minLength: 24)
164 VStack(spacing: 12) { actions() }
165 }
166 }
167
168 private func feature(_ symbol: String, _ title: LocalizedStringKey, _ text: LocalizedStringKey) -> some View {
169 HStack(alignment: .top, spacing: 14) {
170 Image(systemName: symbol).font(.title2).foregroundStyle(Color.accentColor).frame(width: 32)
171 VStack(alignment: .leading, spacing: 2) {
172 Text(title).font(.headline)
173 Text(text).font(.subheadline).foregroundStyle(.secondary)
174 }
175 }
176 }
177
178 private func primary(_ title: LocalizedStringKey, action: @escaping () -> Void) -> some View {
179 Button(action: action) {
180 Text(title).font(.body.weight(.semibold)).frame(maxWidth: .infinity, minHeight: 50)
181 }
182 .buttonStyle(.borderedProminent)
183 .buttonBorderShape(.capsule)
184 }
185
186 private func secondary(_ title: LocalizedStringKey, action: @escaping () -> Void) -> some View {
187 Button(title, action: action)
188 .font(.body.weight(.medium))
189 .frame(minHeight: 44)
190 }
191}
192#endif
Sources/OrgstarMobile/OrgstarMobileApp.swift +28 −4
@@ -119,6 +119,8 @@ struct RootView: View {
119119 @State private var showingClockReport = false
120120 @State private var message: String?
121121 @Environment(\.scenePhase) private var scenePhase
122 @AppStorage(OnboardingScreen.doneKey) private var onboarded = false
123 @State private var onboarding = false
122124
123125 private var session: DocumentSession { model.session }
124126
@@ -129,6 +131,8 @@ struct RootView: View {
129131 let workspace: WorkspaceModel
130132 let agenda: AgendaModel
131133 let active: Bool
134 /// Notifications and badges ask for permission, which onboarding asks for first.
135 let onboarded: Bool
132136 let hour: Int
133137
134138 private var session: DocumentSession { model.session }
@@ -137,8 +141,8 @@ struct RootView: View {
137141 Color.clear
138142 // Reminders follow the files, the settings, coming back to the app and the hour.
139143 .task(id: ReminderKey(hidden: HiddenFolders.shared.all, files: workspace.files.count, changed: workspace.changedFile?.version, edits: session.editVersion,
140 settings: model.settingsVersion, active: active, hour: hour)) {
141 guard active else { return }
144 settings: model.settingsVersion, active: active, onboarded: onboarded, hour: hour)) {
145 guard active, onboarded else { return }
142146 try? await Task.sleep(for: .seconds(1))
143147 // After the agenda's refresh, whose parsed files these share.
144148 while agenda.isComputing, !Task.isCancelled { try? await Task.sleep(for: .milliseconds(100)) }
@@ -167,6 +171,7 @@ struct RootView: View {
167171 var edits: Int
168172 var settings: Int
169173 var active: Bool
174 var onboarded: Bool
170175 var hour: Int
171176 }
172177
@@ -194,7 +199,26 @@ struct RootView: View {
194199 .clockAccessory(model.clock, perform: clock)
195200 .tint(model.theme.accentColor)
196201 // Until a folder is added there is nothing for the agenda to show.
197 .onAppear { if workspace.rootPaths.isEmpty { tab = .folders } }
202 .onAppear {
203 if workspace.rootPaths.isEmpty { tab = .folders }
204 // First launch only; a workspace from before onboarding existed skips it.
205 guard !onboarded else { return }
206 if workspace.rootPaths.isEmpty, ProcessInfo.processInfo.environment["ORGSTAR_ROOT"] == nil {
207 var transaction = Transaction()
208 transaction.disablesAnimations = true
209 withTransaction(transaction) { onboarding = true }
210 } else {
211 onboarded = true
212 }
213 }
214 .fullScreenCover(isPresented: $onboarding) {
215 OnboardingScreen(model: model, workspace: workspace) {
216 onboarding = false
217 onboarded = true
218 if !workspace.rootPaths.isEmpty { tab = .agenda }
219 }
220 .interactiveDismissDisabled()
221 }
198222 .sheet(item: Binding(get: { model.clockPrompts.pending }, set: { if $0 == nil { model.clockPrompts.answer(nil) } })) { pending in
199223 ClockPromptSheet(prompt: pending.prompt) { model.clockPrompts.answer($0) }
200224 }
@@ -282,7 +306,7 @@ struct RootView: View {
282306 hour += 1
283307 }
284308 }
285 .background { BackgroundWork(model: model, workspace: workspace, agenda: agenda, active: scenePhase == .active, hour: hour) }
309 .background { BackgroundWork(model: model, workspace: workspace, agenda: agenda, active: scenePhase == .active, onboarded: onboarded, hour: hour) }
286310 .onContinueUserActivity(CSSearchableItemActionType) { activity in
287311 if let path = activity.userInfo?[CSSearchableItemActivityIdentifier] as? String { model.openRequest = .file(path) }
288312 }
Tests/OrgCoreTests/EntryFieldsTests.swift added +85
@@ -0,0 +1,85 @@
1import Foundation
2import Testing
3@testable import OrgCore
4
5struct EntryFieldsTests {
6 static let text = """
7 * TODO [#A] Call bank :work:home:
8 SCHEDULED: <2026-10-17 Sat 18:00> DEADLINE: <2026-10-20 Tue>
9 :PROPERTIES:
10 :ID: x
11 :END:
12 :LOGBOOK:
13 CLOCK: [2026-10-16 Fri 09:00]--[2026-10-16 Fri 09:30] => 0:30
14 :END:
15 Line one
16 Line two
17
18 ** Child
19 child body
20
21 """
22
23 @Test func readsTheHeadingPlanningAndNotes() throws {
24 let fields = try #require(EntryFields.read(Self.text, at: 0, settings: .default))
25 #expect(fields.todo == "TODO")
26 #expect(fields.priority == "A")
27 #expect(fields.title == "Call bank")
28 #expect(fields.tags == ["work", "home"])
29 #expect(fields.scheduled == "2026-10-17 Sat 18:00")
30 #expect(fields.deadline == "2026-10-20 Tue")
31 #expect(fields.notes == "Line one\nLine two")
32 }
33
34 @Test func readsAPlainHeading() throws {
35 let fields = try #require(EntryFields.read("* Just a title\n", at: 0, settings: .default))
36 #expect(fields == EntryFields(todo: nil, priority: nil, title: "Just a title", tags: [], scheduled: nil, deadline: nil, notes: ""))
37 #expect(EntryFields.read("no heading\n", at: 0, settings: .default) == nil)
38 }
39
40 @Test func setsTheTitleKeepingKeywordCookieAndTags() {
41 let result = runCommand(SetHeadingTitle(title: "Call the bank"), Self.text, caret: 0)
42 #expect(result.failure == nil)
43 let line = result.text.prefix { $0 != "\n" }
44 #expect(line.hasPrefix("* TODO [#A] Call the bank "))
45 #expect(line.hasSuffix(" :work:home:"))
46 #expect(runCommand(SetHeadingTitle(title: "Named"), "* TODO\nbody\n", caret: 0).text == "* TODO Named\nbody\n")
47 #expect(runCommand(SetHeadingTitle(title: " Trimmed "), "* Old\n", caret: 0).text == "* Trimmed\n")
48 #expect(runCommand(SetHeadingTitle(title: "Two\nlines\n"), "* Old\n", caret: 0).text == "* Two lines\n")
49 }
50
51 @Test func replacesNotesKeepingMetaDataAndChildren() {
52 let result = runCommand(SetEntryNotes(notes: "New note\n\n"), Self.text, caret: 0)
53 #expect(result.failure == nil)
54 #expect(result.text == Self.text.replacingOccurrences(of: "Line one\nLine two\n", with: "New note\n"))
55 let cleared = runCommand(SetEntryNotes(notes: ""), Self.text, caret: 0).text
56 #expect(cleared == Self.text.replacingOccurrences(of: "Line one\nLine two\n", with: ""))
57 }
58
59 @Test func addsNotesWhereThereWereNone() {
60 #expect(runCommand(SetEntryNotes(notes: "Body"), "* A\n* B\n", caret: 0).text == "* A\nBody\n* B\n")
61 #expect(runCommand(SetEntryNotes(notes: "Body"), "* A", caret: 0).text == "* A\nBody\n")
62 #expect(runCommand(SetEntryNotes(notes: "Body"), "* A\nSCHEDULED: <2026-10-17 Sat>\n", caret: 0).text == "* A\nSCHEDULED: <2026-10-17 Sat>\nBody\n")
63 }
64}
65
66struct ReplaceChangedTextTests {
67 @Test func writesTheDifferenceAsOneEdit() throws {
68 let old = "* TODO Call bank\nbody\n* Next\n"
69 let new = "* DONE Call bank\nbody\nmore\n* Next\n"
70 let command = try #require(ReplaceChangedText(from: old, to: new))
71 #expect(command.edit.range == 2..<21)
72 #expect(runCommand(command, old, caret: 0).text == new)
73 #expect(ReplaceChangedText(from: old, to: old) == nil)
74 }
75
76 @Test func refusesTextThatChangedSince() throws {
77 let command = try #require(ReplaceChangedText(from: "* TODO A\n", to: "* DONE A\n"))
78 #expect(runCommand(command, "* WAIT A\n", caret: 0).failure != nil)
79 }
80
81 @Test func keepsSurrogatePairsWhole() throws {
82 let command = try #require(ReplaceChangedText(from: "* 😀\n", to: "* 😃\n"))
83 #expect(runCommand(command, "* 😀\n", caret: 0).text == "* 😃\n")
84 }
85}
Tests/OrgPresentationTests/AgendaRowsTests.swift +11 −4
@@ -31,6 +31,11 @@ struct AgendaRowsTests {
3131 :PROPERTIES:
3232 :STYLE: habit
3333 :END:
34 * TODO Walk dog
35 SCHEDULED: <2026-10-03 Sat 18:00 .+1d>
36 :PROPERTIES:
37 :STYLE: habit
38 :END:
3439 * Far off
3540 <2026-10-11 Sun>
3641 """
@@ -79,7 +84,10 @@ struct AgendaRowsTests {
7984 check("Dentist", "13:50–14:30", .normal, .timestamp)
8085 check("Birthday", "All day", .normal, .timestamp)
8186 check("Conference", "Day 2/3", .normal, .timestamp)
82 check("Stretch", "Habit", .overdue, .habit)
87 check("Stretch", "1d ago", .overdue, .habit)
88 // An earlier day's time says nothing about today.
89 check("Walk dog", "2d ago", .overdue, .habit)
90 #expect(rows["Walk dog"]?.start == nil)
8391 #expect(rows["Dentist"]?.start == 1350 && rows["Dentist"]?.end == 1430)
8492 let rent = rows["Pay rent"]!
8593 #expect(rent.category == "life" && rent.tags == ["home"] && rent.todo == "TODO" && rent.priority == "B" && rent.progress == "0/2")
@@ -125,9 +133,8 @@ struct AgendaRowsTests {
125133
126134 @Test func overdueEntriesGroupAboveTodayOldestFirst() {
127135 let today = AgendaRows.groups(Self.days(), today: Self.today)[0]
128 #expect(today.overdue.map(\.title) == ["Ancient chore", "Pay rent", "Send forms"])
129 #expect(!today.rows.contains { $0.status == .overdue && $0.icon != .habit })
130 #expect(today.rows.contains { $0.title == "Stretch" })
136 #expect(today.overdue.map(\.title) == ["Ancient chore", "Pay rent", "Send forms", "Walk dog", "Stretch"])
137 #expect(!today.rows.contains { $0.status == .overdue })
131138 #expect(Set(today.rows.map(\.id)).count == today.rows.count)
132139 }
133140
docs/manual/guide/07-agenda.org +2 −2
@@ -116,7 +116,7 @@ The entries follow =org-agenda-get-day-entries= with Org's default entry types.
116116| Repeating timestamp =<… +1w>= | On each occurrence within the span | =All day= |
117117| Date range =<…>--<…>= | On every day of the range | =Day 2/5= (day 2 of 5) |
118118| Diary sexp =%%(…)= line or =<%%(…)>= | On each day the sexp applies; see [[*Diary sexps][Diary sexps]] | =All day= |
119| Habit (=STYLE: habit=) | On today only, while not done, unless habits only today is off; see [[*Habits][Habits]] | =Habit=, with a consistency graph |
119| Habit (=STYLE: habit=) | On today only, while not done, unless habits only today is off; see [[*Habits][Habits]]; in the Overdue group when scheduled on an earlier day | =Habit=, or =2d ago= when overdue, with a consistency graph |
120120
121121An entry with a time of day shows the time instead of the status: =08:00=, or =13:50–14:30= with an end time.
122122
@@ -139,7 +139,7 @@ Days without entries are left out. Today always shows, with =Nothing scheduled=
139139org-agenda-show-all-dates = true
140140#+END_SRC
141141
142Today's past deadlines and entries scheduled on earlier days, habits excepted, go in a group headed =Overdue= with their count, above today's other entries. The oldest date comes first; entries with the same date keep Org's order. Click or tap the header to collapse or expand the group; it stays as you left it.
142Today's past deadlines and entries and habits scheduled on earlier days go in a group headed =Overdue= with their count, above today's other entries; on iOS it is a section of its own above today. Their left column shows how late they are, not the time of day they had. The oldest date comes first; entries with the same date keep Org's order. Click or tap the header to collapse or expand the group; it stays as you left it.
143143
144144Days with a time grid show dotted lines at the grid's times among the timed entries, as =org-agenda-time-grid= does: by default at 8:00, 10:00 and every two hours to 20:00, on today and in one-day views, when the day has a timed entry. An entry at a grid line's time comes before the line. On today, a line marked with the current time sits among them: before the first entry that starts later, or after the last one when all have started. The grid's days and times are set in =[org-agenda-time-grid]= in =config.toml=, =org-agenda-use-time-grid= turns the grid off, and =org-agenda-show-current-time-in-grid= the now line (see [[file:13-configuration.org][Configuration]]). With the grid off there is no now line, as in Org.
145145
docs/manual/guide/14-ios.org +4 −4
@@ -4,7 +4,7 @@
44
55* Overview
66
7The app has three tabs, and opens on Folders until a folder has been added:
7On first launch, a few screens introduce the app, ask for the folder of org files, and offer notifications, Calendar events and Reminders; each permission is asked for only when you choose it, and every one can be changed later in Settings. The 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.
@@ -33,7 +33,7 @@ There is no way to open a single file from the Files app. Add the folder that co
3333
3434* The reader
3535
36Tap a file in Folders, Search or the agenda to read it.
36Tap a file in Folders or Search, or Open in File in an agenda entry's sheet, to read it.
3737
3838- Tap a heading to fold or unfold it, as =TAB= cycles it on the Mac. A chevron marks headings with content.
3939- The file opens with the visibility its =#+STARTUP= line asks for, then each heading's =VISIBILITY= property when =#+STARTUP= sets a visibility. Drawers and blocks are folded as =org-cycle-hide-drawer-startup= and =org-cycle-hide-block-startup= say, or as the file's =#+STARTUP= says (=hidedrawers=, =nohideblocks= and the like). Tap a folded drawer's first line or its =…= to open it, and the first line again to fold it.
@@ -186,14 +186,14 @@ Tap a result to open it in the reader. A heading result opens at that heading.
186186
187187* The agenda
188188
189The Agenda tab shows the agenda over all your folders, with the span and start day from the settings (10 days from 3 days ago by default). Each day lists its entries in rows: the time or a status such as =Due today= or =3d late= on the left, the category and the keyword above the title. Days without entries are hidden, except today. Today's overdue entries are in a group of their own, and a line marks the current time between timed entries. Pull down to refresh.
189The Agenda tab shows the agenda over all your folders, with the span and start day from the settings (10 days from 3 days ago by default). Each day lists its entries in rows: the time or a status such as =Due today= or =3d late= on the left, the category and the keyword above the title. Days without entries are hidden, except today. Today's overdue entries are in a section of their own above today, and a line marks the current time between timed entries. Pull down to refresh.
190190
191191- Views (top left) :: the built-in views and those in =views.toml=, Tags and Properties… (a match such as =+work-home= or ~TODO="WAIT"~), and Search… (a phrase, or snippets such as =+invoice -paid=).
192192- Folders (top right, with more than one folder) :: shows or hides each folder's files in the agenda, the widgets, the watch and the badge; the shown folders' names appear under the title. A Focus can hide folders too, and mute their reminders (see Hiding folders in [[file:07-agenda.org][The agenda]]).
193193- The bar at the bottom :: Earlier, Filter, Today, Go to Date, the span (Day, Week, Month or the configured span, and Log Mode, which adds closed entries and clocked time) and Later.
194194- Filter :: keep or leave out tags and categories of the entries shown, or type a filter as Org's =/= takes it: =+keep= and =-drop= tags or categories, =<0:30= for effort, =/regexp/=. The filter in use shows above the bar.
195195- + on a day's header :: captures an entry scheduled on that day (see [[file:08-capture.org][Capture]]).
196- Tap :: an entry to read it, at its heading.
196- Tap :: an entry to open it in a sheet: its title, TODO state, priority, scheduled date, deadline, tags and notes. Changes use the same commands as the editor and are written to the file together on Done, or dropped on Cancel; Undo and Redo step through them. More ▸ Open in File saves and shows the entry in the reader.
197197- Swipe left :: on a TODO entry for Done, which sets the first done keyword of its sequence, or Next State; on any entry with a heading for Delete, which asks first.
198198- Swipe right :: for Tomorrow, Next Week (next Monday) or Pick Date, which move the entry's scheduled date, or its deadline on a deadline row.
199199- Touch and hold :: an entry for TODO State…, Reschedule, Schedule…, Deadline…, Tags…, Priority…, Clock In, Add to Calendar…, Refile…, Archive…, and Delete…. Delete… removes the heading and every line under it, after asking. Refile… lists each file and the headings in it down to level 3, as the Mac's prompt does; the entry goes to the end of the file, or under the heading, you choose. Search narrows the list by file and heading path.