Skip to content

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

fix(notes): give note formatting a ten-minute deadline and stop retrying timeouts (#2204)

Gabriel Stein94aeecb75aae
diff --git a/.github/workflows/llm-canary.yml b/.github/workflows/llm-canary.yml
index 9b2bf6633..b7ce1b237 100644
--- a/.github/workflows/llm-canary.yml
+++ b/.github/workflows/llm-canary.yml
@@ -1,7 +1,9 @@
# Weekly live check that every LLM provider still accepts the exact request
# shapes the app sends (reasoning params, token-limit param, temperature), plus
-# a model-catalog drift diff. Deliberately NOT part of PR CI: it exercises
-# external APIs and their failures are provider news, not code regressions.
+# a model-catalog drift diff and one meeting-sized Generate AI Summary request
+# per provider timed against the app's note-formatting deadline. Deliberately
+# NOT part of PR CI: it exercises external APIs and their failures are provider
+# news, not code regressions.
name: llm-canary
on:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 72ad585fa..93196a078 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Notes
+
+- **Generate AI Summary with your own API key or an enterprise provider no longer times out on a real transcript.** Every bring-your-own-key request shared the 30-second deadline meant for dictation cleanup (enterprise providers had 60 seconds), and a timeout was treated like a dropped connection and retried three more times. A 2,000-word transcript through a reasoning model such as GPT-5.6 Terra needs longer than that to think before it writes, so the summary spun for about a minute and a half, four requests were billed, and it ended with a timeout error and no note. Note formatting now waits up to ten minutes, matching OpenAI's own client default, and a request that does hit its deadline fails once instead of being re-sent. Dictation cleanup keeps its 30-second deadline on every provider.
+
## [1.10.1] - 2026-09-14
A follow-up to 1.10.0 built from everything that landed since. Notes open straight onto their AI Summary when one exists and the raw tab becomes **Your notes**; the "Enhanced" label is gone in favour of **AI Summary** everywhere, a meeting that ends on its own still offers the summary, and the post-meeting notification is retired. Team spaces get one **Settings** dialog with a built-in emoji picker and a single flat member roster, Teams are called **Groups** in workspace copy, the sidebar gains **Invite your team**, and the tray and dictation pill pick up quick actions. Uploads accept video and nearly every audio container, Windows finds the right microphone again and starts listening sooner, local dictation skips a decode step, and bring-your-own-key Deepgram and AssemblyAI work again. Cleanup no longer pastes a reply the model cut short, whisper.cpp stops dropping words at window boundaries, local models size their context to the request, assistant answers finally render tables, and Reset app data restarts the app so history keeps working.
diff --git a/scripts/lib/note-formatting-probe.mjs b/scripts/lib/note-formatting-probe.mjs
new file mode 100644
index 000000000..fd6e7c148
--- /dev/null
+++ b/scripts/lib/note-formatting-probe.mjs
@@ -0,0 +1,129 @@
+/**
+ * Fixture for the live note-formatting probe in scripts/llm-canary.mjs: a
+ * meeting-sized transcript and the exact system prompt the note action store
+ * sends for Detailed Notes, so the probe measures the request users make.
+ */
+import {
+ BUILTIN_ACTIONS,
+ DETAILED_NOTES_KEY,
+ MEETING_INPUT_PREAMBLE,
+} from "../../src/helpers/builtinActions.js";
+
+/** A real 45-minute meeting lands around here; the 1.10.1 report was 2,170 words. */
+export const NOTE_PROBE_MIN_WORDS = 2000;
+
+const SPEAKERS = ["You", "Priya", "Marcus"];
+
+// Sentence templates in agenda order. Placeholders are filled from a seeded
+// generator so the transcript is deterministic yet not word-for-word repetitive.
+const SENTENCES = [
+ "Let's start with the beta rollout, since the {date1} milestone is the one leadership keeps asking about.",
+ "We have {n1} customers in the beta cohort today and the plan was {n2} by {date1}.",
+ "Support is seeing about {n3} tickets a day from the cohort, and most of them are about the export flow.",
+ "I would rather slip the cohort target by a week than widen the beta while the export flow is in that state.",
+ "Agreed, so the export fix comes first and we revisit the cohort number on {date2}.",
+ "The export bug is the one where a workspace with more than {n4} notes times out halfway through the archive.",
+ "I have a fix on a branch that streams the archive instead of building it in memory, and it needs a review.",
+ "I can review it tomorrow morning, and I want a test that covers a workspace with {n5} notes before it merges.",
+ "On pricing, finance signed off on {n6} dollars a seat for the team tier, with the annual discount at {pct1} percent.",
+ "That is higher than the {n7} dollars we floated in the survey, so the launch copy needs to explain what the tier adds.",
+ "The team tier adds shared spaces, the admin roster and the audit log, which is what the {n8} enterprise trials asked for.",
+ "Then the copy should lead with shared spaces, because that is the feature every trial mentioned first.",
+ "Marketing wants the pricing page live {n9} days before launch so the announcement can link to it.",
+ "That means the page has to be final by {date3}, which is tight but doable if legal returns the terms this week.",
+ "Legal said {date4} for the terms, and I will chase them if nothing arrives by then.",
+ "Let's talk about the Windows microphone issue, because it is still the top complaint in the community forum.",
+ "The fix that pins the default device is in the release candidate and {n10} of the {n11} reporters confirmed it works.",
+ "The remaining reporters are on machines with a virtual audio cable, which we do not detect as a real device.",
+ "I think we ship the fix as is and document the virtual cable case, rather than hold the release for it.",
+ "Fine with me, as long as the release notes say it plainly instead of burying it in a known issues list.",
+ "Next is the meeting transcription accuracy work; the diarization change moved the error rate from {pct2} to {pct3} percent.",
+ "That is a solid improvement, but it costs about {n12} percent more processing time on the local path.",
+ "On a laptop that means a {n13}-minute meeting takes roughly {n14} seconds longer to finish, which nobody will notice.",
+ "The cloud path is unchanged, so the only people affected are those who chose local processing on purpose.",
+ "Then we keep it, and I will add the accuracy numbers to the changelog so the trade-off is visible.",
+ "We should also decide what to do about the onboarding drop-off between the permissions step and the first dictation.",
+ "The funnel shows {pct4} percent of new users leave at the accessibility permission, mostly on macOS.",
+ "Most of them never granted it because the system dialog opens behind our window on the newer OS versions.",
+ "I have a change that brings the settings pane to the front and polls for the grant, and it needs a designer's eye on the copy.",
+ "I can look at the copy this afternoon, and let's ship it in the same release since it is a two-line change.",
+ "Let's go through the hiring update, because the backend role has been open for {n15} weeks now.",
+ "We have {n16} candidates in the final round, and two of them are strong on the audio pipeline work we need.",
+ "I would like to make an offer by {date5}, and I need the compensation band confirmed before I do.",
+ "The band was approved at the last planning meeting, so you can move ahead as soon as the references come back.",
+ "On support load, response times went from {n17} hours to {n18} hours after the macro cleanup, which is the best we have had.",
+ "The macros still point to the old settings layout in {n19} places, and I will fix those before the release goes out.",
+ "One more thing on the release itself: the auto-updater staged rollout should start at {pct5} percent this time.",
+ "Last release we went straight to everyone and the Linux crash reached {n20} users before we could pause it.",
+ "So {pct5} percent for the first day, then {pct6} percent if the crash rate stays flat, then everyone.",
+ "I will set that up in the release pipeline and add the crash-rate check to the go/no-go checklist.",
+ "Before we close, the customer advisory call is on {date6} and I want three customers from the beta on it.",
+ "I can invite the two design agencies and the law firm, since they gave the most detailed feedback so far.",
+ "Good, send the invites today so they have two weeks' notice, and add the questions doc to the calendar entry.",
+ "To recap, export fix first, pricing page by {date3}, Windows fix ships with a documented caveat, and staged rollout at {pct5} percent.",
+ "I will write this up and send it to the channel within the hour so nobody has to rely on memory.",
+];
+
+function seededRandom(seed) {
+ let state = seed >>> 0;
+ return () => {
+ state = (state + 0x6d2b79f5) >>> 0;
+ let t = state;
+ t = Math.imul(t ^ (t >>> 15), t | 1);
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
+ };
+}
+
+const MONTHS = ["March", "April", "May", "June", "July", "September", "October"];
+
+function fillPlaceholders(template, random) {
+ return template.replace(/\{(n|pct|date)(\d+)\}/g, (_match, kind) => {
+ if (kind === "date") {
+ const month = MONTHS[Math.floor(random() * MONTHS.length)];
+ return `${month} ${1 + Math.floor(random() * 28)}`;
+ }
+ if (kind === "pct") return String(5 + Math.floor(random() * 60));
+ return String(2 + Math.floor(random() * 400));
+ });
+}
+
+export function countWords(text) {
+ return text.split(/\s+/).filter((word) => /[\p{L}\p{N}]/u.test(word)).length;
+}
+
+/**
+ * A deterministic meeting transcript in the note editor's layout, at least
+ * NOTE_PROBE_MIN_WORDS long. Word count grows by cycling the agenda with fresh
+ * numbers, which keeps the input meeting-shaped rather than a wall of the same
+ * line.
+ */
+export function buildNoteProbeTranscript({ minWords = NOTE_PROBE_MIN_WORDS, seed = 1101 } = {}) {
+ const random = seededRandom(seed);
+ const header = [
+ "## Meeting Context",
+ "Note owner: You",
+ "Participants: Priya, Marcus",
+ "",
+ "## Meeting Transcript",
+ ].join("\n");
+ const lines = [];
+ let words = countWords(header);
+ let index = 0;
+ while (words < minWords) {
+ const template = SENTENCES[index % SENTENCES.length];
+ const speaker = SPEAKERS[index % SPEAKERS.length];
+ const line = `${speaker}: ${fillPlaceholders(template, random)}`;
+ lines.push(line);
+ words += countWords(line);
+ index += 1;
+ }
+ return `${header}\n${lines.join("\n")}\n`;
+}
+
+/** Exactly what actionProcessingStore sends for the built-in Detailed Notes action on a meeting note. */
+export function buildNoteProbeSystemPrompt() {
+ const action = BUILTIN_ACTIONS.find((entry) => entry.translationKey === DETAILED_NOTES_KEY);
+ if (!action) throw new Error("Detailed Notes is no longer a built-in action");
+ return MEETING_INPUT_PREAMBLE + action.prompt;
+}
diff --git a/scripts/llm-canary.mjs b/scripts/llm-canary.mjs
index 283d26e33..d3bd14245 100644
--- a/scripts/llm-canary.mjs
+++ b/scripts/llm-canary.mjs
@@ -8,6 +8,13 @@
* pinned id or a new member of a constrained family is exactly the drift that
* caused Tinfoil+gpt-oss to break unnoticed.
*
+ * Also runs one meeting-sized Generate AI Summary request per keyed provider
+ * through the app's real provider code and the note-formatting deadline. A
+ * 1-token probe cannot see a reasoning model that thinks for longer than the
+ * app is willing to wait (1.10.1: every BYOK summary timed out at 30s), so
+ * this measures the request users actually make and reports how close it runs
+ * to the deadline.
+ *
* Run: node --import tsx scripts/llm-canary.mjs
* Keys come from LLM_CANARY_<PROVIDER>_KEY env vars; providers without a key
* are skipped and listed. Exit 1 when any probe on a keyed provider fails, or
@@ -15,7 +22,17 @@
* not report green.
*/
import { applyChatCompletionsParams } from "../src/services/ai/chatRequestBody.ts";
+import { openaiProvider } from "../src/services/ai/inferenceProviders/openai.ts";
+import { geminiProvider } from "../src/services/ai/inferenceProviders/gemini.ts";
+import { getLlmRequestTimeoutSeconds } from "../src/helpers/llmRequestTimeout.js";
+import { NOTE_OUTPUT_MAX_TOKENS } from "../src/helpers/builtinActions.js";
+import logger from "../src/utils/logger.ts";
import registryData from "../src/models/modelRegistryData.json" with { type: "json" };
+import {
+ buildNoteProbeSystemPrompt,
+ buildNoteProbeTranscript,
+ countWords,
+} from "./lib/note-formatting-probe.mjs";
const CONSTRAINED_FAMILY = /gpt-oss|qwen|magistral/i;
@@ -126,6 +143,91 @@ async function probe(entry, model, apiKey) {
return { ok: true };
}
+// One reasoning-capable model per keyed provider whose note request the
+// renderer sends itself under the app's client deadline. Registry ids only,
+// for the same reason as PROVIDERS.
+const NOTE_PROBES = [
+ {
+ id: "openai",
+ keyEnv: "LLM_CANARY_OPENAI_KEY",
+ // The model in the 1.10.1 report; the provider raises its output cap to
+ // 25k tokens for reasoning models, which is what lets it think past 30s.
+ model: "gpt-5.6-terra",
+ provider: openaiProvider,
+ config: { provider: "openai" },
+ },
+ {
+ id: "gemini",
+ keyEnv: "LLM_CANARY_GEMINI_KEY",
+ model: "gemini-3.5-flash",
+ provider: geminiProvider,
+ config: {},
+ },
+];
+
+const NOTE_DEADLINE_SECONDS = getLlmRequestTimeoutSeconds({ scope: "noteFormatting" });
+// Elapsed time past this fraction of the deadline is reported as slow so the
+// budget is questioned before a provider change crosses it.
+const NOTE_SLOW_FRACTION = 0.5;
+
+async function probeNoteFormatting(entry, apiKey) {
+ const transcript = buildNoteProbeTranscript();
+ const config = {
+ ...entry.config,
+ inferenceScope: "noteFormatting",
+ systemPrompt: buildNoteProbeSystemPrompt(),
+ maxTokens: NOTE_OUTPUT_MAX_TOKENS,
+ temperature: 0.3,
+ };
+ const ctx = {
+ getApiKey: async () => apiKey,
+ getSystemPrompt: () => "",
+ getCustomDictionary: () => [],
+ getPreferredLanguage: () => "en",
+ getUiLanguage: () => "en",
+ callChatCompletionsApi: async () => {
+ throw new Error("note probe does not delegate to chat completions");
+ },
+ calculateMaxTokens: () => NOTE_OUTPUT_MAX_TOKENS,
+ };
+
+ // The providers only log token usage; lift it out of the debug log for the report.
+ let tokens = null;
+ const originalLogReasoning = logger.logReasoning;
+ logger.logReasoning = (stage, details) => {
+ if (typeof details?.tokensUsed === "number") tokens = details.tokensUsed;
+ if (typeof details?.usageMetadata?.totalTokenCount === "number") {
+ tokens = details.usageMetadata.totalTokenCount;
+ }
+ return originalLogReasoning(stage, details);
+ };
+
+ const startedAt = Date.now();
+ try {
+ const text = await entry.provider.call({
+ text: transcript,
+ model: entry.model,
+ agentName: null,
+ config,
+ ctx,
+ });
+ const seconds = Math.round((Date.now() - startedAt) / 1000);
+ const slow = seconds > NOTE_DEADLINE_SECONDS * NOTE_SLOW_FRACTION;
+ return {
+ ok: true,
+ seconds,
+ tokens,
+ words: countWords(text),
+ detail: slow ? `⚠️ slow: ${seconds}s of the ${NOTE_DEADLINE_SECONDS}s note deadline` : "✅",
+ };
+ } catch (err) {
+ const seconds = Math.round((Date.now() - startedAt) / 1000);
+ return { ok: false, seconds, tokens, words: 0, detail: `❌ ${err.message}` };
+ } finally {
+ logger.logReasoning = originalLogReasoning;
+ }
+}
+
async function catalogDiff(entry, apiKey) {
const res = await fetch(`${entry.base}/models`, {
headers: { Authorization: `Bearer ${apiKey}` },
@@ -188,6 +290,21 @@ for (const entry of PROVIDERS) {
}
}
+const noteReport = [];
+const noteSkipped = [];
+for (const entry of NOTE_PROBES) {
+ const apiKey = process.env[entry.keyEnv];
+ if (!apiKey) {
+ noteSkipped.push(entry.id);
+ continue;
+ }
+ const result = await probeNoteFormatting(entry, apiKey);
+ noteReport.push(
+ `| ${entry.id} | ${entry.model} | ${result.seconds}s | ${result.tokens ?? "?"} | ${result.words} | ${result.detail} |`
+ );
+ if (!result.ok) failures.push(`note formatting ${entry.id}/${entry.model}: ${result.detail}`);
+}
+
if (skipped.length === PROVIDERS.length) {
failures.push("no canary secrets configured — every provider was skipped, nothing was probed");
}
@@ -196,6 +313,15 @@ console.log("## LLM request-shape canary\n");
console.log("| provider | model | result |\n|---|---|---|");
for (const line of report) console.log(line);
if (skipped.length) console.log(`\nSkipped (no key configured): ${skipped.join(", ")}`);
+
+console.log(
+ `\n## Note formatting latency (${countWords(buildNoteProbeTranscript())}-word transcript, ${NOTE_DEADLINE_SECONDS}s deadline)\n`
+);
+console.log(
+ "| provider | model | elapsed | tokens | output words | result |\n|---|---|---|---|---|---|"
+);
+for (const line of noteReport) console.log(line);
+if (noteSkipped.length) console.log(`\nSkipped (no key configured): ${noteSkipped.join(", ")}`);
if (failures.length) {
console.log(`\n### ${failures.length} failure(s)\n`);
for (const f of failures) console.log(`- ${f}`);
diff --git a/src/helpers/builtinActions.js b/src/helpers/builtinActions.js
index d865df1b4..377133752 100644
--- a/src/helpers/builtinActions.js
+++ b/src/helpers/builtinActions.js
@@ -149,6 +149,64 @@ Open questions
Omit any section that has no supported content. Return only the email.`;
+// System-prompt wrappers the note action store puts around a built-in or
+// custom action prompt. They live here, with the action prompts, so the live
+// canary can send the exact request the app sends.
+export const BASE_SYSTEM_PROMPT = `You are a note enhancement assistant. The user will provide raw notes — possibly voice-transcribed, rough, or unstructured. Your job is to clean them up according to the instructions below while preserving all original meaning and information. Output clean markdown.
+
+FORMAT RULES (strict):
+- Do NOT include any preamble: no title, no date/time/location, no attendee list, no topic header. Start directly with the content.
+- Do NOT use tables, horizontal rules, or block quotes.
+- Do NOT list or guess participant names/roles.
+- Keep the tone professional and concise. Bias toward brevity.
+
+Instructions: `;
+
+export const MEETING_SYSTEM_PROMPT = `You are a professional meeting notes assistant. You will receive a meeting transcript where each line is prefixed with the speaker's label — a real name when known, otherwise "You" (the note owner), "Them", or "Speaker N". A "## Meeting Context" block may identify the note owner and the invited participants. Manual notes the user took may be included as well.
+
+Your job is to produce clean, actionable meeting notes in markdown. Follow these rules:
+
+FORMAT RULES (strict):
+- Do NOT include any preamble: no title, no "# Meeting Notes", no date/time/location, no attendee list, no topic header. Start directly with the summary.
+- Do NOT reproduce the Meeting Context block in the output.
+- Do NOT use tables, horizontal rules, or block quotes.
+- Refer to people only by the speaker labels used in the transcript. NEVER guess or invent an identity: the note owner is who the Meeting Context says they are — never a name mentioned in conversation. Keep unnamed speakers as "Them" or "Speaker N".
+- Start with a concise 1–2 sentence summary of what the meeting was about.
+- Use clear section headings: ## Key Discussion Points, ## Decisions Made, ## Action Items, ## Follow-ups (omit any section that has no content).
+- Under Action Items, use checkboxes in the format \`- [ ] Action — Owner\`, attributing each item to its owner by speaker label where clear.
+
+CONTENT RULES:
+- Preserve important quotes or specific commitments verbatim when they carry meaning.
+- Remove filler, small talk, false starts, and repeated/redundant content.
+- Where speakers refer to the same topic across multiple turns, consolidate into a coherent point rather than listing every utterance.
+- If the user included manual notes alongside the transcript, integrate them — they represent the user's emphasis on what matters most.
+- Keep the tone professional and concise. Bias toward brevity.
+
+Instructions: `;
+
+// Standalone built-in prompts are complete instructions, so they only get told
+// how the material is laid out instead of being wrapped in the generic prompts.
+export const MEETING_INPUT_PREAMBLE = `The material is laid out as follows. Transcript lines are prefixed with the speaker's label: a real name when known, otherwise "You" (the note owner), "Them", or "Speaker N". A "## Meeting Context" block may identify the note owner and the invited participants; it is reference material, never something to reproduce. Manual notes the user took may precede the transcript.
+
+`;
+export const NOTE_INPUT_PREAMBLE = `The material is the user's own notes, possibly voice-transcribed, rough, or unstructured. There is no transcript.
+
+`;
+
+/**
+ * Output budget for a formatted note.
+ *
+ * Without an explicit value this inherited the generic 2048-token default from
+ * calculateMaxTokens — roughly 1,500 words — so summaries of long meetings were
+ * cut off and saved anyway, with nothing to say they were incomplete (#2142).
+ *
+ * Deliberately not paired with requireCompleteOutput: unlike a selection edit,
+ * where a partial replacement corrupts the user's own text, a clipped summary
+ * is still worth keeping. The context preflight counts this reservation, so
+ * asking for more output room can grow the window rather than squeeze it.
+ */
+export const NOTE_OUTPUT_MAX_TOKENS = 4096;
+
export const BUILTIN_ACTIONS = [
{
translationKey: GENERATE_NOTES_KEY,
diff --git a/src/helpers/llmRequestTimeout.js b/src/helpers/llmRequestTimeout.js
index 382a58a52..1c26cda62 100644
--- a/src/helpers/llmRequestTimeout.js
+++ b/src/helpers/llmRequestTimeout.js
@@ -1,6 +1,25 @@
const LLM_REQUEST_TIMEOUT_SECONDS = 30;
const LLM_STREAMING_TIMEOUT_SECONDS = 60;
+// Note formatting sends a whole transcript through a model that may reason at
+// length before writing: a 2,000-word meeting through GPT-5.6 Terra runs well
+// past 30 seconds. OpenAI's own SDK defaults to a 10-minute request timeout.
+const LLM_LONG_TASK_TIMEOUT_SECONDS = 600;
-export function getLlmRequestTimeoutSeconds({ streaming = false } = {}) {
- return streaming ? LLM_STREAMING_TIMEOUT_SECONDS : LLM_REQUEST_TIMEOUT_SECONDS;
+export const LLM_REQUEST_TIMEOUT_CODE = "LLM_REQUEST_TIMEOUT";
+
+/**
+ * Client-side deadline for one LLM request.
+ * @param {{ streaming?: boolean, scope?: string }} [options] `scope` is the
+ * request's inference scope; note formatting gets the long deadline.
+ */
+export function getLlmRequestTimeoutSeconds({ streaming = false, scope } = {}) {
+ if (streaming) return LLM_STREAMING_TIMEOUT_SECONDS;
+ return scope === "noteFormatting" ? LLM_LONG_TASK_TIMEOUT_SECONDS : LLM_REQUEST_TIMEOUT_SECONDS;
+}
+
+/** The coded error a request raises when its client-side deadline expires; createApiRetryStrategy never retries it. */
+export function llmRequestTimeoutError(timeoutSeconds) {
+ return Object.assign(new Error(`Request timed out after ${timeoutSeconds}s`), {
+ code: LLM_REQUEST_TIMEOUT_CODE,
+ });
}
diff --git a/src/services/ReasoningService.ts b/src/services/ReasoningService.ts
index 96362e592..5746733f1 100644
--- a/src/services/ReasoningService.ts
+++ b/src/services/ReasoningService.ts
@@ -14,7 +14,10 @@ import logger from "../utils/logger";
import { getSettings, isCloudCleanupMode } from "../stores/settingsStore";
import { wrapCleanupTranscript } from "../config/prompts";
import { stripThinkingTags } from "../helpers/stripThinking.js";
-import { getLlmRequestTimeoutSeconds } from "../helpers/llmRequestTimeout.js";
+import {
+ getLlmRequestTimeoutSeconds,
+ llmRequestTimeoutError,
+} from "../helpers/llmRequestTimeout.js";
import { streamText, stepCountIs } from "ai";
import { getAIModel } from "./ai/providers";
import { createEnterpriseChatModel } from "./ai/enterpriseChatModel";
@@ -332,7 +335,7 @@ class ReasoningService extends BaseReasoningService {
}
const controller = new AbortController();
this.activeRequestControllers.add(controller);
- const timeoutSeconds = getLlmRequestTimeoutSeconds();
+ const timeoutSeconds = getLlmRequestTimeoutSeconds({ scope: config.inferenceScope });
const timeoutId = setTimeout(() => controller.abort(), timeoutSeconds * 1000);
try {
const headers: Record<string, string> = {
@@ -396,7 +399,7 @@ class ReasoningService extends BaseReasoningService {
if (requestGeneration !== this.requestCancellationGeneration) {
throw httpError("Request cancelled", 499);
}
- throw new Error(`Request timed out after ${timeoutSeconds}s`);
+ throw llmRequestTimeoutError(timeoutSeconds);
}
throw error;
} finally {
diff --git a/src/services/ai/inferenceProviders/enterprise.ts b/src/services/ai/inferenceProviders/enterprise.ts
index 340340aa2..25bd0a4cb 100644
--- a/src/services/ai/inferenceProviders/enterprise.ts
+++ b/src/services/ai/inferenceProviders/enterprise.ts
@@ -7,6 +7,7 @@ import {
import { getSettings } from "../../../stores/settingsStore";
import { getEnterpriseCallSettings } from "../enterpriseSettings";
import { wrapCleanupTranscript } from "../../../config/prompts";
+import { getLlmRequestTimeoutSeconds } from "../../../helpers/llmRequestTimeout.js";
import logger from "../../../utils/logger";
export const enterpriseProvider: InferenceProvider = {
@@ -38,6 +39,7 @@ export const enterpriseProvider: InferenceProvider = {
systemPrompt,
provider: enterpriseId,
supportsTemperature,
+ timeoutMs: getLlmRequestTimeoutSeconds({ scope: config.inferenceScope }) * 1000,
...getEnterpriseCallSettings(enterpriseId, config.inferenceScope || "dictationCleanup"),
}
);
diff --git a/src/services/ai/inferenceProviders/gemini.ts b/src/services/ai/inferenceProviders/gemini.ts
index 9db5c3d70..3648741ed 100644
--- a/src/services/ai/inferenceProviders/gemini.ts
+++ b/src/services/ai/inferenceProviders/gemini.ts
@@ -1,7 +1,10 @@
import type { InferenceProvider } from "./types";
import { withRetry, createApiRetryStrategy, httpError } from "../../../utils/retry";
import { API_ENDPOINTS } from "../../../config/constants";
-import { getLlmRequestTimeoutSeconds } from "../../../helpers/llmRequestTimeout.js";
+import {
+ getLlmRequestTimeoutSeconds,
+ llmRequestTimeoutError,
+} from "../../../helpers/llmRequestTimeout.js";
import { extractGeminiText } from "../../../helpers/geminiResponse.js";
import { wrapCleanupTranscript } from "../../../config/prompts";
import { extractApiErrorMessage } from "../apiErrorMessage";
@@ -100,7 +103,7 @@ export const geminiProvider: InferenceProvider = {
});
const controller = new AbortController();
- const timeoutSeconds = getLlmRequestTimeoutSeconds();
+ const timeoutSeconds = getLlmRequestTimeoutSeconds({ scope: config.inferenceScope });
const timeoutId = setTimeout(() => controller.abort(), timeoutSeconds * 1000);
try {
const res = await fetch(`${API_ENDPOINTS.GEMINI}/models/${model}:generateContent`, {
@@ -143,7 +146,7 @@ export const geminiProvider: InferenceProvider = {
return jsonResponse;
} catch (error) {
if ((error as Error).name === "AbortError") {
- throw new Error(`Request timed out after ${timeoutSeconds}s`);
+ throw llmRequestTimeoutError(timeoutSeconds);
}
throw error;
} finally {
diff --git a/src/services/ai/inferenceProviders/openai.ts b/src/services/ai/inferenceProviders/openai.ts
index 618082c28..d00b407b0 100644
--- a/src/services/ai/inferenceProviders/openai.ts
+++ b/src/services/ai/inferenceProviders/openai.ts
@@ -13,7 +13,10 @@ import {
truncatedOutputError,
} from "../chatRequestBody";
import { detectEndpointDialect } from "../thinkingSuppressionDialects";
-import { getLlmRequestTimeoutSeconds } from "../../../helpers/llmRequestTimeout.js";
+import {
+ getLlmRequestTimeoutSeconds,
+ llmRequestTimeoutError,
+} from "../../../helpers/llmRequestTimeout.js";
import { extractApiErrorMessage } from "../apiErrorMessage";
import { wrapCleanupTranscript } from "../../../config/prompts";
import { openCodeSessionHeaders } from "../openCodeSession";
@@ -227,7 +230,7 @@ export const openaiProvider: InferenceProvider = {
for (const { url: endpoint, type } of endpointCandidates) {
const controller = new AbortController();
- const timeoutSeconds = getLlmRequestTimeoutSeconds();
+ const timeoutSeconds = getLlmRequestTimeoutSeconds({ scope: config.inferenceScope });
const timeoutId = setTimeout(() => controller.abort(), timeoutSeconds * 1000);
try {
const requestedMaxTokens =
@@ -313,7 +316,7 @@ export const openaiProvider: InferenceProvider = {
return res.json();
} catch (error) {
if ((error as Error).name === "AbortError") {
- throw new Error(`Request timed out after ${timeoutSeconds}s`);
+ throw llmRequestTimeoutError(timeoutSeconds);
}
lastError = error as Error;
if (retryStrategy.shouldRetry(lastError)) {
diff --git a/src/services/ai/inferenceProviders/tinfoil.ts b/src/services/ai/inferenceProviders/tinfoil.ts
index e8d096aaf..8c82589fa 100644
--- a/src/services/ai/inferenceProviders/tinfoil.ts
+++ b/src/services/ai/inferenceProviders/tinfoil.ts
@@ -9,7 +9,10 @@ import {
truncatedOutputError,
} from "../chatRequestBody";
import { getTinfoilChatClient } from "../tinfoilClient";
-import { getLlmRequestTimeoutSeconds } from "../../../helpers/llmRequestTimeout.js";
+import {
+ getLlmRequestTimeoutSeconds,
+ llmRequestTimeoutError,
+} from "../../../helpers/llmRequestTimeout.js";
import { wrapCleanupTranscript } from "../../../config/prompts";
export const tinfoilProvider: InferenceProvider = {
@@ -45,15 +48,22 @@ export const tinfoilProvider: InferenceProvider = {
applyChatCompletionsParams(requestBody, { model, provider: "tinfoil", config, maxTokens });
// Keep SDK-internal retries off so withRetry stays the single retry layer.
- const timeoutMs = getLlmRequestTimeoutSeconds() * 1000;
- const response = await withRetry(
- () =>
- client.chat.completions.create(requestBody as any, {
- timeout: timeoutMs,
+ const timeoutSeconds = getLlmRequestTimeoutSeconds({ scope: config.inferenceScope });
+ const response = await withRetry(async () => {
+ try {
+ return await client.chat.completions.create(requestBody as any, {
+ timeout: timeoutSeconds * 1000,
maxRetries: 0,
- }),
- createApiRetryStrategy()
- );
+ });
+ } catch (error) {
+ // The SDK reports an expired deadline as a connection error, which
+ // withRetry would otherwise treat as a network drop and re-send.
+ if ((error as Error).name === "APIConnectionTimeoutError") {
+ throw llmRequestTimeoutError(timeoutSeconds);
+ }
+ throw error;
+ }
+ }, createApiRetryStrategy());
const responseText =
response.choices
diff --git a/src/stores/actionProcessingStore.ts b/src/stores/actionProcessingStore.ts
index ff0d639ba..5db8ada86 100644
--- a/src/stores/actionProcessingStore.ts
+++ b/src/stores/actionProcessingStore.ts
@@ -1,5 +1,12 @@
import { create } from "zustand";
-import { STANDALONE_PROMPT_KEYS } from "../helpers/builtinActions";
+import {
+ BASE_SYSTEM_PROMPT,
+ MEETING_INPUT_PREAMBLE,
+ MEETING_SYSTEM_PROMPT,
+ NOTE_INPUT_PREAMBLE,
+ NOTE_OUTPUT_MAX_TOKENS,
+ STANDALONE_PROMPT_KEYS,
+} from "../helpers/builtinActions";
import reasoningService from "../services/ReasoningService";
import { getSettings, selectResolvedNoteFormatting } from "./settingsStore";
import { appendDictionarySuffix } from "../config/prompts";
@@ -8,20 +15,6 @@ import { buildNoteFormattingOverrides } from "../helpers/noteFormattingOverrides
import { tagActionItemOwners, type MentionPerson } from "../utils/mentionMarkdown";
import type { ActionItem } from "../types/electron";
-/**
- * Output budget for a formatted note.
- *
- * Without an explicit value this inherited the generic 2048-token default from
- * calculateMaxTokens — roughly 1,500 words — so summaries of long meetings were
- * cut off and saved anyway, with nothing to say they were incomplete (#2142).
- *
- * Deliberately not paired with requireCompleteOutput: unlike a selection edit,
- * where a partial replacement corrupts the user's own text, a clipped summary
- * is still worth keeping. The context preflight counts this reservation, so
- * asking for more output room can grow the window rather than squeeze it.
- */
-export const NOTE_OUTPUT_MAX_TOKENS = 4096;
-
export type ActionProcessingStatus = "idle" | "processing" | "success";
export interface NoteActionState {
@@ -73,47 +66,6 @@ export const useActionProcessingStore = create<ActionProcessingStoreState>()(()
errorEvents: [],
}));
-const BASE_SYSTEM_PROMPT = `You are a note enhancement assistant. The user will provide raw notes — possibly voice-transcribed, rough, or unstructured. Your job is to clean them up according to the instructions below while preserving all original meaning and information. Output clean markdown.
-
-FORMAT RULES (strict):
-- Do NOT include any preamble: no title, no date/time/location, no attendee list, no topic header. Start directly with the content.
-- Do NOT use tables, horizontal rules, or block quotes.
-- Do NOT list or guess participant names/roles.
-- Keep the tone professional and concise. Bias toward brevity.
-
-Instructions: `;
-
-const MEETING_SYSTEM_PROMPT = `You are a professional meeting notes assistant. You will receive a meeting transcript where each line is prefixed with the speaker's label — a real name when known, otherwise "You" (the note owner), "Them", or "Speaker N". A "## Meeting Context" block may identify the note owner and the invited participants. Manual notes the user took may be included as well.
-
-Your job is to produce clean, actionable meeting notes in markdown. Follow these rules:
-
-FORMAT RULES (strict):
-- Do NOT include any preamble: no title, no "# Meeting Notes", no date/time/location, no attendee list, no topic header. Start directly with the summary.
-- Do NOT reproduce the Meeting Context block in the output.
-- Do NOT use tables, horizontal rules, or block quotes.
-- Refer to people only by the speaker labels used in the transcript. NEVER guess or invent an identity: the note owner is who the Meeting Context says they are — never a name mentioned in conversation. Keep unnamed speakers as "Them" or "Speaker N".
-- Start with a concise 1–2 sentence summary of what the meeting was about.
-- Use clear section headings: ## Key Discussion Points, ## Decisions Made, ## Action Items, ## Follow-ups (omit any section that has no content).
-- Under Action Items, use checkboxes in the format \`- [ ] Action — Owner\`, attributing each item to its owner by speaker label where clear.
-
-CONTENT RULES:
-- Preserve important quotes or specific commitments verbatim when they carry meaning.
-- Remove filler, small talk, false starts, and repeated/redundant content.
-- Where speakers refer to the same topic across multiple turns, consolidate into a coherent point rather than listing every utterance.
-- If the user included manual notes alongside the transcript, integrate them — they represent the user's emphasis on what matters most.
-- Keep the tone professional and concise. Bias toward brevity.
-
-Instructions: `;
-
-// Standalone built-in prompts are complete instructions, so they only get told
-// how the material is laid out instead of being wrapped in the generic prompts.
-const MEETING_INPUT_PREAMBLE = `The material is laid out as follows. Transcript lines are prefixed with the speaker's label: a real name when known, otherwise "You" (the note owner), "Them", or "Speaker N". A "## Meeting Context" block may identify the note owner and the invited participants; it is reference material, never something to reproduce. Manual notes the user took may precede the transcript.
-
-`;
-const NOTE_INPUT_PREAMBLE = `The material is the user's own notes, possibly voice-transcribed, rough, or unstructured. There is no transcript.
-
-`;
-
export interface RunActionOptions {
isCloudMode: boolean;
modelId: string;
diff --git a/src/utils/retry.ts b/src/utils/retry.ts
index 0e3459a9b..4bded5d37 100644
--- a/src/utils/retry.ts
+++ b/src/utils/retry.ts
@@ -1,4 +1,5 @@
import { RETRY_CONFIG } from "../config/constants.ts";
+import { LLM_REQUEST_TIMEOUT_CODE } from "../helpers/llmRequestTimeout.js";
export interface RetryOptions {
maxRetries?: number;
@@ -48,7 +49,11 @@ export function httpError(message: string, status: number): Error & { status: nu
export function createApiRetryStrategy() {
return {
shouldRetry: (error: any) => {
- // No HTTP status means the request never got an answer (network drop, timeout).
+ // A client-side deadline is not a transient fault: the same request under
+ // the same deadline expires again, and the provider bills every attempt.
+ if (error?.code === LLM_REQUEST_TIMEOUT_CODE) return false;
+
+ // No HTTP status means the request never got an answer (network drop).
const status = error?.status ?? error?.response?.status;
if (typeof status !== "number") return true;
diff --git a/test/helpers/apiRetryStrategy.test.js b/test/helpers/apiRetryStrategy.test.js
index 49483a9bf..e79302a44 100644
--- a/test/helpers/apiRetryStrategy.test.js
+++ b/test/helpers/apiRetryStrategy.test.js
@@ -11,7 +11,14 @@ test("errors without a status retry, since they mean the request never got an an
const { shouldRetry } = createApiRetryStrategy();
assert.equal(shouldRetry(new Error("fetch failed")), true);
- assert.equal(shouldRetry(new Error("Request timed out after 30s")), true);
+});
+
+test("a client-side deadline does not retry, since the same request expires again and every attempt is billed", async () => {
+ const { createApiRetryStrategy } = await load();
+ const { llmRequestTimeoutError } = await import("../../src/helpers/llmRequestTimeout.js");
+ const { shouldRetry } = createApiRetryStrategy();
+
+ assert.equal(shouldRetry(llmRequestTimeoutError(30)), false);
});
test("4xx rejections do not retry, because the same request will be refused again", async () => {
@@ -97,3 +104,20 @@ test("withRetry keeps retrying a 5xx up to maxRetries", async () => {
);
assert.equal(attempts, 3, "initial attempt plus two retries");
});
+
+test("withRetry makes exactly one attempt for a client-side deadline", async () => {
+ const { withRetry, createApiRetryStrategy } = await load();
+ const { llmRequestTimeoutError } = await import("../../src/helpers/llmRequestTimeout.js");
+
+ let attempts = 0;
+ const expire = async () => {
+ attempts += 1;
+ throw llmRequestTimeoutError(600);
+ };
+
+ await assert.rejects(
+ () => withRetry(expire, { ...createApiRetryStrategy(), initialDelay: 1 }),
+ /Request timed out after 600s/
+ );
+ assert.equal(attempts, 1, "each retry of an expired deadline is another billed request");
+});
diff --git a/test/helpers/llmRequestTimeout.test.js b/test/helpers/llmRequestTimeout.test.js
index 40d205f77..e825bfbc0 100644
--- a/test/helpers/llmRequestTimeout.test.js
+++ b/test/helpers/llmRequestTimeout.test.js
@@ -8,6 +8,7 @@ test("non-streaming LLM requests use the fixed 30-second timeout", async () => {
assert.equal(typeof getLlmRequestTimeoutSeconds, "function");
assert.equal(getLlmRequestTimeoutSeconds(), 30);
+ assert.equal(getLlmRequestTimeoutSeconds({ scope: "dictationCleanup" }), 30);
});
test("streaming LLM requests keep their fixed 60-second timeout", async () => {
@@ -15,4 +16,62 @@ test("streaming LLM requests keep their fixed 60-second timeout", async () => {
assert.equal(typeof getLlmRequestTimeoutSeconds, "function");
assert.equal(getLlmRequestTimeoutSeconds({ streaming: true }), 60);
+ // Streaming keeps its idle deadline whatever the scope: bytes are expected to flow.
+ assert.equal(getLlmRequestTimeoutSeconds({ streaming: true, scope: "noteFormatting" }), 60);
+});
+
+test("note formatting gets a long deadline, since a whole transcript can take minutes to reason over", async () => {
+ const { getLlmRequestTimeoutSeconds } = await load();
+
+ assert.equal(getLlmRequestTimeoutSeconds({ scope: "noteFormatting" }), 600);
+});
+
+test("a deadline error carries the timeout code and the seconds it waited", async () => {
+ const { llmRequestTimeoutError, LLM_REQUEST_TIMEOUT_CODE } = await load();
+
+ const error = llmRequestTimeoutError(30);
+ assert.ok(error instanceof Error);
+ assert.equal(error.message, "Request timed out after 30s");
+ assert.equal(error.code, LLM_REQUEST_TIMEOUT_CODE);
+});
+
+// Every scope has to say whether someone is sitting there waiting for the
+// answer. The 1.10.1 note timeout came from a background task silently
+// inheriting the deadline of the one interactive task the constant was written
+// for; a scope added here without a verdict fails the test.
+const DEADLINE_CLASS_BY_SCOPE = {
+ dictationCleanup: "interactive", // user is waiting to paste
+ dictationAgent: "interactive",
+ dictationAgentVision: "interactive",
+ dictationTranslation: "interactive",
+ chatIntelligence: "interactive", // typed chat; streaming carries its own idle deadline
+ noteFormatting: "background", // whole transcript, runs off-screen with a cancel button
+};
+const INTERACTIVE_MAX_SECONDS = 60;
+const BACKGROUND_MIN_SECONDS = 300;
+
+test("every inference scope is classified as interactive or background, and its deadline matches", async () => {
+ const { INFERENCE_SCOPES } = await import("../../src/config/inferenceScopes.ts");
+ const { getLlmRequestTimeoutSeconds } = await load();
+
+ assert.deepEqual(
+ Object.keys(INFERENCE_SCOPES).sort(),
+ Object.keys(DEADLINE_CLASS_BY_SCOPE).sort(),
+ "a new inference scope must be classified in DEADLINE_CLASS_BY_SCOPE: does a user wait on it?"
+ );
+
+ for (const [scope, kind] of Object.entries(DEADLINE_CLASS_BY_SCOPE)) {
+ const seconds = getLlmRequestTimeoutSeconds({ scope });
+ if (kind === "interactive") {
+ assert.ok(
+ seconds <= INTERACTIVE_MAX_SECONDS,
+ `${scope}: someone is waiting, so its deadline must be at most ${INTERACTIVE_MAX_SECONDS}s (got ${seconds}s)`
+ );
+ } else {
+ assert.ok(
+ seconds >= BACKGROUND_MIN_SECONDS,
+ `${scope}: a whole document goes through the model, so its deadline must be at least ${BACKGROUND_MIN_SECONDS}s (got ${seconds}s)`
+ );
+ }
+ }
});
diff --git a/test/helpers/noteFormattingProbe.test.js b/test/helpers/noteFormattingProbe.test.js
new file mode 100644
index 000000000..25bc99dc5
--- /dev/null
+++ b/test/helpers/noteFormattingProbe.test.js
@@ -0,0 +1,34 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+
+// The live canary's note probe is only worth its weekly tokens if it sends the
+// request the app sends: a meeting-sized transcript in the editor's layout and
+// the exact Detailed Notes system prompt.
+
+const load = () => import("../../scripts/lib/note-formatting-probe.mjs");
+
+test("the probe transcript is meeting-sized, deterministic and in the editor's layout", async () => {
+ const { buildNoteProbeTranscript, countWords, NOTE_PROBE_MIN_WORDS } = await load();
+
+ const transcript = buildNoteProbeTranscript();
+ assert.ok(
+ countWords(transcript) >= NOTE_PROBE_MIN_WORDS,
+ `expected at least ${NOTE_PROBE_MIN_WORDS} words, got ${countWords(transcript)}`
+ );
+ assert.equal(transcript, buildNoteProbeTranscript(), "the fixture must not change between runs");
+ assert.match(transcript, /^## Meeting Context\n/);
+ assert.match(transcript, /\n## Meeting Transcript\n/);
+ for (const speaker of ["You", "Priya", "Marcus"]) {
+ assert.match(transcript, new RegExp(`\\n${speaker}: `), `${speaker} should have lines`);
+ }
+ assert.doesNotMatch(transcript, /\{(n|pct|date)\d+\}/, "every placeholder must be filled");
+});
+
+test("the probe sends the Detailed Notes prompt exactly as the note store assembles it", async () => {
+ const { buildNoteProbeSystemPrompt } = await load();
+ const { BUILTIN_ACTIONS, DETAILED_NOTES_KEY, MEETING_INPUT_PREAMBLE } =
+ await import("../../src/helpers/builtinActions.js");
+ const detailed = BUILTIN_ACTIONS.find((action) => action.translationKey === DETAILED_NOTES_KEY);
+
+ assert.equal(buildNoteProbeSystemPrompt(), MEETING_INPUT_PREAMBLE + detailed.prompt);
+});
diff --git a/test/services/llmRequestDeadline.test.js b/test/services/llmRequestDeadline.test.js
new file mode 100644
index 000000000..b4b2c3147
--- /dev/null
+++ b/test/services/llmRequestDeadline.test.js
@@ -0,0 +1,284 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+const { createRendererServer, installBrowserGlobals } = require("../lib/rendererTestHarness");
+
+// Generate AI Summary sends a whole transcript to a model that may reason for a
+// minute or more before writing. Under the 30-second dictation deadline every
+// such request was aborted and, counted as a network fault, retried three more
+// times: four billed requests and no note (1.10.1).
+
+const NOTE_CONFIG = {
+ systemPrompt: "Summarize the meeting.",
+ inferenceScope: "noteFormatting",
+ maxTokens: 4096,
+ temperature: 0.3,
+};
+
+const CTX = {
+ getApiKey: async () => "test-key",
+ getSystemPrompt: () => "Clean the transcript",
+ getCustomDictionary: () => [],
+ getPreferredLanguage: () => "en",
+ getUiLanguage: () => "en",
+ callChatCompletionsApi: async () => {
+ throw new Error("Unexpected chat completions delegation");
+ },
+ calculateMaxTokens: () => 4096,
+};
+
+// A fetch whose POSTs never answer on their own but honor the abort signal,
+// the way a real request does while the model is still generating.
+function installHangingFetch(t) {
+ const originalFetch = globalThis.fetch;
+ t.after(() => {
+ globalThis.fetch = originalFetch;
+ });
+
+ const posts = [];
+ globalThis.fetch = (input, init = {}) => {
+ const method = init.method || "GET";
+ if (method === "GET") {
+ return Promise.resolve(
+ new Response(JSON.stringify({ error: { message: "not found" } }), {
+ status: 404,
+ headers: { "Content-Type": "application/json" },
+ })
+ );
+ }
+ posts.push(String(input));
+ return new Promise((_resolve, reject) => {
+ init.signal?.addEventListener("abort", () => {
+ reject(Object.assign(new Error("The operation was aborted"), { name: "AbortError" }));
+ });
+ });
+ };
+ return posts;
+}
+
+const settle = () => new Promise((resolve) => setImmediate(resolve));
+
+async function runDeadlineScenario(t, startRequest) {
+ t.mock.timers.enable({ apis: ["setTimeout"] });
+ const posts = installHangingFetch(t);
+
+ let outcome = null;
+ const request = startRequest().then(
+ (value) => {
+ outcome = { value };
+ },
+ (error) => {
+ outcome = { error };
+ }
+ );
+ await settle();
+ assert.equal(posts.length, 1, "the request should be in flight");
+
+ // The dictation deadline must not fire on a note.
+ t.mock.timers.tick(30_000);
+ await settle();
+ assert.equal(outcome, null, "a note request must survive the 30-second dictation deadline");
+
+ t.mock.timers.tick(600_000);
+ await settle();
+ // A retry would be waiting on its backoff timer here; drain it so the second
+ // POST shows up in `posts` instead of leaving `request` pending.
+ t.mock.timers.tick(10_000);
+ await settle();
+
+ assert.equal(posts.length, 1, "a timed-out request must not be retried");
+ assert.ok(outcome?.error, "the request should end in an error once the long deadline expires");
+ assert.match(outcome.error.message, /Request timed out after 600s/);
+ await request;
+}
+
+test("OpenAI note formatting waits ten minutes and does not retry a timed-out request", async (t) => {
+ const { openaiProvider } = await import("../../src/services/ai/inferenceProviders/openai.ts");
+ await runDeadlineScenario(t, () =>
+ openaiProvider.call({
+ text: "Alice: we agreed to ship on Friday.\n".repeat(200),
+ model: "gpt-5.6-terra",
+ agentName: null,
+ config: { provider: "openai", ...NOTE_CONFIG },
+ ctx: CTX,
+ })
+ );
+});
+
+test("Gemini note formatting waits ten minutes and does not retry a timed-out request", async (t) => {
+ const { geminiProvider } = await import("../../src/services/ai/inferenceProviders/gemini.ts");
+ await runDeadlineScenario(t, () =>
+ geminiProvider.call({
+ text: "Alice: we agreed to ship on Friday.\n".repeat(200),
+ model: "gemini-3.5-flash",
+ agentName: null,
+ config: NOTE_CONFIG,
+ ctx: CTX,
+ })
+ );
+});
+
+test("dictation cleanup keeps its 30-second deadline", async (t) => {
+ const { openaiProvider } = await import("../../src/services/ai/inferenceProviders/openai.ts");
+ t.mock.timers.enable({ apis: ["setTimeout"] });
+ const posts = installHangingFetch(t);
+
+ let outcome = null;
+ const request = openaiProvider
+ .call({
+ text: "clean this up",
+ model: "gpt-4.1-mini",
+ agentName: null,
+ config: { provider: "openai" },
+ ctx: CTX,
+ })
+ .then(
+ (value) => {
+ outcome = { value };
+ },
+ (error) => {
+ outcome = { error };
+ }
+ );
+ await settle();
+ assert.equal(posts.length, 1);
+
+ t.mock.timers.tick(30_000);
+ await settle();
+ await request;
+
+ assert.match(outcome?.error?.message ?? "", /Request timed out after 30s/);
+});
+
+// The provider tests above prove each client honours the scope. This one
+// proves the scope arrives: the note store's overrides go through the real
+// ReasoningService dispatch (managed-scope resolution, provider selection,
+// retry) to the OpenAI client, and the request still outlives the dictation
+// deadline and is sent once.
+test("a note request through the real ReasoningService survives the dictation deadline and is sent once", async (t) => {
+ installBrowserGlobals(t, {
+ window: { electronAPI: { getOpenAIKey: async () => "test-key" } },
+ });
+ const vite = await createRendererServer(t, { cachePrefix: "openwhispr-note-deadline-test-" });
+ const reasoningService = (await vite.ssrLoadModule("/services/ReasoningService.ts")).default;
+ const { usePolicyStore } = await vite.ssrLoadModule("/stores/policyStore.ts");
+ usePolicyStore.setState({ status: "unmanaged", appVersion: "1.10.1", policy: null });
+ const { buildNoteFormattingOverrides } = await vite.ssrLoadModule(
+ "/helpers/noteFormattingOverrides.js"
+ );
+ t.after(() => reasoningService.destroy());
+
+ try {
+ await runDeadlineScenario(t, () =>
+ reasoningService.processText(
+ "## Meeting Transcript\n" + "Alice: we agreed to ship on Friday.\n".repeat(200),
+ "gpt-5.6-terra",
+ null,
+ {
+ systemPrompt: "Summarize the meeting.",
+ maxTokens: 4096,
+ temperature: 0.3,
+ ...buildNoteFormattingOverrides({ mode: "providers", provider: "openai" }, false),
+ }
+ )
+ );
+ } finally {
+ // Hand real timers back before the harness tears the Vite server down.
+ t.mock.timers.reset();
+ }
+});
+
+// Enterprise requests run in the main process, whose handler applies its own
+// 60-second default unless the renderer sends the deadline along.
+test("enterprise note formatting sends the long deadline to the main process", async (t) => {
+ const ipcConfigs = [];
+ installBrowserGlobals(t, {
+ window: {
+ electronAPI: {
+ processEnterpriseReasoning: async (_text, _model, _agentName, config) => {
+ ipcConfigs.push(config);
+ return { success: true, text: "# Notes" };
+ },
+ },
+ },
+ });
+ const vite = await createRendererServer(t, {
+ cachePrefix: "openwhispr-enterprise-deadline-test-",
+ mockModules: {
+ "/models/ModelRegistry": `
+ export const getOpenAiApiConfig = () => ({ supportsTemperature: true });
+ export const isEnterpriseProvider = (provider) => provider === "bedrock";
+ `,
+ "/stores/settingsStore": "export const getSettings = () => ({ cleanupProvider: 'bedrock' });",
+ "/services/ai/enterpriseSettings": "export const getEnterpriseCallSettings = () => ({});",
+ "/utils/logger": "export default { logReasoning() {} };",
+ },
+ });
+ const { enterpriseProvider } = await vite.ssrLoadModule(
+ "/services/ai/inferenceProviders/enterprise.ts"
+ );
+ const call = (config) =>
+ enterpriseProvider.call({
+ text: "Alice: we agreed to ship on Friday.",
+ model: "anthropic.claude-sonnet",
+ agentName: null,
+ config: { provider: "bedrock", ...config },
+ ctx: CTX,
+ });
+
+ await call(NOTE_CONFIG);
+ await call({});
+
+ assert.equal(ipcConfigs[0].timeoutMs, 600_000);
+ assert.equal(ipcConfigs[1].timeoutMs, 30_000, "dictation cleanup keeps the short deadline");
+});
+
+// Tinfoil goes through the OpenAI SDK, which reports an expired deadline as a
+// connection error; without the mapping, withRetry would re-send it.
+test("Tinfoil note formatting passes the long deadline to the SDK and does not retry its timeout", async (t) => {
+ installBrowserGlobals(t);
+ const vite = await createRendererServer(t, {
+ cachePrefix: "openwhispr-tinfoil-deadline-test-",
+ mockModules: {
+ "/tinfoilClient": `
+ export const getTinfoilChatClient = async () => ({
+ chat: {
+ completions: {
+ create: async (_body, options) => {
+ globalThis.__tinfoilCreateCalls.push(options);
+ throw Object.assign(new Error("Request timed out."), {
+ name: "APIConnectionTimeoutError",
+ });
+ },
+ },
+ },
+ });
+ `,
+ },
+ });
+ globalThis.__tinfoilCreateCalls = [];
+ t.after(() => {
+ delete globalThis.__tinfoilCreateCalls;
+ });
+ const { tinfoilProvider } = await vite.ssrLoadModule(
+ "/services/ai/inferenceProviders/tinfoil.ts"
+ );
+
+ await assert.rejects(
+ tinfoilProvider.call({
+ text: "Alice: we agreed to ship on Friday.",
+ model: "glm-5-3",
+ agentName: null,
+ config: NOTE_CONFIG,
+ ctx: CTX,
+ }),
+ /Request timed out after 600s/
+ );
+
+ assert.equal(
+ globalThis.__tinfoilCreateCalls.length,
+ 1,
+ "an expired deadline must not be re-sent"
+ );
+ assert.equal(globalThis.__tinfoilCreateCalls[0].timeout, 600_000);
+ assert.equal(globalThis.__tinfoilCreateCalls[0].maxRetries, 0);
+});
diff --git a/test/stores/actionProcessingNoteOutput.test.js b/test/stores/actionProcessingNoteOutput.test.js
index f1ba196bf..665a31dda 100644
--- a/test/stores/actionProcessingNoteOutput.test.js
+++ b/test/stores/actionProcessingNoteOutput.test.js
@@ -116,3 +116,22 @@ test("a blank result is reported as an error and never saved as the enhanced not
await waitFor(() => store.consumeErrorEvents().length > 0 || updates.length > 0, "an outcome");
assert.equal(updates.length, 0);
});
+
+test("note formatting requests carry the noteFormatting scope, which is what buys them the long deadline", async (t) => {
+ // The scope is the only thing that tells the providers this request may run
+ // for minutes. If the overrides stop being spread into the config, the note
+ // silently drops back to the 30-second dictation deadline (1.10.1).
+ const { store, calls, updates } = await loadStore(t);
+
+ store.runBackgroundAction(
+ 10,
+ "## Meeting Transcript\nYou: ship on Friday.",
+ "hash",
+ ACTION,
+ { modelId: "gpt-5.6-terra", isCloudMode: true, isMeetingNote: true },
+ LABELS
+ );
+
+ await waitFor(() => updates.length > 0, "the note to be written");
+ assert.equal(calls[0].config.inferenceScope, "noteFormatting");
+});