feat(ios): make the session-detail widget configurable

- Replace the automatic Focus card with Session Detail configured by a
  session picker (AppIntentConfiguration + AppEntity).
- Multiple Session Detail widgets can be added and stacked in a Smart
  Stack, each bound to a different session.
- Keep the automatic fallback when no session is selected or it vanished.
- Bump the local build to 31.

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
2026-11-07 12:33:31 +08:00
co-authored by HAPI Claude Code
parent 339bd35ee3
commit 2fd8c4e553
3 changed files with 129 additions and 11 deletions
+6 -6
View File
@@ -481,7 +481,7 @@
CODE_SIGN_ENTITLEMENTS = Hapi/Hapi.entitlements;
"CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "Hapi/Hapi-macOS.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 30;
CURRENT_PROJECT_VERSION = 31;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = NO;
DEVELOPMENT_TEAM = X75CUV458P;
ENABLE_PREVIEWS = YES;
@@ -516,7 +516,7 @@
CODE_SIGN_ENTITLEMENTS = Hapi/Hapi.entitlements;
"CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "Hapi/Hapi-macOS.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 30;
CURRENT_PROJECT_VERSION = 31;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = NO;
DEVELOPMENT_TEAM = X75CUV458P;
ENABLE_PREVIEWS = YES;
@@ -549,7 +549,7 @@
CODE_SIGN_ENTITLEMENTS = HapiNotificationService/HapiNotificationService.entitlements;
"CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "HapiNotificationService/HapiNotificationService-macOS.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 30;
CURRENT_PROJECT_VERSION = 31;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = NO;
DEVELOPMENT_TEAM = X75CUV458P;
GENERATE_INFOPLIST_FILE = YES;
@@ -578,7 +578,7 @@
CODE_SIGN_ENTITLEMENTS = HapiNotificationService/HapiNotificationService.entitlements;
"CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "HapiNotificationService/HapiNotificationService-macOS.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 30;
CURRENT_PROJECT_VERSION = 31;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = NO;
DEVELOPMENT_TEAM = X75CUV458P;
GENERATE_INFOPLIST_FILE = YES;
@@ -607,7 +607,7 @@
APPLICATION_EXTENSION_API_ONLY = YES;
CODE_SIGN_ENTITLEMENTS = HapiWidgets/HapiWidgets.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 30;
CURRENT_PROJECT_VERSION = 31;
DEVELOPMENT_TEAM = X75CUV458P;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = HapiWidgets/Info.plist;
@@ -637,7 +637,7 @@
APPLICATION_EXTENSION_API_ONLY = YES;
CODE_SIGN_ENTITLEMENTS = HapiWidgets/HapiWidgets.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 30;
CURRENT_PROJECT_VERSION = 31;
DEVELOPMENT_TEAM = X75CUV458P;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = HapiWidgets/Info.plist;
+89 -5
View File
@@ -1,3 +1,4 @@
import AppIntents
import HapiProtocol
import SwiftUI
import UIKit
@@ -830,20 +831,103 @@ private struct HapiModeWidgetView: View {
/// One-session detail card: the task, the latest assistant result and progress.
struct HapiFocusWidget: Widget {
var body: some WidgetConfiguration {
StaticConfiguration(kind: WidgetSnapshotStore.focusWidgetKind, provider: HapiWidgetProvider()) { entry in
AppIntentConfiguration(
kind: WidgetSnapshotStore.focusWidgetKind,
intent: FocusConfigurationIntent.self,
provider: FocusProvider()
) { entry in
HapiFocusWidgetView(entry: entry)
}
.configurationDisplayName("Focus")
.description("Task and latest result for one session.")
.configurationDisplayName("Session Detail")
.description("Task and latest result for a chosen session.")
.supportedFamilies([.systemLarge])
}
}
struct HapiFocusEntry: TimelineEntry {
let date: Date
let snapshot: WidgetSnapshot
let sessionId: String?
}
struct FocusProvider: AppIntentTimelineProvider {
func placeholder(in context: Context) -> HapiFocusEntry {
HapiFocusEntry(date: Date(), snapshot: .empty, sessionId: nil)
}
func snapshot(for configuration: FocusConfigurationIntent, in context: Context) async -> HapiFocusEntry {
HapiFocusEntry(
date: Date(),
snapshot: WidgetSnapshotStore.load() ?? .empty,
sessionId: configuration.session?.id
)
}
func timeline(for configuration: FocusConfigurationIntent, in context: Context) async -> Timeline<HapiFocusEntry> {
let now = Date()
let entry = HapiFocusEntry(
date: now,
snapshot: WidgetSnapshotStore.load() ?? .empty,
sessionId: configuration.session?.id
)
return Timeline(entries: [entry], policy: .after(now.addingTimeInterval(5 * 60)))
}
}
struct FocusConfigurationIntent: WidgetConfigurationIntent {
static var title: LocalizedStringResource = "Session Detail"
static var description = IntentDescription("Pick a session for the detail card.")
@Parameter(title: "Session")
var session: SessionEntity?
static var parameterSummary: some ParameterSummary {
Summary("Show \(\.$session)")
}
}
struct SessionEntity: AppEntity {
let id: String
let title: String
let project: String
static var typeDisplayRepresentation: TypeDisplayRepresentation = "Session"
static var defaultQuery = SessionEntityQuery()
var displayRepresentation: DisplayRepresentation {
DisplayRepresentation(
title: "\(title)",
subtitle: project.isEmpty ? nil : "\(project)"
)
}
}
struct SessionEntityQuery: EntityQuery {
func entities(for identifiers: [String]) async throws -> [SessionEntity] {
let wanted = Set(identifiers)
return allEntities().filter { wanted.contains($0.id) }
}
func suggestedEntities() async throws -> [SessionEntity] {
allEntities()
}
private func allEntities() -> [SessionEntity] {
(WidgetSnapshotStore.load()?.sessions ?? []).map {
SessionEntity(id: $0.id, title: $0.title, project: $0.project)
}
}
}
private struct HapiFocusWidgetView: View {
let entry: HapiWidgetEntry
let entry: HapiFocusEntry
private var session: WidgetSnapshot.Session? {
entry.snapshot.sessions.first { $0.isUnread == true && $0.status != .working }
if let selected = entry.sessionId,
let match = entry.snapshot.sessions.first(where: { $0.id == selected }) {
return match
}
return entry.snapshot.sessions.first { $0.isUnread == true && $0.status != .working }
?? entry.snapshot.sessions.first { $0.status == .working }
?? entry.snapshot.sessions.first { $0.isUnread == true }
?? entry.snapshot.sessions.first
+34
View File
@@ -374,6 +374,40 @@
}
}
}
},
"Session Detail" : {
"extractionState" : "manual",
"localizations" : {
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Детали сеанса"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "会话详情"
}
}
}
},
"Session" : {
"extractionState" : "manual",
"localizations" : {
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Сеанс"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "会话"
}
}
}
}
},
"version" : "1.0"