From 8f0b3447212f3f626db1318520bd84f1584ddf2b Mon Sep 17 00:00:00 2001 From: Beingpax Date: Sat, 30 Aug 2025 08:21:10 +0545 Subject: [PATCH] Reset recording state on app launch --- VoiceInk/VoiceInk.swift | 5 +++++ VoiceInk/Whisper/WhisperState+UI.swift | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/VoiceInk/VoiceInk.swift b/VoiceInk/VoiceInk.swift index 772e004..549a500 100644 --- a/VoiceInk/VoiceInk.swift +++ b/VoiceInk/VoiceInk.swift @@ -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() } diff --git a/VoiceInk/Whisper/WhisperState+UI.swift b/VoiceInk/Whisper/WhisperState+UI.swift index 6506441..0a0e9ca 100644 --- a/VoiceInk/Whisper/WhisperState+UI.swift +++ b/VoiceInk/Whisper/WhisperState+UI.swift @@ -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