From 51b2eb0e6296734960f37cebd40fee34a1f261f9 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Thu, 14 May 2026 13:18:55 -0500 Subject: feat: add App Intents for Hutch navigation - add read-only App Intents for core Hutch workflows - route intents through the existing Hutch navigation/deep-link model - expose Work Queue, Recent Activity, System Status, pinned resources, projects, failed builds, assigned tickets, saved searches, and search where supported - keep App Intents non-mutating for the initial implementation - preserve existing widget, Safari extension, and hutch:// routing behavior References: https://todo.sr.ht/~ccleberg/hutch/71 --- Shared/SystemStatusWidgetSnapshot.swift | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'Shared/SystemStatusWidgetSnapshot.swift') diff --git a/Shared/SystemStatusWidgetSnapshot.swift b/Shared/SystemStatusWidgetSnapshot.swift index 0b19365..025e58c 100644 --- a/Shared/SystemStatusWidgetSnapshot.swift +++ b/Shared/SystemStatusWidgetSnapshot.swift @@ -34,11 +34,11 @@ enum SystemStatusWidgetSnapshotStore { private static let snapshotKey = "systemStatus.widgetSnapshot" static func load( - accountID: String? = ActiveAccountContextStore.load(), + accountID: String? = nil, defaults: UserDefaults? = sharedDefaults() ) -> SystemStatusWidgetSnapshot? { guard let defaults, - let data = defaults.data(forKey: scopedKey(for: accountID)) else { + let data = defaults.data(forKey: scopedKey(for: resolvedAccountID(accountID, defaults: defaults))) else { return nil } return try? JSONDecoder().decode(SystemStatusWidgetSnapshot.self, from: data) @@ -46,22 +46,23 @@ enum SystemStatusWidgetSnapshotStore { static func save( _ snapshot: SystemStatusWidgetSnapshot, - accountID: String? = ActiveAccountContextStore.load(), + accountID: String? = nil, defaults: UserDefaults? = sharedDefaults() ) { guard let defaults, let data = try? JSONEncoder().encode(snapshot) else { return } - defaults.set(data, forKey: scopedKey(for: accountID)) + defaults.set(data, forKey: scopedKey(for: resolvedAccountID(accountID, defaults: defaults))) reloadWidgetTimelines() } static func clear( - accountID: String? = ActiveAccountContextStore.load(), + accountID: String? = nil, defaults: UserDefaults? = sharedDefaults() ) { - defaults?.removeObject(forKey: scopedKey(for: accountID)) + guard let defaults else { return } + defaults.removeObject(forKey: scopedKey(for: resolvedAccountID(accountID, defaults: defaults))) reloadWidgetTimelines() } @@ -74,6 +75,10 @@ enum SystemStatusWidgetSnapshotStore { return "\(snapshotKey).\(accountID)" } + private static func resolvedAccountID(_ accountID: String?, defaults: UserDefaults) -> String? { + accountID ?? ActiveAccountContextStore.load(defaults: defaults) + } + private static func reloadWidgetTimelines() { #if canImport(WidgetKit) WidgetCenter.shared.reloadTimelines(ofKind: SystemStatusWidgetConfiguration.kind) -- cgit v1.2.3