mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-18 03:27:08 +00:00
- Include the latest assistant preview in the silent-push fingerprint so result-only changes wake the phone; the status-only fingerprint missed results that landed while a session stayed working. - Coalesce WidgetKit reloads (60s) and reload only installed widget kinds, with a fallback when configuration lookup is empty; the previous every-update/all-kind reloads exhausted the system redraw budget. - Wait for AppModel/hub restoration on a cold silent-push launch instead of clearing the last good snapshot. - Use a 15-minute widget timeline fallback and 60-second hub push throttle. - Add the medium Session Detail layout with in-card paging, plain-text previews, status labels, and the hidden-row indicator. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run> Co-Authored-By: Claude Code <noreply@anthropic.com>
38 lines
1.3 KiB
Swift
38 lines
1.3 KiB
Swift
import HapiClient
|
|
import HapiProtocol
|
|
|
|
/// Cross-platform seam for the home-screen widget snapshot writer. The real
|
|
/// writer is iOS-only (WidgetKit); Catalyst gets a no-op.
|
|
@MainActor
|
|
protocol WidgetSnapshotControlling: AnyObject {
|
|
func update(_ sessions: [SessionSummary], unreadSessionIds: Set<String>, hubUrl: String)
|
|
func flush()
|
|
/// Background tasks must wait for the App Group write before they report
|
|
/// completion; iOS may suspend the process immediately afterwards.
|
|
func flushAndWait() async
|
|
/// Force a WidgetKit reload after a foreground flush; background writes
|
|
/// are deliberately throttled to stay inside the system reload budget.
|
|
func reloadNow()
|
|
func clear()
|
|
}
|
|
|
|
@MainActor
|
|
final class NoopWidgetSnapshotController: WidgetSnapshotControlling {
|
|
func update(_ sessions: [SessionSummary], unreadSessionIds: Set<String>, hubUrl: String) {}
|
|
func flush() {}
|
|
func flushAndWait() async {}
|
|
func reloadNow() {}
|
|
func clear() {}
|
|
}
|
|
|
|
enum WidgetSnapshotControllerFactory {
|
|
@MainActor
|
|
static func make() -> any WidgetSnapshotControlling {
|
|
#if os(iOS) && !targetEnvironment(macCatalyst)
|
|
return WidgetSnapshotUpdater()
|
|
#else
|
|
return NoopWidgetSnapshotController()
|
|
#endif
|
|
}
|
|
}
|