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(transcription): report partial and failed local decodes on Re-transcribe (#2718)
Chad Piha3577e5c9b2b0
diff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsxindex 76c005bef..a543941b2 100644--- a/src/components/ControlPanel.tsx+++ b/src/components/ControlPanel.tsx@@ -832,6 +832,10 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro? "controlPanel.history.discarded.recovered": "controlPanel.history.retrySuccess"),+ // A partial result still replaced the row; say so, as dictation does.+ ...(result.warning+ ? { description: t("hooks.audioRecording.partialTranscription.description") }+ : {}),});} else {toast({diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex 8191d689b..87857d535 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -92,6 +92,19 @@ function assertAnalyticsSyncContext(context) {}return context.accountId;}+// Local engines resolve a failed decode instead of throwing. Retry turns that+// into a coded error so the toast says what went wrong rather than blaming a+// missing engine.+function localTranscriptionFailure(result) {+ const error = new Error(result.message || result.error || "Local transcription failed");+ if (result.code === "NO_SPEECH_DETECTED" || result.message === "No audio detected") {+ error.code = "NO_SPEECH_DETECTED";+ } else if (result.error === "invalid_response") {+ error.code = "INVALID_RESPONSE";+ error.messageKey = "controlPanel.history.retryErrors.invalidResponse";+ }+ return error;+}// Which diarization dialect a resolved endpoint speaks, for Custom endpoints// that front a known provider. Null when the host offers no known dialect.const diarizationHost = (endpoint) => {@@ -6929,13 +6942,11 @@ class IPCHandlers {});}const data = await response.json();- if (data?.text) {- result = {- text: data.text,- source: "self-hosted",- model: route.model,- };- }+ result = {+ text: data?.text,+ source: "self-hosted",+ model: route.model,+ };} else if (route.transport === "local") {if (isSherpaLocalProvider(settings.localTranscriptionProvider)) {const model =@@ -6970,13 +6981,13 @@ class IPCHandlers {sessionId: this.sessionId,};if (buffer.length > CLOUD_INLINE_LIMIT) {- const { text } = await chunkedCloudTranscribe({+ const { text, warning } = await chunkedCloudTranscribe({buffer,apiUrl,policyHeaders: withPolicyHeaders(authHeader),multipartFields,});- result = { text, source: "openwhispr", model: "cloud" };+ result = { text, source: "openwhispr", model: "cloud", warning };} else {const { body, boundary } = buildMultipartBody(buffer,@@ -7014,7 +7025,7 @@ class IPCHandlers {language: route.language,apiKey: this.environmentManager.getTinfoilKey(),});- if (text) result = { text, source: "tinfoil", model };+ result = { text, source: "tinfoil", model };} else if (route.transport === "proxied" && route.provider === "corti") {// Corti uses OAuth + an interaction-based REST flow, so it can't use// the generic fetch below.@@ -7035,7 +7046,7 @@ class IPCHandlers {audioBuffer: buffer,language: route.language,});- if (text) result = { text, source: "corti", model: route.model };+ result = { text, source: "corti", model: route.model };} else if (route.transport === "proxied" && route.provider === "gemini") {if (route.sizeCapBytes && buffer.byteLength > route.sizeCapBytes) {throw new Error(byokSizeCapError(route.sizeCapBytes));@@ -7047,7 +7058,7 @@ class IPCHandlers {language: route.language,apiKey: this.environmentManager.getGeminiKey(),});- if (text) result = { text, source: "gemini", model: route.model };+ result = { text, source: "gemini", model: route.model };} else {// mistral/xai have no OpenAI-compatible endpoint — main talks to them// directly; everything else consumes the route endpoint as-is.@@ -7141,14 +7152,20 @@ class IPCHandlers {});}const data = await response.json();- if (data?.text) {- result = { text: data.text, source: provider, model: route.model };- }+ result = { text: data?.text, source: provider, model: route.model };}- if (!result?.text) {+ if (result?.success === false) {+ throw localTranscriptionFailure(result);+ }+ if (!result) {return { success: false, error: "No transcription engine available" };}+ if (!result.text) {+ throw Object.assign(new Error("No speech detected in audio"), {+ code: "NO_SPEECH_DETECTED",+ });+ }this.databaseManager.updateTranscriptionText(id, result.text, result.text);this.databaseManager.updateTranscriptionStatus(id, "completed");@@ -7169,7 +7186,13 @@ class IPCHandlers {void this._ensureAnalyticsHistoryBackfilled();});}- return { success: true, transcription: updated };+ // A partial result (local truncation, lost cloud chunks) still replaces the+ // row, as dictation keeps it, but the renderer must say so.+ return {+ success: true,+ transcription: updated,+ ...(result.warning ? { warning: result.warning } : {}),+ };} catch (rawError) {const error = providerErrorContext? asProviderError(rawError, providerErrorContext)@@ -7179,6 +7202,11 @@ class IPCHandlers {{ id, error: error.message, code: error.code },"audio-storage");+ if (error.code === "NO_SPEECH_DETECTED" && !error.messageKey) {+ // Every engine reports silence with this code, so it is translated+ // here once rather than per route.+ error.messageKey = "notes.upload.noSpeechDetected";+ }if (error.code) {return { success: false, ...ipcErrorFields(error) };}diff --git a/src/locales/ar/translation.json b/src/locales/ar/translation.jsonindex b75c586a3..d021248e2 100644--- a/src/locales/ar/translation.json+++ b/src/locales/ar/translation.json@@ -572,6 +572,9 @@"retrying": "جاري إعادة التفريغ...","retrySuccess": "تم تحديث التفريغ","retryError": "فشلت إعادة التفريغ",+ "retryErrors": {+ "invalidResponse": "أعاد محرك التفريغ استجابة غير متوقعة. حاول مرة أخرى."+ },"audioNotFound": "الملف الصوتي غير موجود أو انتهت صلاحيته","noAiProcessing": "لم يتم تطبيق أي معالجة بالذكاء الاصطناعي على هذا النص المفرَّغ","transcriptionFailed": "فشل التفريغ",diff --git a/src/locales/de/translation.json b/src/locales/de/translation.jsonindex baeccfb13..71522616e 100644--- a/src/locales/de/translation.json+++ b/src/locales/de/translation.json@@ -680,6 +680,9 @@"retrying": "Wird erneut transkribiert…","retrySuccess": "Transkription aktualisiert","retryError": "Erneute Transkription fehlgeschlagen",+ "retryErrors": {+ "invalidResponse": "Die Transkriptions-Engine hat eine unerwartete Antwort zurückgegeben. Bitte versuchen Sie es erneut."+ },"audioNotFound": "Audiodatei nicht gefunden oder abgelaufen","noAiProcessing": "Auf diese Transkription wurde keine KI-Verarbeitung angewendet","transcriptionFailed": "Transkription fehlgeschlagen",diff --git a/src/locales/en/translation.json b/src/locales/en/translation.jsonindex 7bdcf9d5d..1d0b40e0b 100644--- a/src/locales/en/translation.json+++ b/src/locales/en/translation.json@@ -680,6 +680,9 @@"retrying": "Re-transcribing...","retrySuccess": "Transcription updated","retryError": "Failed to re-transcribe",+ "retryErrors": {+ "invalidResponse": "The transcription engine returned an unexpected response. Try again."+ },"audioNotFound": "Audio file not found or expired","noAiProcessing": "No AI processing was applied to this transcription","transcriptionFailed": "Transcription failed",diff --git a/src/locales/es/translation.json b/src/locales/es/translation.jsonindex f26488965..ebf690c7a 100644--- a/src/locales/es/translation.json+++ b/src/locales/es/translation.json@@ -702,6 +702,9 @@"retrying": "Transcribiendo de nuevo…","retrySuccess": "Transcripción actualizada","retryError": "Error al volver a transcribir",+ "retryErrors": {+ "invalidResponse": "El motor de transcripción devolvió una respuesta inesperada. Inténtalo de nuevo."+ },"audioNotFound": "Archivo de audio no encontrado o expirado","noAiProcessing": "No se aplicó procesamiento de IA a esta transcripción","rawTranscript": "Transcripción sin procesar",diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.jsonindex 8f1b462ff..62cf115f5 100644--- a/src/locales/fr/translation.json+++ b/src/locales/fr/translation.json@@ -680,6 +680,9 @@"retrying": "Retranscription en cours…","retrySuccess": "Transcription mise à jour","retryError": "Échec de la retranscription",+ "retryErrors": {+ "invalidResponse": "Le moteur de transcription a renvoyé une réponse inattendue. Réessayez."+ },"audioNotFound": "Fichier audio introuvable ou expiré","noAiProcessing": "Aucun traitement IA n'a été appliqué à cette transcription","transcriptionFailed": "La transcription a échoué",diff --git a/src/locales/it/translation.json b/src/locales/it/translation.jsonindex 879e00412..1de0fd830 100644--- a/src/locales/it/translation.json+++ b/src/locales/it/translation.json@@ -693,6 +693,9 @@"retrying": "Ritrascrizione in corso…","retrySuccess": "Trascrizione aggiornata","retryError": "Ritrascrizione non riuscita",+ "retryErrors": {+ "invalidResponse": "Il motore di trascrizione ha restituito una risposta inattesa. Riprova."+ },"audioNotFound": "File audio non trovato o scaduto","noAiProcessing": "Nessuna elaborazione IA applicata a questa trascrizione","rawTranscript": "Trascrizione grezza",diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.jsonindex ec56883a9..ba89b72c1 100644--- a/src/locales/ja/translation.json+++ b/src/locales/ja/translation.json@@ -693,6 +693,9 @@"retrying": "再文字起こし中…","retrySuccess": "文字起こしが更新されました","retryError": "再文字起こしに失敗しました",+ "retryErrors": {+ "invalidResponse": "文字起こしエンジンから予期しない応答が返されました。もう一度お試しください。"+ },"audioNotFound": "音声ファイルが見つからないか有効期限切れです","noAiProcessing": "この文字起こしにはAI処理が適用されていません","rawTranscript": "生の文字起こし",diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.jsonindex 6ef3e20f4..94eb9282f 100644--- a/src/locales/pt/translation.json+++ b/src/locales/pt/translation.json@@ -672,6 +672,9 @@"retrying": "Retranscrevendo…","retrySuccess": "Transcrição atualizada","retryError": "Falha ao retranscrever",+ "retryErrors": {+ "invalidResponse": "O mecanismo de transcrição retornou uma resposta inesperada. Tente novamente."+ },"audioNotFound": "Arquivo de áudio não encontrado ou expirado","noAiProcessing": "Nenhum processamento de IA foi aplicado a esta transcrição","rawTranscript": "Transcrição bruta",diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.jsonindex e799e95a7..5582d87d7 100644--- a/src/locales/ru/translation.json+++ b/src/locales/ru/translation.json@@ -693,6 +693,9 @@"retrying": "Повторная расшифровка…","retrySuccess": "Расшифровка обновлена","retryError": "Не удалось повторить расшифровку",+ "retryErrors": {+ "invalidResponse": "Модуль расшифровки вернул неожиданный ответ. Попробуйте ещё раз."+ },"audioNotFound": "Аудиофайл не найден или истёк срок хранения","noAiProcessing": "К этой расшифровке не применялась обработка ИИ","rawTranscript": "Исходная расшифровка",diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.jsonindex fd4392085..5cf0e1c36 100644--- a/src/locales/zh-CN/translation.json+++ b/src/locales/zh-CN/translation.json@@ -693,6 +693,9 @@"retrying": "正在重新转录…","retrySuccess": "转录已更新","retryError": "重新转录失败",+ "retryErrors": {+ "invalidResponse": "转录引擎返回了意外的响应。请重试。"+ },"audioNotFound": "音频文件未找到或已过期","noAiProcessing": "此转录未应用 AI 处理","rawTranscript": "原始转录",diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.jsonindex 8a16b7486..5cf419692 100644--- a/src/locales/zh-TW/translation.json+++ b/src/locales/zh-TW/translation.json@@ -693,6 +693,9 @@"retrying": "正在重新轉錄…","retrySuccess": "轉錄已更新","retryError": "重新轉錄失敗",+ "retryErrors": {+ "invalidResponse": "轉錄引擎傳回了非預期的回應。請再試一次。"+ },"audioNotFound": "找不到音訊檔案或檔案已過期","noAiProcessing": "此轉錄未套用 AI 處理","rawTranscript": "原始轉錄",diff --git a/src/types/electron.ts b/src/types/electron.tsindex 7a7455cfc..8738cebae 100644--- a/src/types/electron.ts+++ b/src/types/electron.ts@@ -1650,8 +1650,9 @@ declare global {) => Promise<{success: boolean;transcription?: TranscriptionItem;+ warning?: string;error?: string;- code?: TranscriptionErrorCode;+ code?: string;messageKey?: string;}>;updateTranscriptionText: (diff --git a/test/helpers/retryTranscriptionHandler.test.js b/test/helpers/retryTranscriptionHandler.test.jsindex 92cab32cb..6071a31e6 100644--- a/test/helpers/retryTranscriptionHandler.test.js+++ b/test/helpers/retryTranscriptionHandler.test.js@@ -1,6 +1,8 @@const test = require("node:test");const assert = require("node:assert/strict");const Module = require("node:module");+const fs = require("node:fs");+const path = require("node:path");const handlersModulePath = require.resolve("../../src/helpers/ipcHandlers");const originalLoad = Module._load;@@ -40,15 +42,22 @@ const electronStub = {static getAllWindows() {return [];}- static fromWebContents() {- return null;+ // Cloud retries need a window to read auth from; a sender opts in with one.+ static fromWebContents(sender) {+ return sender?.window ?? null;}},shell: {},dialog: {},screen: { getPrimaryDisplay: () => ({ workAreaSize: { width: 0, height: 0 } }) },systemPreferences: { getMediaAccessStatus: () => "granted" },- session: { fromPartition: () => ({}) },+ session: {+ fromPartition: () => ({+ webRequest: { onBeforeSendHeaders: () => {} },+ fetch: (url, init) => electronStub.net.fetch(url, init),+ closeAllConnections: async () => {},+ }),+ },clipboard: {},nativeImage: {},globalShortcut: {},@@ -64,6 +73,9 @@ const WAV_BUFFER = Buffer.concat([Buffer.alloc(32),]);const CONVERTED_WAV = Buffer.concat([WAV_BUFFER, Buffer.from("converted")]);+// Just over the inline upload limit, so an OpenWhispr Cloud retry is chunked.+const CHUNKED_BUFFER = Buffer.alloc(4 * 1024 * 1024 + 1);+const CLOUD_CHUNKS = ["chunk-000.mp3", "chunk-001.mp3", "chunk-002.mp3", "chunk-003.mp3"];// Conversion is mocked rather than run: spawning ffmpeg from a unit test would// make it slow and dependent on the runner having a usable binary.@@ -72,6 +84,10 @@ let convertBehavior = async () => CONVERTED_WAV;const cortiCalls = [];const tinfoilCalls = [];+const textUpdates = [];+const statusUpdates = [];+let parakeetBehavior = async () => ({ success: true, text: "local text" });+let whisperBehavior = async () => ({ success: true, text: "whisper text" });let cortiBehavior = async () => ({ text: "corti text" });// Kept installed for the whole file: the corti client is require()d lazily at@@ -96,6 +112,9 @@ Module._load = function loadWithMocks(request, parent, isMain) {getTinfoilChatModels: () => [],};}+ if (request === "./tokenStore") {+ return { ...originalLoad.call(this, request, parent, isMain), get: () => "test-token" };+ }if (request === "./windowBroadcast") {return { broadcastToWindows: () => {} };}@@ -107,6 +126,11 @@ Module._load = function loadWithMocks(request, parent, isMain) {wavConversions.push(buffer);return convertBehavior(buffer, options);},+ splitAudioFile: async (inputPath, chunkDir) => {+ const chunkPaths = CLOUD_CHUNKS.map((name) => path.join(chunkDir, name));+ for (const chunkPath of chunkPaths) fs.writeFileSync(chunkPath, "audio");+ return { chunkPaths, durationSeconds: 120 };+ },};}}@@ -134,15 +158,31 @@ function buildFakeThis() {const target = {sessionId: "test-session",audioStorageManager: {- // 7 is a stored WebM recording, 8 one already in WAV.- getAudioBuffer: (id) => (id === 7 ? Buffer.from([1, 2, 3]) : id === 8 ? WAV_BUFFER : null),+ // 7 is a stored WebM recording, 8 one already in WAV, 9 one too large to+ // upload inline.+ getAudioBuffer: (id) =>+ id === 7+ ? Buffer.from([1, 2, 3])+ : id === 8+ ? WAV_BUFFER+ : id === 9+ ? CHUNKED_BUFFER+ : null,},databaseManager: {- updateTranscriptionText: () => {},- updateTranscriptionStatus: () => {},+ updateTranscriptionText: (id, text) => textUpdates.push({ id, text }),+ updateTranscriptionStatus: (id, status) => statusUpdates.push({ id, status }),updateTranscriptionAudio: () => {},getTranscriptionById: (id) => dbRows.get(id),},+ parakeetManager: {+ transcribeLocalParakeet: (buffer, options) => parakeetBehavior(buffer, options),+ },+ whisperManager: {+ serverManager: { isAvailable: () => true },+ transcribeLocalWhisper: (buffer, options) => whisperBehavior(buffer, options),+ },+ _resolveWhisperVadOptions: () => ({}),environmentManager: {getOpenAIKey: () => "sk-openai",getGroqKey: () => "gk-groq",@@ -365,6 +405,202 @@ test("retry: a custom URL on Tinfoil's host is refused in the main process", asyassert.equal(tinfoilCalls.length, 0);});+const PARAKEET_SETTINGS = {+ transcriptionMode: "local",+ useLocalWhisper: true,+ localTranscriptionProvider: "nvidia",+ parakeetModel: "parakeet-tdt-0.6b-v3",+};+const WHISPER_SETTINGS = {+ transcriptionMode: "local",+ useLocalWhisper: true,+ localTranscriptionProvider: "whisper",+ whisperModel: "base",+};++async function withLocalResult(behavior, settings, run) {+ const key = settings === WHISPER_SETTINGS ? "whisper" : "parakeet";+ const original = key === "whisper" ? whisperBehavior : parakeetBehavior;+ if (key === "whisper") whisperBehavior = behavior;+ else parakeetBehavior = behavior;+ textUpdates.length = 0;+ statusUpdates.length = 0;+ try {+ return await run(await invoke(settings));+ } finally {+ if (key === "whisper") whisperBehavior = original;+ else parakeetBehavior = original;+ }+}++test("retry: a clean local decode reports no warning", async () => {+ await withLocalResult(+ async () => ({ success: true, text: "local text" }),+ PARAKEET_SETTINGS,+ (result) => {+ assert.equal(result.success, true);+ assert.equal("warning" in result, false);+ assert.deepEqual(textUpdates, [{ id: 7, text: "local text" }]);+ }+ );+});++test("retry: a truncated Parakeet decode keeps its text and returns the warning", async () => {+ await withLocalResult(+ async () => ({ success: true, text: "first half", warning: "truncated" }),+ PARAKEET_SETTINGS,+ (result) => {+ assert.equal(result.success, true);+ assert.equal(result.warning, "truncated", "the renderer needs it for the partial toast");+ assert.deepEqual(textUpdates, [{ id: 7, text: "first half" }]);+ assert.deepEqual(statusUpdates, [{ id: 7, status: "completed" }]);+ }+ );+});++test("retry: an all-empty Parakeet decode reports the invalid response, not a missing engine", async () => {+ await withLocalResult(+ async () => ({+ success: false,+ error: "invalid_response",+ message: "Transcription engine returned an unexpected response",+ }),+ PARAKEET_SETTINGS,+ (result) => {+ assert.equal(result.success, false);+ assert.equal(result.code, "INVALID_RESPONSE");+ assert.equal(result.messageKey, "controlPanel.history.retryErrors.invalidResponse");+ assert.equal(result.error, "Transcription engine returned an unexpected response");+ assert.equal(textUpdates.length, 0, "a failed retry must leave the row alone");+ assert.equal(statusUpdates.length, 0);+ }+ );+});++test("retry: no speech from a local engine is reported as such", async (t) => {+ for (const [name, settings, failure] of [+ [+ "parakeet",+ PARAKEET_SETTINGS,+ { success: false, code: "NO_SPEECH_DETECTED", message: "No audio detected" },+ ],+ ["whisper", WHISPER_SETTINGS, { success: false, message: "No audio detected" }],+ ]) {+ await t.test(name, () =>+ withLocalResult(+ async () => failure,+ settings,+ (result) => {+ assert.equal(result.success, false);+ assert.equal(result.code, "NO_SPEECH_DETECTED");+ assert.equal(result.messageKey, "notes.upload.noSpeechDetected");+ assert.equal(textUpdates.length, 0);+ }+ )+ );+ }+});++test("retry: an unclassified local failure keeps the engine's own message", async () => {+ await withLocalResult(+ async () => ({ success: false, error: "decode_failed", message: "Decoder crashed" }),+ PARAKEET_SETTINGS,+ (result) => {+ assert.equal(result.success, false);+ assert.equal(result.error, "Decoder crashed");+ assert.equal(result.messageKey, undefined);+ }+ );+});++const CLOUD_SETTINGS = {+ transcriptionMode: "providers",+ cloudTranscriptionMode: "openwhispr",+ cloudTranscriptionProvider: "openai",+};++async function withCloudResponse(t, respond, id) {+ const originalFetchResponse = fetchResponse;+ const originalApiUrl = process.env.OPENWHISPR_API_URL;+ t.after(() => {+ fetchResponse = originalFetchResponse;+ if (originalApiUrl === undefined) delete process.env.OPENWHISPR_API_URL;+ else process.env.OPENWHISPR_API_URL = originalApiUrl;+ });+ process.env.OPENWHISPR_API_URL = "https://api.openwhispr.test";+ fetchResponse = (url, init) => {+ const { status, body } = respond(init);+ return { ok: status === 200, status, text: async () => JSON.stringify(body) };+ };+ textUpdates.length = 0;+ return retryHandler({ sender: { window: {} } }, id, CLOUD_SETTINGS);+}++test("retry: no speech from OpenWhispr Cloud is translated like a local engine's", async (t) => {+ const result = await withCloudResponse(+ t,+ () => ({+ status: 422,+ body: { code: "NO_SPEECH_DETECTED", error: "No speech detected in audio" },+ }),+ 7+ );+ assert.equal(result.success, false);+ assert.equal(result.code, "NO_SPEECH_DETECTED");+ assert.equal(result.messageKey, "notes.upload.noSpeechDetected");+ assert.equal(textUpdates.length, 0);+});++test("retry: an empty answer from a BYOK engine is no speech, not a missing engine", async (t) => {+ const originalFetchResponse = fetchResponse;+ const originalCortiBehavior = cortiBehavior;+ t.after(() => {+ fetchResponse = originalFetchResponse;+ cortiBehavior = originalCortiBehavior;+ });+ fetchResponse = () => ({ ok: true, status: 200, json: async () => ({ text: "" }) });+ cortiBehavior = async () => ({ text: "" });+ for (const [name, settings] of [+ ["custom", CUSTOM_SETTINGS],+ [+ "corti",+ {+ cloudTranscriptionProvider: "corti",+ cloudTranscriptionMode: "byok",+ transcriptionMode: "providers",+ },+ ],+ ]) {+ textUpdates.length = 0;+ const result = await invoke(settings);+ assert.equal(result.success, false, name);+ assert.equal(result.code, "NO_SPEECH_DETECTED", name);+ assert.equal(result.messageKey, "notes.upload.noSpeechDetected", name);+ assert.equal(textUpdates.length, 0, name);+ }+});++test("retry: a chunked cloud retry that lost a chunk saves the rest and returns the warning", async (t) => {+ const result = await withCloudResponse(+ t,+ (init) =>+ init.body.includes("chunk-001.mp3")+ ? { status: 400, body: { error: "Bad chunk" } }+ : { status: 200, body: { text: "part" } },+ 9+ );+ assert.equal(result.success, true, JSON.stringify(result));+ assert.equal(result.warning, "1 of 4 chunks failed");+ assert.equal(textUpdates.length, 1);+ assert.match(textUpdates[0].text, /part/);+});++test("retry: a clean chunked cloud retry reports no warning", async (t) => {+ const result = await withCloudResponse(t, () => ({ status: 200, body: { text: "part" } }), 9);+ assert.equal(result.success, true, JSON.stringify(result));+ assert.equal("warning" in result, false);+});+test("retry: mistral goes to Mistral with x-api-key", async () => {fetches.length = 0;const result = await invoke({diff --git a/test/services/cleanupOutputValidation.test.js b/test/services/cleanupOutputValidation.test.jsindex 4e9200f5a..bc1731fe8 100644--- a/test/services/cleanupOutputValidation.test.js+++ b/test/services/cleanupOutputValidation.test.js@@ -105,7 +105,7 @@ test("cleanup validates completed provider output using the request's prompt set});- await t.test("history retry keeps the raw row and reports rejected cleanup", async () => {+ await t.test("history retry keeps the raw row on rejected cleanup, flags partials", async () => {setCustomPrompt("");useSettingsStore.setState({cleanupMode: "local",@@ -178,5 +178,33 @@ test("cleanup validates completed provider output using the request's prompt set),JSON.stringify(toasts));++ // A clean retry confirms without a description.+ toasts.length = 0;+ window.electronAPI.processLocalReasoning = async () => ({ success: true, text: RAW });+ await retry(row.id);+ // Toasts are built in the vm's realm; copy them so deepEqual compares values.+ const shown = () => toasts.map((toast) => ({ ...toast }));+ assert.deepEqual(shown(), [{ title: "controlPanel.history.retrySuccess" }]);++ // A partial result must say so, as dictation does, while still confirming the+ // retry or recovery the user asked for.+ window.electronAPI.retryTranscription = async () => ({+ success: true,+ transcription: row,+ warning: "truncated",+ });+ for (const [options, title] of [+ [undefined, "controlPanel.history.retrySuccess"],+ [{ isRecover: true }, "controlPanel.history.discarded.recovered"],+ ]) {+ toasts.length = 0;+ await retry(row.id, options);+ assert.deepEqual(+ shown(),+ [{ title, description: "hooks.audioRecording.partialTranscription.description" }],+ JSON.stringify(options)+ );+ }});});