Files
SubMiner/backlog/tasks/task-320 - Refresh-current-subtitle-known-word-highlight-after-successful-mining.md
T

3.1 KiB

id, title, status, assignee, created_date, updated_date, labels, dependencies, priority
id title status assignee created_date updated_date labels dependencies priority
TASK-320 Refresh current subtitle known-word highlight after successful mining Done
Codex
2026-05-03 03:22 2026-05-03 03:29
bug
anki
subtitle-annotations
medium

Description

After a sentence card is mined successfully, the mined word is added to the known-word cache and future subtitle appearances render as known. The currently displayed subtitle must also be refreshed immediately so the mined word turns known-color without waiting for a later cue.

Acceptance Criteria

  • #1 Successful sentence-card mining refreshes the current displayed subtitle so newly mined known words render immediately.
  • #2 Unsuccessful/no-op mining does not refresh the current subtitle.
  • #3 Regression coverage verifies the successful and unsuccessful mining paths.

Implementation Plan

  1. Add a regression test around AnkiIntegration known-word cache appends: when mined note info changes known words, a callback fires.
  2. Make KnownWordCacheManager.appendFromNoteInfo report whether it changed the immediate known-word cache.
  3. Add an AnkiIntegration known-word-cache-updated callback and invoke it after successful immediate append.
  4. Wire main process callback to subtitleProcessingController.refreshCurrentSubtitle(appState.currentSubText), forcing active-line retokenization after popup/proxy or local mining updates the known-word cache.
  5. Add a changelog fragment and run targeted tests plus typecheck.

Implementation Notes

Implemented generic known-word-cache update notification instead of shortcut-only refresh. KnownWordCacheManager.appendFromNoteInfo now returns whether in-memory known words changed; AnkiIntegration notifies a callback after successful append. Main process wires that callback to subtitleProcessingController.refreshCurrentSubtitle(appState.currentSubText), forcing retokenization without using stale prefetch/cache data. Added regression coverage in anki-integration.test.ts.

Final Summary

Summary:

  • Added a known-word-cache update callback on AnkiIntegration and wired it in the main process to refresh the current subtitle after mined note info changes known words.
  • Made KnownWordCacheManager.appendFromNoteInfo report whether it changed the known-word cache, so refresh only happens after an actual immediate known-word append.
  • Added regression coverage proving mined note info updates known words and emits the update notification.

Verification:

  • bun test src/anki-integration.test.ts src/anki-integration/known-word-cache.test.ts src/main/runtime/anki-actions.test.ts src/main/runtime/anki-actions-main-deps.test.ts
  • bun run typecheck
  • bun run changelog:lint currently blocked by pre-existing invalid metadata in changes/319-interjection-annotation-filter.md.