Skip to content

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

fix(dictation): stop blocking the recording start on the cloud STT config (#1710)

Aditya Painuli42a5b68c4b7b
diff --git a/src/helpers/sttConfigPolicy.js b/src/helpers/sttConfigPolicy.js
new file mode 100644
index 000000000..8eca2bacd
--- /dev/null
+++ b/src/helpers/sttConfigPolicy.js
@@ -0,0 +1,12 @@
+// Decides whether the recording start path must wait for the cloud STT config
+// before opening the mic. The config only influences the start decision in the
+// signed-in OpenWhispr-cloud path (shouldUseStreaming reads
+// sttConfig.dictation.mode there); for local STT or a signed-out session the
+// awaited fetch stalls on auth resolution for seconds and then changes
+// nothing (#1673).
+export function needsSttConfigBeforeStart(settings) {
+ const s = settings || {};
+ if (s.useLocalWhisper) return false;
+ if (s.cloudTranscriptionMode !== "openwhispr") return false;
+ return !!s.isSignedIn;
+}
diff --git a/src/hooks/useAudioRecording.js b/src/hooks/useAudioRecording.js
index cf1e686e5..af5c651b0 100644
--- a/src/hooks/useAudioRecording.js
+++ b/src/hooks/useAudioRecording.js
@@ -7,6 +7,7 @@ import { getSettings } from "../stores/settingsStore";
import { expandSnippets } from "../utils/snippets";
import { getRecordingErrorTitle, getRecordingErrorDescription } from "../utils/recordingErrors";
import { isAccessibilitySkipped } from "../utils/permissions";
+import { needsSttConfigBeforeStart } from "../helpers/sttConfigPolicy";
import {
isAgentAllowed,
isScreenContextAllowed,
@@ -162,11 +163,21 @@ export const useAudioRecording = (toast, options = {}) => {
audioManagerRef.current.beginSelectionCapture();
}
- // Retry STT config fetch if it wasn't loaded on mount (e.g. auth wasn't ready)
+ // Retry STT config fetch if it wasn't loaded on mount (e.g. auth wasn't ready).
+ // Await it only when it can change the start decision (signed-in
+ // OpenWhispr-cloud streaming); for local STT or a signed-out session the
+ // fetch stalls on auth resolution and would delay the mic open (#1673).
if (!audioManagerRef.current.sttConfig) {
- const config = await window.electronAPI.getSttConfig?.();
- if (config?.success) {
- audioManagerRef.current.setSttConfig(config);
+ const configFetch = (async () => {
+ const config = await window.electronAPI.getSttConfig?.();
+ if (config?.success) {
+ audioManagerRef.current.setSttConfig(config);
+ }
+ })().catch((error) => {
+ logger.warn("STT config fetch failed", { error: error?.message });
+ });
+ if (needsSttConfigBeforeStart(getSettings())) {
+ await configFetch;
}
}
diff --git a/test/helpers/sttConfigPolicy.test.js b/test/helpers/sttConfigPolicy.test.js
new file mode 100644
index 000000000..aa538f2f7
--- /dev/null
+++ b/test/helpers/sttConfigPolicy.test.js
@@ -0,0 +1,67 @@
+const { test, describe } = require("node:test");
+const assert = require("node:assert/strict");
+
+const loadPolicy = () => import("../../src/helpers/sttConfigPolicy.js");
+
+describe("needsSttConfigBeforeStart", () => {
+ test("signed-in OpenWhispr cloud mode blocks the start on the config", async () => {
+ const { needsSttConfigBeforeStart } = await loadPolicy();
+ assert.equal(
+ needsSttConfigBeforeStart({
+ useLocalWhisper: false,
+ cloudTranscriptionMode: "openwhispr",
+ isSignedIn: true,
+ }),
+ true
+ );
+ });
+
+ test("local STT never blocks the mic open (#1673)", async () => {
+ const { needsSttConfigBeforeStart } = await loadPolicy();
+ assert.equal(
+ needsSttConfigBeforeStart({
+ useLocalWhisper: true,
+ cloudTranscriptionMode: "openwhispr",
+ isSignedIn: true,
+ }),
+ false
+ );
+ });
+
+ test("signed-out session never blocks — streaming is impossible anyway (#1673)", async () => {
+ const { needsSttConfigBeforeStart } = await loadPolicy();
+ assert.equal(
+ needsSttConfigBeforeStart({
+ useLocalWhisper: false,
+ cloudTranscriptionMode: "openwhispr",
+ isSignedIn: false,
+ }),
+ false
+ );
+ assert.equal(
+ needsSttConfigBeforeStart({
+ useLocalWhisper: false,
+ cloudTranscriptionMode: "openwhispr",
+ }),
+ false
+ );
+ });
+
+ test("BYOK mode decides streaming without the config", async () => {
+ const { needsSttConfigBeforeStart } = await loadPolicy();
+ assert.equal(
+ needsSttConfigBeforeStart({
+ useLocalWhisper: false,
+ cloudTranscriptionMode: "byok",
+ isSignedIn: true,
+ }),
+ false
+ );
+ });
+
+ test("missing settings fail open to a non-blocking start", async () => {
+ const { needsSttConfigBeforeStart } = await loadPolicy();
+ assert.equal(needsSttConfigBeforeStart(null), false);
+ assert.equal(needsSttConfigBeforeStart({}), false);
+ });
+});