Skip to content

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

test(settings): pin the explicit-click commit sequences for model selection

Gabriel Stein43cc03a554e3
diff --git a/test/helpers/policyRules.test.js b/test/helpers/policyRules.test.js
index 43db9e748..ef5fbfc16 100644
--- a/test/helpers/policyRules.test.js
+++ b/test/helpers/policyRules.test.js
@@ -651,6 +651,54 @@ test("re-entering providers mode replaces a dormant policy-disallowed provider",
);
});
+// The STT picker feeds reconcile the browsed tab (browsedCloudProvider ??
+// selectedCloudProvider) while the committed pair stays untouched in the store.
+test("a browsed provider resolves for display without leaking the committed model", async () => {
+ const { reconcileCloudProviderSelection } = await load();
+ const allowedProviders = [
+ { id: "openai", models: [{ id: "whisper-1" }] },
+ { id: "groq", models: [{ id: "whisper-large-v3" }] },
+ ];
+
+ // Browsing an allowed tab: the display lands on the browsed provider with
+ // its own default — the committed model (openai's) never leaks into it.
+ assert.deepEqual(
+ reconcileCloudProviderSelection({
+ selectedProvider: "groq",
+ selectedModel: "whisper-1",
+ allowedProviders,
+ customAllowed: false,
+ hasCustomUrl: false,
+ }),
+ { provider: "groq", model: "whisper-large-v3" }
+ );
+
+ // Browsing the Custom tab is always a valid input (null = no correction);
+ // the caller must echo the browsed input, not the committed pair.
+ assert.equal(
+ reconcileCloudProviderSelection({
+ selectedProvider: "custom",
+ selectedModel: "whisper-1",
+ allowedProviders,
+ customAllowed: true,
+ hasCustomUrl: false,
+ }),
+ null
+ );
+
+ // A browsed provider that policy has since disallowed falls back.
+ assert.deepEqual(
+ reconcileCloudProviderSelection({
+ selectedProvider: "xai",
+ selectedModel: "whisper-1",
+ allowedProviders,
+ customAllowed: false,
+ hasCustomUrl: false,
+ }),
+ { provider: "openai", model: "whisper-1" }
+ );
+});
+
test("active control-panel views reroute on their specific policy capability", async () => {
const { isControlPanelViewAllowed } = await load();
diff --git a/test/helpers/reasoningModelMemory.test.js b/test/helpers/reasoningModelMemory.test.js
index d4e60a5df..d04b086c8 100644
--- a/test/helpers/reasoningModelMemory.test.js
+++ b/test/helpers/reasoningModelMemory.test.js
@@ -69,6 +69,51 @@ test("per-provider reasoning model memory", async (t) => {
});
});
+// The reasoning picker commits only on an explicit model click via the plain
+// scope setters (provider, then model). Pin that the pair lands atomically
+// and that per-provider memory never overrides an explicit click.
+test("explicit model click commits the (provider, model) pair atomically", async (t) => {
+ installBrowserGlobals(t, {
+ initialStorage: {
+ _llmScopeKeysMigrated: "1",
+ cleanupMode: "providers",
+ cleanupProvider: "openai",
+ cleanupModel: "gpt-5-mini",
+ },
+ });
+ const vite = await createRendererServer(t, {
+ cachePrefix: "openwhispr-reasoning-click-commit-test-",
+ });
+ const { useSettingsStore } = await vite.ssrLoadModule("/stores/settingsStore.ts");
+ const state = () => useSettingsStore.getState();
+
+ // Seed per-provider memory: anthropic remembers claude-opus-4-6.
+ state().switchReasoningProvider("dictationCleanup", "anthropic", "claude-sonnet-4-6");
+ state().setCleanupModel("claude-opus-4-6");
+ state().switchReasoningProvider("dictationCleanup", "openai", "gpt-5.2");
+ assert.equal(state().cleanupModel, "gpt-5-mini", "switch-and-return restores openai's model");
+
+ // Explicit click on claude-haiku-4-5 under the browsed anthropic tab:
+ // the clicked pair commits, not the remembered claude-opus-4-6.
+ state().setCleanupProvider("anthropic");
+ state().setCleanupModel("claude-haiku-4-5");
+ assert.equal(state().cleanupProvider, "anthropic");
+ assert.equal(
+ state().cleanupModel,
+ "claude-haiku-4-5",
+ "per-provider memory must not resurrect over an explicit click"
+ );
+
+ // A later provider-only write must not drag the model along.
+ state().setCleanupProvider("openai");
+ assert.equal(state().cleanupProvider, "openai");
+ assert.equal(
+ state().cleanupModel,
+ "claude-haiku-4-5",
+ "the plain provider setter writes the provider alone"
+ );
+});
+
test("corrupt persisted reasoning model memory hydrates as empty, not a crash", async (t) => {
installBrowserGlobals(t, {
initialStorage: {
diff --git a/test/helpers/transcriptionModelMemory.test.js b/test/helpers/transcriptionModelMemory.test.js
index 1a186c6f7..f5d19d73f 100644
--- a/test/helpers/transcriptionModelMemory.test.js
+++ b/test/helpers/transcriptionModelMemory.test.js
@@ -113,6 +113,49 @@ test("per-provider transcription model memory", async (t) => {
});
});
+// The picker commits a cloud selection only on an explicit model click:
+// switchCloudTranscriptionProvider(ctx, browsedProvider) followed by
+// setCloudTranscriptionModel(clickedId). Pin that sequence at store level.
+test("explicit model click commits the clicked model, not the remembered one", async (t) => {
+ installBrowserGlobals(t, {
+ initialStorage: {
+ _providerSettingsMigrated: "1",
+ uploadTranscriptionMigrated: "true",
+ cloudTranscriptionProvider: "openai",
+ cloudTranscriptionModel: "gpt-4o-transcribe",
+ cloudTranscriptionBaseUrl: "https://stt.parasail.example.com/v1",
+ transcriptionModelByProvider: JSON.stringify({
+ "dictation:groq": "whisper-large-v3",
+ }),
+ },
+ });
+ const vite = await createRendererServer(t, {
+ cachePrefix: "openwhispr-model-click-commit-test-",
+ });
+ const { useSettingsStore } = await vite.ssrLoadModule("/stores/settingsStore.ts");
+ const state = () => useSettingsStore.getState();
+
+ state().switchCloudTranscriptionProvider("dictation", "groq");
+ state().setCloudTranscriptionModel("whisper-large-v3-turbo");
+
+ assert.equal(state().cloudTranscriptionProvider, "groq");
+ assert.equal(
+ state().cloudTranscriptionModel,
+ "whisper-large-v3-turbo",
+ "the clicked model must win over the remembered/default one"
+ );
+ assert.equal(
+ state().transcriptionModelByProvider["dictation:openai"],
+ "gpt-4o-transcribe",
+ "the outgoing provider's model is remembered"
+ );
+ assert.equal(
+ state().cloudTranscriptionBaseUrl,
+ "https://stt.parasail.example.com/v1",
+ "the custom URL slot must never be touched by the commit sequence (#1459/#1463)"
+ );
+});
+
test("corrupt persisted model memory hydrates as empty, not a crash", async (t) => {
installBrowserGlobals(t, {
initialStorage: {