mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-20 12:11:28 -07:00
fix: reduce prefetched subtitle annotation delay
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
---
|
||||
id: TASK-196
|
||||
title: Fix subtitle prefetch cache-key mismatch and active-cue window
|
||||
status: Done
|
||||
assignee: []
|
||||
created_date: '2026-03-18 16:05'
|
||||
labels: []
|
||||
dependencies: []
|
||||
references:
|
||||
- /home/sudacode/projects/japanese/SubMiner/src/core/services/subtitle-processing-controller.ts
|
||||
- /home/sudacode/projects/japanese/SubMiner/src/core/services/subtitle-prefetch.ts
|
||||
documentation: []
|
||||
priority: high
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
<!-- SECTION:DESCRIPTION:BEGIN -->
|
||||
Investigate and fix file-backed subtitle annotation latency where prefetch should warm upcoming lines but live playback still tokenizes each subtitle line. Likely causes: cache-key mismatch between parsed cue text and mpv `sub-text`, and priority-window selection skipping the currently active cue during mid-line starts/seeks.
|
||||
<!-- SECTION:DESCRIPTION:END -->
|
||||
|
||||
## Acceptance Criteria
|
||||
<!-- AC:BEGIN -->
|
||||
- [x] #1 Prefetched subtitle entries are reused when live subtitle text differs only by normalization details such as ASS `\N`, newline collapsing, or surrounding whitespace.
|
||||
- [x] #2 Priority-window selection includes the currently active cue when playback starts or seeks into the middle of a cue.
|
||||
- [x] #3 Regression tests cover the cache-hit normalization path and active-cue priority-window behavior.
|
||||
- [x] #4 Verification covers the touched prefetch/controller lane.
|
||||
<!-- AC:END -->
|
||||
|
||||
## Implementation Plan
|
||||
|
||||
<!-- SECTION:PLAN:BEGIN -->
|
||||
1. Add failing regression tests in `subtitle-processing-controller.test.ts` and `subtitle-prefetch.test.ts`.
|
||||
2. Normalize cache keys in the subtitle processing controller so prefetch/live paths share keys.
|
||||
3. Adjust prefetch priority-window selection to include the active cue.
|
||||
4. Run targeted tests, then SubMiner verification lane for touched files.
|
||||
<!-- SECTION:PLAN:END -->
|
||||
|
||||
## Outcome
|
||||
|
||||
<!-- SECTION:OUTCOME:BEGIN -->
|
||||
Normalized subtitle cache keys inside the processing controller so prefetched ASS/VTT/live subtitle text variants reuse the same cache entry, and changed priority-window selection to include the currently active cue based on cue end time. Added regression coverage for both paths and verified the change with the `core` lane.
|
||||
<!-- SECTION:OUTCOME:END -->
|
||||
@@ -0,0 +1,45 @@
|
||||
---
|
||||
id: TASK-197
|
||||
title: Eliminate per-line plain subtitle flash on prefetch cache hit
|
||||
status: Done
|
||||
assignee: []
|
||||
created_date: '2026-03-18 16:28'
|
||||
labels: []
|
||||
dependencies:
|
||||
- TASK-196
|
||||
references:
|
||||
- /home/sudacode/projects/japanese/SubMiner/src/core/services/subtitle-processing-controller.ts
|
||||
- /home/sudacode/projects/japanese/SubMiner/src/main/runtime/mpv-main-event-actions.ts
|
||||
- /home/sudacode/projects/japanese/SubMiner/src/main/runtime/mpv-main-event-main-deps.ts
|
||||
documentation: []
|
||||
priority: high
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
<!-- SECTION:DESCRIPTION:BEGIN -->
|
||||
Remove the remaining small per-line subtitle annotation delay after prefetch warmup by avoiding the unconditional plain-subtitle broadcast on mpv subtitle-change events when a cached annotated payload already exists.
|
||||
<!-- SECTION:DESCRIPTION:END -->
|
||||
|
||||
## Acceptance Criteria
|
||||
<!-- AC:BEGIN -->
|
||||
- [x] #1 On a subtitle cache hit, the mpv subtitle-change path can emit annotated subtitle payload synchronously instead of first broadcasting `tokens: null`.
|
||||
- [x] #2 Cache-miss behavior still preserves immediate plain-text subtitle display while async tokenization runs.
|
||||
- [x] #3 Regression tests cover the controller cache-consume path and the mpv subtitle-change handler cache-hit branch.
|
||||
- [x] #4 Verification covers the touched core/runtime lane.
|
||||
<!-- AC:END -->
|
||||
|
||||
## Implementation Plan
|
||||
|
||||
<!-- SECTION:PLAN:BEGIN -->
|
||||
1. Add failing tests for controller cache consumption and mpv subtitle-change immediate annotated emission.
|
||||
2. Add a controller method that consumes cached subtitle payload synchronously while updating internal latest/emitted state.
|
||||
3. Wire the mpv subtitle-change handler to use the immediate cached payload when present, falling back to the existing plain-text path on misses.
|
||||
4. Run focused tests and the cheapest sufficient verification lane.
|
||||
<!-- SECTION:PLAN:END -->
|
||||
|
||||
## Outcome
|
||||
|
||||
<!-- SECTION:OUTCOME:BEGIN -->
|
||||
Added `consumeCachedSubtitle` to the subtitle processing controller so cache hits can be claimed synchronously without reprocessing, then wired the mpv subtitle-change handler to emit cached annotated payloads immediately while preserving the existing plain-text fallback for misses. Verified with focused unit tests plus the `runtime-compat` lane.
|
||||
<!-- SECTION:OUTCOME:END -->
|
||||
@@ -0,0 +1,45 @@
|
||||
---
|
||||
id: TASK-199
|
||||
title: Forward launcher log level into mpv plugin script opts
|
||||
status: Done
|
||||
assignee: []
|
||||
created_date: '2026-03-18 21:16'
|
||||
labels: []
|
||||
dependencies:
|
||||
- TASK-198
|
||||
references:
|
||||
- /home/sudacode/projects/japanese/SubMiner/launcher/aniskip-metadata.ts
|
||||
- /home/sudacode/projects/japanese/SubMiner/launcher/mpv.ts
|
||||
- /home/sudacode/projects/japanese/SubMiner/launcher/main.test.ts
|
||||
- /home/sudacode/projects/japanese/SubMiner/launcher/aniskip-metadata.test.ts
|
||||
documentation: []
|
||||
priority: medium
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
<!-- SECTION:DESCRIPTION:BEGIN -->
|
||||
Make `subminer --log-level=debug ...` reach the mpv plugin auto-start path by forwarding the launcher log level into `--script-opts`, so plugin-started overlay and texthooker subprocesses inherit debug logging.
|
||||
<!-- SECTION:DESCRIPTION:END -->
|
||||
|
||||
## Acceptance Criteria
|
||||
<!-- AC:BEGIN -->
|
||||
- [x] #1 Launcher mpv playback includes `subminer-log_level=<level>` in `--script-opts` when a non-info CLI log level is used.
|
||||
- [x] #2 Detached idle mpv launch uses the same script-opt forwarding.
|
||||
- [x] #3 Regression tests cover launcher script-opt forwarding.
|
||||
<!-- AC:END -->
|
||||
|
||||
## Implementation Plan
|
||||
|
||||
<!-- SECTION:PLAN:BEGIN -->
|
||||
1. Add a failing launcher regression test that captures mpv argv and expects `subminer-log_level=debug` inside `--script-opts`.
|
||||
2. Extend the shared script-opt builder to accept launcher log level and emit `subminer-log_level` for non-info runs.
|
||||
3. Reuse that builder in both normal mpv playback and detached idle mpv launch.
|
||||
4. Run focused launcher tests and launcher-plugin verification.
|
||||
<!-- SECTION:PLAN:END -->
|
||||
|
||||
## Outcome
|
||||
|
||||
<!-- SECTION:OUTCOME:BEGIN -->
|
||||
Forwarded launcher log level into mpv plugin script opts via the shared builder and reused that builder for idle mpv launch. `subminer --log-level=debug ...` now gives the plugin `opts.log_level=debug`, so auto-started overlay and texthooker subprocesses include `--log-level debug` and the tokenizer timing logs can actually appear in the app log.
|
||||
<!-- SECTION:OUTCOME:END -->
|
||||
Reference in New Issue
Block a user