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
+12 -4
View File
@@ -14,10 +14,15 @@ enum MacMLXLiveCapture {
audioStream: AsyncStream<AudioBufferSnapshot>,
finishSignal: AsyncStream<Void>,
store: AppGroupStore,
targetAppBundleIdentifier: String?,
onPartial: @escaping @Sendable (String) -> Void
) async -> MacLiveASRCaptureResult {
let locale = Locale(identifier: store.localeId.isEmpty ? "zh-CN" : store.localeId)
let bias = resolveBias(store: store, locale: locale)
let bias = resolveBias(
store: store,
locale: locale,
targetAppBundleIdentifier: targetAppBundleIdentifier
)
guard let model = MacLocalASRService.selectedModelDefinition(),
model.backend == .mlx,
@@ -133,14 +138,17 @@ enum MacMLXLiveCapture {
}
}
private static func resolveBias(store: AppGroupStore, locale: Locale) -> LocalASRBiasPayload? {
MacAppContextService.captureAndPersist(to: store)
private static func resolveBias(
store: AppGroupStore,
locale: Locale,
targetAppBundleIdentifier: String?
) -> LocalASRBiasPayload? {
let capabilities = MacLocalASRService.currentCapabilities()
let bias = LocalASRBiasAdapter.adapt(
LocalASRBiasRequest(
dictionary: store.personalDictionary,
locale: locale,
frontAppBundleId: MacAppContextService.frontmostBundleIdentifier(),
frontAppBundleId: targetAppBundleIdentifier,
capabilities: capabilities
)
)