From efb7e9db97c384fb1e33193d0041ec68d1d65712 Mon Sep 17 00:00:00 2001 From: sudacode Date: Tue, 9 Jun 2026 00:44:28 -0700 Subject: [PATCH] fix(anki): honor runtime AnkiConnect URL override in Open in Anki fallba - Use getEffectiveAnkiConnectConfig for fallback client URL resolution - Fall back to DEFAULT_CONFIG.ankiConnect.url when effective URL is unset --- changes/overlay-notifications.md | 1 + src/main.ts | 8 +++++++- src/main/main-wiring.test.ts | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/changes/overlay-notifications.md b/changes/overlay-notifications.md index 17c4b902..e8938d0a 100644 --- a/changes/overlay-notifications.md +++ b/changes/overlay-notifications.md @@ -14,6 +14,7 @@ breaking: true - Updated repeated progress notifications such as subsync syncing in place so their spinner stays live instead of flickering on every tick. - Fixed mined-card overlay notifications so `overlay` and `both` modes show generated card thumbnails in both live cards and the notification history panel. - Added Open in Anki buttons to mined-card overlay notifications and their history entries, with a direct AnkiConnect fallback when the live integration is unavailable. +- Fixed those Open in Anki buttons so their fallback honors runtime AnkiConnect URL overrides and the default AnkiConnect endpoint. - Added an Update button to overlay update-available notifications so users can start the app update flow from the notification. - Fixed sentence-card mining so the Ctrl+S flow shows only the Anki update progress notification instead of also stacking a generic SubMiner toast. - Fixed overlay notification layering so notification close/actions stay clickable above subtitle bars on Linux overlays. diff --git a/src/main.ts b/src/main.ts index 048d6b94..13a4ce6a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3488,7 +3488,13 @@ async function openAnkiCardFromNotification(noteId: number): Promise { return; } - const fallbackClient = new AnkiConnectClient(getResolvedConfig().ankiConnect.url); + const resolvedConfig = getResolvedConfig(); + const effectiveAnkiConfig = + appState.runtimeOptionsManager?.getEffectiveAnkiConnectConfig(resolvedConfig.ankiConnect) ?? + resolvedConfig.ankiConnect; + const fallbackClient = new AnkiConnectClient( + effectiveAnkiConfig.url || DEFAULT_CONFIG.ankiConnect.url, + ); await fallbackClient.openNoteInBrowser(noteId); } diff --git a/src/main/main-wiring.test.ts b/src/main/main-wiring.test.ts index 9d90dbec..b33030e0 100644 --- a/src/main/main-wiring.test.ts +++ b/src/main/main-wiring.test.ts @@ -174,7 +174,8 @@ test('update overlay notification action triggers install flow', () => { assert.match(source, /installWhenAvailable:\s*true/); assert.match(source, /actionId === OPEN_ANKI_CARD_ACTION_ID && noteId !== undefined/); assert.match(source, /appState\.ankiIntegration\?\.openNoteInAnki\(noteId\)/); - assert.match(source, /new AnkiConnectClient\(getResolvedConfig\(\)\.ankiConnect\.url/); + assert.match(source, /appState\.runtimeOptionsManager\?\.getEffectiveAnkiConnectConfig/); + assert.match(source, /new AnkiConnectClient\(\s*effectiveAnkiConfig\.url \|\| DEFAULT_CONFIG\.ankiConnect\.url/); assert.match(source, /fallbackClient\.openNoteInBrowser\(noteId\)/); });