Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix: stabilize cancel hotkey listener and fix formatting

Gabriel Stein1cbb97f6437c
diff --git a/src/App.jsx b/src/App.jsx
index af6bcf726..4e771a0a6 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -212,12 +212,15 @@ export default function App() {
return () => unsubscribe?.();
}, []);
+ const isRecordingRef = useRef(isRecording);
+ isRecordingRef.current = isRecording;
+
useEffect(() => {
const unsubscribe = window.electronAPI?.onCancelHotkeyPressed?.(() => {
- if (isRecording) cancelRecording();
+ if (isRecordingRef.current) cancelRecording();
});
return () => unsubscribe?.();
- }, [isRecording, cancelRecording]);
+ }, [cancelRecording]);
// Auto-hide the floating icon when idle (setting enabled or dictation cycle completed)
useEffect(() => {
diff --git a/src/components/ui/SidebarModal.tsx b/src/components/ui/SidebarModal.tsx
index ae7852855..b28c39460 100644
--- a/src/components/ui/SidebarModal.tsx
+++ b/src/components/ui/SidebarModal.tsx
@@ -86,7 +86,8 @@ export default function SidebarModal<T extends string>({
onEscapeKeyDown={(e) => {
if (document.querySelector("[data-capturing]")) e.preventDefault();
}}
- className="fixed left-[50%] top-[50%] z-50 max-h-[85vh] w-[90vw] max-w-4xl translate-x-[-50%] translate-y-[-50%] rounded-xl p-0 overflow-hidden bg-background border border-border shadow-[0_25px_50px_-12px_rgba(0,0,0,0.25)] dark:bg-surface-1 dark:border-border-subtle dark:shadow-[0_25px_60px_-12px_rgba(0,0,0,0.5),0_0_0_1px_rgba(255,255,255,0.05)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98">
+ className="fixed left-[50%] top-[50%] z-50 max-h-[85vh] w-[90vw] max-w-4xl translate-x-[-50%] translate-y-[-50%] rounded-xl p-0 overflow-hidden bg-background border border-border shadow-[0_25px_50px_-12px_rgba(0,0,0,0.25)] dark:bg-surface-1 dark:border-border-subtle dark:shadow-[0_25px_60px_-12px_rgba(0,0,0,0.5),0_0_0_1px_rgba(255,255,255,0.05)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98"
+ >
<div className="relative h-full max-h-[85vh] overflow-hidden">
<DialogPrimitive.Close className="absolute right-4 top-4 z-10 rounded-md p-1.5 opacity-40 ring-offset-background transition-[opacity,background-color] hover:opacity-100 bg-transparent hover:bg-muted dark:hover:bg-surface-raised focus:outline-none focus:ring-2 focus:ring-ring/30 focus:ring-offset-1">
<X className="h-3.5 w-3.5 text-muted-foreground" />
diff --git a/src/hooks/useAudioRecording.js b/src/hooks/useAudioRecording.js
index 48d239b97..b02c27046 100644
--- a/src/hooks/useAudioRecording.js
+++ b/src/hooks/useAudioRecording.js
@@ -235,7 +235,7 @@ export const useAudioRecording = (toast, options = {}) => {
};
}, [toast, onToggle, performStartRecording, performStopRecording, t]);
- const cancelRecording = async () => {
+ const cancelRecording = useCallback(async () => {
if (audioManagerRef.current) {
window.electronAPI?.unregisterCancelHotkey?.();
const state = audioManagerRef.current.getState();
@@ -248,7 +248,7 @@ export const useAudioRecording = (toast, options = {}) => {
return audioManagerRef.current.cancelRecording();
}
return false;
- };
+ }, []);
const cancelProcessing = () => {
if (audioManagerRef.current) {