Commit 1f8e73bc44

1f8e73bc44bbf42b00b648fa98a5fc5c52741945

parent: d4ccb12cca

Verified · cmc

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

Hide folders from the agenda, by menu or Focus filter

A Folders menu in the agenda toolbar (Mac and iOS, with more than one
folder) shows or hides each folder's files; the shown folders' names go
under the title. The Hide Folders Focus filter hides its folders too while
the Focus is on and mutes their reminders through each notification's
filterCriteria. A folder either hides is left out of the agenda, widgets,
watch and badge. Both lists are kept per device in HiddenFolders.

Layout: unified · split

Sources/OrgApp/AgendaModel.swift +15 −3
@@ -38,6 +38,8 @@ public final class AgendaModel {
38 public var includeSubfolders = false 38 public var includeSubfolders = false
39 /// Files other agenda files archive to are left out. 39 /// Files other agenda files archive to are left out.
40 public var excludeArchives = OrgPreferences.agendaExcludeArchives() 40 public var excludeArchives = OrgPreferences.agendaExcludeArchives()
41 /// Files in these folders (root paths) are left out; see `HiddenFolders`.
42 public var hiddenFolders: Set<String> = []
41 /// `org-agenda-files`: when not empty, the agenda reads these instead of the folders' files. 43 /// `org-agenda-files`: when not empty, the agenda reads these instead of the folders' files.
42 public var agendaFiles = OrgPreferences.agendaFiles() 44 public var agendaFiles = OrgPreferences.agendaFiles()
43 public var options = AgendaOptions() 45 public var options = AgendaOptions()
@@ -68,7 +70,10 @@ public final class AgendaModel {
68 70
69 /// Org files directly in each folder (or below it, with `includeSubfolders`), by path, as 71 /// Org files directly in each folder (or below it, with `includeSubfolders`), by path, as
70 /// Emacs lists a directory in `org-agenda-files`. 72 /// Emacs lists a directory in `org-agenda-files`.
71 public var files: [String] { workspace.agendaFilePaths(list: agendaFiles, includeSubfolders: includeSubfolders) } 73 public var files: [String] {
74 let paths = workspace.agendaFilePaths(list: agendaFiles, includeSubfolders: includeSubfolders)
75 return hiddenFolders.isEmpty ? paths : paths.filter { !HiddenFolders.hides(hiddenFolders, path: $0) }
76 }
72 77
73 /// Recomputes the days. `open` is the open buffers' text by path. 78 /// Recomputes the days. `open` is the open buffers' text by path.
74 public func refresh(open: [String: String], now: Date = Date(), calendar: Calendar = .current) async { 79 public func refresh(open: [String: String], now: Date = Date(), calendar: Calendar = .current) async {
@@ -139,10 +144,17 @@ public final class AgendaModel {
139 isComputing = false 144 isComputing = false
140 } 145 }
141 146
142 /// Reminders for the timed entries of the next `days` days. 147 /// Reminders for the timed entries of the next `days` days, each with the folder it is in.
143 public func reminders(open: [String: String], now: Date = Date(), calendar: Calendar = .current, days: Int = 7, lead: Int = 12) async -> [Reminder] { 148 public func reminders(open: [String: String], now: Date = Date(), calendar: Calendar = .current, days: Int = 7, lead: Int = 12) async -> [Reminder] {
144 let all = await sources(open: open) 149 let all = await sources(open: open)
145 return await Task.detached { Reminders.upcoming(all, now: now, calendar: calendar, days: days, lead: lead) }.value 150 let roots = workspace.rootPaths
151 return await Task.detached {
152 Reminders.upcoming(all, now: now, calendar: calendar, days: days, lead: lead).map { reminder in
153 var reminder = reminder
154 reminder.folder = roots.first { HiddenFolders.hides([$0], path: reminder.path) }
155 return reminder
156 }
157 }.value
146 } 158 }
147 159
148 /// The habits of the agenda files, file by file. 160 /// The habits of the agenda files, file by file.
Sources/OrgApp/HiddenFolders.swift added +40
@@ -0,0 +1,40 @@
1import Foundation
2import Observation
3
4/// The folders the agenda leaves out on this device, by root path: the ones hidden from the
5/// agenda's folder menu and the ones the active Focus filter hides. A folder either hides is
6/// hidden. Reminders stay on for both; the Focus filter mutes its folders' through the
7/// system, by each notification's `filterCriteria`.
8@MainActor
9@Observable
10public final class HiddenFolders {
11 public static let shared = HiddenFolders()
12
13 /// Hidden from the agenda's folder menu.
14 public var manual: Set<String> { didSet { defaults.set(manual.sorted(), forKey: Self.manualKey) } }
15 /// Hidden by the active Focus filter.
16 public var focus: Set<String> { didSet { defaults.set(focus.sorted(), forKey: Self.focusKey) } }
17
18 public var all: Set<String> { manual.union(focus) }
19
20 static let manualKey = "agendaHiddenFolders"
21 static let focusKey = "agendaFocusHiddenFolders"
22 @ObservationIgnored private let defaults: UserDefaults
23
24 public init(defaults: UserDefaults = .standard) {
25 self.defaults = defaults
26 manual = Set(defaults.stringArray(forKey: Self.manualKey) ?? [])
27 focus = Set(defaults.stringArray(forKey: Self.focusKey) ?? [])
28 }
29
30 /// `path` is one of `folders` or inside one.
31 public nonisolated static func hides(_ folders: Set<String>, path: String) -> Bool {
32 folders.contains { path == $0 || path.hasPrefix($0.hasSuffix("/") ? $0 : $0 + "/") }
33 }
34
35 /// For a Focus filter's app context: notifications whose `filterCriteria` (their folder) is
36 /// not one of `folders`.
37 public nonisolated static func notificationPredicate(hiding folders: Set<String>) -> NSPredicate {
38 NSPredicate(format: "NOT (SELF IN %@)", folders.sorted())
39 }
40}
Sources/OrgApp/ReminderScheduler.swift +1
@@ -99,6 +99,7 @@ public struct SystemReminderCenter: ReminderCenter {
99 content.body = reminder.body 99 content.body = reminder.body
100 content.sound = .default 100 content.sound = .default
101 content.userInfo = ["path": reminder.path, "offset": reminder.offset] 101 content.userInfo = ["path": reminder.path, "offset": reminder.offset]
102 if let folder = reminder.folder { content.filterCriteria = folder }
102 let components = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute, .second], from: reminder.fireDate) 103 let components = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute, .second], from: reminder.fireDate)
103 let trigger = UNCalendarNotificationTrigger(dateMatching: components, repeats: false) 104 let trigger = UNCalendarNotificationTrigger(dateMatching: components, repeats: false)
104 try await UNUserNotificationCenter.current().add(UNNotificationRequest(identifier: reminder.id, content: content, trigger: trigger)) 105 try await UNUserNotificationCenter.current().add(UNNotificationRequest(identifier: reminder.id, content: content, trigger: trigger))
Sources/OrgApp/WorkspaceModel.swift +9 −1
@@ -64,13 +64,21 @@ public final class WorkspaceModel {
64 } 64 }
65 65
66 /// `~/Library/Application Support/Orgstar`, or `ORGSTAR_DATA_DIR` when set (for development). 66 /// `~/Library/Application Support/Orgstar`, or `ORGSTAR_DATA_DIR` when set (for development).
67 public static var defaultDirectory: URL { 67 public nonisolated static var defaultDirectory: URL {
68 if let override = ProcessInfo.processInfo.environment["ORGSTAR_DATA_DIR"] { 68 if let override = ProcessInfo.processInfo.environment["ORGSTAR_DATA_DIR"] {
69 return URL(fileURLWithPath: override) 69 return URL(fileURLWithPath: override)
70 } 70 }
71 return FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0].appendingPathComponent("Orgstar") 71 return FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0].appendingPathComponent("Orgstar")
72 } 72 }
73 73
74 /// The resolved paths of the roots saved in `directory`, without opening the index: for
75 /// App Intents, which may run before the app's models.
76 public nonisolated static func savedRootPaths(in directory: URL = defaultDirectory) -> [String] {
77 guard let data = try? Data(contentsOf: directory.appendingPathComponent("roots.json")),
78 let roots = try? JSONDecoder().decode([WorkspaceRoot].self, from: data) else { return [] }
79 return roots.compactMap { try? $0.resolve().url.path }.sorted()
80 }
81
74 // MARK: - Roots 82 // MARK: - Roots
75 83
76 public func addRoot(_ url: URL) async throws { 84 public func addRoot(_ url: URL) async throws {
Sources/OrgCore/Agenda/Reminders.swift +2
@@ -10,6 +10,8 @@ public struct Reminder: Sendable, Equatable {
10 public let body: String 10 public let body: String
11 public let path: String 11 public let path: String
12 public let offset: Int 12 public let offset: Int
13 /// The folder the entry's file is in, for Focus filters to mute.
14 public var folder: String?
13 15
14 public init(id: String, fireDate: Date, eventDate: Date, title: String, body: String, path: String, offset: Int) { 16 public init(id: String, fireDate: Date, eventDate: Date, title: String, body: String, path: String, offset: Int) {
15 self.id = id 17 self.id = id
Sources/Orgstar/AgendaView+Toolbar.swift +36
@@ -63,6 +63,7 @@ extension AgendaView {
63 } 63 }
64 } 64 }
65 } 65 }
66 if workspace.rootPaths.count > 1 || hidesFolders { foldersMenu }
66 Menu { 67 Menu {
67 Button("Filter…") { askFilter("/") } 68 Button("Filter…") { askFilter("/") }
68 Button("By Tag…") { askFilter("\\") } 69 Button("By Tag…") { askFilter("\\") }
@@ -81,6 +82,41 @@ extension AgendaView {
81 } 82 }
82 } 83 }
83 84
85 /// Shows or hides each folder's files; folders the Focus hides stay hidden.
86 private var foldersMenu: some View {
87 let hidden = HiddenFolders.shared
88 return Menu {
89 Button("All Folders") { hidden.manual = [] }
90 .disabled(hidden.manual.isEmpty)
91 Divider()
92 ForEach(workspace.rootPaths, id: \.self) { root in
93 Toggle((root as NSString).lastPathComponent, isOn: Binding {
94 !hidden.all.contains(root)
95 } set: { shown in
96 if shown { hidden.manual.remove(root) } else { hidden.manual.insert(root) }
97 })
98 .disabled(hidden.focus.contains(root))
99 }
100 if !hidden.focus.isDisjoint(with: workspace.rootPaths) {
101 Divider()
102 Text("Dimmed folders are hidden by the current Focus.")
103 }
104 } label: {
105 Label("Folders", systemImage: hidesFolders ? "folder.fill" : "folder")
106 }
107 .help("The folders the agenda shows")
108 }
109
110 /// Some folder is hidden.
111 var hidesFolders: Bool { !HiddenFolders.shared.all.isDisjoint(with: workspace.rootPaths) }
112
113 /// The folders shown, by name, while some are hidden.
114 var shownFolders: String? {
115 guard hidesFolders else { return nil }
116 let shown = workspace.rootPaths.filter { !HiddenFolders.shared.all.contains($0) }
117 return shown.isEmpty ? "No folders" : shown.map { ($0 as NSString).lastPathComponent }.joined(separator: ", ")
118 }
119
84 /// The span shown, as the window's title: `Week of 5 Oct 2026`. 120 /// The span shown, as the window's title: `Week of 5 Oct 2026`.
85 var title: String { 121 var title: String {
86 guard isAgenda else { return viewName.replacingOccurrences(of: "…", with: "") } 122 guard isAgenda else { return viewName.replacingOccurrences(of: "…", with: "") }
Sources/Orgstar/AgendaView.swift +7 −3
@@ -141,6 +141,7 @@ struct AgendaView: View {
141 var startOffset: Int 141 var startOffset: Int
142 var startOnWeekday: String 142 var startOnWeekday: String
143 var includeSubfolders: Bool 143 var includeSubfolders: Bool
144 var hidden: Set<String>
144 var prefix: [String] 145 var prefix: [String]
145 var settings: [String] 146 var settings: [String]
146 var logMode: Bool 147 var logMode: Bool
@@ -156,7 +157,7 @@ struct AgendaView: View {
156 /// they redraw only it. 157 /// they redraw only it.
157 private var refreshKey: RefreshKey { 158 private var refreshKey: RefreshKey {
158 RefreshKey( 159 RefreshKey(
159 mode: agenda.mode, start: agenda.start, span: span, startOffset: startOffset, startOnWeekday: startOnWeekday, includeSubfolders: includeSubfolders, prefix: [prefixAgenda, prefixTodo, prefixTags], 160 mode: agenda.mode, start: agenda.start, span: span, startOffset: startOffset, startOnWeekday: startOnWeekday, includeSubfolders: includeSubfolders, hidden: HiddenFolders.shared.all, prefix: [prefixAgenda, prefixTodo, prefixTags],
160 settings: [sortAgenda, sortTodo, sortTags, sortSearch, gridWhen, gridTimes, "\(useTimeGrid) \(showCurrentTime)", stuckMatch, stuckTodo, stuckTags, stuckRegexp, agendaFileList], 161 settings: [sortAgenda, sortTodo, sortTags, sortSearch, gridWhen, gridTimes, "\(useTimeGrid) \(showCurrentTime)", stuckMatch, stuckTodo, stuckTags, stuckRegexp, agendaFileList],
161 logMode: logMode, 162 logMode: logMode,
162 calendars: (calendarEventsOn ? [calendarNames] : []) + (remindersOn ? ["reminders", reminderListNames] : []), files: 0, changed: nil, edits: 0, path: nil, tick: tick 163 calendars: (calendarEventsOn ? [calendarNames] : []) + (remindersOn ? ["reminders", reminderListNames] : []), files: 0, changed: nil, edits: 0, path: nil, tick: tick
@@ -169,6 +170,7 @@ struct AgendaView: View {
169 agenda.startOnWeekday = Int(startOnWeekday) 170 agenda.startOnWeekday = Int(startOnWeekday)
170 agenda.includeSubfolders = includeSubfolders 171 agenda.includeSubfolders = includeSubfolders
171 agenda.excludeArchives = OrgPreferences.agendaExcludeArchives() 172 agenda.excludeArchives = OrgPreferences.agendaExcludeArchives()
173 agenda.hiddenFolders = HiddenFolders.shared.all
172 agenda.agendaFiles = OrgPreferences.agendaFiles() 174 agenda.agendaFiles = OrgPreferences.agendaFiles()
173 agenda.options.prefixFormat = ["agenda": prefixAgenda, "todo": prefixTodo, "tags": prefixTags] 175 agenda.options.prefixFormat = ["agenda": prefixAgenda, "todo": prefixTodo, "tags": prefixTags]
174 agenda.options.logMode = logMode 176 agenda.options.logMode = logMode
@@ -353,8 +355,10 @@ struct AgendaView: View {
353 } 355 }
354 .toolbar { toolbar } 356 .toolbar { toolbar }
355 .overlay { 357 .overlay {
356 if agenda.files.isEmpty { 358 if agenda.files.isEmpty, !hidesFolders {
357 ContentUnavailableView("No agenda files", systemImage: "calendar", description: Text("The agenda reads the org files at the top of each folder you add.")) 359 ContentUnavailableView("No agenda files", systemImage: "calendar", description: Text("The agenda reads the org files at the top of each folder you add."))
360 } else if agenda.files.isEmpty {
361 ContentUnavailableView("All folders hidden", systemImage: "folder", description: Text("Show a folder from the Folders menu."))
358 } 362 }
359 } 363 }
360 .sheet(item: $eventRequest) { request in 364 .sheet(item: $eventRequest) { request in
@@ -412,7 +416,7 @@ struct AgendaView: View {
412 } 416 }
413 } 417 }
414 .navigationTitle(title) 418 .navigationTitle(title)
415 .navigationSubtitle(isAgenda && viewName != AgendaViewLoader.builtIn[0].name ? viewName : "") 419 .navigationSubtitle(([isAgenda && viewName != AgendaViewLoader.builtIn[0].name ? viewName : ""] + [shownFolders ?? ""]).filter { !$0.isEmpty }.joined(separator: " · "))
416 .onChange(of: viewName) { applyView() } 420 .onChange(of: viewName) { applyView() }
417 .onChange(of: commands.agendaRequest?.start, initial: true) { showRequestedDays() } 421 .onChange(of: commands.agendaRequest?.start, initial: true) { showRequestedDays() }
418 .onChange(of: commands.agendaRequest?.days) { showRequestedDays() } 422 .onChange(of: commands.agendaRequest?.days) { showRequestedDays() }
Sources/Orgstar/ContentView.swift +4 −1
@@ -459,7 +459,7 @@ struct ContentView: View {
459 Text(workspace.lastError ?? session.lastError ?? "") 459 Text(workspace.lastError ?? session.lastError ?? "")
460 } 460 }
461 .task(id: ReminderKey( 461 .task(id: ReminderKey(
462 enabled: remindersEnabled, lead: reminderLead, subfolders: agendaSubfolders, files: workspace.files.count, 462 enabled: remindersEnabled, lead: reminderLead, subfolders: agendaSubfolders, hidden: HiddenFolders.shared.all, files: workspace.files.count,
463 changed: workspace.changedFile?.version, edits: session.editVersion, hour: hour, theme: theme 463 changed: workspace.changedFile?.version, edits: session.editVersion, hour: hour, theme: theme
464 )) { 464 )) {
465 await updateReminders() 465 await updateReminders()
@@ -909,6 +909,8 @@ struct ContentView: View {
909 var enabled: Bool 909 var enabled: Bool
910 var lead: Int 910 var lead: Int
911 var subfolders: Bool 911 var subfolders: Bool
912 /// The widgets leave out hidden folders.
913 var hidden: Set<String>
912 var files: Int 914 var files: Int
913 var changed: Int? 915 var changed: Int?
914 var edits: Int 916 var edits: Int
@@ -946,6 +948,7 @@ struct ContentView: View {
946 days.startOnWeekday = nil 948 days.startOnWeekday = nil
947 days.includeSubfolders = agendaSubfolders 949 days.includeSubfolders = agendaSubfolders
948 days.excludeArchives = OrgPreferences.agendaExcludeArchives() 950 days.excludeArchives = OrgPreferences.agendaExcludeArchives()
951 days.hiddenFolders = HiddenFolders.shared.all
949 days.agendaFiles = OrgPreferences.agendaFiles() 952 days.agendaFiles = OrgPreferences.agendaFiles()
950 days.options = OrgPreferences.agendaOptions(days.options) 953 days.options = OrgPreferences.agendaOptions(days.options)
951 days.options.logMode = false 954 days.options.logMode = false
Sources/Orgstar/FocusFilter.swift added +44
@@ -0,0 +1,44 @@
1import AppIntents
2import OrgApp
3
4/// A folder the user added, by its path.
5struct FolderEntity: AppEntity {
6 static let typeDisplayRepresentation: TypeDisplayRepresentation = "Folder"
7 static let defaultQuery = Query()
8
9 var id: String
10
11 var displayRepresentation: DisplayRepresentation {
12 DisplayRepresentation(title: "\((id as NSString).lastPathComponent)", subtitle: "\(id)")
13 }
14
15 struct Query: EntityQuery {
16 func entities(for identifiers: [String]) async throws -> [FolderEntity] { identifiers.map(FolderEntity.init) }
17 func suggestedEntities() async throws -> [FolderEntity] { WorkspaceModel.savedRootPaths().map(FolderEntity.init) }
18 }
19}
20
21/// While a Focus with this filter is on, the agenda and widgets leave out its folders and
22/// their reminders are muted. The system performs it again with no folders when the Focus ends.
23struct AgendaFocusFilter: SetFocusFilterIntent {
24 static let title: LocalizedStringResource = "Hide Folders"
25 static let description = IntentDescription("Leaves folders out of the agenda and widgets, and mutes their reminders, while this Focus is on.")
26
27 @Parameter(title: "Folders", default: [])
28 var folders: [FolderEntity]
29
30 var displayRepresentation: DisplayRepresentation {
31 let names = folders.map { ($0.id as NSString).lastPathComponent }.joined(separator: ", ")
32 return DisplayRepresentation(title: names.isEmpty ? "No folders hidden" : "Hide \(names)")
33 }
34
35 var appContext: FocusFilterAppContext {
36 FocusFilterAppContext(notificationFilterPredicate: HiddenFolders.notificationPredicate(hiding: Set(folders.map(\.id))))
37 }
38
39 @MainActor
40 func perform() async throws -> some IntentResult {
41 HiddenFolders.shared.focus = Set(folders.map(\.id))
42 return .result()
43 }
44}
Sources/OrgstarMobile/AgendaScreen.swift +37 −1
@@ -90,6 +90,7 @@ struct AgendaScreen: View, Equatable {
90 var span: Int 90 var span: Int
91 var startOffset: Int 91 var startOffset: Int
92 var subfolders: Bool 92 var subfolders: Bool
93 var hidden: Set<String>
93 var settings: Int 94 var settings: Int
94 var logMode: Bool 95 var logMode: Bool
95 } 96 }
@@ -151,6 +152,7 @@ struct AgendaScreen: View, Equatable {
151 // The now line is shorter than a row. 152 // The now line is shorter than a row.
152 .environment(\.defaultMinListRowHeight, 16) 153 .environment(\.defaultMinListRowHeight, 16)
153 .navigationTitle(title) 154 .navigationTitle(title)
155 .navigationSubtitle(shownFolders ?? "")
154 .navigationBarTitleDisplayMode(.inline) 156 .navigationBarTitleDisplayMode(.inline)
155 .sensoryFeedback(.success, trigger: done) 157 .sensoryFeedback(.success, trigger: done)
156 .sensoryFeedback(.impact(weight: .light), trigger: moved) 158 .sensoryFeedback(.impact(weight: .light), trigger: moved)
@@ -212,6 +214,9 @@ struct AgendaScreen: View, Equatable {
212 Label("Views", systemImage: "list.bullet.rectangle") 214 Label("Views", systemImage: "list.bullet.rectangle")
213 } 215 }
214 } 216 }
217 if workspace.rootPaths.count > 1 || shownFolders != nil {
218 ToolbarItem(placement: .topBarTrailing) { foldersMenu }
219 }
215 } 220 }
216 .fullScreenCover(isPresented: $showingBoard) { 221 .fullScreenCover(isPresented: $showingBoard) {
217 BoardScreen(workspace: workspace, session: session) { showingBoard = false } 222 BoardScreen(workspace: workspace, session: session) { showingBoard = false }
@@ -318,6 +323,36 @@ struct AgendaScreen: View, Equatable {
318 .background { Refresher(workspace: workspace, session: session, agenda: agenda, model: model, tick: tick, logMode: logMode) } 323 .background { Refresher(workspace: workspace, session: session, agenda: agenda, model: model, tick: tick, logMode: logMode) }
319 } 324 }
320 325
326 /// Shows or hides each folder's files; folders the Focus hides stay hidden.
327 private var foldersMenu: some View {
328 let hidden = HiddenFolders.shared
329 let hides = !hidden.all.isDisjoint(with: workspace.rootPaths)
330 return Menu {
331 Button("All Folders", systemImage: "folder") { hidden.manual = [] }
332 .disabled(hidden.manual.isEmpty)
333 Section(hidden.focus.isDisjoint(with: workspace.rootPaths) ? "" : "Dimmed folders are hidden by the current Focus.") {
334 ForEach(workspace.rootPaths, id: \.self) { root in
335 Toggle((root as NSString).lastPathComponent, isOn: Binding {
336 !hidden.all.contains(root)
337 } set: { shown in
338 if shown { hidden.manual.remove(root) } else { hidden.manual.insert(root) }
339 })
340 .disabled(hidden.focus.contains(root))
341 }
342 }
343 } label: {
344 Label("Folders", systemImage: hides ? "folder.fill" : "folder")
345 }
346 }
347
348 /// The folders shown, by name, while some are hidden.
349 private var shownFolders: String? {
350 let hidden = HiddenFolders.shared.all
351 guard !hidden.isDisjoint(with: workspace.rootPaths) else { return nil }
352 let shown = workspace.rootPaths.filter { !hidden.contains($0) }
353 return shown.isEmpty ? "No folders" : shown.map { ($0 as NSString).lastPathComponent }.joined(separator: ", ")
354 }
355
321 /// Refreshes the agenda when files, edits or settings change. Its own view, so that what it 356 /// Refreshes the agenda when files, edits or settings change. Its own view, so that what it
322 /// watches redraws only it, not the whole list. 357 /// watches redraws only it, not the whole list.
323 private struct Refresher: View { 358 private struct Refresher: View {
@@ -332,11 +367,12 @@ struct AgendaScreen: View, Equatable {
332 Color.clear 367 Color.clear
333 .task(id: Key(files: workspace.files.count, changed: workspace.changedFile?.version, edits: session.editVersion, tick: tick, 368 .task(id: Key(files: workspace.files.count, changed: workspace.changedFile?.version, edits: session.editVersion, tick: tick,
334 mode: agenda.mode, start: agenda.start, span: agenda.span, startOffset: agenda.startOffset, 369 mode: agenda.mode, start: agenda.start, span: agenda.span, startOffset: agenda.startOffset,
335 subfolders: agenda.includeSubfolders, settings: model.settingsVersion, logMode: logMode)) { 370 subfolders: agenda.includeSubfolders, hidden: HiddenFolders.shared.all, settings: model.settingsVersion, logMode: logMode)) {
336 // Changes come in bursts (a folder scan, typing); a newer one cancels this wait. 371 // Changes come in bursts (a folder scan, typing); a newer one cancels this wait.
337 try? await Task.sleep(for: .milliseconds(150)) 372 try? await Task.sleep(for: .milliseconds(150))
338 guard !Task.isCancelled else { return } 373 guard !Task.isCancelled else { return }
339 agenda.options.logMode = logMode 374 agenda.options.logMode = logMode
375 agenda.hiddenFolders = HiddenFolders.shared.all
340 await agenda.refresh(open: session.openTexts) 376 await agenda.refresh(open: session.openTexts)
341 } 377 }
342 } 378 }
Sources/OrgstarMobile/FocusFilter.swift added +48
@@ -0,0 +1,48 @@
1#if os(iOS)
2import AppIntents
3import OrgApp
4
5/// A folder the user added, by its path.
6struct FolderEntity: AppEntity {
7 static let typeDisplayRepresentation: TypeDisplayRepresentation = "Folder"
8 static let defaultQuery = Query()
9
10 var id: String
11
12 var displayRepresentation: DisplayRepresentation {
13 DisplayRepresentation(title: "\((id as NSString).lastPathComponent)", subtitle: "\(id)")
14 }
15
16 struct Query: EntityQuery {
17 func entities(for identifiers: [String]) async throws -> [FolderEntity] { identifiers.map(FolderEntity.init) }
18 func suggestedEntities() async throws -> [FolderEntity] { WorkspaceModel.savedRootPaths().map(FolderEntity.init) }
19 }
20}
21
22/// While a Focus with this filter is on, the agenda and widgets leave out its folders and
23/// their reminders are muted. The system performs it again with no folders when the Focus ends.
24struct AgendaFocusFilter: SetFocusFilterIntent {
25 static let title: LocalizedStringResource = "Hide Folders"
26 static let description = IntentDescription("Leaves folders out of the agenda and widgets, and mutes their reminders, while this Focus is on.")
27
28 @Parameter(title: "Folders", default: [])
29 var folders: [FolderEntity]
30
31 var displayRepresentation: DisplayRepresentation {
32 let names = folders.map { ($0.id as NSString).lastPathComponent }.joined(separator: ", ")
33 return DisplayRepresentation(title: names.isEmpty ? "No folders hidden" : "Hide \(names)")
34 }
35
36 var appContext: FocusFilterAppContext {
37 FocusFilterAppContext(notificationFilterPredicate: HiddenFolders.notificationPredicate(hiding: Set(folders.map(\.id))))
38 }
39
40 @MainActor
41 func perform() async throws -> some IntentResult {
42 HiddenFolders.shared.focus = Set(folders.map(\.id))
43 // The app may be in the background, where the widgets would wait for it to come back.
44 await MobileModel.shared.updateWidgets()
45 return .result()
46 }
47}
48#endif
Sources/OrgstarMobile/MobileModel.swift +1
@@ -295,6 +295,7 @@ final class MobileModel {
295 let days = AgendaModel(workspace: workspace, cache: agenda?.cache ?? AgendaSourceCache()) 295 let days = AgendaModel(workspace: workspace, cache: agenda?.cache ?? AgendaSourceCache())
296 days.mode = .agenda(span: AgendaSnapshot.dayCount, startOffset: 0) 296 days.mode = .agenda(span: AgendaSnapshot.dayCount, startOffset: 0)
297 days.startOnWeekday = nil 297 days.startOnWeekday = nil
298 days.hiddenFolders = HiddenFolders.shared.all
298 if let agenda { 299 if let agenda {
299 days.includeSubfolders = agenda.includeSubfolders 300 days.includeSubfolders = agenda.includeSubfolders
300 days.excludeArchives = agenda.excludeArchives 301 days.excludeArchives = agenda.excludeArchives
Sources/OrgstarMobile/OrgstarMobileApp.swift +3 −1
@@ -136,7 +136,7 @@ struct RootView: View {
136 var body: some View { 136 var body: some View {
137 Color.clear 137 Color.clear
138 // Reminders follow the files, the settings, coming back to the app and the hour. 138 // Reminders follow the files, the settings, coming back to the app and the hour.
139 .task(id: ReminderKey(files: workspace.files.count, changed: workspace.changedFile?.version, edits: session.editVersion, 139 .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)) { 140 settings: model.settingsVersion, active: active, hour: hour)) {
141 guard active else { return } 141 guard active else { return }
142 try? await Task.sleep(for: .seconds(1)) 142 try? await Task.sleep(for: .seconds(1))
@@ -160,6 +160,8 @@ struct RootView: View {
160 } 160 }
161 161
162 private struct ReminderKey: Equatable { 162 private struct ReminderKey: Equatable {
163 /// The widgets leave out hidden folders.
164 var hidden: Set<String>
163 var files: Int 165 var files: Int
164 var changed: Int? 166 var changed: Int?
165 var edits: Int 167 var edits: Int
Tests/OrgAppTests/AppTests.swift +39
@@ -654,6 +654,45 @@ struct AgendaModelTests {
654 await agenda.refresh(open: [:], now: now, calendar: utc) 654 await agenda.refresh(open: [:], now: now, calendar: utc)
655 #expect(Set(agenda.days[0].items.map(\.text)) == ["TODO Live", "TODO Task", "TODO Mine"]) 655 #expect(Set(agenda.days[0].items.map(\.text)) == ["TODO Live", "TODO Task", "TODO Mine"])
656 } 656 }
657
658 @Test func leavesOutHiddenFoldersAndTagsReminders() async throws {
659 let work = try Folder()
660 let home = try Folder()
661 try work.write("work.org", "* TODO Report\nSCHEDULED: <2026-10-05 Mon 14:00>\n")
662 try home.write("home.org", "* TODO Groceries\nSCHEDULED: <2026-10-05 Mon 15:00>\n")
663 let model = try WorkspaceModel(directory: nil)
664 try await model.addRoot(work.url)
665 try await model.addRoot(home.url)
666 let workRoot = try #require(model.files.first { $0.name == "work.org" }?.root)
667 let agenda = AgendaModel(workspace: model)
668 agenda.span = 1
669 var utc = Calendar(identifier: .gregorian)
670 utc.timeZone = TimeZone(identifier: "UTC")!
671 let now = try #require(utc.date(from: DateComponents(year: 2026, month: 10, day: 5, hour: 9)))
672
673 agenda.hiddenFolders = [workRoot]
674 await agenda.refresh(open: [:], now: now, calendar: utc)
675 #expect(agenda.days[0].items.filter { $0.path != nil }.map(\.title) == ["Groceries"])
676
677 // Reminders keep hidden folders' entries and carry their folder for Focus filters.
678 let reminders = await AgendaModel(workspace: model).reminders(open: [:], now: now, calendar: utc)
679 #expect(Set(reminders.map(\.title)) == ["Report", "Groceries"])
680 #expect(reminders.first { $0.title == "Report" }?.folder == workRoot)
681 }
682
683 @Test func hiddenFoldersPersistAndMatchPaths() {
684 let defaults = UserDefaults(suiteName: "hidden-\(UUID().uuidString)")!
685 let folders = HiddenFolders(defaults: defaults)
686 folders.manual = ["/a"]
687 folders.focus = ["/b"]
688 let reloaded = HiddenFolders(defaults: defaults)
689 #expect(reloaded.all == ["/a", "/b"])
690 #expect(HiddenFolders.hides(["/a"], path: "/a/x.org"))
691 #expect(!HiddenFolders.hides(["/a"], path: "/ab/x.org"))
692 let predicate = HiddenFolders.notificationPredicate(hiding: ["/a"])
693 #expect(!predicate.evaluate(with: "/a"))
694 #expect(predicate.evaluate(with: "/b"))
695 }
657} 696}
658 697
659@MainActor 698@MainActor
docs/manual/guide/07-agenda.org +6
@@ -64,6 +64,12 @@ An entry's category is the nearest =CATEGORY= property on it or an ancestor, els
64 64
65If no agenda file exists, the window says so. 65If no agenda file exists, the window says so.
66 66
67** Hiding folders
68
69With more than one folder, the Folders menu in the agenda's toolbar shows or hides each folder's files; All Folders shows them all again. While some are hidden, the shown folders' names appear under the title. The choice is kept on each device, and it applies to the agenda, the widgets, the Apple Watch and the iOS icon's badge. Reminders still fire for hidden folders.
70
71To hide folders with a Focus, add orgstar's Hide Folders filter to the Focus in System Settings ▸ Focus (Settings ▸ Focus on iOS) and choose the folders. While the Focus is on, those folders are hidden as well as the ones you hid from the menu, where they show dimmed, and their reminders are muted. When the Focus ends they show again.
72
67* The day, week and month view 73* The day, week and month view
68 74
69The default view is =org-agenda-list=: a run of days, each under a header with its date, such as =Monday 5 October= (with the year when it isn't the current year). Today, tomorrow and yesterday are named before the date: =Today · Thursday 8 October=. Today's header is in the =agenda-today= color and days before today are grey. Each header stays at the top of the window while you scroll through its day. 75The default view is =org-agenda-list=: a run of days, each under a header with its date, such as =Monday 5 October= (with the year when it isn't the current year). Today, tomorrow and yesterday are named before the date: =Today · Thursday 8 October=. Today's header is in the =agenda-today= color and days before today are grey. Each header stays at the top of the window while you scroll through its day.
docs/manual/guide/14-ios.org +1
@@ -189,6 +189,7 @@ Tap a result to open it in the reader. A heading result opens at that heading.
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 group of their own, and a line marks the current time between timed entries. Pull down to refresh.
190 190
191- 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=). 191- 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=).
192- 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]]).
192- 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. 193- 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.
193- 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. 194- 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.
194- + on a day's header :: captures an entry scheduled on that day (see [[file:08-capture.org][Capture]]). 195- + on a day's header :: captures an entry scheduled on that day (see [[file:08-capture.org][Capture]]).