feat(app): add crash visibility, memory relief, and clipboard reply work
Squashes the working tree that had accumulated on cloud-agent. Two strands of work, kept in one commit at the maintainer's request. Crash and stability (this session): - Subscribe to MetricKit so crash, hang, CPU, and disk-write diagnostics are recorded on device. Keyboard-extension memory kills are the most likely way a user loses the keyboard mid-sentence and iOS does not classify them as crashes, so they never reach App Store Connect. - Upload those reports to POST /v1/analytics/diagnostics from internal builds only (local Debug and TestFlight), reusing the analytics installation identifier and skipping entirely when analytics are off. App Store builds keep everything on device. - Shed the Chinese engine, English lexicon, and in-flight pipeline work at the 40 MiB and 48 MiB budget thresholds instead of waiting for a system memory warning that jetsam often preempts. - Install audio taps with the input node's live format through one shared adaptive resampler, so an audio-route change mid-recording no longer raises an uncatchable format-mismatch exception. Covers the dictation preview and the Mac recorder, which still used the pattern the Flow capture path had already moved away from. - Harden the librime bridge: never pass a nil string across a nonnull boundary when a user dictionary holds malformed UTF-8, null-check the engine API vector, and distrust a candidate count without its array. - Guard the expanded candidate grid against a list that shrinks while the collection view is still laying out against the previous count. - Resolve localized text without the App Group so the screen shown when that container is missing renders its message instead of crashing on launch, which is the one situation it exists to handle. - Gate CI on the App Group and Keychain wiring that the keyboard extension hard-depends on, with a self-test proving the check fails. Clipboard, reply, and semantics (pre-existing working tree): - Unify the reply center, refresh keyboard AI features, and add native event and reminder exporters. - Expand clipboard semantic routing with authored corpora and a product-blind holdout, plus the scripts that build and validate them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -50,12 +50,27 @@ public struct AppGroupConfiguration: Sendable, Equatable {
|
||||
public static let clipboardHistoryEnabled = "config.clipboardHistoryEnabled"
|
||||
/// When true (and history is on), show the newest clipboard item as a suggestion strip.
|
||||
public static let clipboardCandidateBarEnabled = "config.clipboardCandidateBarEnabled"
|
||||
/// When true (and history is on), auto-route a freshly copied, replyable
|
||||
/// message into the Reply flow when the keyboard opens. Device-local.
|
||||
public static let clipboardAutoModeEnabled = "config.clipboardAutoModeEnabled"
|
||||
/// When true (and history is on), auto-translate a freshly copied,
|
||||
/// non-system-language paste on open. Device-local.
|
||||
public static let clipboardAutoTranslateEnabled = "config.clipboardAutoTranslateEnabled"
|
||||
/// When true (and history is on), auto-draft a reply when a freshly
|
||||
/// copied paste is detected as an email. Device-local.
|
||||
public static let clipboardAutoEmailReplyEnabled = "config.clipboardAutoEmailReplyEnabled"
|
||||
public static let detectedAppContext = "config.detectedAppContext"
|
||||
public static let detectedAppContextAt = "config.detectedAppContextAt"
|
||||
public static let personalDictionary = "config.personalDictionary.v1"
|
||||
public static let polishStyleCatalog = "config.polishStyles.v1"
|
||||
public static let activePolishStyleId = "config.activePolishStyleId"
|
||||
public static let polishStylesMigrated = "config.polishStyles.migrated"
|
||||
/// Distilled personal style used for AI replies. Empty means disabled.
|
||||
/// Deliberately separate from `activePolishStyleId`: voice input and AI
|
||||
/// replies must not share one selection.
|
||||
public static let personalReplyStyleId = "config.personalReplyStyleId"
|
||||
/// One-shot: split the personal style out of the voice-polish selection.
|
||||
public static let personalReplyStyleMigrated = "config.personalReplyStyle.migrated"
|
||||
/// Legacy keys from the removed manual scenario implementation.
|
||||
public static let legacyPolishScenarioId = "config.polishScenarioId"
|
||||
public static let legacySystemPrompt = "config.systemPrompt"
|
||||
@@ -122,9 +137,21 @@ public struct AppGroupConfiguration: Sendable, Equatable {
|
||||
public var clipboardHistoryEnabled: Bool
|
||||
/// Opt-in clipboard suggestion strip above the key surfaces.
|
||||
public var clipboardCandidateBarEnabled: Bool
|
||||
/// Opt-in: auto-route a freshly copied replyable message into the Reply
|
||||
/// flow when the keyboard opens. Off by default; never syncs via iCloud.
|
||||
public var clipboardAutoModeEnabled: Bool
|
||||
/// Opt-in: auto-translate a freshly copied non-system-language paste on
|
||||
/// open. Off by default; never syncs via iCloud.
|
||||
public var clipboardAutoTranslateEnabled: Bool
|
||||
/// Opt-in: auto-draft a reply when a freshly copied paste is an email.
|
||||
/// Off by default; never syncs via iCloud.
|
||||
public var clipboardAutoEmailReplyEnabled: Bool
|
||||
public var personalDictionary: PersonalDictionary
|
||||
public var polishStyleCatalog: PolishStyleCatalog
|
||||
/// Voice-input polish style. Never a distilled personal style.
|
||||
public var activePolishStyleId: String
|
||||
/// Distilled personal style applied to AI replies; empty when disabled.
|
||||
public var personalReplyStyleId: String
|
||||
/// Opt-in iCloud KVS sync for the personal dictionary (main app only).
|
||||
public var personalDictionaryICloudSyncEnabled: Bool
|
||||
/// Opt-in iCloud KVS sync for user settings (main app only).
|
||||
@@ -325,11 +352,17 @@ public struct AppGroupConfiguration: Sendable, Equatable {
|
||||
}(),
|
||||
llmThinkingEnabled: defaults.bool(forKey: Keys.llmThinkingEnabled),
|
||||
clipboardHistoryEnabled: defaults.bool(forKey: Keys.clipboardHistoryEnabled),
|
||||
clipboardCandidateBarEnabled: defaults.bool(forKey: Keys.clipboardCandidateBarEnabled),
|
||||
// Paste capsule is always on now (its opt-in toggle was removed), so
|
||||
// default to true when the key was never written.
|
||||
clipboardCandidateBarEnabled: defaults.object(forKey: Keys.clipboardCandidateBarEnabled) as? Bool ?? true,
|
||||
clipboardAutoModeEnabled: defaults.bool(forKey: Keys.clipboardAutoModeEnabled),
|
||||
clipboardAutoTranslateEnabled: defaults.bool(forKey: Keys.clipboardAutoTranslateEnabled),
|
||||
clipboardAutoEmailReplyEnabled: defaults.bool(forKey: Keys.clipboardAutoEmailReplyEnabled),
|
||||
personalDictionary: decodePersonalDictionary(from: defaults),
|
||||
polishStyleCatalog: decodePolishStyleCatalog(from: defaults),
|
||||
activePolishStyleId: defaults.string(forKey: Keys.activePolishStyleId)
|
||||
?? PolishStylePackCatalog.defaultID,
|
||||
personalReplyStyleId: defaults.string(forKey: Keys.personalReplyStyleId) ?? "",
|
||||
personalDictionaryICloudSyncEnabled: {
|
||||
if defaults.object(forKey: Keys.personalDictionaryICloudSyncEnabled) == nil {
|
||||
return true
|
||||
@@ -443,6 +476,7 @@ public struct AppGroupConfiguration: Sendable, Equatable {
|
||||
defaults.set("polish", forKey: Keys.modeId)
|
||||
}
|
||||
migrateLegacyPolishStyleIfNeeded(configuration: &config, defaults: defaults)
|
||||
migratePersonalReplyStyleIfNeeded(configuration: &config, defaults: defaults)
|
||||
return config
|
||||
}
|
||||
|
||||
@@ -471,7 +505,11 @@ public struct AppGroupConfiguration: Sendable, Equatable {
|
||||
defaults.set(llmThinkingEnabled, forKey: Keys.llmThinkingEnabled)
|
||||
defaults.set(clipboardHistoryEnabled, forKey: Keys.clipboardHistoryEnabled)
|
||||
defaults.set(clipboardCandidateBarEnabled, forKey: Keys.clipboardCandidateBarEnabled)
|
||||
defaults.set(clipboardAutoModeEnabled, forKey: Keys.clipboardAutoModeEnabled)
|
||||
defaults.set(clipboardAutoTranslateEnabled, forKey: Keys.clipboardAutoTranslateEnabled)
|
||||
defaults.set(clipboardAutoEmailReplyEnabled, forKey: Keys.clipboardAutoEmailReplyEnabled)
|
||||
defaults.set(activePolishStyleId, forKey: Keys.activePolishStyleId)
|
||||
defaults.set(personalReplyStyleId, forKey: Keys.personalReplyStyleId)
|
||||
defaults.set(flowSkipAppSwitch, forKey: Keys.flowSkipAppSwitch)
|
||||
defaults.set(flowInactivityDuration.rawValue, forKey: Keys.flowInactivityDuration)
|
||||
defaults.set(localASRCustomLanguageModelEnabled, forKey: Keys.localASRCustomLanguageModelEnabled)
|
||||
@@ -568,11 +606,31 @@ public struct AppGroupConfiguration: Sendable, Equatable {
|
||||
previous: baseline.clipboardCandidateBarEnabled,
|
||||
key: Keys.clipboardCandidateBarEnabled
|
||||
)
|
||||
set(
|
||||
clipboardAutoModeEnabled,
|
||||
previous: baseline.clipboardAutoModeEnabled,
|
||||
key: Keys.clipboardAutoModeEnabled
|
||||
)
|
||||
set(
|
||||
clipboardAutoTranslateEnabled,
|
||||
previous: baseline.clipboardAutoTranslateEnabled,
|
||||
key: Keys.clipboardAutoTranslateEnabled
|
||||
)
|
||||
set(
|
||||
clipboardAutoEmailReplyEnabled,
|
||||
previous: baseline.clipboardAutoEmailReplyEnabled,
|
||||
key: Keys.clipboardAutoEmailReplyEnabled
|
||||
)
|
||||
set(
|
||||
activePolishStyleId,
|
||||
previous: baseline.activePolishStyleId,
|
||||
key: Keys.activePolishStyleId
|
||||
)
|
||||
set(
|
||||
personalReplyStyleId,
|
||||
previous: baseline.personalReplyStyleId,
|
||||
key: Keys.personalReplyStyleId
|
||||
)
|
||||
set(flowSkipAppSwitch, previous: baseline.flowSkipAppSwitch, key: Keys.flowSkipAppSwitch)
|
||||
set(
|
||||
flowInactivityDuration.rawValue,
|
||||
@@ -644,6 +702,40 @@ public struct AppGroupConfiguration: Sendable, Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
/// Splits the distilled personal style out of the voice-polish selection.
|
||||
///
|
||||
/// Before this migration one `activePolishStyleId` drove both pipelines, so
|
||||
/// selecting a learned pack let it outrank the core filler cleanup, and
|
||||
/// selecting a built-in silently disabled personalization for AI replies —
|
||||
/// "clean voice input" and "replies that sound like me" were mutually
|
||||
/// exclusive. Runs after `migrateLegacyPolishStyleIfNeeded`, which may
|
||||
/// itself rewrite `activePolishStyleId`.
|
||||
private static func migratePersonalReplyStyleIfNeeded(
|
||||
configuration: inout AppGroupConfiguration,
|
||||
defaults: UserDefaults
|
||||
) {
|
||||
guard !defaults.bool(forKey: Keys.personalReplyStyleMigrated) else { return }
|
||||
defer { defaults.set(true, forKey: Keys.personalReplyStyleMigrated) }
|
||||
|
||||
let catalog = configuration.polishStyleCatalog
|
||||
let active = catalog.entries.first { $0.id == configuration.activePolishStyleId }
|
||||
if let active, PolishStylePackCatalog.isPersonalReplyStyle(active) {
|
||||
// Keep the personal style working where it now belongs, and give
|
||||
// voice input its cleanup back.
|
||||
configuration.personalReplyStyleId = active.id
|
||||
configuration.activePolishStyleId = PolishStylePackCatalog.defaultID
|
||||
} else if let latest = PolishStylePackCatalog.latestPersonalReplyStyle(userCatalog: catalog) {
|
||||
// These users generated a personal style but were not using it: the
|
||||
// single selector forced them to pick voice cleanup instead. Turning
|
||||
// it on for replies restores the intent behind generating it.
|
||||
configuration.personalReplyStyleId = latest.id
|
||||
} else {
|
||||
configuration.personalReplyStyleId = ""
|
||||
}
|
||||
defaults.set(configuration.activePolishStyleId, forKey: Keys.activePolishStyleId)
|
||||
defaults.set(configuration.personalReplyStyleId, forKey: Keys.personalReplyStyleId)
|
||||
}
|
||||
|
||||
private static func migrateLegacyPolishStyleIfNeeded(
|
||||
configuration: inout AppGroupConfiguration,
|
||||
defaults: UserDefaults
|
||||
|
||||
Reference in New Issue
Block a user