Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
fix(reasoning): stop Groq dictation cleanup from failing silently
Alcahest8e394fad4b74
diff --git a/src/components/CleanupFailureToastListener.tsx b/src/components/CleanupFailureToastListener.tsxnew file mode 100644index 000000000..3ba3852a6--- /dev/null+++ b/src/components/CleanupFailureToastListener.tsx@@ -0,0 +1,34 @@+import { useEffect } from "react";+import { useTranslation } from "react-i18next";+import { useToast } from "./ui/useToast";+import { consumeCleanupFailures, useCleanupFailureStore } from "../stores/cleanupFailureStore";++const isDictationPanelWindow = () => {+ const { search, pathname } = window.location;+ return !pathname.includes("control") && !search.includes("panel=true");+};++/** Tells the user their dictation was pasted raw because AI cleanup failed. */+export default function CleanupFailureToastListener() {+ const { t } = useTranslation();+ const { toast } = useToast();++ const pending = useCleanupFailureStore((s) => s.pending);++ useEffect(() => {+ if (pending === 0) return;+ // Draining first keeps a re-run of this effect from toasting the same failure twice.+ if (consumeCleanupFailures() === 0) return;+ // The panel may already be hidden after dictation; surface it so the toast is seen.+ if (isDictationPanelWindow()) {+ window.electronAPI?.showDictationPanel?.();+ }+ toast({+ title: t("app.toasts.cleanupFailed.title"),+ description: t("app.toasts.cleanupFailed.description"),+ duration: 10000,+ });+ }, [pending, toast, t]);++ return null;+}diff --git a/src/helpers/audioManager.js b/src/helpers/audioManager.jsindex 3bf12d902..95a6e570c 100644--- a/src/helpers/audioManager.js+++ b/src/helpers/audioManager.js@@ -24,6 +24,7 @@ import {isCloudCleanupMode,isCloudDictationAgentMode,} from "../stores/settingsStore";+import { recordCleanupFailure } from "../stores/cleanupFailureStore";import { getBatchTranscriptionModel, getTranscriptionProvider } from "../models/ModelRegistry";import { shouldSkipTranscriptionApiKey } from "./transcriptionAuth";import {@@ -1356,8 +1357,9 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);});if (useReasoning) {+ let route;try {- const route = resolveReasoningRoute(+ route = resolveReasoningRoute(normalizedText,getSettings(),agentName,@@ -1397,6 +1399,8 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);fallbackToCleanup: true,});logger.warn("Reasoning failed", { source, error: error.message }, "notes");+ // Retries are already spent here: the raw transcript is what the user gets.+ if (route?.kind === "cleanup") recordCleanupFailure();}}@@ -1672,6 +1676,8 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);{ error: reasonError.message },"transcription");+ // Retries are already spent here: the raw transcript is what the user gets.+ if (route.kind === "cleanup") recordCleanupFailure();}timings.reasoningProcessingDurationMs = Math.round(performance.now() - reasoningStart);}@@ -3175,6 +3181,8 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);{ error: reasonError.message },"streaming");+ // Retries are already spent here: the raw transcript is what the user gets.+ if (route.kind === "cleanup") recordCleanupFailure();}}diff --git a/src/locales/de/translation.json b/src/locales/de/translation.jsonindex 75df050f1..820e583fd 100644--- a/src/locales/de/translation.json+++ b/src/locales/de/translation.json@@ -2506,6 +2506,10 @@"title": "GPU-Beschleunigung nicht verfügbar","description": "Die Transkription verwendet stattdessen die CPU. Du kannst die GPU-Beschleunigung in den Einstellungen deaktivieren."},+ "cleanupFailed": {+ "title": "Bereinigung fehlgeschlagen",+ "description": "Dein Diktat wurde ohne KI-Bereinigung eingefügt."+ },"addedToDict": "{{words}} zu deinem Wörterbuch hinzugefügt","undo": "Rückgängig","accessibilityMissing": {diff --git a/src/locales/en/translation.json b/src/locales/en/translation.jsonindex 471b324be..061e61b04 100644--- a/src/locales/en/translation.json+++ b/src/locales/en/translation.json@@ -2642,6 +2642,10 @@"title": "GPU acceleration unavailable","description": "Transcription is using the CPU instead. You can disable GPU acceleration in Settings."},+ "cleanupFailed": {+ "title": "Cleanup failed",+ "description": "Your dictation was pasted without AI cleanup."+ },"addedToDict": "Added {{words}} to your dictionary","undo": "Undo","accessibilityMissing": {diff --git a/src/locales/es/translation.json b/src/locales/es/translation.jsonindex 92d5d61f3..b78b58ab2 100644--- a/src/locales/es/translation.json+++ b/src/locales/es/translation.json@@ -2554,6 +2554,10 @@"title": "Aceleración GPU no disponible","description": "La transcripción está usando la CPU. Puedes desactivar la aceleración GPU en Configuración."},+ "cleanupFailed": {+ "title": "Limpieza fallida",+ "description": "Tu dictado se pegó sin limpieza con IA."+ },"addedToDict": "{{words}} añadido a tu diccionario","undo": "Deshacer","accessibilityMissing": {diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.jsonindex 155c95777..9cdd099cd 100644--- a/src/locales/fr/translation.json+++ b/src/locales/fr/translation.json@@ -2554,6 +2554,10 @@"title": "Accélération GPU indisponible","description": "La transcription utilise le CPU à la place. Vous pouvez désactiver l'accélération GPU dans les paramètres."},+ "cleanupFailed": {+ "title": "Échec du nettoyage",+ "description": "Votre dictée a été collée sans nettoyage par IA."+ },"addedToDict": "{{words}} ajouté à votre dictionnaire","undo": "Annuler","accessibilityMissing": {diff --git a/src/locales/it/translation.json b/src/locales/it/translation.jsonindex d4555951a..e3c1c3091 100644--- a/src/locales/it/translation.json+++ b/src/locales/it/translation.json@@ -2506,6 +2506,10 @@"title": "Accelerazione GPU non disponibile","description": "La trascrizione sta usando la CPU. Puoi disattivare l'accelerazione GPU nelle Impostazioni."},+ "cleanupFailed": {+ "title": "Pulizia non riuscita",+ "description": "La dettatura è stata incollata senza pulizia IA."+ },"addedToDict": "{{words}} aggiunto al tuo dizionario","undo": "Annulla","accessibilityMissing": {diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.jsonindex 8795482f1..9be5a0692 100644--- a/src/locales/ja/translation.json+++ b/src/locales/ja/translation.json@@ -2506,6 +2506,10 @@"title": "GPU アクセラレーションを利用できません","description": "文字起こしは代わりに CPU を使用しています。設定で GPU アクセラレーションを無効にできます。"},+ "cleanupFailed": {+ "title": "クリーンアップに失敗しました",+ "description": "ディクテーションは AI クリーンアップなしで貼り付けられました。"+ },"addedToDict": "{{words}} を辞書に追加しました","undo": "元に戻す","accessibilityMissing": {diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.jsonindex 6e2f352b9..d9d7a69bb 100644--- a/src/locales/pt/translation.json+++ b/src/locales/pt/translation.json@@ -2506,6 +2506,10 @@"title": "Aceleração GPU indisponível","description": "A transcrição está usando a CPU. Você pode desativar a aceleração GPU nas Configurações."},+ "cleanupFailed": {+ "title": "Falha na limpeza",+ "description": "Seu ditado foi colado sem limpeza por IA."+ },"addedToDict": "{{words}} adicionado ao seu dicionário","undo": "Desfazer","accessibilityMissing": {diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.jsonindex 8f2dbb82c..b40d6593a 100644--- a/src/locales/ru/translation.json+++ b/src/locales/ru/translation.json@@ -2510,6 +2510,10 @@"title": "Ускорение GPU недоступно","description": "Транскрипция выполняется на CPU. Вы можете отключить ускорение GPU в настройках."},+ "cleanupFailed": {+ "title": "Не удалось выполнить очистку",+ "description": "Диктовка вставлена без ИИ-очистки."+ },"addedToDict": "{{words}} добавлено в ваш словарь","undo": "Отменить","accessibilityMissing": {diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.jsonindex 167fee06f..f3a4b3f66 100644--- a/src/locales/zh-CN/translation.json+++ b/src/locales/zh-CN/translation.json@@ -2501,6 +2501,10 @@"title": "GPU 加速不可用","description": "转录正在使用 CPU。你可以在设置中关闭 GPU 加速。"},+ "cleanupFailed": {+ "title": "清理失败",+ "description": "你的听写已直接粘贴,未经 AI 清理。"+ },"addedToDict": "已将 {{words}} 添加到你的词典","undo": "撤消","accessibilityMissing": {diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.jsonindex 9bad9bdf1..55d77e1de 100644--- a/src/locales/zh-TW/translation.json+++ b/src/locales/zh-TW/translation.json@@ -2501,6 +2501,10 @@"title": "GPU 加速無法使用","description": "轉錄正在使用 CPU。你可以在設定中關閉 GPU 加速。"},+ "cleanupFailed": {+ "title": "清理失敗",+ "description": "你的聽寫已直接貼上,未經 AI 清理。"+ },"addedToDict": "已將 {{words}} 加入到你的詞典","undo": "復原","accessibilityMissing": {diff --git a/src/main.jsx b/src/main.jsxindex b2d2a3399..e74c492ea 100644--- a/src/main.jsx+++ b/src/main.jsx@@ -3,6 +3,7 @@ import ReactDOM from "react-dom/client";import { I18nextProvider } from "react-i18next";import AppRouter from "./AppRouter.jsx";import ErrorBoundary from "./components/ErrorBoundary.tsx";+import CleanupFailureToastListener from "./components/CleanupFailureToastListener.tsx";import TinfoilModelSwitchToastListener from "./components/TinfoilModelSwitchToastListener.tsx";import { ToastProvider } from "./components/ui/Toast.tsx";import { SettingsProvider } from "./hooks/useSettings";@@ -18,6 +19,7 @@ root.render(<SettingsProvider><ToastProvider><TinfoilModelSwitchToastListener />+ <CleanupFailureToastListener /><AppRouter /></ToastProvider></SettingsProvider>diff --git a/src/services/ReasoningService.ts b/src/services/ReasoningService.tsindex 7ec7ae576..20e0c1d3d 100644--- a/src/services/ReasoningService.ts+++ b/src/services/ReasoningService.ts@@ -264,7 +264,10 @@ class ReasoningService extends BaseReasoningService {errorData.message ||errorData.error ||`${providerName} API error: ${res.status}`;- throw new Error(errorMessage);+ // Carry the status so the retry layer can tell a rejection from a network fault.+ const apiError = new Error(errorMessage) as Error & { status?: number };+ apiError.status = res.status;+ throw apiError;}const jsonResponse = await res.json();diff --git a/src/services/ai/inferenceProviders/gemini.ts b/src/services/ai/inferenceProviders/gemini.tsindex c1638c3b7..f644c8920 100644--- a/src/services/ai/inferenceProviders/gemini.ts+++ b/src/services/ai/inferenceProviders/gemini.ts@@ -97,7 +97,10 @@ export const geminiProvider: InferenceProvider = {errorData.message ||(typeof errorData.error === "string" ? errorData.error : null) ||`Gemini API error: ${res.status}`;- throw new Error(errMsg);+ // Carry the status so the retry layer can tell a rejection from a network fault.+ const apiError = new Error(errMsg) as Error & { status?: number };+ apiError.status = res.status;+ throw apiError;}const jsonResponse = (await res.json()) as GeminiResponse;diff --git a/src/services/ai/inferenceProviders/openai.ts b/src/services/ai/inferenceProviders/openai.tsindex 37128b4a6..b769e5ec9 100644--- a/src/services/ai/inferenceProviders/openai.ts+++ b/src/services/ai/inferenceProviders/openai.ts@@ -246,7 +246,10 @@ export const openaiProvider: InferenceProvider = {continue;}- throw new Error(errorMessage);+ // Carry the status so the retry layer can tell a rejection from a network fault.+ const apiError = new Error(errorMessage) as Error & { status?: number };+ apiError.status = res.status;+ throw apiError;}rememberPreference(openAiBase, type);diff --git a/src/services/ai/thinkingSuppression.ts b/src/services/ai/thinkingSuppression.tsindex a5b1317ce..c375e384b 100644--- a/src/services/ai/thinkingSuppression.ts+++ b/src/services/ai/thinkingSuppression.ts@@ -1,30 +1,6 @@import type { ReasoningConfig } from "../BaseReasoningService";import { getCloudModel, getLocalModel } from "../../models/ModelRegistry";--// `lan` always talks to an OpenAI-compat /v1 endpoint: the `reasoning` object-// disables Ollama thinking; other backends drop it (flat reasoning_effort trips vLLM).-function suppressThinking(requestBody: Record<string, unknown>, providerKey: string): void {- if (providerKey === "gemini") {- requestBody.reasoning_effort = "minimal";- return;- }-- // OpenRouter forwards unknown params to upstream backends, which may reject- // them — use its native reasoning control instead.- if (providerKey === "openrouter") {- requestBody.reasoning = { enabled: false };- return;- }-- if (providerKey === "local") {- requestBody.think = false;- } else if (providerKey === "lan") {- requestBody.reasoning = { effort: "none" };- } else {- requestBody.reasoning_effort = "none";- }- requestBody.chat_template_kwargs = { enable_thinking: false };-}+import { suppressThinking } from "./thinkingSuppressionDialects";export function applyThinkingSuppression(requestBody: Record<string, unknown>,@@ -36,7 +12,7 @@ export function applyThinkingSuppression(const cloudModel = getCloudModel(model);if (cloudModel?.disableThinking && providerKey === "groq") {- suppressThinking(requestBody, providerKey);+ suppressThinking(requestBody, providerKey, model);return;}@@ -46,5 +22,5 @@ export function applyThinkingSuppression(const knownModel = cloudModel || localModel;if (knownModel && !knownModel.supportsThinking) return;- suppressThinking(requestBody, providerKey);+ suppressThinking(requestBody, providerKey, model);}diff --git a/src/services/ai/thinkingSuppressionDialects.ts b/src/services/ai/thinkingSuppressionDialects.tsnew file mode 100644index 000000000..b9b980155--- /dev/null+++ b/src/services/ai/thinkingSuppressionDialects.ts@@ -0,0 +1,46 @@+/**+ * Per-provider dialects for turning a model's thinking off. Kept free of runtime+ * imports so the dialect table stays unit-testable on its own.+ */+export function suppressThinking(+ requestBody: Record<string, unknown>,+ providerKey: string,+ model: string+): void {+ if (providerKey === "gemini") {+ requestBody.reasoning_effort = "minimal";+ return;+ }++ // OpenRouter forwards unknown params to upstream backends, which may reject+ // them — use its native reasoning control instead.+ if (providerKey === "openrouter") {+ requestBody.reasoning = { enabled: false };+ return;+ }++ // Groq rejects unknown fields outright and takes a different reasoning_effort+ // enum per model family, so send nothing unless the family is known.+ if (providerKey === "groq") {+ const groqModel = (model || "").toLowerCase();+ if (groqModel.includes("qwen")) {+ // qwen3 accepts none|default only.+ requestBody.reasoning_effort = "none";+ } else if (groqModel.includes("gpt-oss")) {+ // gpt-oss accepts low|medium|high only; it has no off switch.+ requestBody.reasoning_effort = "low";+ }+ return;+ }++ if (providerKey === "local") {+ requestBody.think = false;+ } else if (providerKey === "lan") {+ // `lan` always talks to an OpenAI-compat /v1 endpoint: the `reasoning` object+ // disables Ollama thinking; other backends drop it (flat reasoning_effort trips vLLM).+ requestBody.reasoning = { effort: "none" };+ } else {+ requestBody.reasoning_effort = "none";+ }+ requestBody.chat_template_kwargs = { enable_thinking: false };+}diff --git a/src/stores/cleanupFailureStore.ts b/src/stores/cleanupFailureStore.tsnew file mode 100644index 000000000..06cd447d7--- /dev/null+++ b/src/stores/cleanupFailureStore.ts@@ -0,0 +1,22 @@+import { create } from "zustand";++interface CleanupFailureState {+ /** Dictations handed back raw because cleanup failed, not yet surfaced to the user. */+ pending: number;+}++export const useCleanupFailureStore = create<CleanupFailureState>(() => ({+ pending: 0,+}));++export function recordCleanupFailure(): void {+ useCleanupFailureStore.setState((state) => ({ pending: state.pending + 1 }));+}++export function consumeCleanupFailures(): number {+ const { pending } = useCleanupFailureStore.getState();+ if (pending > 0) {+ useCleanupFailureStore.setState({ pending: 0 });+ }+ return pending;+}diff --git a/src/tsconfig.json b/src/tsconfig.jsonindex 4e3de6645..a746b46d3 100644--- a/src/tsconfig.json+++ b/src/tsconfig.json@@ -7,6 +7,7 @@"jsx": "react-jsx","strict": false,"noEmit": true,+ "allowImportingTsExtensions": true,"allowJs": true,"checkJs": false,"esModuleInterop": true,diff --git a/src/utils/retry.ts b/src/utils/retry.tsindex 3c0967068..a92089d8a 100644--- a/src/utils/retry.ts+++ b/src/utils/retry.ts@@ -1,4 +1,4 @@-import { RETRY_CONFIG } from "../config/constants";+import { RETRY_CONFIG } from "../config/constants.ts";export interface RetryOptions {maxRetries?: number;@@ -43,11 +43,12 @@ export async function withRetry<T>(fn: () => Promise<T>, options: RetryOptions =export function createApiRetryStrategy() {return {shouldRetry: (error: any) => {- // Retry on network errors or 5xx status codes- if (!error.response) return true; // Network error+ // No HTTP status means the request never got an answer (network drop, timeout).+ const status = error?.status ?? error?.response?.status;+ if (typeof status !== "number") return true;- const status = error.response?.status || error.status;- return status >= 500 && status < 600;+ // 4xx are deterministic rejections; only rate limits and server faults can clear on retry.+ return status === 429 || (status >= 500 && status < 600);},};}diff --git a/test/helpers/apiRetryStrategy.test.js b/test/helpers/apiRetryStrategy.test.jsnew file mode 100644index 000000000..dca214af3--- /dev/null+++ b/test/helpers/apiRetryStrategy.test.js@@ -0,0 +1,92 @@+const test = require("node:test");+const assert = require("node:assert/strict");++// Requires Node's native TypeScript type-stripping (Node >= 22.6 with+// --experimental-strip-types, on by default in Node 23.6+/24). CI runs Node 24.++const load = () => import("../../src/utils/retry.ts");++test("errors without a status retry, since they mean the request never got an answer", async () => {+ const { createApiRetryStrategy } = await load();+ const { shouldRetry } = createApiRetryStrategy();++ assert.equal(shouldRetry(new Error("fetch failed")), true);+ assert.equal(shouldRetry(new Error("Request timed out after 30s")), true);+});++test("4xx rejections do not retry, because the same request will be refused again", async () => {+ const { createApiRetryStrategy } = await load();+ const { shouldRetry } = createApiRetryStrategy();++ assert.equal(shouldRetry(Object.assign(new Error("bad request"), { status: 400 })), false);+ assert.equal(shouldRetry(Object.assign(new Error("not found"), { status: 404 })), false);+});++test("429 retries, since rate limits clear on their own", async () => {+ const { createApiRetryStrategy } = await load();+ const { shouldRetry } = createApiRetryStrategy();++ assert.equal(shouldRetry(Object.assign(new Error("rate limited"), { status: 429 })), true);+});++test("5xx server faults retry", async () => {+ const { createApiRetryStrategy } = await load();+ const { shouldRetry } = createApiRetryStrategy();++ assert.equal(shouldRetry(Object.assign(new Error("server error"), { status: 500 })), true);+ assert.equal(shouldRetry(Object.assign(new Error("unavailable"), { status: 503 })), true);+});++test("a status above the 5xx range does not retry", async () => {+ const { createApiRetryStrategy } = await load();+ const { shouldRetry } = createApiRetryStrategy();++ assert.equal(shouldRetry(Object.assign(new Error("nonsense"), { status: 600 })), false);+});++test("a status nested under response is honored", async () => {+ const { createApiRetryStrategy } = await load();+ const { shouldRetry } = createApiRetryStrategy();++ assert.equal(shouldRetry({ response: { status: 502 } }), true);+ assert.equal(shouldRetry({ response: { status: 403 } }), false);+});++test("a response carrying a non-numeric status is treated as a network failure and retries", async () => {+ const { createApiRetryStrategy } = await load();+ const { shouldRetry } = createApiRetryStrategy();++ assert.equal(shouldRetry({ response: { status: undefined } }), true);+ assert.equal(shouldRetry({ response: {} }), true);+});++test("withRetry stops after one attempt when the strategy refuses to retry", async () => {+ const { withRetry, createApiRetryStrategy } = await load();++ let attempts = 0;+ const failWith400 = async () => {+ attempts += 1;+ throw Object.assign(new Error("groq rejected the request"), { status: 400 });+ };++ await assert.rejects(+ () => withRetry(failWith400, { ...createApiRetryStrategy(), initialDelay: 1 }),+ /groq rejected the request/+ );+ assert.equal(attempts, 1, "a 400 must fail fast instead of burning the backoff ladder");+});++test("withRetry keeps retrying a 5xx up to maxRetries", async () => {+ const { withRetry, createApiRetryStrategy } = await load();++ let attempts = 0;+ const failWith503 = async () => {+ attempts += 1;+ throw Object.assign(new Error("unavailable"), { status: 503 });+ };++ await assert.rejects(() =>+ withRetry(failWith503, { ...createApiRetryStrategy(), maxRetries: 2, initialDelay: 1 })+ );+ assert.equal(attempts, 3, "initial attempt plus two retries");+});diff --git a/test/helpers/cleanupFailureStore.test.js b/test/helpers/cleanupFailureStore.test.jsnew file mode 100644index 000000000..bb6b9205a--- /dev/null+++ b/test/helpers/cleanupFailureStore.test.js@@ -0,0 +1,42 @@+const test = require("node:test");+const assert = require("node:assert/strict");++// Requires Node's native TypeScript type-stripping (Node >= 22.6 with+// --experimental-strip-types, on by default in Node 23.6+/24). CI runs Node 24.++const load = () => import("../../src/stores/cleanupFailureStore.ts");++const reset = (store) => store.useCleanupFailureStore.setState({ pending: 0 });++test("recordCleanupFailure increments the pending count", async () => {+ const store = await load();+ reset(store);++ store.recordCleanupFailure();+ assert.equal(store.useCleanupFailureStore.getState().pending, 1);++ store.recordCleanupFailure();+ assert.equal(store.useCleanupFailureStore.getState().pending, 2);+});++test("consumeCleanupFailures returns the pending count and resets it to zero", async () => {+ const store = await load();+ reset(store);++ store.recordCleanupFailure();+ store.recordCleanupFailure();++ assert.equal(store.consumeCleanupFailures(), 2);+ assert.equal(store.useCleanupFailureStore.getState().pending, 0);+});++test("consuming an empty store returns zero, so a re-run cannot toast the same failure twice", async () => {+ const store = await load();+ reset(store);++ assert.equal(store.consumeCleanupFailures(), 0);++ store.recordCleanupFailure();+ assert.equal(store.consumeCleanupFailures(), 1);+ assert.equal(store.consumeCleanupFailures(), 0);+});diff --git a/test/helpers/thinkingSuppressionDialects.test.js b/test/helpers/thinkingSuppressionDialects.test.jsnew file mode 100644index 000000000..3a86610de--- /dev/null+++ b/test/helpers/thinkingSuppressionDialects.test.js@@ -0,0 +1,108 @@+const test = require("node:test");+const assert = require("node:assert/strict");++// Requires Node's native TypeScript type-stripping (Node >= 22.6 with+// --experimental-strip-types, on by default in Node 23.6+/24). CI runs Node 24.++const load = () => import("../../src/services/ai/thinkingSuppressionDialects.ts");++test("groq qwen models get reasoning_effort none and never chat_template_kwargs", async () => {+ const { suppressThinking } = await load();++ const body = {};+ suppressThinking(body, "groq", "qwen/qwen3-32b");++ assert.deepEqual(body, { reasoning_effort: "none" });+ assert.ok(!("chat_template_kwargs" in body), "Groq rejects chat_template_kwargs with a 400");+});++test("groq gpt-oss models get reasoning_effort low, the lowest value that family accepts", async () => {+ const { suppressThinking } = await load();++ const body = {};+ suppressThinking(body, "groq", "openai/gpt-oss-120b");++ assert.deepEqual(body, { reasoning_effort: "low" });+ assert.ok(!("chat_template_kwargs" in body), "Groq rejects chat_template_kwargs with a 400");+});++test("groq model family matching is case insensitive", async () => {+ const { suppressThinking } = await load();++ const qwen = {};+ suppressThinking(qwen, "groq", "Qwen/Qwen3-32B");+ assert.equal(qwen.reasoning_effort, "none");++ const gptOss = {};+ suppressThinking(gptOss, "groq", "OpenAI/GPT-OSS-20B");+ assert.equal(gptOss.reasoning_effort, "low");+});++test("groq models of an unknown family are left untouched rather than sent a guessed enum", async () => {+ const { suppressThinking } = await load();++ const body = { model: "llama-3.3-70b-versatile", messages: [] };+ suppressThinking(body, "groq", "llama-3.3-70b-versatile");++ assert.deepEqual(body, { model: "llama-3.3-70b-versatile", messages: [] });+});++test("groq tolerates a missing model without throwing", async () => {+ const { suppressThinking } = await load();++ const body = {};+ suppressThinking(body, "groq", undefined);++ assert.deepEqual(body, {});+});++test("gemini gets reasoning_effort minimal and nothing else", async () => {+ const { suppressThinking } = await load();++ const body = {};+ suppressThinking(body, "gemini", "gemini-3-flash-preview");++ assert.deepEqual(body, { reasoning_effort: "minimal" });+});++test("openrouter gets its native reasoning toggle and nothing else", async () => {+ const { suppressThinking } = await load();++ const body = {};+ suppressThinking(body, "openrouter", "qwen/qwen3-32b");++ assert.deepEqual(body, { reasoning: { enabled: false } });+});++test("local gets think false plus chat_template_kwargs", async () => {+ const { suppressThinking } = await load();++ const body = {};+ suppressThinking(body, "local", "qwen3-8b");++ assert.deepEqual(body, { think: false, chat_template_kwargs: { enable_thinking: false } });+});++test("lan gets the nested reasoning object plus chat_template_kwargs", async () => {+ const { suppressThinking } = await load();++ const body = {};+ suppressThinking(body, "lan", "qwen3-8b");++ assert.deepEqual(body, {+ reasoning: { effort: "none" },+ chat_template_kwargs: { enable_thinking: false },+ });+});++test("unlisted providers keep the legacy reasoning_effort none plus chat_template_kwargs", async () => {+ const { suppressThinking } = await load();++ const body = {};+ suppressThinking(body, "openai", "gpt-5.2");++ assert.deepEqual(body, {+ reasoning_effort: "none",+ chat_template_kwargs: { enable_thinking: false },+ });+});