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
Make the non-streaming LLM request timeout configurable
Sebastian Schmid9c16a56729f3
diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsxindex c34d0cf7b..b9cf465cc 100644--- a/src/components/SettingsPage.tsx+++ b/src/components/SettingsPage.tsx@@ -105,6 +105,10 @@ import { cn } from "./lib/utils";import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";import { startMigration, useMigration } from "../stores/noteStore.js";import { syncService } from "../services/SyncService.js";+import {+ LLM_REQUEST_TIMEOUT_SECONDS_MIN,+ LLM_REQUEST_TIMEOUT_SECONDS_MAX,+} from "../helpers/llmRequestTimeout.js";import { formatBytes } from "../utils/formatBytes";import {clearMissingLocalModelSelections,@@ -648,6 +652,8 @@ function LlmsTabs({}) {const { t } = useTranslation();const agentAllowed = usePolicyStore(isAgentAllowed);+ const llmRequestTimeoutSeconds = useSettingsStore((s) => s.llmRequestTimeoutSeconds);+ const setLlmRequestTimeoutSeconds = useSettingsStore((s) => s.setLlmRequestTimeoutSeconds);const visibleTabIds = agentAllowed? LLM_TABS: LLM_TABS.filter((tabId) => !AGENT_LLM_TABS.has(tabId));@@ -688,6 +694,28 @@ function LlmsTabs({{agentAllowed && (<TabPanel active={tab === "chatIntelligence"}>{renderChatIntelligence()}</TabPanel>)}++ {/* Applies to every scope above — the shared abort timeout for non-streaming requests. */}+ <div className="border-t border-border/40 pt-4 mt-4">+ <SettingsPanel>+ <SettingsPanelRow>+ <SettingsRow+ label={t("settingsPage.llms.requestTimeout.label")}+ description={t("settingsPage.llms.requestTimeout.description")}+ >+ <Input+ type="number"+ min={LLM_REQUEST_TIMEOUT_SECONDS_MIN}+ max={LLM_REQUEST_TIMEOUT_SECONDS_MAX}+ step={5}+ value={llmRequestTimeoutSeconds}+ onChange={(e) => setLlmRequestTimeoutSeconds(Number(e.target.value))}+ className="w-20"+ />+ </SettingsRow>+ </SettingsPanelRow>+ </SettingsPanel>+ </div></div>);}diff --git a/src/helpers/llmRequestTimeout.js b/src/helpers/llmRequestTimeout.jsnew file mode 100644index 000000000..f47a5d750--- /dev/null+++ b/src/helpers/llmRequestTimeout.js@@ -0,0 +1,17 @@+// Every non-streaming reasoning request (cleanup, note formatting, chat/dictation+// agent tool calls, self-hosted LAN calls) shares one configurable abort timeout.+// Self-hosted/local models can legitimately take well past the historical 30s+// default; the range below just keeps a bad or hand-edited value from firing+// instantly or hanging forever. Streaming requests have their own inactivity+// timeouts and don't use this.+export const LLM_REQUEST_TIMEOUT_SECONDS_MIN = 10;+export const LLM_REQUEST_TIMEOUT_SECONDS_MAX = 600;+export const LLM_REQUEST_TIMEOUT_SECONDS_DEFAULT = 30;++export function resolveLlmRequestTimeoutSeconds(configured) {+ const seconds = Number.isFinite(configured) ? configured : LLM_REQUEST_TIMEOUT_SECONDS_DEFAULT;+ return Math.min(+ LLM_REQUEST_TIMEOUT_SECONDS_MAX,+ Math.max(LLM_REQUEST_TIMEOUT_SECONDS_MIN, seconds)+ );+}diff --git a/src/hooks/useSettings.ts b/src/hooks/useSettings.tsindex 755095b63..31fa9fd02 100644--- a/src/hooks/useSettings.ts+++ b/src/hooks/useSettings.ts@@ -264,6 +264,8 @@ function useSettingsInternal() {remoteTranscriptionModel: store.remoteTranscriptionModel,cleanupMode: store.cleanupMode,cleanupRemoteUrl: store.cleanupRemoteUrl,+ llmRequestTimeoutSeconds: store.llmRequestTimeoutSeconds,+ setLlmRequestTimeoutSeconds: store.setLlmRequestTimeoutSeconds,customDictionary: store.customDictionary,snippets: store.snippets,setSnippets: store.setSnippets,diff --git a/src/locales/de/translation.json b/src/locales/de/translation.jsonindex 3a82db7d2..59d642603 100644--- a/src/locales/de/translation.json+++ b/src/locales/de/translation.json@@ -2113,6 +2113,10 @@"noteFormatting": "Notizformatierung","chatIntelligence": "Chat","dictationTranslation": "Übersetzung"+ },+ "requestTimeout": {+ "label": "Zeitlimit für Anfragen (Sekunden)",+ "description": "Wie lange auf eine Antwort gewartet wird, bevor abgebrochen wird. Selbst gehostete oder lokale Modelle benötigen oft mehr als die Standardeinstellung von 30 s, besonders bei langen Notizen."}},"noteFormatting": {diff --git a/src/locales/en/translation.json b/src/locales/en/translation.jsonindex db600a2a3..0a4a66085 100644--- a/src/locales/en/translation.json+++ b/src/locales/en/translation.json@@ -2113,6 +2113,10 @@"noteFormatting": "Note Formatting","chatIntelligence": "Chat","dictationTranslation": "Translation"+ },+ "requestTimeout": {+ "label": "Request timeout (seconds)",+ "description": "How long to wait for a response before giving up. Self-hosted or local models may need more than the default 30s, especially for long notes."}},"noteFormatting": {diff --git a/src/locales/es/translation.json b/src/locales/es/translation.jsonindex 53539b43c..467786680 100644--- a/src/locales/es/translation.json+++ b/src/locales/es/translation.json@@ -1878,6 +1878,10 @@"noteFormatting": "Formato de notas","chatIntelligence": "Chat","dictationTranslation": "Traducción"+ },+ "requestTimeout": {+ "label": "Tiempo de espera de la solicitud (segundos)",+ "description": "Cuánto tiempo esperar una respuesta antes de desistir. Los modelos autoalojados o locales pueden necesitar más de los 30 s predeterminados, sobre todo con notas largas."}},"noteFormatting": {diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.jsonindex 1561106df..a0385c7ab 100644--- a/src/locales/fr/translation.json+++ b/src/locales/fr/translation.json@@ -2113,6 +2113,10 @@"noteFormatting": "Mise en forme des notes","chatIntelligence": "Chat","dictationTranslation": "Traduction"+ },+ "requestTimeout": {+ "label": "Délai d'expiration de la requête (secondes)",+ "description": "Durée d'attente d'une réponse avant abandon. Les modèles auto-hébergés ou locaux peuvent nécessiter plus que les 30 s par défaut, surtout pour les notes longues."}},"noteFormatting": {diff --git a/src/locales/it/translation.json b/src/locales/it/translation.jsonindex 1b47b76b3..dedd4d331 100644--- a/src/locales/it/translation.json+++ b/src/locales/it/translation.json@@ -1830,6 +1830,10 @@"noteFormatting": "Formattazione note","chatIntelligence": "Chat","dictationTranslation": "Traduzione"+ },+ "requestTimeout": {+ "label": "Timeout della richiesta (secondi)",+ "description": "Per quanto tempo attendere una risposta prima di rinunciare. I modelli self-hosted o locali possono richiedere più dei 30 s predefiniti, soprattutto per le note lunghe."}},"noteFormatting": {diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.jsonindex 76533aec1..64c4d713c 100644--- a/src/locales/ja/translation.json+++ b/src/locales/ja/translation.json@@ -1830,6 +1830,10 @@"noteFormatting": "ノートのフォーマット","chatIntelligence": "チャット","dictationTranslation": "翻訳"+ },+ "requestTimeout": {+ "label": "リクエストのタイムアウト(秒)",+ "description": "応答を待つ時間の上限です。セルフホストやローカルモデルでは、特に長いノートの場合、デフォルトの30秒より長い時間が必要になることがあります。"}},"noteFormatting": {diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.jsonindex 21c6dc85b..6dcb5b23d 100644--- a/src/locales/pt/translation.json+++ b/src/locales/pt/translation.json@@ -1809,6 +1809,10 @@"noteFormatting": "Formatação de notas","chatIntelligence": "Chat","dictationTranslation": "Tradução"+ },+ "requestTimeout": {+ "label": "Tempo limite da solicitação (segundos)",+ "description": "Quanto tempo aguardar por uma resposta antes de desistir. Modelos auto-hospedados ou locais podem precisar de mais que os 30 s padrão, especialmente para notas longas."}},"noteFormatting": {diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.jsonindex 95466bb6c..d7629d050 100644--- a/src/locales/ru/translation.json+++ b/src/locales/ru/translation.json@@ -1836,6 +1836,10 @@"noteFormatting": "Форматирование заметок","chatIntelligence": "Чат","dictationTranslation": "Перевод"+ },+ "requestTimeout": {+ "label": "Тайм-аут запроса (секунды)",+ "description": "Как долго ждать ответа, прежде чем отменить запрос. Локальным или self-hosted моделям может потребоваться больше стандартных 30 секунд, особенно для длинных заметок."}},"noteFormatting": {diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.jsonindex 1141dd3a6..3032c1d54 100644--- a/src/locales/zh-CN/translation.json+++ b/src/locales/zh-CN/translation.json@@ -1830,6 +1830,10 @@"noteFormatting": "笔记格式化","chatIntelligence": "聊天","dictationTranslation": "翻译"+ },+ "requestTimeout": {+ "label": "请求超时时间(秒)",+ "description": "放弃前等待响应的时长。自托管或本地模型可能需要超过默认的 30 秒,尤其是处理较长的笔记时。"}},"noteFormatting": {diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.jsonindex 854661bd6..982be6b8b 100644--- a/src/locales/zh-TW/translation.json+++ b/src/locales/zh-TW/translation.json@@ -1830,6 +1830,10 @@"noteFormatting": "筆記格式化","chatIntelligence": "聊天","dictationTranslation": "翻譯"+ },+ "requestTimeout": {+ "label": "請求逾時時間(秒)",+ "description": "放棄前等待回應的時長。自架或本機模型可能需要超過預設的 30 秒,尤其是處理較長的筆記時。"}},"noteFormatting": {diff --git a/src/services/ReasoningService.ts b/src/services/ReasoningService.tsindex 9b943f370..0fea80bb2 100644--- a/src/services/ReasoningService.ts+++ b/src/services/ReasoningService.ts@@ -14,6 +14,7 @@ import logger from "../utils/logger";import { getSettings, isCloudCleanupMode } from "../stores/settingsStore";import { wrapCleanupTranscript } from "../config/prompts";import { stripThinkingTags } from "../helpers/stripThinking.js";+import { resolveLlmRequestTimeoutSeconds } from "../helpers/llmRequestTimeout.js";import { streamText, stepCountIs } from "ai";import { getAIModel } from "./ai/providers";import { createEnterpriseChatModel } from "./ai/enterpriseChatModel";@@ -310,7 +311,14 @@ class ReasoningService extends BaseReasoningService {const response = await withRetry(async () => {const controller = new AbortController();- const timeoutId = setTimeout(() => controller.abort(), 30000);+ // Self-hosted/local models can legitimately take well past the 30s default+ // to format a long note; the setting is clamped to a sane range in case of+ // a stray or hand-edited value. Streaming requests have their own+ // inactivity timeouts and don't go through here.+ const timeoutSeconds = resolveLlmRequestTimeoutSeconds(+ getSettings().llmRequestTimeoutSeconds+ );+ const timeoutId = setTimeout(() => controller.abort(), timeoutSeconds * 1000);try {const headers: Record<string, string> = {"Content-Type": "application/json",@@ -369,7 +377,7 @@ class ReasoningService extends BaseReasoningService {return jsonResponse;} catch (error) {if ((error as Error).name === "AbortError") {- throw new Error("Request timed out after 30s");+ throw new Error(`Request timed out after ${timeoutSeconds}s`);}throw error;} finally {diff --git a/src/stores/settingsStore.ts b/src/stores/settingsStore.tsindex 673674c11..d0a0b30de 100644--- a/src/stores/settingsStore.ts+++ b/src/stores/settingsStore.ts@@ -298,6 +298,7 @@ const NUMERIC_SETTINGS = new Set(["micWarmHoldSeconds","audioRetentionDays","transcriptRetentionDays",+ "llmRequestTimeoutSeconds","whisperVadThreshold","whisperVadMinSpeechDurationMs","whisperVadMinSilenceDurationMs",@@ -616,6 +617,10 @@ export interface SettingsStateremoteTranscriptionModel: string;cleanupMode: InferenceMode;cleanupRemoteUrl: string;+ // Abort timeout for every non-streaming LLM request (cleanup, note formatting,+ // agent tool calls, self-hosted LAN calls), in seconds. Clamped to a sane range+ // at the point of use — see src/helpers/llmRequestTimeout.js.+ llmRequestTimeoutSeconds: number;meetingTranscriptionMode: InferenceMode;meetingUseLocalWhisper: boolean;@@ -718,6 +723,7 @@ export interface SettingsStatesetRemoteTranscriptionModel: (model: string) => void;setCleanupMode: (mode: InferenceMode) => void;setCleanupRemoteUrl: (url: string) => void;+ setLlmRequestTimeoutSeconds: (seconds: number) => void;setMeetingTranscriptionMode: (mode: InferenceMode) => void;setMeetingUseLocalWhisper: (value: boolean) => void;@@ -1374,6 +1380,7 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({return "openwhispr" as InferenceMode;})(),cleanupRemoteUrl: readString("cleanupRemoteUrl", ""),+ llmRequestTimeoutSeconds: readNumber("llmRequestTimeoutSeconds", 30),meetingTranscriptionMode: (() => {const v = readString("meetingTranscriptionMode", "openwhispr");@@ -1471,6 +1478,7 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({setRemoteTranscriptionModel: createStringSetter("remoteTranscriptionModel"),setCleanupMode: createStringSetter("cleanupMode") as (mode: InferenceMode) => void,setCleanupRemoteUrl: createStringSetter("cleanupRemoteUrl"),+ setLlmRequestTimeoutSeconds: createNumberSetter("llmRequestTimeoutSeconds"),setMeetingTranscriptionMode: createStringSetter("meetingTranscriptionMode") as (mode: InferenceModediff --git a/test/helpers/llmRequestTimeout.test.js b/test/helpers/llmRequestTimeout.test.jsnew file mode 100644index 000000000..05d29261f--- /dev/null+++ b/test/helpers/llmRequestTimeout.test.js@@ -0,0 +1,25 @@+const test = require("node:test");+const assert = require("node:assert/strict");++const load = () => import("../../src/helpers/llmRequestTimeout.js");++test("uses the configured value when it's within range", async () => {+ const { resolveLlmRequestTimeoutSeconds } = await load();+ assert.equal(resolveLlmRequestTimeoutSeconds(90), 90);+});++test("falls back to the 30s default when unset or invalid", async () => {+ const { resolveLlmRequestTimeoutSeconds } = await load();+ assert.equal(resolveLlmRequestTimeoutSeconds(undefined), 30);+ assert.equal(resolveLlmRequestTimeoutSeconds(NaN), 30);+});++test("clamps below the 10s floor", async () => {+ const { resolveLlmRequestTimeoutSeconds } = await load();+ assert.equal(resolveLlmRequestTimeoutSeconds(1), 10);+});++test("clamps above the 600s ceiling", async () => {+ const { resolveLlmRequestTimeoutSeconds } = await load();+ assert.equal(resolveLlmRequestTimeoutSeconds(9999), 600);+});