Reset recording state on app launch

This commit is contained in:
Beingpax 2025-08-30 08:21:10 +05:45
parent dc3355b91c
commit 8f0b344721
2 changed files with 18 additions and 0 deletions

View File

@ -84,6 +84,11 @@ struct VoiceInkApp: App {
activeWindowService.configureWhisperState(whisperState)
_activeWindowService = StateObject(wrappedValue: activeWindowService)
// Ensure no lingering recording state from previous runs
Task {
await whisperState.resetOnLaunch()
}
AppShortcuts.updateAppShortcutParameters()
}

View File

@ -80,6 +80,19 @@ extension WhisperState {
}
}
func resetOnLaunch() async {
logger.notice("🔄 Resetting recording state on launch")
await recorder.stopRecording()
hideRecorderPanel()
await MainActor.run {
isMiniRecorderVisible = false
shouldCancelRecording = false
miniRecorderError = nil
recordingState = .idle
}
await cleanupModelResources()
}
func cancelRecording() async {
SoundManager.shared.playEscSound()
shouldCancelRecording = true