Skip to content

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

feat: save failed transcriptions with audio for retry

Gabriel Steinbd6efa45502a
diff --git a/preload.js b/preload.js
index 151e03ced..024ca0cb2 100644
--- a/preload.js
+++ b/preload.js
@@ -31,7 +31,8 @@ contextBridge.exposeInMainWorld("electronAPI", {
onStopDictation: registerListener("stop-dictation", (callback) => () => callback()),
// Database functions
- saveTranscription: (text, rawText) => ipcRenderer.invoke("db-save-transcription", text, rawText),
+ saveTranscription: (text, rawText, options) =>
+ ipcRenderer.invoke("db-save-transcription", text, rawText, options),
getTranscriptions: (limit) => ipcRenderer.invoke("db-get-transcriptions", limit),
clearTranscriptions: () => ipcRenderer.invoke("db-clear-transcriptions"),
deleteTranscription: (id) => ipcRenderer.invoke("db-delete-transcription", id),
@@ -155,6 +156,11 @@ contextBridge.exposeInMainWorld("electronAPI", {
ipcRenderer.on("transcriptions-cleared", listener);
return () => ipcRenderer.removeListener("transcriptions-cleared", listener);
},
+ onTranscriptionUpdated: (callback) => {
+ const listener = (_event, transcription) => callback?.(transcription);
+ ipcRenderer.on("transcription-updated", listener);
+ return () => ipcRenderer.removeListener("transcription-updated", listener);
+ },
// Environment variables
getOpenAIKey: () => ipcRenderer.invoke("get-openai-key"),
diff --git a/src/components/ui/TranscriptionItem.tsx b/src/components/ui/TranscriptionItem.tsx
index e4e72a484..589c63a8f 100644
--- a/src/components/ui/TranscriptionItem.tsx
+++ b/src/components/ui/TranscriptionItem.tsx
@@ -2,7 +2,7 @@ import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Button } from "./button";
import { Tooltip } from "./tooltip";
-import { Copy, Trash2, FileText, FolderOpen, RotateCcw, Loader2 } from "lucide-react";
+import { Copy, Trash2, FileText, FolderOpen, RotateCcw, Loader2, AlertCircle } from "lucide-react";
import type { TranscriptionItem as TranscriptionItemType } from "../../types/electron";
import { cn } from "../lib/utils";
import { getCachedPlatform } from "../../utils/platform";
@@ -54,13 +54,19 @@ export default function TranscriptionItem({
}
};
+ const isFailed = item.status === "failed";
const hasRawText = item.raw_text !== null;
const hasAudio = item.has_audio === 1;
const showUtilityGroup = hasRawText || hasAudio;
return (
<div
- className="group rounded-md border border-border/40 dark:border-border-subtle/60 bg-card/50 dark:bg-surface-2/60 px-3 py-2.5 transition-colors duration-150 hover:bg-muted/30 dark:hover:bg-surface-2/80"
+ className={cn(
+ "group rounded-md border px-3 py-2.5 transition-colors duration-150",
+ isFailed
+ ? "border-destructive/30 bg-destructive/5 hover:bg-destructive/10"
+ : "border-border/40 dark:border-border-subtle/60 bg-card/50 dark:bg-surface-2/60 hover:bg-muted/30 dark:hover:bg-surface-2/80"
+ )}
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
>
@@ -71,17 +77,50 @@ export default function TranscriptionItem({
</span>
)}
- <p className="flex-1 min-w-0 text-foreground text-sm leading-[1.5] break-words">
- {item.text}
- </p>
+ {isFailed ? (
+ <div className="flex-1 min-w-0 flex items-center gap-2">
+ <AlertCircle size={14} className="shrink-0 text-destructive" />
+ <div className="min-w-0">
+ <p className="text-sm text-destructive font-medium">
+ {t("controlPanel.history.transcriptionFailed")}
+ </p>
+ {item.error_message && (
+ <p className="text-xs text-muted-foreground mt-0.5 truncate">
+ {item.error_message}
+ </p>
+ )}
+ </div>
+ </div>
+ ) : (
+ <p className="flex-1 min-w-0 text-foreground text-sm leading-[1.5] break-words">
+ {item.text}
+ </p>
+ )}
<div
className={cn(
"flex items-center gap-0.5 shrink-0 transition-opacity duration-150",
- isHovered ? "opacity-100" : "opacity-0"
+ isFailed ? "opacity-100" : isHovered ? "opacity-100" : "opacity-0"
)}
>
- {hasRawText && (
+ {isFailed && hasAudio && (
+ <Tooltip content={t("controlPanel.history.retryTranscription")}>
+ <Button
+ size="icon"
+ variant="ghost"
+ onClick={handleRetry}
+ disabled={isRetrying}
+ className="h-6 w-6 rounded-sm text-destructive hover:text-destructive hover:bg-destructive/10"
+ >
+ {isRetrying ? (
+ <Loader2 size={12} className="animate-spin" />
+ ) : (
+ <RotateCcw size={12} />
+ )}
+ </Button>
+ </Tooltip>
+ )}
+ {!isFailed && hasRawText && (
<Tooltip content={t("controlPanel.history.viewRawTranscript")}>
<Button
size="icon"
@@ -108,7 +147,7 @@ export default function TranscriptionItem({
</Button>
</Tooltip>
)}
- {hasAudio && (
+ {!isFailed && hasAudio && (
<Tooltip content={t("controlPanel.history.retryTranscription")}>
<Button
size="icon"
@@ -126,16 +165,18 @@ export default function TranscriptionItem({
</Tooltip>
)}
{showUtilityGroup && <div className="w-px h-3 bg-border/30" />}
- <Tooltip content={t("controlPanel.history.copyText")}>
- <Button
- size="icon"
- variant="ghost"
- onClick={() => onCopy(item.text)}
- className="h-6 w-6 rounded-sm text-muted-foreground hover:text-foreground hover:bg-foreground/10"
- >
- <Copy size={12} />
- </Button>
- </Tooltip>
+ {!isFailed && (
+ <Tooltip content={t("controlPanel.history.copyText")}>
+ <Button
+ size="icon"
+ variant="ghost"
+ onClick={() => onCopy(item.text)}
+ className="h-6 w-6 rounded-sm text-muted-foreground hover:text-foreground hover:bg-foreground/10"
+ >
+ <Copy size={12} />
+ </Button>
+ </Tooltip>
+ )}
<Tooltip content={t("controlPanel.history.deleteItem")}>
<Button
size="icon"
@@ -149,24 +190,26 @@ export default function TranscriptionItem({
</div>
</div>
- <div
- className={cn(
- "overflow-hidden transition-all duration-200",
- isExpanded ? "max-h-96" : "max-h-0"
- )}
- >
- <div className="border-t border-border/20 mt-2 pt-2">
- <span className="text-[10px] font-medium text-muted-foreground uppercase tracking-wider">
- {t("controlPanel.history.rawTranscript")}
- </span>
- <p className="text-xs text-muted-foreground/80 leading-relaxed mt-1">{item.raw_text}</p>
- {item.raw_text === item.text && (
- <p className="text-[10px] text-muted-foreground/50 italic mt-1">
- {t("controlPanel.history.noAiProcessing")}
- </p>
+ {!isFailed && (
+ <div
+ className={cn(
+ "overflow-hidden transition-all duration-200",
+ isExpanded ? "max-h-96" : "max-h-0"
)}
+ >
+ <div className="border-t border-border/20 mt-2 pt-2">
+ <span className="text-[10px] font-medium text-muted-foreground uppercase tracking-wider">
+ {t("controlPanel.history.rawTranscript")}
+ </span>
+ <p className="text-xs text-muted-foreground/80 leading-relaxed mt-1">{item.raw_text}</p>
+ {item.raw_text === item.text && (
+ <p className="text-[10px] text-muted-foreground/50 italic mt-1">
+ {t("controlPanel.history.noAiProcessing")}
+ </p>
+ )}
+ </div>
</div>
- </div>
+ )}
</div>
);
}
diff --git a/src/helpers/audioManager.js b/src/helpers/audioManager.js
index 8aa81f096..2a93d888f 100644
--- a/src/helpers/audioManager.js
+++ b/src/helpers/audioManager.js
@@ -534,6 +534,11 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
description: `Transcription failed: ${error.message}`,
code: error.code,
});
+
+ // Save failed transcription with audio so the user can retry later
+ if (this.lastAudioBlob) {
+ this.saveFailedTranscription(error.message, metadata);
+ }
}
} finally {
if (this.isProcessing) {
@@ -1860,6 +1865,47 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
}
}
+ async saveFailedTranscription(errorMessage, metadata = {}) {
+ try {
+ const result = await window.electronAPI.saveTranscription("", null, {
+ status: "failed",
+ errorMessage,
+ });
+
+ if (result?.id && this.lastAudioBlob) {
+ try {
+ const durationMs = metadata?.durationSeconds
+ ? Math.round(metadata.durationSeconds * 1000)
+ : null;
+ const arrayBuffer = await this.lastAudioBlob.arrayBuffer();
+ await window.electronAPI.saveTranscriptionAudio(result.id, arrayBuffer, {
+ durationMs,
+ provider: null,
+ model: null,
+ });
+ } catch (audioErr) {
+ logger.warn(
+ "Failed to save audio for failed transcription",
+ {
+ error: audioErr.message,
+ },
+ "audio"
+ );
+ }
+ this.lastAudioBlob = null;
+ this.lastAudioMetadata = null;
+ }
+ } catch (error) {
+ logger.error(
+ "Failed to save failed transcription record",
+ {
+ error: error.message,
+ },
+ "audio"
+ );
+ }
+ }
+
getState() {
return {
isRecording: this.isRecording,
diff --git a/src/helpers/database.js b/src/helpers/database.js
index c39187d36..f10e7b622 100644
--- a/src/helpers/database.js
+++ b/src/helpers/database.js
@@ -55,6 +55,18 @@ class DatabaseManager {
} catch (err) {
if (!err.message.includes("duplicate column")) throw err;
}
+ try {
+ this.db.exec(
+ "ALTER TABLE transcriptions ADD COLUMN status TEXT NOT NULL DEFAULT 'completed'"
+ );
+ } catch (err) {
+ if (!err.message.includes("duplicate column")) throw err;
+ }
+ try {
+ this.db.exec("ALTER TABLE transcriptions ADD COLUMN error_message TEXT");
+ } catch (err) {
+ if (!err.message.includes("duplicate column")) throw err;
+ }
this.db.exec(`
CREATE TABLE IF NOT EXISTS custom_dictionary (
@@ -327,13 +339,15 @@ class DatabaseManager {
}
}
- saveTranscription(text, rawText = null) {
+ saveTranscription(text, rawText = null, { status = "completed", errorMessage = null } = {}) {
try {
if (!this.db) {
throw new Error("Database not initialized");
}
- const stmt = this.db.prepare("INSERT INTO transcriptions (text, raw_text) VALUES (?, ?)");
- const result = stmt.run(text, rawText);
+ const stmt = this.db.prepare(
+ "INSERT INTO transcriptions (text, raw_text, status, error_message) VALUES (?, ?, ?, ?)"
+ );
+ const result = stmt.run(text, rawText, status, errorMessage);
const fetchStmt = this.db.prepare("SELECT * FROM transcriptions WHERE id = ?");
const transcription = fetchStmt.get(result.lastInsertRowid);
@@ -413,6 +427,24 @@ class DatabaseManager {
}
}
+ updateTranscriptionStatus(id, status, errorMessage = null) {
+ try {
+ if (!this.db) throw new Error("Database not initialized");
+ const stmt = this.db.prepare(
+ "UPDATE transcriptions SET status = ?, error_message = ? WHERE id = ?"
+ );
+ stmt.run(status, errorMessage, id);
+ return { success: true };
+ } catch (error) {
+ debugLogger.error(
+ "Error updating transcription status",
+ { error: error.message },
+ "database"
+ );
+ throw error;
+ }
+ }
+
getTranscriptionById(id) {
try {
if (!this.db) throw new Error("Database not initialized");
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 5b544ade1..4981113b6 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -348,8 +348,8 @@ class IPCHandlers {
return this.environmentManager.createProductionEnvFile(apiKey);
});
- ipcMain.handle("db-save-transcription", async (event, text, rawText) => {
- const result = this.databaseManager.saveTranscription(text, rawText);
+ ipcMain.handle("db-save-transcription", async (event, text, rawText, options) => {
+ const result = this.databaseManager.saveTranscription(text, rawText, options);
if (result?.success && result?.transcription) {
setImmediate(() => {
this.broadcastToWindows("transcription-added", result.transcription);
@@ -2162,6 +2162,7 @@ class IPCHandlers {
}
this.databaseManager.updateTranscriptionText(id, result.text, result.text);
+ this.databaseManager.updateTranscriptionStatus(id, "completed");
const provider = result.source || "local";
const model = result.model || null;
this.databaseManager.updateTranscriptionAudio(id, {
@@ -2171,6 +2172,11 @@ class IPCHandlers {
model,
});
const updated = this.databaseManager.getTranscriptionById(id);
+ if (updated) {
+ setImmediate(() => {
+ this.broadcastToWindows("transcription-updated", updated);
+ });
+ }
return { success: true, transcription: updated };
} catch (error) {
debugLogger.error(
diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json
index 3a1058132..20e7818be 100644
--- a/src/locales/de/translation.json
+++ b/src/locales/de/translation.json
@@ -222,7 +222,8 @@
"dateGroups": {
"today": "Heute",
"yesterday": "Gestern"
- }
+ },
+ "transcriptionFailed": "Transkription fehlgeschlagen"
},
"cloudMigration": {
"title": "Willkommen bei OpenWhispr Pro",
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index 98dd80d25..fb172142d 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -238,6 +238,7 @@
"retryError": "Failed to re-transcribe",
"audioNotFound": "Audio file not found or expired",
"noAiProcessing": "No AI processing was applied to this transcription",
+ "transcriptionFailed": "Transcription failed",
"rawTranscript": "Raw Transcript"
},
"cloudMigration": {
diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json
index c8ca81704..698f953ba 100644
--- a/src/locales/es/translation.json
+++ b/src/locales/es/translation.json
@@ -222,7 +222,8 @@
"dateGroups": {
"today": "Hoy",
"yesterday": "Ayer"
- }
+ },
+ "transcriptionFailed": "La transcripción falló"
},
"cloudMigration": {
"title": "Bienvenido a OpenWhispr Pro",
diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json
index 7a6b4ab33..e11b0f1b2 100644
--- a/src/locales/fr/translation.json
+++ b/src/locales/fr/translation.json
@@ -222,7 +222,8 @@
"dateGroups": {
"today": "Aujourd'hui",
"yesterday": "Hier"
- }
+ },
+ "transcriptionFailed": "La transcription a échoué"
},
"cloudMigration": {
"title": "Bienvenue sur OpenWhispr Pro",
diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json
index 5986d8fe3..bda3cbafb 100644
--- a/src/locales/it/translation.json
+++ b/src/locales/it/translation.json
@@ -222,7 +222,8 @@
"dateGroups": {
"today": "Oggi",
"yesterday": "Ieri"
- }
+ },
+ "transcriptionFailed": "La trascrizione è fallita"
},
"cloudMigration": {
"title": "Benvenuto in OpenWhispr Pro",
diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json
index 11000a74a..d55259d41 100644
--- a/src/locales/ja/translation.json
+++ b/src/locales/ja/translation.json
@@ -222,7 +222,8 @@
"dateGroups": {
"today": "今日",
"yesterday": "昨日"
- }
+ },
+ "transcriptionFailed": "文字起こしに失敗しました"
},
"cloudMigration": {
"title": "OpenWhispr Pro へようこそ",
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index 7a849356b..d6f8e200d 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -194,7 +194,8 @@
"dateGroups": {
"today": "Hoje",
"yesterday": "Ontem"
- }
+ },
+ "transcriptionFailed": "A transcrição falhou"
},
"cloudMigration": {
"title": "Boas-vindas ao OpenWhispr Pro",
diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json
index c70eea224..33256920e 100644
--- a/src/locales/ru/translation.json
+++ b/src/locales/ru/translation.json
@@ -222,7 +222,8 @@
"dateGroups": {
"today": "Сегодня",
"yesterday": "Вчера"
- }
+ },
+ "transcriptionFailed": "Транскрипция не удалась"
},
"cloudMigration": {
"title": "Добро пожаловать в OpenWhispr Pro",
diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json
index 05e0eb8bd..d8e685c5c 100644
--- a/src/locales/zh-CN/translation.json
+++ b/src/locales/zh-CN/translation.json
@@ -222,7 +222,8 @@
"dateGroups": {
"today": "今天",
"yesterday": "昨天"
- }
+ },
+ "transcriptionFailed": "转录失败"
},
"cloudMigration": {
"title": "欢迎使用 OpenWhispr Pro",
diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json
index 9b1bcb301..be644b1b5 100644
--- a/src/locales/zh-TW/translation.json
+++ b/src/locales/zh-TW/translation.json
@@ -222,7 +222,8 @@
"dateGroups": {
"today": "今天",
"yesterday": "昨天"
- }
+ },
+ "transcriptionFailed": "轉錄失敗"
},
"cloudMigration": {
"title": "歡迎使用 OpenWhispr Pro",
diff --git a/src/stores/transcriptionStore.ts b/src/stores/transcriptionStore.ts
index 11e401b6f..258eb4132 100644
--- a/src/stores/transcriptionStore.ts
+++ b/src/stores/transcriptionStore.ts
@@ -40,6 +40,17 @@ function ensureIpcListeners() {
}
}
+ if (window.electronAPI?.onTranscriptionUpdated) {
+ const dispose = window.electronAPI.onTranscriptionUpdated((item) => {
+ if (item) {
+ updateTranscription(item);
+ }
+ });
+ if (typeof dispose === "function") {
+ disposers.push(dispose);
+ }
+ }
+
if (window.electronAPI?.onTranscriptionsCleared) {
const dispose = window.electronAPI.onTranscriptionsCleared(() => {
clearTranscriptions();
diff --git a/src/types/electron.ts b/src/types/electron.ts
index 91f6e8403..2dd138df2 100644
--- a/src/types/electron.ts
+++ b/src/types/electron.ts
@@ -1,5 +1,7 @@
export type LocalTranscriptionProvider = "whisper" | "nvidia";
+export type TranscriptionStatus = "completed" | "failed" | "pending";
+
export interface TranscriptionItem {
id: number;
text: string;
@@ -10,6 +12,8 @@ export interface TranscriptionItem {
audio_duration_ms: number | null;
provider: string | null;
model: string | null;
+ status: TranscriptionStatus;
+ error_message: string | null;
}
export interface NoteItem {
@@ -289,7 +293,8 @@ declare global {
// Database operations
saveTranscription: (
text: string,
- rawText?: string | null
+ rawText?: string | null,
+ options?: { status?: TranscriptionStatus; errorMessage?: string | null }
) => Promise<{ id: number; success: boolean; transcription?: TranscriptionItem }>;
getTranscriptions: (limit?: number) => Promise<TranscriptionItem[]>;
clearTranscriptions: () => Promise<{ cleared: number; success: boolean }>;
@@ -418,6 +423,7 @@ declare global {
// Database event listeners
onTranscriptionAdded?: (callback: (item: TranscriptionItem) => void) => () => void;
+ onTranscriptionUpdated?: (callback: (item: TranscriptionItem) => void) => () => void;
onTranscriptionDeleted?: (callback: (payload: { id: number }) => void) => () => void;
onTranscriptionsCleared?: (callback: (payload: { cleared: number }) => void) => () => void;