Commit 68713d7d2d

68713d7d2d6d1639dde4cea824091b453ecbd1d5

parent: 67fadc8623

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-11 16:15 UTC

Reminders in the agenda

agenda-reminders and agenda-reminder-lists show incomplete reminders with a due date from Reminders in the agenda, read-only: timed ones at their time, date-only ones as Reminder, overdue ones in today's Overdue group. Mac and iOS settings choose the lists; rows open Reminders. Mirroring scheduled TODOs to a Reminders list is not included.

Closes #60

Layout: unified · split

Sources/OrgApp/AgendaModel.swift +10
@@ -47,6 +47,10 @@ public final class AgendaModel {
4747 public private(set) var events: [AgendaEvent] = []
4848 public var calendarEvents: CalendarEvents?
4949 public var calendarNames: [String] = []
50 /// Reminders due by the last day shown, from `reminderLists` (nil reads none) and the lists
51 /// in `reminderListNames` (all when empty), among the events.
52 public var reminderLists: ReminderLists?
53 public var reminderListNames: [String] = []
5054 /// Today and the calendar of the last refresh.
5155 public private(set) var today = Days.absolute(Date(), calendar: .current)
5256 @ObservationIgnored private var calendar = Calendar.current
@@ -89,6 +93,11 @@ public final class AgendaModel {
8993 let provider = calendarEvents
9094 let names = calendarNames
9195 let all = await sources(open: open)
96 let agendaEnd = jobs.filter { if case .agenda = $0.mode { true } else { false } }.map { $0.first + $0.span }.max()
97 var reminders: [AgendaEvent] = []
98 if let agendaEnd, let reminderLists {
99 reminders = await reminderLists.reminders(before: Self.date(agendaEnd, calendar: calendar), chosen: reminderListNames, calendar: calendar)
100 }
92101 let results = await Task.detached {
93102 jobs.map { job in
94103 var result = AgendaBlockResult(header: job.header, mode: job.mode)
@@ -99,6 +108,7 @@ public final class AgendaModel {
99108 let from = Self.date(job.first, calendar: calendar)
100109 result.events = provider.events(from: from, to: Self.date(job.first + job.span, calendar: calendar), chosen: names)
101110 }
111 result.events += reminders
102112 case .todo(let keywords):
103113 result.list = Agenda.todoList(all, keywords: keywords, options: job.options, today: today)
104114 case .match(let match, let todoOnly):
Sources/OrgApp/OrgPreferences.swift +6
@@ -195,6 +195,12 @@ public enum OrgPreferences {
195195 public static func calendarEventCalendars(_ defaults: UserDefaults = .standard) -> [String] {
196196 string("calendarEventCalendars", defaults).split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty }
197197 }
198 /// `agenda-reminders`: Reminders' incomplete reminders show in the agenda.
199 public static func agendaReminders(_ defaults: UserDefaults = .standard) -> Bool { bool("agendaReminders", defaults) }
200 /// `agenda-reminder-lists`: the lists chosen, by title or identifier; empty for all.
201 public static func agendaReminderLists(_ defaults: UserDefaults = .standard) -> [String] {
202 string("agendaReminderLists", defaults).split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty }
203 }
198204 public static func reminders(_ defaults: UserDefaults = .standard) -> Bool { bool("reminders", defaults) }
199205 /// `appt-message-warning-time`, in minutes.
200206 public static func reminderLead(_ defaults: UserDefaults = .standard) -> Int { integer("reminderLead", defaults) }
Sources/OrgApp/ReminderLists.swift added +75
@@ -0,0 +1,75 @@
1import CoreGraphics
2import EventKit
3import Foundation
4import OrgPresentation
5
6/// What the agenda reads from a reminder: `EKReminder`, or a value made in tests.
7public protocol ReminderRecord {
8 var recordID: String { get }
9 var recordTitle: String { get }
10 var recordDue: DateComponents? { get }
11 var recordListID: String { get }
12 var recordListTitle: String { get }
13 var recordListColor: CGColor? { get }
14}
15
16extension EKReminder: ReminderRecord {
17 public var recordID: String { calendarItemIdentifier }
18 public var recordTitle: String { title ?? "" }
19 public var recordDue: DateComponents? { dueDateComponents }
20 public var recordListID: String { calendar?.calendarIdentifier ?? "" }
21 public var recordListTitle: String { calendar?.title ?? "" }
22 public var recordListColor: CGColor? { calendar?.cgColor }
23}
24
25/// Read-only incomplete reminders with a due date from Reminders for the agenda
26/// (`agenda-reminders` in config.toml), from the lists `agenda-reminder-lists` names.
27public final class ReminderLists: @unchecked Sendable {
28 private let store = EKEventStore()
29
30 public init() {}
31
32 public static var isAuthorized: Bool { EKEventStore.authorizationStatus(for: .reminder) == .fullAccess }
33
34 /// Asks for access once; later calls answer with what the person chose.
35 public func requestAccess() async -> Bool {
36 if Self.isAuthorized { return true }
37 return (try? await store.requestFullAccessToReminders()) ?? false
38 }
39
40 /// The reminder lists, for choosing among them.
41 public func lists() -> [(id: String, title: String, color: RGBA?)] {
42 guard Self.isAuthorized else { return [] }
43 return store.calendars(for: .reminder).map { ($0.calendarIdentifier, $0.title, $0.cgColor.flatMap(CalendarEvents.rgba)) }
44 }
45
46 /// Incomplete reminders due before `end` in the chosen lists (all when `chosen` is empty),
47 /// by due date. Earlier ones are overdue and show today. None without access.
48 public func reminders(before end: Date, chosen: [String], calendar: Calendar = .current) async -> [AgendaEvent] {
49 guard Self.isAuthorized else { return [] }
50 let lists = store.calendars(for: .reminder).filter { CalendarEvents.chooses(id: $0.calendarIdentifier, title: $0.title, chosen: chosen) }
51 guard !lists.isEmpty else { return [] }
52 let predicate = store.predicateForIncompleteReminders(withDueDateStarting: nil, ending: end, calendars: lists)
53 let store = store
54 let found: [AgendaEvent] = await withCheckedContinuation { continuation in
55 store.fetchReminders(matching: predicate) { reminders in
56 continuation.resume(returning: (reminders ?? []).compactMap { Self.event($0, calendar: calendar) })
57 }
58 }
59 return found.sorted { $0.start < $1.start }
60 }
61
62 /// Nil without a due date.
63 public static func event(_ record: some ReminderRecord, calendar: Calendar = .current) -> AgendaEvent? {
64 guard let due = record.recordDue, due.year != nil, due.month != nil, due.day != nil else { return nil }
65 let timed = due.hour != nil
66 var parts = DateComponents(year: due.year, month: due.month, day: due.day, hour: due.hour ?? 0, minute: due.minute ?? 0)
67 parts.timeZone = due.timeZone
68 guard let date = (due.timeZone.map { zone -> Calendar in var c = calendar; c.timeZone = zone; return c } ?? calendar).date(from: parts)
69 else { return nil }
70 return AgendaEvent(
71 id: record.recordID, title: record.recordTitle, calendarID: record.recordListID, calendarTitle: record.recordListTitle,
72 color: record.recordListColor.flatMap(CalendarEvents.rgba), start: date, end: date, isAllDay: !timed, isReminder: true
73 )
74 }
75}
Sources/OrgApp/UserConfig.swift +4
@@ -318,6 +318,10 @@ public enum UserConfig {
318318 comment: "show events from Calendar in the agenda, read-only", legacy: ""),
319319 Setting(section: "orgstar", key: "calendar-event-calendars", defaultsKey: "calendarEventCalendars", kind: .string, fallback: .string(""),
320320 comment: "the calendars whose events show, by title or identifier, separated by commas; \"\" for all", legacy: ""),
321 Setting(section: "orgstar", key: "agenda-reminders", defaultsKey: "agendaReminders", kind: .bool, fallback: .bool(false),
322 comment: "show incomplete reminders with a due date from Reminders in the agenda, read-only", legacy: ""),
323 Setting(section: "orgstar", key: "agenda-reminder-lists", defaultsKey: "agendaReminderLists", kind: .string, fallback: .string(""),
324 comment: "the Reminders lists shown, by title or identifier, separated by commas; \"\" for all", legacy: ""),
321325 Setting(section: "orgstar", key: "global-capture-hotkey", defaultsKey: "globalCapture", kind: .bool, fallback: .bool(true),
322326 comment: "⌃⌥Space opens Capture from any app; templates go in capture.toml", legacy: "capture.global-hotkey"),
323327 ]
Sources/OrgPresentation/AgendaRows.swift +29 −11
@@ -1,7 +1,9 @@
11import Foundation
22import OrgCore
33
4/// An event from the system Calendar, read-only (OrgApp's `CalendarEvents` reads them).
4/// An event from the system Calendar or a reminder from Reminders, read-only (OrgApp's
5/// `CalendarEvents` and `ReminderLists` read them). A reminder starts and ends at its due date;
6/// one without a time is all day.
57public struct AgendaEvent: Sendable, Equatable, Identifiable {
68 public let id: String
79 public let title: String
@@ -13,10 +15,11 @@ public struct AgendaEvent: Sendable, Equatable, Identifiable {
1315 public let end: Date
1416 public let isAllDay: Bool
1517 public let location: String?
18 public let isReminder: Bool
1619
1720 public init(
1821 id: String, title: String, calendarID: String, calendarTitle: String, color: RGBA?, start: Date, end: Date,
19 isAllDay: Bool, location: String? = nil
22 isAllDay: Bool, location: String? = nil, isReminder: Bool = false
2023 ) {
2124 self.id = id
2225 self.title = title
@@ -27,6 +30,7 @@ public struct AgendaEvent: Sendable, Equatable, Identifiable {
2730 self.end = end
2831 self.isAllDay = isAllDay
2932 self.location = location
33 self.isReminder = isReminder
3034 }
3135
3236 /// The days (as `Days` numbers them) the event covers; an end at midnight ends the day before.
@@ -58,7 +62,7 @@ public struct AgendaRow: Sendable, Equatable, Identifiable {
5862 }
5963
6064 public enum Icon: String, Sendable {
61 case scheduled, deadline, habit, event, timestamp
65 case scheduled, deadline, habit, event, timestamp, reminder
6266 }
6367
6468 /// Unique within a day group.
@@ -164,6 +168,7 @@ public struct AgendaRow: Sendable, Equatable, Identifiable {
164168
165169 /// The event's row on `day`: its times on the day it starts (the end only when it ends that
166170 /// day too), `Until 10:00` on the day a longer event ends, `All day` otherwise.
171 /// A reminder due before `day` shows as late, untimed.
167172 public init(event: AgendaEvent, day: Int, calendar: Calendar) {
168173 let days = event.days(calendar: calendar)
169174 func hhmm(_ date: Date) -> Int {
@@ -173,7 +178,16 @@ public struct AgendaRow: Sendable, Equatable, Identifiable {
173178 var start: Int?
174179 var end: Int?
175180 let gutter: String
176 if event.isAllDay || (day != days.lowerBound && day != days.upperBound) {
181 if event.isReminder {
182 if days.lowerBound < day {
183 gutter = "\(AgendaAge.compact(day - days.lowerBound)) late"
184 } else if event.isAllDay {
185 gutter = "Reminder"
186 } else {
187 start = hhmm(event.start)
188 gutter = Self.timeText(start!, nil)
189 }
190 } else if event.isAllDay || (day != days.lowerBound && day != days.upperBound) {
177191 gutter = "All day"
178192 } else if day == days.lowerBound {
179193 start = hhmm(event.start)
@@ -182,10 +196,10 @@ public struct AgendaRow: Sendable, Equatable, Identifiable {
182196 } else {
183197 gutter = "Until " + Self.timeText(hhmm(event.end), nil)
184198 }
185 self.id = "event\u{1f}" + event.id
199 self.id = (event.isReminder ? "reminder\u{1f}" : "event\u{1f}") + event.id
186200 self.gutter = gutter
187 self.status = .normal
188 self.icon = .event
201 self.status = event.isReminder && days.lowerBound < day ? .overdue : .normal
202 self.icon = event.isReminder ? .reminder : .event
189203 self.category = event.calendarTitle
190204 self.title = event.title
191205 self.tags = []
@@ -198,7 +212,7 @@ public struct AgendaRow: Sendable, Equatable, Identifiable {
198212 self.prefixDetail = nil
199213 self.start = start
200214 self.end = end
201 self.planningDay = nil
215 self.planningDay = event.isReminder ? days.lowerBound : nil
202216 self.item = nil
203217 self.event = event
204218 }
@@ -313,7 +327,8 @@ public enum AgendaRows {
313327 /// oldest date first, Org's order among the same date.
314328 /// - Other rows keep Org's order (timed by time, then untimed by urgency, habits last).
315329 /// All-day events come first, timed events go among the timed entries by start time,
316 /// after entries at the same time.
330 /// after entries at the same time. Reminders due before today show in today's
331 /// `overdue`.
317332 /// - `keep` filters the Org entries (an `AgendaFilter`); events are not filtered.
318333 public static func groups(
319334 _ days: [AgendaDay], events: [AgendaEvent] = [], today: Int, showAllDates: Bool = false, calendar: Calendar = .current,
@@ -337,11 +352,14 @@ public enum AgendaRows {
337352 rows.append(row)
338353 }
339354 }
355 let dayEvents = eventDays.filter { event, days in
356 days.contains(day.day) || (event.isReminder && day.day == today && days.upperBound < today)
357 }.map { AgendaRow(event: $0.0, day: day.day, calendar: calendar) }
358 overdue += dayEvents.filter { $0.status == .overdue }
340359 overdue = overdue.enumerated().sorted { a, b in
341360 a.element.planningDay! != b.element.planningDay! ? a.element.planningDay! < b.element.planningDay! : a.offset < b.offset
342361 }.map(\.element)
343 let dayEvents = eventDays.filter { $0.1.contains(day.day) }.map { AgendaRow(event: $0.0, day: day.day, calendar: calendar) }
344 rows = merge(rows, events: dayEvents)
362 rows = merge(rows, events: dayEvents.filter { $0.status != .overdue })
345363 let orgIndices = rows.indices.filter { !rows[$0].isEvent }
346364 var group = AgendaDayGroup(day: day.day, isToday: day.day == today, header: day.header, overdue: unique(overdue), rows: unique(rows))
347365 group.grid = grid.map { .init(before: $0.ordinal < orgIndices.count ? orgIndices[$0.ordinal] : rows.count, time: $0.time) }
Sources/Orgstar/AgendaRowView.swift +1
@@ -94,6 +94,7 @@ struct AgendaRowView: View {
9494 case .deadline: return "flag.fill"
9595 case .habit: return "repeat"
9696 case .event: return "circle.fill"
97 case .reminder: return "circle"
9798 case .timestamp: return row.start == nil ? "calendar" : "clock"
9899 }
99100 }
Sources/Orgstar/AgendaView.swift +19 −5
@@ -10,10 +10,11 @@ enum AgendaSpan: String, CaseIterable {
1010 case day, week, month
1111}
1212
13/// The app's one reader of Calendar events, for the agenda and Settings.
13/// The app's one reader of Calendar events and of Reminders, for the agenda and Settings.
1414@MainActor
1515enum CalendarAccess {
1616 static let events = CalendarEvents()
17 static let reminders = ReminderLists()
1718}
1819
1920/// The agenda window: the day/week agenda, the TODO list, tag matches, text search and saved views.
@@ -75,6 +76,8 @@ struct AgendaView: View {
7576 @AppStorage("agendaShowAllDates") private var showAllDates = false
7677 @AppStorage("calendarEvents") private var calendarEventsOn = false
7778 @AppStorage("calendarEventCalendars") private var calendarNames = ""
79 @AppStorage("agendaReminders") private var remindersOn = false
80 @AppStorage("agendaReminderLists") private var reminderListNames = ""
7881 @AppStorage("agendaPrefixAgenda") private var prefixAgenda = PrefixFormat.defaults["agenda"]!
7982 @AppStorage("agendaPrefixTodo") private var prefixTodo = PrefixFormat.defaults["todo"]!
8083 @AppStorage("agendaPrefixTags") private var prefixTags = PrefixFormat.defaults["tags"]!
@@ -154,7 +157,7 @@ struct AgendaView: View {
154157 mode: agenda.mode, start: agenda.start, span: span, startOffset: startOffset, startOnWeekday: startOnWeekday, includeSubfolders: includeSubfolders, prefix: [prefixAgenda, prefixTodo, prefixTags],
155158 settings: [sortAgenda, sortTodo, sortTags, sortSearch, gridWhen, gridTimes, "\(useTimeGrid) \(showCurrentTime)", stuckMatch, stuckTodo, stuckTags, stuckRegexp, agendaFileList],
156159 logMode: logMode,
157 calendars: calendarEventsOn ? [calendarNames] : [], files: 0, changed: nil, edits: 0, path: nil, tick: tick
160 calendars: (calendarEventsOn ? [calendarNames] : []) + (remindersOn ? ["reminders", reminderListNames] : []), files: 0, changed: nil, edits: 0, path: nil, tick: tick
158161 )
159162 }
160163
@@ -173,6 +176,12 @@ struct AgendaView: View {
173176 } else {
174177 agenda.calendarEvents = nil
175178 }
179 agenda.reminderListNames = OrgPreferences.agendaReminderLists()
180 if remindersOn, isAgenda || isBlocks {
181 agenda.reminderLists = await CalendarAccess.reminders.requestAccess() ? CalendarAccess.reminders : nil
182 } else {
183 agenda.reminderLists = nil
184 }
176185 await agenda.refresh(open: session.openTexts)
177186 }
178187
@@ -536,7 +545,7 @@ struct AgendaView: View {
536545 @ViewBuilder
537546 private func menu(_ line: Line) -> some View {
538547 if let event = line.row.event {
539 Button("Show in Calendar") { openEvent(event) }
548 Button(event.isReminder ? "Show in Reminders" : "Show in Calendar") { openEvent(event) }
540549 } else if line.row.item != nil {
541550 Button("Open") { selection = line.id; jump(line.id) }
542551 Divider()
@@ -561,14 +570,19 @@ struct AgendaView: View {
561570
562571 func item(_ id: String) -> AgendaItem? { line(id)?.row.item }
563572
564 /// Return and double click: the entry in the main window, or the event in Calendar.
573 /// Return and double click: the entry in the main window, or the event in Calendar or Reminders.
565574 func open(_ line: Line) {
566575 selection = line.id
567576 if let event = line.row.event { openEvent(event) } else { jump(line.id) }
568577 }
569578
570 /// Calendar shows an event from its identifier (`AgendaEvent.id` adds `@` and the start).
579 /// Calendar shows an event from its identifier (`AgendaEvent.id` adds `@` and the start);
580 /// Reminders a reminder from its own.
571581 private func openEvent(_ event: AgendaEvent) {
582 if event.isReminder {
583 if let url = URL(string: "x-apple-reminderkit://REMCDReminder/\(event.id)") { NSWorkspace.shared.open(url) }
584 return
585 }
572586 let identifier = event.id.split(separator: "@").dropLast().joined(separator: "@")
573587 guard !identifier.isEmpty, let encoded = identifier.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed),
574588 let url = URL(string: "ical://ekevent/\(encoded)?method=show&options=more") else { return }
Sources/Orgstar/OrgstarApp.swift +37 −5
@@ -579,6 +579,9 @@ struct SettingsView: View {
579579 @AppStorage("calendarEvents") private var calendarEvents = false
580580 @AppStorage("calendarEventCalendars") private var calendarEventCalendars = ""
581581 @State private var calendars: [(id: String, title: String, color: RGBA?)] = []
582 @AppStorage("agendaReminders") private var agendaReminders = false
583 @AppStorage("agendaReminderLists") private var agendaReminderLists = ""
584 @State private var reminderLists: [(id: String, title: String, color: RGBA?)] = []
582585 @AppStorage("reminders") private var reminders = true
583586 @AppStorage("reminderLead") private var reminderLead = 12
584587 @AppStorage("clockIdleTime") private var clockIdleTime = 0
@@ -765,7 +768,7 @@ struct SettingsView: View {
765768 .foregroundStyle(.secondary)
766769 }
767770 ForEach(calendars, id: \.id) { calendar in
768 Toggle(isOn: calendarChosen(calendar)) {
771 Toggle(isOn: chosen(calendar, among: calendars, setting: $calendarEventCalendars)) {
769772 HStack(spacing: 6) {
770773 Circle()
771774 .fill(calendar.color.map { Color(.sRGB, red: $0.red, green: $0.green, blue: $0.blue, opacity: $0.alpha) } ?? .secondary)
@@ -783,6 +786,32 @@ struct SettingsView: View {
783786 let allowed = calendarEvents ? await CalendarAccess.events.requestAccess() : false
784787 calendars = allowed ? CalendarAccess.events.calendars() : []
785788 }
789 Section {
790 Toggle("Show reminders from Reminders", isOn: $agendaReminders)
791 if agendaReminders {
792 if reminderLists.isEmpty {
793 Text(ReminderLists.isAuthorized ? "No lists." : "Allow orgstar to read your reminders in System Settings ▸ Privacy & Security ▸ Reminders.")
794 .foregroundStyle(.secondary)
795 }
796 ForEach(reminderLists, id: \.id) { list in
797 Toggle(isOn: chosen(list, among: reminderLists, setting: $agendaReminderLists)) {
798 HStack(spacing: 6) {
799 Circle()
800 .fill(list.color.map { Color(.sRGB, red: $0.red, green: $0.green, blue: $0.blue, opacity: $0.alpha) } ?? .secondary)
801 .frame(width: 8, height: 8)
802 Text(list.title)
803 }
804 }
805 }
806 }
807 } footer: {
808 Text("Incomplete reminders with a due date show in the agenda read-only, overdue ones under today; double-click one to open it in Reminders.")
809 .settingsFooter()
810 }
811 .task(id: agendaReminders) {
812 let allowed = agendaReminders ? await CalendarAccess.reminders.requestAccess() : false
813 reminderLists = allowed ? CalendarAccess.reminders.lists() : []
814 }
786815 Section {
787816 Toggle("Notify before timed agenda entries", isOn: $reminders)
788817 Stepper("\(reminderLead) minutes before", value: $reminderLead, in: 0...120)
@@ -809,9 +838,12 @@ struct SettingsView: View {
809838 .frame(height: 560)
810839 }
811840
812 /// `calendar-event-calendars`: empty for every calendar, else the titles checked.
813 private func calendarChosen(_ calendar: (id: String, title: String, color: RGBA?)) -> Binding<Bool> {
814 let chosen = calendarEventCalendars.split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty }
841 /// `calendar-event-calendars` and `agenda-reminder-lists`: empty for every calendar or
842 /// list, else the titles checked.
843 private func chosen(
844 _ calendar: (id: String, title: String, color: RGBA?), among calendars: [(id: String, title: String, color: RGBA?)], setting: Binding<String>
845 ) -> Binding<Bool> {
846 let chosen = setting.wrappedValue.split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty }
815847 return Binding {
816848 CalendarEvents.chooses(id: calendar.id, title: calendar.title, chosen: chosen)
817849 } set: { on in
@@ -822,7 +854,7 @@ struct SettingsView: View {
822854 if on { titles.append(calendar.title) }
823855 // An empty list means every calendar; turning events off hides them all.
824856 guard !titles.isEmpty else { return }
825 calendarEventCalendars = Set(titles) == Set(calendars.map(\.title)) ? "" : titles.joined(separator: ", ")
857 setting.wrappedValue = Set(titles) == Set(calendars.map(\.title)) ? "" : titles.joined(separator: ", ")
826858 }
827859 }
828860
Sources/OrgstarMobile/AgendaScreen.swift +7 −4
@@ -294,10 +294,11 @@ struct AgendaScreen: View, Equatable {
294294 if Days.absolute(now, calendar: .current) != agenda.today { tick += 1 }
295295 }
296296 }
297 // Calendar access is asked for when calendar-events is turned on.
297 // Calendar and Reminders access are asked for when calendar-events and
298 // agenda-reminders are turned on.
298299 .task(id: model.settingsVersion) {
299 guard OrgPreferences.calendarEvents(), !CalendarEvents.isAuthorized else { return }
300 if await model.calendarEvents.requestAccess() { tick += 1 }
300 if OrgPreferences.calendarEvents(), !CalendarEvents.isAuthorized, await model.calendarEvents.requestAccess() { tick += 1 }
301 if OrgPreferences.agendaReminders(), !ReminderLists.isAuthorized, await model.reminderLists.requestAccess() { tick += 1 }
301302 }
302303 .background { Refresher(workspace: workspace, session: session, agenda: agenda, model: model, tick: tick, logMode: logMode) }
303304 }
@@ -611,7 +612,8 @@ struct AgendaScreen: View, Equatable {
611612 } else if let event = row.event {
612613 // Calendar can't be asked for one event by URL; it opens on the event's day.
613614 Button {
614 if let url = URL(string: "calshow:\(event.start.timeIntervalSinceReferenceDate)") { openURL(url) }
615 let link = event.isReminder ? "x-apple-reminderkit://REMCDReminder/\(event.id)" : "calshow:\(event.start.timeIntervalSinceReferenceDate)"
616 if let url = URL(string: link) { openURL(url) }
615617 } label: {
616618 AgendaRowView(row: row, day: day, theme: theme, dark: isDark)
617619 }
@@ -935,6 +937,7 @@ struct AgendaRowView: View {
935937 case .deadline: row.status == .overdue ? "exclamationmark.triangle.fill" : "flag.fill"
936938 case .habit: "repeat"
937939 case .event: "calendar"
940 case .reminder: "circle"
938941 case .timestamp: "clock"
939942 case nil: nil
940943 }
Sources/OrgstarMobile/MobileModel.swift +6
@@ -38,6 +38,8 @@ final class MobileModel {
3838 var captureRequest: CaptureRequest?
3939 /// Calendar's events for the agenda, with `calendar-events`.
4040 let calendarEvents = CalendarEvents()
41 /// Reminders for the agenda, with `agenda-reminders`.
42 let reminderLists = ReminderLists()
4143
4244 struct AgendaDays: Equatable {
4345 let start: Int
@@ -150,6 +152,8 @@ final class MobileModel {
150152 agenda.options = OrgPreferences.agendaOptions(agenda.options)
151153 agenda.calendarEvents = OrgPreferences.calendarEvents() ? calendarEvents : nil
152154 agenda.calendarNames = OrgPreferences.calendarEventCalendars()
155 agenda.reminderLists = OrgPreferences.agendaReminders() ? reminderLists : nil
156 agenda.reminderListNames = OrgPreferences.agendaReminderLists()
153157 }
154158 settingsVersion += 1
155159 }
@@ -284,6 +288,8 @@ final class MobileModel {
284288 days.options.logMode = false
285289 days.calendarEvents = agenda.calendarEvents
286290 days.calendarNames = agenda.calendarNames
291 days.reminderLists = agenda.reminderLists
292 days.reminderListNames = agenda.reminderListNames
287293 }
288294 await days.refresh(open: session.openTexts)
289295 let groups = days.groups()
Sources/OrgstarMobile/SettingsScreen.swift +61 −6
@@ -11,6 +11,7 @@ struct SettingsScreen: View {
1111 let model: MobileModel
1212 @State private var choosing = false
1313 @State private var calendars: [CalendarChoice] = []
14 @State private var reminderLists: [CalendarChoice] = []
1415 @State private var badges: Bool?
1516 @Environment(\.openURL) private var openURL
1617 @Environment(\.scenePhase) private var scenePhase
@@ -86,6 +87,7 @@ struct SettingsScreen: View {
8687 if badges == false { Text("Turn on Badges in orgstar's notification settings.") }
8788 }
8889 calendarSection
90 reminderSection
8991 Section("In use") {
9092 let _ = model.settingsVersion
9193 LabeledContent("TODO keywords", value: todoKeywords)
@@ -143,6 +145,58 @@ struct SettingsScreen: View {
143145 .task(id: on) { loadCalendars() }
144146 }
145147
148 /// `agenda-reminders` and `agenda-reminder-lists`, written to config.toml.
149 private var reminderSection: some View {
150 let _ = model.settingsVersion
151 let on = OrgPreferences.agendaReminders()
152 let chosen = OrgPreferences.agendaReminderLists()
153 return Section {
154 Toggle("Show Reminders", isOn: Binding {
155 on
156 } set: { value in
157 model.set("agendaReminders", to: .bool(value))
158 if value { Task { await requestReminders() } }
159 })
160 if on {
161 if !ReminderLists.isAuthorized {
162 Button("Allow Access to Reminders…") { Task { await requestReminders() } }
163 }
164 ForEach(reminderLists, id: \.id) { list in
165 let shown = CalendarEvents.chooses(id: list.id, title: list.title, chosen: chosen)
166 Button {
167 toggle(list.title, shown: shown, chosen: chosen, among: reminderLists, key: "agendaReminderLists")
168 } label: {
169 HStack {
170 Circle().fill(list.color?.swiftUI ?? .secondary).frame(width: 10, height: 10)
171 Text(list.title).foregroundStyle(.primary)
172 Spacer()
173 if shown { Image(systemName: "checkmark").foregroundStyle(Color.accentColor) }
174 }
175 }
176 .tint(.primary)
177 }
178 }
179 } header: {
180 Text("Reminders")
181 } footer: {
182 Text(on ? "Incomplete reminders with a due date from the checked lists show in the agenda, read-only; overdue ones under today."
183 : "Show reminders from Reminders in the agenda, read-only.")
184 }
185 .task(id: on) { loadReminderLists() }
186 }
187
188 private func requestReminders() async {
189 _ = await model.reminderLists.requestAccess()
190 loadReminderLists()
191 model.reloadConfig()
192 }
193
194 private func loadReminderLists() {
195 reminderLists = model.reminderLists.lists()
196 .sorted { $0.title.localizedStandardCompare($1.title) == .orderedAscending }
197 .map { CalendarChoice(id: $0.id, title: $0.title, color: $0.color) }
198 }
199
146200 private func requestCalendars() async {
147201 _ = await model.calendarEvents.requestAccess()
148202 loadCalendars()
@@ -155,15 +209,16 @@ struct SettingsScreen: View {
155209 .map { CalendarChoice(id: $0.id, title: $0.title, color: $0.color) }
156210 }
157211
158 /// Shows or hides a calendar's events; with every calendar checked the setting is empty.
159 /// The last checked calendar stays checked, as an empty list means every calendar.
160 private func toggle(_ title: String, shown: Bool, chosen: [String]) {
161 var titles = calendars.filter { CalendarEvents.chooses(id: $0.id, title: $0.title, chosen: chosen) }.map(\.title)
212 /// Shows or hides a calendar's events or a list's reminders; with every one checked the
213 /// setting is empty. The last checked one stays checked, as an empty list means every one.
214 private func toggle(_ title: String, shown: Bool, chosen: [String], among choices: [CalendarChoice]? = nil, key: String = "calendarEventCalendars") {
215 let choices = choices ?? calendars
216 var titles = choices.filter { CalendarEvents.chooses(id: $0.id, title: $0.title, chosen: chosen) }.map(\.title)
162217 titles.removeAll { $0 == title }
163218 if !shown { titles.append(title) }
164219 guard !titles.isEmpty else { return }
165 let value = Set(titles) == Set(calendars.map(\.title)) ? "" : titles.joined(separator: ", ")
166 model.set("calendarEventCalendars", to: .string(value))
220 let value = Set(titles) == Set(choices.map(\.title)) ? "" : titles.joined(separator: ", ")
221 model.set(key, to: .string(value))
167222 }
168223
169224 /// The span and start day, worded as the Mac's Settings word the start.
Tests/OrgAppTests/ReminderListsTests.swift added +60
@@ -0,0 +1,60 @@
1import CoreGraphics
2import Foundation
3import OrgCore
4import OrgPresentation
5import Testing
6@testable import OrgApp
7
8struct ReminderListsTests {
9 struct Record: ReminderRecord {
10 var recordID = "r1"
11 var recordTitle = "Call the bank"
12 var recordDue: DateComponents? = DateComponents(year: 2026, month: 10, day: 12, hour: 15, minute: 30)
13 var recordListID = "list-1"
14 var recordListTitle = "Errands"
15 var recordListColor: CGColor? = CGColor(srgbRed: 0, green: 0.5, blue: 1, alpha: 1)
16 }
17
18 static var utc: Calendar {
19 var c = Calendar(identifier: .gregorian)
20 c.timeZone = TimeZone(identifier: "UTC")!
21 return c
22 }
23
24 @Test func recordsBecomeAgendaEvents() throws {
25 let event = try #require(ReminderLists.event(Record(), calendar: Self.utc))
26 #expect(event.isReminder && !event.isAllDay && event.title == "Call the bank" && event.calendarTitle == "Errands")
27 #expect(event.start == event.end && Self.utc.dateComponents([.hour, .minute], from: event.start) == DateComponents(hour: 15, minute: 30))
28 var untimed = Record()
29 untimed.recordDue = DateComponents(year: 2026, month: 10, day: 12)
30 #expect(ReminderLists.event(untimed, calendar: Self.utc)?.isAllDay == true)
31 var none = Record()
32 none.recordDue = nil
33 #expect(ReminderLists.event(none, calendar: Self.utc) == nil)
34 }
35
36 @Test func remindersGoOnTheirDayAndOverdueOnesToday() throws {
37 let calendar = Self.utc
38 let timed = try #require(ReminderLists.event(Record(), calendar: calendar))
39 var untimedRecord = Record()
40 untimedRecord.recordID = "r2"
41 untimedRecord.recordDue = DateComponents(year: 2026, month: 10, day: 13)
42 let untimed = try #require(ReminderLists.event(untimedRecord, calendar: calendar))
43 var lateRecord = Record()
44 lateRecord.recordID = "r3"
45 lateRecord.recordDue = DateComponents(year: 2026, month: 10, day: 9, hour: 9, minute: 0)
46 let late = try #require(ReminderLists.event(lateRecord, calendar: calendar))
47 let today = Days.absolute(calendar.date(from: DateComponents(year: 2026, month: 10, day: 11))!, calendar: calendar)
48 let days = Agenda.list([], start: today, days: 4, today: today, now: (8, 0), options: AgendaOptions())
49 let groups = AgendaRows.groups(days, events: [timed, untimed, late], today: today, calendar: calendar)
50 let todayGroup = try #require(groups.first { $0.day == today })
51 #expect(todayGroup.overdue.map(\.gutter) == ["2d late"])
52 #expect(todayGroup.overdue.first?.status == .overdue && todayGroup.overdue.first?.icon == .reminder)
53 let monday = try #require(groups.first { $0.day == today + 1 })
54 #expect(monday.rows.map(\.gutter) == ["15:30"] && monday.rows[0].category == "Errands" && monday.rows[0].isEvent)
55 let tuesday = try #require(groups.first { $0.day == today + 2 })
56 #expect(tuesday.rows.map(\.gutter) == ["Reminder"])
57 // The late reminder isn't repeated on the days after today.
58 #expect(!groups.contains { $0.day != today && ($0.rows + $0.overdue).contains { $0.title == "Call the bank" && $0.gutter.hasSuffix("late") } })
59 }
60}
docs/manual/guide/07-agenda.org +24
@@ -217,6 +217,30 @@ Events appear only in the day, week and month view:
217217
218218On the Mac, double-click an event, or select it and press =RET=, to open it in Calendar; its context menu has Show in Calendar. Entry commands such as =t= don't apply to events.
219219
220* Reminders
221
222The agenda can also show reminders from the Reminders app (EventKit), read-only. It is off by default. To turn it on:
223
224- On the Mac, turn on Settings ▸ Agenda ▸ Show reminders from Reminders, and check the lists to show.
225- On iOS, turn on Settings ▸ Reminders ▸ Show Reminders, and tap the lists to show.
226- Or set the keys in =config.toml=:
227
228#+BEGIN_SRC toml
229[orgstar]
230agenda-reminders = true
231agenda-reminder-lists = "Errands, Work"
232#+END_SRC
233
234=agenda-reminder-lists= names lists by title or identifier, separated by commas; =""= (the default) shows every list. The first time reminders are turned on, orgstar asks for full access to your reminders; if you declined, allow it in System Settings ▸ Privacy & Security ▸ Reminders on the Mac, or in the Settings app on iOS.
235
236Only incomplete reminders with a due date show, in the day, week and month view:
237
238- A reminder with a due time shows at that time among the timed entries, as a timed event does. One with only a due date shows =Reminder= with the all-day events.
239- A reminder due before today shows in today's Overdue group as =2d late=, among the overdue entries by date.
240- The row's category is the list's name, and the dot takes the list's color.
241
242Completing or editing a reminder is done in Reminders. On the Mac, double-click a reminder, or press =RET=, to open it in Reminders; its context menu has Show in Reminders. On iOS, tap it.
243
220244* Done keywords the agenda doesn't know
221245
222246A keyword that isn't in =org-todo-keywords= or the file's =#+TODO= lines is not a keyword to orgstar, as to Org: it is part of the title. A heading such as =SKIPPED Call the bank= with a =SCHEDULED= date last week is therefore an open entry, and shows as overdue. To make such a word a done state, add it after the ~|~:
docs/manual/guide/13-configuration.org +5 −1
@@ -112,6 +112,8 @@ See Themes and Fonts below.
112112| Blocked entries | Dimmed; Hidden; Shown as usual | Dimmed | =org-agenda-dim-blocked-tasks= |
113113| Show events from Calendar | On or off | Off | =calendar-events= |
114114| A checkbox for each calendar | On or off | All on | =calendar-event-calendars= |
115| Show reminders from Reminders | On or off | Off | =agenda-reminders= |
116| A checkbox for each list | On or off | All on | =agenda-reminder-lists= |
115117| Notify before timed agenda entries | On or off | On | =reminders= |
116118| N minutes before | 0 to 120 | 12 | =appt-message-warning-time= |
117119| Ask what to do with idle time while clocked in | On or off | Off | =org-clock-idle-time= |
@@ -120,7 +122,7 @@ See Themes and Fonts below.
120122
121123An entry's =APPT_WARNTIME= property overrides the lead time. The agenda is covered in [[file:07-agenda.org][The agenda]].
122124
123The calendar checkboxes appear once Show events from Calendar is on and orgstar may read your calendars; turning the switch on asks for that access. While every calendar is checked, =calendar-event-calendars= is empty, so calendars you add later show too. The last checked calendar can't be unchecked; turn off Show events from Calendar instead.
125The calendar checkboxes appear once Show events from Calendar is on and orgstar may read your calendars; turning the switch on asks for that access. While every calendar is checked, =calendar-event-calendars= is empty, so calendars you add later show too. The last checked calendar can't be unchecked; turn off Show events from Calendar instead. The Reminders list checkboxes work the same way. See [[file:07-agenda.org][The agenda]].
124126
125127Turning on the idle question sets =org-clock-idle-time= to 15 minutes; turning it off sets it to =0=. The minutes stepper is disabled while the question is off. Idle time and the clock history are covered in [[file:06-dates-and-clocking.org][Dates and clocking]].
126128
@@ -365,6 +367,8 @@ Any other key in =[theme]= is a color; see Themes below.
365367| =reminders= | boolean | =true= | Notify before timed entries. |
366368| =calendar-events= | boolean | =false= | Show events from Calendar in the agenda, read-only. |
367369| =calendar-event-calendars= | string | =""= | The calendars whose events show, by title or identifier, separated by commas; =""= for all. |
370| =agenda-reminders= | boolean | =false= | Show incomplete reminders with a due date from Reminders in the agenda, read-only. |
371| =agenda-reminder-lists= | string | =""= | The Reminders lists shown, by title or identifier, separated by commas; =""= for all. |
368372| =global-capture-hotkey= | boolean | =true= | =⌃⌥Space= opens Capture from any app. |
369373
370374The default =ignored-folders= is:
docs/manual/guide/14-ios.org +4 −3
@@ -179,7 +179,7 @@ The Agenda tab shows the agenda over all your folders, with the span and start d
179179
180180Commands from the agenda change the file directly when it isn't open, and through the editor when it is. If the heading changed since the agenda was built, nothing runs.
181181
182With =calendar-events= on, the agenda also shows events from the Calendar app; see Settings below.
182With =calendar-events= on, the agenda also shows events from the Calendar app, and with =agenda-reminders= on, reminders from the Reminders app; see Settings below.
183183
184184See [[file:07-agenda.org][The agenda]] for the rows, the views and matches, and the differences from the Mac.
185185
@@ -346,13 +346,14 @@ Import from Emacs reads an Emacs or Doom configuration folder, such as a synced
346346
347347With a configuration folder, settings and structure templates are written to its =config.toml=, and capture templates, key bindings and agenda views to its =capture.toml=, =keymap.toml= and =views.toml=, so the Mac reads them too. Without one, settings are kept on the device. Folders from =org-agenda-files= name the Mac's paths and aren't offered.
348348
349The Agenda, TODO Dependencies and Calendar sections are the only places the app changes a setting itself:
349The Agenda, TODO Dependencies, Calendar and Reminders sections are the only places the app changes a setting itself, besides Import from Emacs:
350350
351351- Show days without entries :: turns =org-agenda-show-all-dates= on or off.
352352- Blocked entries :: Dimmed, Hidden or Shown as usual (=org-agenda-dim-blocked-tasks=).
353353- TODO Dependencies :: Not done before TODO children (=org-enforce-todo-dependencies=) and Not done with unchecked boxes (=org-enforce-todo-checkbox-dependencies=).
354354- Show Calendar Events :: turns on =calendar-events=, and asks for access to your calendars. iOS asks for full access, as Calendar has no read-only level; orgstar only reads. While access is missing the section shows Allow Access to Calendars…; if you declined, allow it in the Settings app under Privacy & Security ▸ Calendars.
355355- The calendars :: tap one to show or hide its events (=calendar-event-calendars=). With every calendar checked the setting is empty, so calendars added later show too.
356- Show Reminders :: turns on =agenda-reminders= and asks for access to your reminders; Allow Access to Reminders… shows while it is missing. Tap a list to show or hide its reminders (=agenda-reminder-lists=).
356357
357358These write =config.toml= in the configuration folder, as the Mac's Settings window does, so the Mac sees the change too. Without a configuration folder they are kept on the device.
358359
@@ -374,7 +375,7 @@ These settings from =config.toml= apply on iOS:
374375- =org-use-speed-commands=, with a hardware keyboard
375376- =electric-pair-mode=, =spell-check=, =auto-fill-mode=
376377- =org-agenda-span=, =org-agenda-start-day=, =org-agenda-start-on-weekday=, =org-deadline-warning-days=, =agenda-include-subfolders=, =org-agenda-show-all-dates=, =org-agenda-skip-scheduled-if-done=, =org-agenda-skip-deadline-if-done=, =org-agenda-search-view-always-boolean=, =org-agenda-search-view-force-full-words=, =org-agenda-log-mode-items=, the =org-agenda-todo-ignore-= settings, =org-agenda-tags-todo-honor-ignore-options=
377- =calendar-events=, =calendar-event-calendars=
378- =calendar-events=, =calendar-event-calendars=, =agenda-reminders=, =agenda-reminder-lists=
378379- =reminders=, =appt-message-warning-time=
379380- =org-clock-history-length=, =org-clock-into-drawer=, =org-clock-rounding-minutes=, =org-clock-out-remove-zero-time-clocks=, =org-clock-in-switch-to-state=, =org-clock-out-when-done=
380381
ios/Orgstar/Info.plist +2
@@ -41,6 +41,8 @@
4141 <string>Face ID unlocks the passphrase of encrypted entries you asked orgstar to remember.</string>
4242 <key>NSCalendarsFullAccessUsageDescription</key>
4343 <string>The agenda shows your calendar events alongside your Org entries. orgstar only reads them.</string>
44 <key>NSRemindersFullAccessUsageDescription</key>
45 <string>The agenda shows your reminders alongside your Org entries. orgstar only reads them.</string>
4446 <key>NSSupportsLiveActivities</key>
4547 <true/>
4648 <key>UIApplicationSceneManifest</key>
scripts/build-app.sh +2
@@ -133,6 +133,8 @@ ${feed_keys}
133133 <string>public.app-category.productivity</string>
134134 <key>NSCalendarsFullAccessUsageDescription</key>
135135 <string>The agenda shows your calendar events alongside your Org entries. orgstar only reads them.</string>
136 <key>NSRemindersFullAccessUsageDescription</key>
137 <string>The agenda shows your reminders alongside your Org entries. orgstar only reads them.</string>
136138 <key>NSHighResolutionCapable</key>
137139 <true/>
138140 <key>NSPrincipalClass</key>
scripts/build-ios-app.sh +2
@@ -53,6 +53,8 @@ cat > "$app/Info.plist" <<PLIST
5353 <string>Face ID unlocks the passphrase of encrypted entries you asked orgstar to remember.</string>
5454 <key>NSCalendarsFullAccessUsageDescription</key>
5555 <string>The agenda shows your calendar events alongside your Org entries. orgstar only reads them.</string>
56 <key>NSRemindersFullAccessUsageDescription</key>
57 <string>The agenda shows your reminders alongside your Org entries. orgstar only reads them.</string>
5658 <key>UIDeviceFamily</key>
5759 <array><integer>1</integer><integer>2</integer></array>
5860 <key>UILaunchScreen</key>