From db854363b408564176cad888530acf87949c42c2 Mon Sep 17 00:00:00 2001 From: CJ Pais Date: Fri, 6 Feb 2026 16:46:17 +0800 Subject: [PATCH] default for post-process and revert ui changes --- src-tauri/src/settings.rs | 13 +++++++++++-- src-tauri/src/shortcut/mod.rs | 10 ++++++---- src/components/settings/GlobalShortcutInput.tsx | 12 +++--------- src/components/settings/HandyKeysShortcutInput.tsx | 12 +++--------- src/i18n/locales/en/translation.json | 1 - 5 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src-tauri/src/settings.rs b/src-tauri/src/settings.rs index 21f9903..44402bc 100644 --- a/src-tauri/src/settings.rs +++ b/src-tauri/src/settings.rs @@ -562,6 +562,15 @@ pub fn get_default_settings() -> AppSettings { current_binding: default_shortcut.to_string(), }, ); + #[cfg(target_os = "windows")] + let default_post_process_shortcut = "ctrl+shift+space"; + #[cfg(target_os = "macos")] + let default_post_process_shortcut = "option+shift+space"; + #[cfg(target_os = "linux")] + let default_post_process_shortcut = "ctrl+shift+space"; + #[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))] + let default_post_process_shortcut = "alt+shift+space"; + bindings.insert( "transcribe_with_post_process".to_string(), ShortcutBinding { @@ -569,8 +578,8 @@ pub fn get_default_settings() -> AppSettings { name: "Transcribe with Post-Processing".to_string(), description: "Converts your speech into text and applies AI post-processing." .to_string(), - default_binding: String::new(), - current_binding: String::new(), + default_binding: default_post_process_shortcut.to_string(), + current_binding: default_post_process_shortcut.to_string(), }, ); bindings.insert( diff --git a/src-tauri/src/shortcut/mod.rs b/src-tauri/src/shortcut/mod.rs index 464b564..6ff5a04 100644 --- a/src-tauri/src/shortcut/mod.rs +++ b/src-tauri/src/shortcut/mod.rs @@ -108,6 +108,11 @@ pub fn change_binding( id: String, binding: String, ) -> Result { + // Reject empty bindings — every shortcut should have a value + if binding.trim().is_empty() { + return Err("Binding cannot be empty".to_string()); + } + let mut settings = settings::get_settings(&app); // Get the binding to modify, or create it from defaults if it doesn't exist @@ -707,10 +712,7 @@ pub fn change_post_process_enabled_setting(app: AppHandle, enabled: bool) -> Res .cloned() { if enabled { - // Only register if the user has actually set a binding - if !binding.current_binding.is_empty() { - let _ = register_shortcut(&app, binding); - } + let _ = register_shortcut(&app, binding); } else { let _ = unregister_shortcut(&app, binding); } diff --git a/src/components/settings/GlobalShortcutInput.tsx b/src/components/settings/GlobalShortcutInput.tsx index 80d6b9e..0bf4517 100644 --- a/src/components/settings/GlobalShortcutInput.tsx +++ b/src/components/settings/GlobalShortcutInput.tsx @@ -293,22 +293,16 @@ export const GlobalShortcutInput: React.FC = ({ {editingShortcutId === shortcutId ? (
setShortcutRef(shortcutId, ref)} - className="px-2 py-1 text-sm font-semibold border border-logo-primary bg-logo-primary/30 rounded min-w-[120px] text-center" + className="px-2 py-1 text-sm font-semibold border border-logo-primary bg-logo-primary/30 rounded" > {formatCurrentKeys()}
) : (
startRecording(shortcutId)} > - {binding.current_binding - ? formatKeyCombination(binding.current_binding, osType) - : t("settings.general.shortcut.notSet")} + {formatKeyCombination(binding.current_binding, osType)}
)} = ({ {isRecording ? (
{formatCurrentKeys()}
) : (
- {binding.current_binding - ? formatKeyCombination(binding.current_binding, osType) - : t("settings.general.shortcut.notSet")} + {formatKeyCombination(binding.current_binding, osType)}
)}