fix(anki): regenerate sentence furigana when mined context changes

- Regenerate SentenceFurigana from the final sentence after timing-review expansion or stats-dashboard word mining
- Add a Yomitan parseText-based generator with a 10s timeout and escaped, highlighted output
- Clear stale furigana on failure so templates fall back to Sentence
- Keep existing furigana formatting when the sentence is unchanged
- Document the behavior in the anki-integration and immersion-tracking docs
This commit is contained in:
2026-09-22 21:46:06 -07:00
16 changed files with 489 additions and 18 deletions
+3
View File
@@ -1,3 +1,4 @@
import { generateSentenceFurigana } from '../../core/services/tokenizer/sentence-furigana';
import path from 'node:path';
import type { BrowserWindow } from 'electron';
import {
@@ -169,6 +170,8 @@ export function createStatsServerRuntime(deps: StatsServerRuntimeDeps): {
}),
resolveAnkiNoteId: (noteId: number) => deps.resolveAnkiNoteId(noteId),
resolveSentenceSearchHeadwords: (term: string) => deps.resolveSentenceSearchHeadwords(term),
generateSentenceFurigana: (text, highlightedText) =>
generateSentenceFurigana(text, highlightedText, yomitanDeps, yomitanLogger),
addYomitanNote: async (word: string) => {
const ankiConnectConfig = deps.getResolvedConfig().ankiConnect;
const ankiUrl = getPreferredYomitanAnkiServerUrl(ankiConnectConfig);