fix(macos): avoid voice tester crash
This commit is contained in:
@@ -32,6 +32,10 @@ private let modelCatalogPathKey = "clawdis.modelCatalogPath"
|
|||||||
private let modelCatalogReloadKey = "clawdis.modelCatalogReload"
|
private let modelCatalogReloadKey = "clawdis.modelCatalogReload"
|
||||||
private let voiceWakeSupported: Bool = ProcessInfo.processInfo.operatingSystemVersion.majorVersion >= 26
|
private let voiceWakeSupported: Bool = ProcessInfo.processInfo.operatingSystemVersion.majorVersion >= 26
|
||||||
|
|
||||||
|
enum UIStrings {
|
||||||
|
static let welcomeTitle = "Welcome to Clawdis"
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - App model
|
// MARK: - App model
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
@@ -2026,13 +2030,13 @@ final class VoiceWakeTester {
|
|||||||
guard let request = recognitionRequest else { return }
|
guard let request = recognitionRequest else { return }
|
||||||
|
|
||||||
self.recognitionTask = recognizer.recognitionTask(with: request) { [weak self] result, error in
|
self.recognitionTask = recognizer.recognitionTask(with: request) { [weak self] result, error in
|
||||||
guard let self, !self.isStopping else { return }
|
|
||||||
let text = result?.bestTranscription.formattedString ?? ""
|
let text = result?.bestTranscription.formattedString ?? ""
|
||||||
let matched = Self.matches(text: text, triggers: triggers)
|
let matched = Self.matches(text: text, triggers: triggers)
|
||||||
let isFinal = result?.isFinal ?? false
|
let isFinal = result?.isFinal ?? false
|
||||||
let errorMessage = error?.localizedDescription
|
let errorMessage = error?.localizedDescription
|
||||||
Task { @MainActor [weak self] in
|
Task { @MainActor [weak self] in
|
||||||
guard let self else { return }
|
// Hop to the MainActor before touching state to avoid isolation assertions
|
||||||
|
guard let self, !self.isStopping else { return }
|
||||||
self.handleResult(
|
self.handleResult(
|
||||||
matched: matched,
|
matched: matched,
|
||||||
text: text,
|
text: text,
|
||||||
@@ -3160,9 +3164,12 @@ final class OnboardingController {
|
|||||||
}
|
}
|
||||||
let hosting = NSHostingController(rootView: OnboardingView())
|
let hosting = NSHostingController(rootView: OnboardingView())
|
||||||
let window = NSWindow(contentViewController: hosting)
|
let window = NSWindow(contentViewController: hosting)
|
||||||
window.title = "Welcome to Clawdis"
|
window.title = UIStrings.welcomeTitle
|
||||||
window.setContentSize(NSSize(width: 640, height: 560))
|
window.setContentSize(NSSize(width: 640, height: 560))
|
||||||
window.styleMask = [.titled, .closable]
|
window.styleMask = [.titled, .closable, .fullSizeContentView]
|
||||||
|
window.titlebarAppearsTransparent = true
|
||||||
|
window.titleVisibility = .hidden
|
||||||
|
window.isMovableByWindowBackground = true
|
||||||
window.center()
|
window.center()
|
||||||
window.makeKeyAndOrderFront(nil)
|
window.makeKeyAndOrderFront(nil)
|
||||||
NSApp.activate(ignoringOtherApps: true)
|
NSApp.activate(ignoringOtherApps: true)
|
||||||
|
|||||||
Reference in New Issue
Block a user