feat: add manual known-word cache refresh path

- Add CLI command flag  with non-GUI dispatch flow and OSD error handling.

- Add runtime integration call and IPC hook so manual refresh works from command runner without app startup.

- Add public AnkiIntegration manual refresh API with force refresh semantics and guard reuse.

- Preserve default n+1 behavior by fixing config validation for malformed  values and adding tests.
This commit is contained in:
2026-02-15 00:03:38 -08:00
parent fb20e1ca25
commit a1f196ee52
17 changed files with 315 additions and 23 deletions

View File

@@ -41,4 +41,9 @@ test("hasExplicitCommand and shouldStartApp preserve command intent", () => {
const noCommand = parseArgs(["--verbose"]);
assert.equal(hasExplicitCommand(noCommand), false);
assert.equal(shouldStartApp(noCommand), false);
const refreshKnownWords = parseArgs(["--refresh-known-words"]);
assert.equal(refreshKnownWords.help, false);
assert.equal(hasExplicitCommand(refreshKnownWords), true);
assert.equal(shouldStartApp(refreshKnownWords), false);
});

View File

@@ -16,6 +16,7 @@ export interface CliArgs {
mineSentence: boolean;
mineSentenceMultiple: boolean;
updateLastCardFromClipboard: boolean;
refreshKnownWords: boolean;
toggleSecondarySub: boolean;
triggerFieldGrouping: boolean;
triggerSubsync: boolean;
@@ -55,6 +56,7 @@ export function parseArgs(argv: string[]): CliArgs {
mineSentence: false,
mineSentenceMultiple: false,
updateLastCardFromClipboard: false,
refreshKnownWords: false,
toggleSecondarySub: false,
triggerFieldGrouping: false,
triggerSubsync: false,
@@ -100,6 +102,7 @@ export function parseArgs(argv: string[]): CliArgs {
else if (arg === "--mine-sentence-multiple") args.mineSentenceMultiple = true;
else if (arg === "--update-last-card-from-clipboard")
args.updateLastCardFromClipboard = true;
else if (arg === "--refresh-known-words") args.refreshKnownWords = true;
else if (arg === "--toggle-secondary-sub") args.toggleSecondarySub = true;
else if (arg === "--trigger-field-grouping")
args.triggerFieldGrouping = true;
@@ -181,6 +184,7 @@ export function hasExplicitCommand(args: CliArgs): boolean {
args.mineSentence ||
args.mineSentenceMultiple ||
args.updateLastCardFromClipboard ||
args.refreshKnownWords ||
args.toggleSecondarySub ||
args.triggerFieldGrouping ||
args.triggerSubsync ||

View File

@@ -17,4 +17,5 @@ test("printHelp includes configured texthooker port", () => {
assert.match(output, /--help\s+Show this help/);
assert.match(output, /default: 7777/);
assert.match(output, /--refresh-known-words/);
});

View File

@@ -18,8 +18,9 @@ SubMiner CLI commands:
--copy-subtitle-multiple Start multi-copy mode
--mine-sentence Mine sentence card from current subtitle
--mine-sentence-multiple Start multi-mine sentence mode
--update-last-card-from-clipboard Update last card from clipboard
--toggle-secondary-sub Cycle secondary subtitle mode
--update-last-card-from-clipboard Update last card from clipboard
--refresh-known-words Refresh known words cache now
--toggle-secondary-sub Cycle secondary subtitle mode
--trigger-field-grouping Trigger Kiku field grouping
--trigger-subsync Run subtitle sync
--mark-audio-card Mark last card as audio card