From 510b425ea29442c5a78aca91a56eb74df3f59aa6 Mon Sep 17 00:00:00 2001 From: Alexey Haidamaka Date: Tue, 26 Aug 2025 22:11:02 +0200 Subject: [PATCH] Added Retry Last Transcription Shortcut --- VoiceInk/HotkeyManager.swift | 13 +++++++++++++ VoiceInk/Views/Settings/SettingsView.swift | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/VoiceInk/HotkeyManager.swift b/VoiceInk/HotkeyManager.swift index 4bf891c..f3eb877 100644 --- a/VoiceInk/HotkeyManager.swift +++ b/VoiceInk/HotkeyManager.swift @@ -7,6 +7,7 @@ extension KeyboardShortcuts.Name { static let toggleMiniRecorder = Self("toggleMiniRecorder") static let toggleMiniRecorder2 = Self("toggleMiniRecorder2") static let pasteLastTranscription = Self("pasteLastTranscription") + static let retryLastTranscription = Self("retryLastTranscription") } @MainActor @@ -133,6 +134,18 @@ class HotkeyManager: ObservableObject { } } + // Add retry last transcription shortcut + if KeyboardShortcuts.getShortcut(for: .retryLastTranscription) == nil { + let defaultRetryShortcut = KeyboardShortcuts.Shortcut(.r, modifiers: [.command, .option]) + KeyboardShortcuts.setShortcut(defaultRetryShortcut, for: .retryLastTranscription) + } + + KeyboardShortcuts.onKeyUp(for: .retryLastTranscription) { [weak self] in + guard let self = self else { return } + Task { @MainActor in + LastTranscriptionService.retryLastTranscription(from: self.whisperState.modelContext, whisperState: self.whisperState) + } + } Task { @MainActor in try? await Task.sleep(nanoseconds: 100_000_000) self.setupHotkeyMonitoring() diff --git a/VoiceInk/Views/Settings/SettingsView.swift b/VoiceInk/Views/Settings/SettingsView.swift index a9aa573..bf1098f 100644 --- a/VoiceInk/Views/Settings/SettingsView.swift +++ b/VoiceInk/Views/Settings/SettingsView.swift @@ -118,6 +118,23 @@ struct SettingsView: View { } } + SettingsSection( + icon: "arrow.clockwise.circle.fill", + title: "Retry Last Transcription", + subtitle: "Configure shortcut to retry transcribing your most recent audio" + ) { + HStack(spacing: 12) { + Text("Retry Shortcut") + .font(.system(size: 13, weight: .medium)) + .foregroundColor(.secondary) + + KeyboardShortcuts.Recorder(for: .retryLastTranscription) + .controlSize(.small) + + Spacer() + } + } + SettingsSection( icon: "speaker.wave.2.bubble.left.fill", title: "Recording Feedback",