fix(mac,asr): harden menu-bar delivery, chunk retry, and polish validator

Retain the external target app for menu-bar paste and polish context, retry
failed middle ASR chunks once, and stop false-positive path/number violations.
This commit is contained in:
Rocky
2026-07-29 18:30:36 +08:00
parent 34be2e8dd1
commit 4c929d8b8b
17 changed files with 646 additions and 39 deletions
+16 -1
View File
@@ -68,7 +68,14 @@ enum MacAppContextService {
}
static func detectContext() -> AppContext {
guard let bundleId = frontmostBundleIdentifier() else { return .unknown }
detectContext(bundleIdentifier: frontmostBundleIdentifier())
}
/// Resolve polish context from the application captured for this dictation
/// session. This avoids reading OSGKeyboard itself after a popover steals
/// focus.
static func detectContext(bundleIdentifier bundleId: String?) -> AppContext {
guard let bundleId else { return .unknown }
if let mapped = contextByBundleId[bundleId] { return mapped }
if chatBundleIdsFromRegistry.contains(bundleId) { return .chat }
if bundleId.hasPrefix("com.apple.Safari") || bundleId.contains("chrome") {
@@ -83,4 +90,12 @@ enum MacAppContextService {
let context = detectContext()
store.setDetectedAppContext(context)
}
static func captureAndPersist(
application: NSRunningApplication?,
to store: AppGroupStore
) {
let context = detectContext(bundleIdentifier: application?.bundleIdentifier)
store.setDetectedAppContext(context)
}
}