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: Refresh-token rotation race, provider filter and other cleanups
Chadpihaf23c8f8c5958
diff --git a/src/components/IntegrationsView.tsx b/src/components/IntegrationsView.tsxindex e30dadcf6..de3422e31 100644--- a/src/components/IntegrationsView.tsx+++ b/src/components/IntegrationsView.tsx@@ -183,6 +183,8 @@ export default function IntegrationsView({ isPaid, onUpgrade }: IntegrationsViewconst [appleSourceNames, setAppleSourceNames] = useState<string[]>([]);const [confirmAppleDisconnect, setConfirmAppleDisconnect] = useState(false);const [appleConnectError, setAppleConnectError] = useState<"denied" | "failed" | null>(null);+ // i18n prefix of the provider whose OAuth flow failed, e.g. "integrations.googleCalendar"+ const [oauthErrorKey, setOauthErrorKey] = useState<string | null>(null);const [apiKeysDialogOpen, setApiKeysDialogOpen] = useState(false);const systemAudio = useSystemAudioPermission();const { request: requestSystemAudioAccess } = systemAudio;@@ -200,6 +202,9 @@ export default function IntegrationsView({ isPaid, onUpgrade }: IntegrationsView...current.filter((a) => a.email !== result.email),{ email: result.email },]);+ } else if (!result?.error?.includes("access_denied")) {+ // access_denied means the user cancelled on the consent screen+ setOauthErrorKey("integrations.googleCalendar");}} finally {setIsConnecting(false);@@ -216,6 +221,8 @@ export default function IntegrationsView({ isPaid, onUpgrade }: IntegrationsView...current.filter((a) => a.email !== result.email),{ email: result.email },]);+ } else if (!result?.error?.includes("access_denied")) {+ setOauthErrorKey("integrations.microsoftCalendar");}} finally {setIsMsConnecting(false);@@ -574,6 +581,14 @@ export default function IntegrationsView({ isPaid, onUpgrade }: IntegrationsViewdescription={t("integrations.appleCalendar.connectFailedDescription")}onOk={() => {}}/>++ <AlertDialog+ open={!!oauthErrorKey}+ onOpenChange={(open) => !open && setOauthErrorKey(null)}+ title={oauthErrorKey ? t(`${oauthErrorKey}.connectFailed`) : ""}+ description={oauthErrorKey ? t(`${oauthErrorKey}.connectFailedDescription`) : ""}+ onOk={() => {}}+ /></div>);}diff --git a/src/helpers/database.js b/src/helpers/database.jsindex 14a52242e..a7e6df988 100644--- a/src/helpers/database.js+++ b/src/helpers/database.js@@ -3187,7 +3187,9 @@ class DatabaseManager {if (calendarIds.length > 0) {const placeholders = calendarIds.map(() => "?").join(", ");this.db- .prepare(`DELETE FROM calendar_events WHERE calendar_id IN (${placeholders})`)+ .prepare(+ `DELETE FROM calendar_events WHERE provider = 'google' AND calendar_id IN (${placeholders})`+ ).run(...calendarIds);}this.db.prepare("DELETE FROM google_calendars WHERE account_email = ?").run(email);@@ -3639,7 +3641,9 @@ class DatabaseManager {if (calendarIds.length > 0) {const placeholders = calendarIds.map(() => "?").join(", ");this.db- .prepare(`DELETE FROM calendar_events WHERE calendar_id IN (${placeholders})`)+ .prepare(+ `DELETE FROM calendar_events WHERE provider = 'microsoft' AND calendar_id IN (${placeholders})`+ ).run(...calendarIds);}this.db.prepare("DELETE FROM microsoft_calendars WHERE account_email = ?").run(email);@@ -3655,7 +3659,7 @@ class DatabaseManager {}}- saveMicrosoftCalendars(calendars, accountEmail = null) {+ saveMicrosoftCalendars(calendars, accountEmail) {try {if (!this.db) throw new Error("Database not initialized");const stmt = this.db.prepare(diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex a3293f16b..9a8791b81 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -9049,6 +9049,11 @@ class IPCHandlers {try {return this.microsoftCalendarManager.getConnectionStatus();} catch (error) {+ debugLogger.error(+ "Microsoft Calendar connection status failed",+ { error: error.message },+ "calendar"+ );return { connected: false, accounts: [] };}});diff --git a/src/helpers/microsoftCalendarOAuth.js b/src/helpers/microsoftCalendarOAuth.jsindex 4ceb9e155..7f808e18c 100644--- a/src/helpers/microsoftCalendarOAuth.js+++ b/src/helpers/microsoftCalendarOAuth.js@@ -13,6 +13,7 @@ const CALENDAR_SCOPE =class MicrosoftCalendarOAuth {constructor(databaseManager) {this.databaseManager = databaseManager;+ this._refreshInFlight = new Map();}getClientId() {@@ -20,6 +21,11 @@ class MicrosoftCalendarOAuth {}startOAuthFlow() {+ if (!this.getClientId()) {+ // Fail fast instead of opening the browser on a client_id=undefined URL+ // and hanging until the loopback flow times out.+ throw new Error("MICROSOFT_CALENDAR_CLIENT_ID is not configured");+ }return runOAuthLoopbackFlow({errorParam: "mcal_error",buildAuthUrl: (redirectUri, state, codeChallenge) => {@@ -89,24 +95,37 @@ class MicrosoftCalendarOAuth {if (!tokens) throw new Error(`No Microsoft tokens found for ${accountEmail}`);const fiveMinutes = 5 * 60 * 1000;- if (tokens.expires_at - fiveMinutes < Date.now()) {- const refreshed = await this.refreshAccessToken(tokens.refresh_token);- if (refreshed.error) {- throw new Error(`Token refresh failed: ${refreshed.error_description || refreshed.error}`);- }-- // Microsoft rotates refresh tokens on every refresh; persist the new one- // or the old refresh token stops working within 24h.- this._saveTokens(tokens.microsoft_email, {- ...refreshed,- refresh_token: refreshed.refresh_token || tokens.refresh_token,- scope: refreshed.scope || tokens.scope,+ if (tokens.expires_at - fiveMinutes >= Date.now()) {+ return tokens.access_token;+ }++ // Microsoft rotates refresh tokens on every refresh, so concurrent+ // refreshes (focus sync racing the interval sync) would persist competing+ // rotations; share one in-flight refresh per account instead.+ let refreshPromise = this._refreshInFlight.get(accountEmail);+ if (!refreshPromise) {+ refreshPromise = this._refreshAndSaveTokens(tokens).finally(() => {+ this._refreshInFlight.delete(accountEmail);});+ this._refreshInFlight.set(accountEmail, refreshPromise);+ }+ return refreshPromise;+ }- return refreshed.access_token;+ async _refreshAndSaveTokens(tokens) {+ const refreshed = await this.refreshAccessToken(tokens.refresh_token);+ if (refreshed.error) {+ throw new Error(`Token refresh failed: ${refreshed.error_description || refreshed.error}`);}- return tokens.access_token;+ // Persist the rotated refresh token or the old one stops working within 24h.+ this._saveTokens(tokens.microsoft_email, {+ ...refreshed,+ refresh_token: refreshed.refresh_token || tokens.refresh_token,+ scope: refreshed.scope || tokens.scope,+ });++ return refreshed.access_token;}_saveTokens(email, tokenData) {diff --git a/src/locales/de/translation.json b/src/locales/de/translation.jsonindex f89456d0e..85b7efa4e 100644--- a/src/locales/de/translation.json+++ b/src/locales/de/translation.json@@ -3179,7 +3179,9 @@"disconnectDescription": "Besprechungsnotizen werden von diesem Kalender nicht mehr aufgezeichnet.","systemAudioRequired": "Systemaudio-Berechtigung erforderlich","systemAudioDescription": "Zum Transkribieren von Meetings benötigt OpenWhispr die Systemaudio-Berechtigung, um den Ton anderer Teilnehmer aufzunehmen. Wir nehmen Ihren Bildschirm nie auf. Sie werden zu den Systemeinstellungen weitergeleitet, um diese zu aktivieren.",- "openSettings": "Systemeinstellungen öffnen"+ "openSettings": "Systemeinstellungen öffnen",+ "connectFailed": "Verbindung fehlgeschlagen",+ "connectFailedDescription": "Beim Verbinden mit Google Calendar ist ein Fehler aufgetreten. Bitte versuche es erneut."},"microsoftCalendar": {"title": "Microsoft Calendar",@@ -3192,7 +3194,9 @@"primaryOnlyDescription": "Termine aus mit dir geteilten Kalendern ignorieren.","disconnect": "Trennen","disconnectConfirm": "{{email}} trennen?",- "disconnectDescription": "Besprechungsnotizen werden von diesem Kalender nicht mehr aufgezeichnet."+ "disconnectDescription": "Besprechungsnotizen werden von diesem Kalender nicht mehr aufgezeichnet.",+ "connectFailed": "Verbindung fehlgeschlagen",+ "connectFailedDescription": "Beim Verbinden mit Microsoft Calendar ist ein Fehler aufgetreten. Bitte versuche es erneut."},"appleCalendar": {"title": "Apple Kalender",diff --git a/src/locales/en/translation.json b/src/locales/en/translation.jsonindex 9eb524e2b..d4c5ad8b5 100644--- a/src/locales/en/translation.json+++ b/src/locales/en/translation.json@@ -3179,7 +3179,9 @@"disconnectDescription": "Meeting notes will no longer be recorded from this calendar.","systemAudioRequired": "System Audio Permission Required","systemAudioDescription": "To transcribe meetings, OpenWhispr needs the System Audio permission to capture other participants' audio. We never record your screen. You'll be taken to System Settings to enable it.",- "openSettings": "Open System Settings"+ "openSettings": "Open System Settings",+ "connectFailed": "Connection Failed",+ "connectFailedDescription": "Something went wrong while connecting Google Calendar. Please try again."},"microsoftCalendar": {"title": "Microsoft Calendar",@@ -3192,7 +3194,9 @@"primaryOnlyDescription": "Ignore events from calendars shared with you.","disconnect": "Disconnect","disconnectConfirm": "Disconnect {{email}}?",- "disconnectDescription": "Meeting notes will no longer be recorded from this calendar."+ "disconnectDescription": "Meeting notes will no longer be recorded from this calendar.",+ "connectFailed": "Connection Failed",+ "connectFailedDescription": "Something went wrong while connecting Microsoft Calendar. Please try again."},"appleCalendar": {"title": "Apple Calendar",diff --git a/src/locales/es/translation.json b/src/locales/es/translation.jsonindex 747283c4d..e8c86a979 100644--- a/src/locales/es/translation.json+++ b/src/locales/es/translation.json@@ -3079,7 +3079,9 @@"disconnectDescription": "Ya no se grabarán notas de reuniones de este calendario.","systemAudioRequired": "Se requiere permiso de Audio del Sistema","systemAudioDescription": "Para transcribir reuniones, OpenWhispr necesita el permiso de Audio del Sistema para capturar el audio de otros participantes. Nunca grabamos tu pantalla. Serás dirigido a Ajustes del Sistema para activarlo.",- "openSettings": "Abrir Ajustes del Sistema"+ "openSettings": "Abrir Ajustes del Sistema",+ "connectFailed": "Error de conexión",+ "connectFailedDescription": "Se produjo un error al conectar con Google Calendar. Inténtalo de nuevo."},"microsoftCalendar": {"title": "Microsoft Calendar",@@ -3092,7 +3094,9 @@"primaryOnlyDescription": "Ignorar los eventos de los calendarios compartidos contigo.","disconnect": "Desconectar","disconnectConfirm": "¿Desconectar {{email}}?",- "disconnectDescription": "Ya no se grabarán notas de reuniones de este calendario."+ "disconnectDescription": "Ya no se grabarán notas de reuniones de este calendario.",+ "connectFailed": "Error de conexión",+ "connectFailedDescription": "Se produjo un error al conectar con Microsoft Calendar. Inténtalo de nuevo."},"appleCalendar": {"title": "Calendario de Apple",diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.jsonindex d61cd9519..a915c3764 100644--- a/src/locales/fr/translation.json+++ b/src/locales/fr/translation.json@@ -3179,7 +3179,9 @@"disconnectDescription": "Les notes de réunion ne seront plus enregistrées depuis ce calendrier.","systemAudioRequired": "Autorisation Audio Système requise","systemAudioDescription": "Pour transcrire les réunions, OpenWhispr a besoin de l'autorisation Audio Système pour capturer l'audio des autres participants. Nous n'enregistrons jamais votre écran. Vous serez dirigé vers les Réglages Système pour l'activer.",- "openSettings": "Ouvrir les Réglages Système"+ "openSettings": "Ouvrir les Réglages Système",+ "connectFailed": "Échec de la connexion",+ "connectFailedDescription": "Une erreur s'est produite lors de la connexion à Google Calendar. Veuillez réessayer."},"microsoftCalendar": {"title": "Microsoft Calendar",@@ -3192,7 +3194,9 @@"primaryOnlyDescription": "Ignorer les événements des calendriers partagés avec vous.","disconnect": "Déconnecter","disconnectConfirm": "Déconnecter {{email}} ?",- "disconnectDescription": "Les notes de réunion ne seront plus enregistrées depuis ce calendrier."+ "disconnectDescription": "Les notes de réunion ne seront plus enregistrées depuis ce calendrier.",+ "connectFailed": "Échec de la connexion",+ "connectFailedDescription": "Une erreur s'est produite lors de la connexion à Microsoft Calendar. Veuillez réessayer."},"appleCalendar": {"title": "Calendrier Apple",diff --git a/src/locales/it/translation.json b/src/locales/it/translation.jsonindex 8466719b8..042235d5d 100644--- a/src/locales/it/translation.json+++ b/src/locales/it/translation.json@@ -3031,7 +3031,9 @@"disconnectDescription": "Le note delle riunioni non saranno più registrate da questo calendario.","systemAudioRequired": "Autorizzazione Audio di Sistema richiesta","systemAudioDescription": "Per trascrivere le riunioni, OpenWhispr necessita dell'autorizzazione Audio di Sistema per catturare l'audio degli altri partecipanti. Non registriamo mai il tuo schermo. Verrai reindirizzato alle Impostazioni di Sistema per attivarla.",- "openSettings": "Apri Impostazioni di Sistema"+ "openSettings": "Apri Impostazioni di Sistema",+ "connectFailed": "Connessione non riuscita",+ "connectFailedDescription": "Si è verificato un errore durante la connessione a Google Calendar. Riprova."},"microsoftCalendar": {"title": "Microsoft Calendar",@@ -3044,7 +3046,9 @@"primaryOnlyDescription": "Ignora gli eventi dei calendari condivisi con te.","disconnect": "Disconnetti","disconnectConfirm": "Disconnettere {{email}}?",- "disconnectDescription": "Le note delle riunioni non saranno più registrate da questo calendario."+ "disconnectDescription": "Le note delle riunioni non saranno più registrate da questo calendario.",+ "connectFailed": "Connessione non riuscita",+ "connectFailedDescription": "Si è verificato un errore durante la connessione a Microsoft Calendar. Riprova."},"appleCalendar": {"title": "Calendario Apple",diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.jsonindex 9c44ee73b..922a34b0a 100644--- a/src/locales/ja/translation.json+++ b/src/locales/ja/translation.json@@ -3031,7 +3031,9 @@"disconnectDescription": "このカレンダーからの会議メモは記録されなくなります。","systemAudioRequired": "システムオーディオの権限が必要です","systemAudioDescription": "会議を文字起こしするには、OpenWhispr に他の参加者の音声を録音するためのシステムオーディオの権限が必要です。画面を録画することはありません。システム設定に移動して有効にします。",- "openSettings": "システム設定を開く"+ "openSettings": "システム設定を開く",+ "connectFailed": "接続に失敗しました",+ "connectFailedDescription": "Google Calendar への接続中にエラーが発生しました。もう一度お試しください。"},"microsoftCalendar": {"title": "Microsoft カレンダー",@@ -3044,7 +3046,9 @@"primaryOnlyDescription": "共有されたカレンダーの予定は無視します。","disconnect": "切断","disconnectConfirm": "{{email}} を切断しますか?",- "disconnectDescription": "このカレンダーからの会議メモは記録されなくなります。"+ "disconnectDescription": "このカレンダーからの会議メモは記録されなくなります。",+ "connectFailed": "接続に失敗しました",+ "connectFailedDescription": "Microsoft Calendar への接続中にエラーが発生しました。もう一度お試しください。"},"appleCalendar": {"title": "Apple カレンダー",diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.jsonindex 53f798220..2922db01b 100644--- a/src/locales/pt/translation.json+++ b/src/locales/pt/translation.json@@ -3031,7 +3031,9 @@"disconnectDescription": "As notas de reunião não serão mais gravadas deste calendário.","systemAudioRequired": "Permissão de Áudio do Sistema Necessária","systemAudioDescription": "Para transcrever reuniões, o OpenWhispr precisa da permissão de Áudio do Sistema para capturar o áudio dos outros participantes. Nunca gravamos a sua tela. Você será levado às Configurações do Sistema para ativá-la.",- "openSettings": "Abrir Configurações do Sistema"+ "openSettings": "Abrir Configurações do Sistema",+ "connectFailed": "Falha na conexão",+ "connectFailedDescription": "Ocorreu um erro ao conectar ao Google Calendar. Tente novamente."},"microsoftCalendar": {"title": "Microsoft Calendar",@@ -3044,7 +3046,9 @@"primaryOnlyDescription": "Ignorar eventos de calendários compartilhados com você.","disconnect": "Desconectar","disconnectConfirm": "Desconectar {{email}}?",- "disconnectDescription": "As notas de reunião não serão mais gravadas deste calendário."+ "disconnectDescription": "As notas de reunião não serão mais gravadas deste calendário.",+ "connectFailed": "Falha na conexão",+ "connectFailedDescription": "Ocorreu um erro ao conectar ao Microsoft Calendar. Tente novamente."},"appleCalendar": {"title": "Calendário da Apple",diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.jsonindex 4f101ebde..673cbd2f2 100644--- a/src/locales/ru/translation.json+++ b/src/locales/ru/translation.json@@ -3061,7 +3061,9 @@"disconnectDescription": "Заметки встреч больше не будут записываться из этого календаря.","systemAudioRequired": "Требуется разрешение «Системное аудио»","systemAudioDescription": "Для транскрипции встреч OpenWhispr нужно разрешение «Системное аудио» для записи звука других участников. Мы никогда не записываем ваш экран. Вы будете перенаправлены в Системные настройки для включения.",- "openSettings": "Открыть Системные настройки"+ "openSettings": "Открыть Системные настройки",+ "connectFailed": "Ошибка подключения",+ "connectFailedDescription": "При подключении к Google Calendar произошла ошибка. Попробуйте снова."},"microsoftCalendar": {"title": "Microsoft Calendar",@@ -3074,7 +3076,9 @@"primaryOnlyDescription": "Игнорировать события из календарей, к которым вам открыли доступ.","disconnect": "Отключить","disconnectConfirm": "Отключить {{email}}?",- "disconnectDescription": "Заметки встреч больше не будут записываться из этого календаря."+ "disconnectDescription": "Заметки встреч больше не будут записываться из этого календаря.",+ "connectFailed": "Ошибка подключения",+ "connectFailedDescription": "При подключении к Microsoft Calendar произошла ошибка. Попробуйте снова."},"appleCalendar": {"title": "Календарь Apple",diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.jsonindex 68532c13b..6646698c6 100644--- a/src/locales/zh-CN/translation.json+++ b/src/locales/zh-CN/translation.json@@ -3031,7 +3031,9 @@"disconnectDescription": "将不再从此日历记录会议笔记。","systemAudioRequired": "需要系统音频权限","systemAudioDescription": "要转录会议,OpenWhispr 需要系统音频权限来录制其他参与者的音频。我们绝不会录制您的屏幕。您将被引导至系统设置以启用此权限。",- "openSettings": "打开系统设置"+ "openSettings": "打开系统设置",+ "connectFailed": "连接失败",+ "connectFailedDescription": "连接 Google Calendar 时出错。请重试。"},"microsoftCalendar": {"title": "Microsoft 日历",@@ -3044,7 +3046,9 @@"primaryOnlyDescription": "忽略他人共享给你的日历事件。","disconnect": "断开","disconnectConfirm": "断开 {{email}}?",- "disconnectDescription": "将不再从此日历记录会议笔记。"+ "disconnectDescription": "将不再从此日历记录会议笔记。",+ "connectFailed": "连接失败",+ "connectFailedDescription": "连接 Microsoft Calendar 时出错。请重试。"},"appleCalendar": {"title": "Apple 日历",diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.jsonindex fa47bf6d2..1e2782dc2 100644--- a/src/locales/zh-TW/translation.json+++ b/src/locales/zh-TW/translation.json@@ -3031,7 +3031,9 @@"disconnectDescription": "將不再從此日曆記錄會議筆記。","systemAudioRequired": "需要系統音訊權限","systemAudioDescription": "要轉錄會議,OpenWhispr 需要系統音訊權限來錄製其他參與者的音訊。我們絕不會錄製您的螢幕。您將被引導至系統設定以啟用此權限。",- "openSettings": "打開系統設定"+ "openSettings": "打開系統設定",+ "connectFailed": "連線失敗",+ "connectFailedDescription": "連線 Google Calendar 時發生錯誤。請再試一次。"},"microsoftCalendar": {"title": "Microsoft 日曆",@@ -3044,7 +3046,9 @@"primaryOnlyDescription": "忽略他人分享給你的日曆事件。","disconnect": "中斷連接","disconnectConfirm": "中斷 {{email}} 的連接?",- "disconnectDescription": "將不再從此日曆記錄會議筆記。"+ "disconnectDescription": "將不再從此日曆記錄會議筆記。",+ "connectFailed": "連線失敗",+ "connectFailedDescription": "連線 Microsoft Calendar 時發生錯誤。請再試一次。"},"appleCalendar": {"title": "Apple 日曆",