Skip to content

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

fix: correct limit error handling for BYOK and cloud reasoning (#941)

Gabriel Stein6c107149a53a
diff --git a/main.js b/main.js
index 331159a2f..fc1519cb6 100644
--- a/main.js
+++ b/main.js
@@ -182,6 +182,26 @@ function restoreHtmlHandlerIfChanged(original) {
}
}
+// True source of truth for whether openwhispr:// resolves on Linux — the same
+// MIME database xdg-open consults. Returns true for deb/rpm/flatpak/AUR installs
+// (scheme registered via the packaged .desktop MimeType) and false for AppImage/
+// tar.gz runs where it genuinely isn't registered, so we never enable a dead-end
+// OAuth flow. Used to recover from setAsDefaultProtocolClient's KDE false negative.
+function isOAuthSchemeRegistered() {
+ if (process.platform !== "linux") return false;
+ try {
+ const { execFileSync } = require("child_process");
+ const handler = execFileSync(
+ "xdg-mime",
+ ["query", "default", `x-scheme-handler/${OAUTH_PROTOCOL}`],
+ { encoding: "utf8", timeout: 3000 }
+ ).trim();
+ return handler.length > 0;
+ } catch {
+ return false;
+ }
+}
+
// Register custom protocol for OAuth callbacks.
// In development, always include the app path argument so macOS/Windows/Linux
// can launch the project app instead of opening bare Electron.
@@ -204,7 +224,11 @@ function registerOpenWhisprProtocol() {
return result;
}
-const protocolRegistered = registerOpenWhisprProtocol();
+// setAsDefaultProtocolClient returns a false negative on KDE/Wayland, so on Linux
+// fall back to probing the system MIME database for an actual handler. This keeps
+// OAuth enabled where the callback can resolve (deb/rpm/flatpak/AUR) and correctly
+// gated where it can't (AppImage/tar.gz with no scheme registration).
+const protocolRegistered = registerOpenWhisprProtocol() || isOAuthSchemeRegistered();
if (!protocolRegistered) {
console.warn(`[Auth] Failed to register ${OAUTH_PROTOCOL}:// protocol handler`);
}
diff --git a/src/components/UpgradePrompt.tsx b/src/components/UpgradePrompt.tsx
index d4eff27a4..b59a49d07 100644
--- a/src/components/UpgradePrompt.tsx
+++ b/src/components/UpgradePrompt.tsx
@@ -72,7 +72,9 @@ export default function UpgradePrompt({
title={t("upgradePrompt.useApiKey")}
description={t("upgradePrompt.useApiKeyDescription")}
onClick={() => {
- useSettingsStore.getState().setCloudTranscriptionMode("byok");
+ const s = useSettingsStore.getState();
+ s.setTranscriptionMode("providers");
+ s.setCloudTranscriptionMode("byok");
onOpenChange(false);
}}
/>
@@ -80,7 +82,10 @@ export default function UpgradePrompt({
title={t("upgradePrompt.switchToLocal")}
description={t("upgradePrompt.switchToLocalDescription")}
onClick={() => {
- useSettingsStore.getState().setUseLocalWhisper(true);
+ const s = useSettingsStore.getState();
+ s.setTranscriptionMode("local");
+ s.setUseLocalWhisper(true);
+ s.setCloudTranscriptionMode("byok");
onOpenChange(false);
}}
/>
diff --git a/src/components/UsageDisplay.tsx b/src/components/UsageDisplay.tsx
index a7d7d2b64..28b530564 100644
--- a/src/components/UsageDisplay.tsx
+++ b/src/components/UsageDisplay.tsx
@@ -114,7 +114,9 @@ export default function UsageDisplay() {
variant="outline"
size="sm"
onClick={() => {
- useSettingsStore.getState().setCloudTranscriptionMode("byok");
+ const s = useSettingsStore.getState();
+ s.setTranscriptionMode("providers");
+ s.setCloudTranscriptionMode("byok");
window.location.reload();
}}
>
diff --git a/src/helpers/audioManager.js b/src/helpers/audioManager.js
index 7402b1764..48977d5ec 100644
--- a/src/helpers/audioManager.js
+++ b/src/helpers/audioManager.js
@@ -1423,53 +1423,61 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
);
const cleanupCloudMode = settings.cleanupCloudMode || "openwhispr";
- if (route.kind === "agent") {
- const reasoned = await this.processWithReasoningModel(
- processedText,
- route.model,
- agentName,
- route.config
- );
- if (reasoned) processedText = reasoned;
- } else if (route.kind === "cleanup" && cleanupCloudMode === "openwhispr") {
- const reasonResult = await withSessionRefresh(async () => {
- const res = await window.electronAPI.cloudReason(processedText, {
- agentName,
- customDictionary: getDictionaryHintWords(settings),
- customPrompt: this.getCustomPrompt(),
- language: settings.preferredLanguage || "auto",
- locale: settings.uiLanguage || "en",
- sttProvider: result.sttProvider,
- sttModel: result.sttModel,
- sttProcessingMs: result.sttProcessingMs,
- sttWordCount: result.sttWordCount,
- sttLanguage: result.sttLanguage,
- audioDurationMs: result.audioDurationMs,
- audioSizeBytes,
- audioFormat,
- });
- if (!res.success) {
- const err = new Error(res.error || "Cloud reasoning failed");
- err.code = res.code;
- throw err;
- }
- return res;
- });
-
- if (reasonResult.success) {
- processedText = reasonResult.text;
- }
- } else if (route.kind === "cleanup") {
- const effectiveModel = getEffectiveCleanupModel();
- if (effectiveModel) {
+ try {
+ if (route.kind === "agent") {
const reasoned = await this.processWithReasoningModel(
processedText,
- effectiveModel,
+ route.model,
agentName,
route.config
);
if (reasoned) processedText = reasoned;
+ } else if (route.kind === "cleanup" && cleanupCloudMode === "openwhispr") {
+ const reasonResult = await withSessionRefresh(async () => {
+ const res = await window.electronAPI.cloudReason(processedText, {
+ agentName,
+ customDictionary: getDictionaryHintWords(settings),
+ customPrompt: this.getCustomPrompt(),
+ language: settings.preferredLanguage || "auto",
+ locale: settings.uiLanguage || "en",
+ sttProvider: result.sttProvider,
+ sttModel: result.sttModel,
+ sttProcessingMs: result.sttProcessingMs,
+ sttWordCount: result.sttWordCount,
+ sttLanguage: result.sttLanguage,
+ audioDurationMs: result.audioDurationMs,
+ audioSizeBytes,
+ audioFormat,
+ });
+ if (!res.success) {
+ const err = new Error(res.error || "Cloud reasoning failed");
+ err.code = res.code;
+ throw err;
+ }
+ return res;
+ });
+
+ if (reasonResult.success) {
+ processedText = reasonResult.text;
+ }
+ } else if (route.kind === "cleanup") {
+ const effectiveModel = getEffectiveCleanupModel();
+ if (effectiveModel) {
+ const reasoned = await this.processWithReasoningModel(
+ processedText,
+ effectiveModel,
+ agentName,
+ route.config
+ );
+ if (reasoned) processedText = reasoned;
+ }
}
+ } catch (reasonError) {
+ logger.error(
+ "Cloud reasoning failed, using raw transcription",
+ { error: reasonError.message },
+ "transcription"
+ );
}
timings.reasoningProcessingDurationMs = Math.round(performance.now() - reasoningStart);
}
@@ -1767,8 +1775,9 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
const err = new Error(`API Error: ${response.status} ${errorText}`);
if (response.status === 401) err.code = "INVALID_KEY";
else if (response.status === 429) {
- err.code = "LIMIT_REACHED";
- err.messageKey = "hooks.audioRecording.errorDescriptions.dailyLimitReached";
+ // The user's own provider rate-limited the request — not an OpenWhispr plan limit
+ err.code = "PROVIDER_RATE_LIMITED";
+ err.messageKey = "hooks.audioRecording.errorDescriptions.providerRateLimited";
} else if (response.status >= 500) err.code = "SERVER_ERROR";
throw err;
}
diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json
index dee3dab80..d7df3192d 100644
--- a/src/locales/de/translation.json
+++ b/src/locales/de/translation.json
@@ -450,7 +450,8 @@
"errorTitles": {
"sessionExpired": "Sitzung abgelaufen",
"offline": "Sie sind offline",
- "dailyLimitReached": "Tägliches Limit erreicht"
+ "dailyLimitReached": "Tägliches Limit erreicht",
+ "providerRateLimited": "Anbieter-Ratenlimit erreicht"
},
"fallback": {
"title": "Fallback-Modus",
@@ -463,7 +464,8 @@
"errorDescriptions": {
"sessionExpired": "Deine OpenWhispr-Cloud-Sitzung ist nicht verfügbar. Bitte melde dich erneut über die Einstellungen an.",
"offline": "Du bist offline. Die Cloud-Transkription benötigt eine Internetverbindung.",
- "dailyLimitReached": "Du hast dein heutiges Transkriptionslimit erreicht. Versuch es morgen erneut oder upgrade deinen Plan."
+ "dailyLimitReached": "Du hast dein heutiges Transkriptionslimit erreicht. Versuch es morgen erneut oder upgrade deinen Plan.",
+ "providerRateLimited": "Dein Transkriptionsanbieter hat die Anfrage begrenzt. Warte kurz und versuch es erneut."
}
},
"clipboard": {
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index 5fd36fac5..2a3cbd8d1 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -450,7 +450,8 @@
"errorTitles": {
"sessionExpired": "Session Expired",
"offline": "You're Offline",
- "dailyLimitReached": "Daily Limit Reached"
+ "dailyLimitReached": "Daily Limit Reached",
+ "providerRateLimited": "Provider Rate Limited"
},
"fallback": {
"title": "Fallback Mode",
@@ -463,7 +464,8 @@
"errorDescriptions": {
"sessionExpired": "Your OpenWhispr Cloud session is unavailable. Please sign in again from Settings.",
"offline": "You're offline. Cloud transcription requires an internet connection.",
- "dailyLimitReached": "You've reached today's transcription limit. Try again tomorrow or upgrade your plan."
+ "dailyLimitReached": "You've reached today's transcription limit. Try again tomorrow or upgrade your plan.",
+ "providerRateLimited": "Your transcription provider rate-limited the request. Wait a moment and try again."
}
},
"clipboard": {
diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json
index 654711481..962862392 100644
--- a/src/locales/es/translation.json
+++ b/src/locales/es/translation.json
@@ -450,7 +450,8 @@
"errorTitles": {
"sessionExpired": "Sesión expirada",
"offline": "Sin conexión",
- "dailyLimitReached": "Límite diario alcanzado"
+ "dailyLimitReached": "Límite diario alcanzado",
+ "providerRateLimited": "Límite de tasa del proveedor"
},
"fallback": {
"title": "Modo de respaldo",
@@ -463,7 +464,8 @@
"errorDescriptions": {
"sessionExpired": "Tu sesión de OpenWhispr Cloud no está disponible. Vuelve a iniciar sesión desde Ajustes.",
"offline": "Estás sin conexión. La transcripción en la nube requiere conexión a Internet.",
- "dailyLimitReached": "Has alcanzado el límite de transcripción de hoy. Inténtalo mañana o mejora tu plan."
+ "dailyLimitReached": "Has alcanzado el límite de transcripción de hoy. Inténtalo mañana o mejora tu plan.",
+ "providerRateLimited": "Tu proveedor de transcripción limitó la solicitud. Espera un momento e inténtalo de nuevo."
}
},
"clipboard": {
diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json
index 3660d3d47..eab4f300e 100644
--- a/src/locales/fr/translation.json
+++ b/src/locales/fr/translation.json
@@ -450,7 +450,8 @@
"errorTitles": {
"sessionExpired": "Session expirée",
"offline": "Vous êtes hors ligne",
- "dailyLimitReached": "Limite quotidienne atteinte"
+ "dailyLimitReached": "Limite quotidienne atteinte",
+ "providerRateLimited": "Limite de débit du fournisseur"
},
"fallback": {
"title": "Mode de secours",
@@ -463,7 +464,8 @@
"errorDescriptions": {
"sessionExpired": "Votre session OpenWhispr Cloud est indisponible. Reconnectez-vous depuis Paramètres.",
"offline": "Vous êtes hors ligne. La transcription cloud nécessite une connexion Internet.",
- "dailyLimitReached": "Vous avez atteint votre limite de transcription du jour. Réessayez demain ou améliorez votre forfait."
+ "dailyLimitReached": "Vous avez atteint votre limite de transcription du jour. Réessayez demain ou améliorez votre forfait.",
+ "providerRateLimited": "Votre fournisseur de transcription a limité la requête. Patientez un instant et réessayez."
}
},
"clipboard": {
diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json
index 98a3f6511..f5910b03b 100644
--- a/src/locales/it/translation.json
+++ b/src/locales/it/translation.json
@@ -450,7 +450,8 @@
"errorTitles": {
"sessionExpired": "Sessione scaduta",
"offline": "Sei offline",
- "dailyLimitReached": "Limite giornaliero raggiunto"
+ "dailyLimitReached": "Limite giornaliero raggiunto",
+ "providerRateLimited": "Limite di velocità del provider"
},
"fallback": {
"title": "Modalità fallback",
@@ -463,7 +464,8 @@
"errorDescriptions": {
"sessionExpired": "La tua sessione OpenWhispr Cloud non è disponibile. Effettua di nuovo l'accesso dalle Impostazioni.",
"offline": "Sei offline. La trascrizione cloud richiede una connessione Internet.",
- "dailyLimitReached": "Hai raggiunto il limite di trascrizioni di oggi. Riprova domani o aggiorna il tuo piano."
+ "dailyLimitReached": "Hai raggiunto il limite di trascrizioni di oggi. Riprova domani o aggiorna il tuo piano.",
+ "providerRateLimited": "Il tuo provider di trascrizione ha limitato la richiesta. Attendi un momento e riprova."
}
},
"clipboard": {
diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json
index 1f9f9cb72..31ee5ad4f 100644
--- a/src/locales/ja/translation.json
+++ b/src/locales/ja/translation.json
@@ -450,7 +450,8 @@
"errorTitles": {
"sessionExpired": "セッション期限切れ",
"offline": "オフラインです",
- "dailyLimitReached": "1 日の上限に達しました"
+ "dailyLimitReached": "1 日の上限に達しました",
+ "providerRateLimited": "プロバイダーのレート制限"
},
"fallback": {
"title": "フォールバックモード",
@@ -463,7 +464,8 @@
"errorDescriptions": {
"sessionExpired": "OpenWhispr Cloud のセッションが利用できません。「設定」から再度サインインしてください。",
"offline": "オフラインです。クラウド文字起こしにはインターネット接続が必要です。",
- "dailyLimitReached": "本日の文字起こし上限に達しました。明日もう一度お試しいただくか、プランをアップグレードしてください。"
+ "dailyLimitReached": "本日の文字起こし上限に達しました。明日もう一度お試しいただくか、プランをアップグレードしてください。",
+ "providerRateLimited": "文字起こしプロバイダーがリクエストを制限しました。しばらく待ってからもう一度お試しください。"
}
},
"clipboard": {
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index 20c240f58..80de33a49 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -422,7 +422,8 @@
"errorTitles": {
"sessionExpired": "Sessão expirada",
"offline": "Sem conexão",
- "dailyLimitReached": "Limite diário atingido"
+ "dailyLimitReached": "Limite diário atingido",
+ "providerRateLimited": "Limite de taxa do provedor"
},
"fallback": {
"title": "Modo de fallback",
@@ -435,7 +436,8 @@
"errorDescriptions": {
"sessionExpired": "Sua sessão do OpenWhispr Cloud está indisponível. Entre novamente nas Configurações.",
"offline": "Você está offline. A transcrição na nuvem exige conexão com a internet.",
- "dailyLimitReached": "Você atingiu o limite de transcrições de hoje. Tente novamente amanhã ou faça upgrade do seu plano."
+ "dailyLimitReached": "Você atingiu o limite de transcrições de hoje. Tente novamente amanhã ou faça upgrade do seu plano.",
+ "providerRateLimited": "Seu provedor de transcrição limitou a solicitação. Aguarde um momento e tente novamente."
}
},
"clipboard": {
diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json
index 2255892ff..75ab7e23e 100644
--- a/src/locales/ru/translation.json
+++ b/src/locales/ru/translation.json
@@ -450,7 +450,8 @@
"errorTitles": {
"sessionExpired": "Сессия истекла",
"offline": "Нет подключения к интернету",
- "dailyLimitReached": "Дневной лимит достигнут"
+ "dailyLimitReached": "Дневной лимит достигнут",
+ "providerRateLimited": "Ограничение провайдера"
},
"fallback": {
"title": "Резервный режим",
@@ -463,7 +464,8 @@
"errorDescriptions": {
"sessionExpired": "Сессия OpenWhispr Cloud недоступна. Войдите снова из Настроек.",
"offline": "Вы офлайн. Облачная транскрипция требует подключения к интернету.",
- "dailyLimitReached": "Достигнут дневной лимит транскрипций. Попробуйте завтра или обновите тариф."
+ "dailyLimitReached": "Достигнут дневной лимит транскрипций. Попробуйте завтра или обновите тариф.",
+ "providerRateLimited": "Ваш провайдер транскрипции ограничил запрос. Подождите немного и попробуйте снова."
}
},
"clipboard": {
diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json
index 2863ff5cf..8b73fdc32 100644
--- a/src/locales/zh-CN/translation.json
+++ b/src/locales/zh-CN/translation.json
@@ -450,7 +450,8 @@
"errorTitles": {
"sessionExpired": "会话已过期",
"offline": "你已离线",
- "dailyLimitReached": "已达到每日上限"
+ "dailyLimitReached": "已达到每日上限",
+ "providerRateLimited": "服务商速率限制"
},
"fallback": {
"title": "回退模式",
@@ -463,7 +464,8 @@
"errorDescriptions": {
"sessionExpired": "OpenWhispr Cloud 会话不可用。请到「设置」中重新登录。",
"offline": "你目前离线。云端转录需要互联网连接。",
- "dailyLimitReached": "已达今日转录上限。请明天再试或升级你的套餐。"
+ "dailyLimitReached": "已达今日转录上限。请明天再试或升级你的套餐。",
+ "providerRateLimited": "你的转录服务商限制了请求频率。请稍候再试。"
}
},
"clipboard": {
diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json
index f495b9617..ecd4886bf 100644
--- a/src/locales/zh-TW/translation.json
+++ b/src/locales/zh-TW/translation.json
@@ -450,7 +450,8 @@
"errorTitles": {
"sessionExpired": "工作階段已過期",
"offline": "你目前離線",
- "dailyLimitReached": "已達每日上限"
+ "dailyLimitReached": "已達每日上限",
+ "providerRateLimited": "服務商速率限制"
},
"fallback": {
"title": "備援模式",
@@ -463,7 +464,8 @@
"errorDescriptions": {
"sessionExpired": "OpenWhispr Cloud 工作階段無法使用。請至「設定」重新登入。",
"offline": "你目前離線。雲端轉錄需要網際網路連線。",
- "dailyLimitReached": "已達今日的轉錄上限。請明天再試或升級你的方案。"
+ "dailyLimitReached": "已達今日的轉錄上限。請明天再試或升級你的方案。",
+ "providerRateLimited": "你的轉錄服務商限制了請求頻率。請稍候再試。"
}
},
"clipboard": {
diff --git a/src/types/electron.ts b/src/types/electron.ts
index 4039c2f3d..47e7f9bde 100644
--- a/src/types/electron.ts
+++ b/src/types/electron.ts
@@ -14,6 +14,7 @@ export type TranscriptionErrorCode =
| "AUTH_EXPIRED"
| "AUTH_REQUIRED"
| "LIMIT_REACHED"
+ | "PROVIDER_RATE_LIMITED"
| "API_KEY_MISSING"
| "INVALID_KEY"
| "MODEL_NOT_AVAILABLE"
diff --git a/src/utils/recordingErrors.ts b/src/utils/recordingErrors.ts
index 7ad3ac020..97e2b9edd 100644
--- a/src/utils/recordingErrors.ts
+++ b/src/utils/recordingErrors.ts
@@ -15,6 +15,8 @@ export function getRecordingErrorTitle(error: RecordingError, t: TFunction): str
if (error.code === "OFFLINE") return t("hooks.audioRecording.errorTitles.offline");
if (error.code === "LIMIT_REACHED")
return t("hooks.audioRecording.errorTitles.dailyLimitReached");
+ if (error.code === "PROVIDER_RATE_LIMITED")
+ return t("hooks.audioRecording.errorTitles.providerRateLimited");
return error.title;
}