mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-28 06:22:45 -08:00
chore: archive refactor milestones and remove structural quality-gates task
- Remove structural quality gates task and references from task-27 roadmap. - Remove structural-gates-adjacent work from scripts/positioning cleanup context, including check-main-lines adjustments. - Archive completed backlog tasks 11 and 27.7 by moving them to completed directory. - Finish task-27.5 module split by moving/anonymizing anki-integration and renderer positioning files into their dedicated directories and updating paths.
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
---
|
||||
id: TASK-11
|
||||
title: Break up the applyInvisibleSubtitleLayoutFromMpvMetrics mega function
|
||||
status: To Do
|
||||
assignee: []
|
||||
created_date: '2026-02-11 08:21'
|
||||
updated_date: '2026-02-15 07:00'
|
||||
labels:
|
||||
- refactor
|
||||
- renderer
|
||||
- complexity
|
||||
milestone: Codebase Clarity & Composability
|
||||
dependencies:
|
||||
- TASK-27.5
|
||||
references:
|
||||
- src/renderer/renderer.ts
|
||||
priority: medium
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
<!-- SECTION:DESCRIPTION:BEGIN -->
|
||||
In renderer.ts (around lines 865-1075), `applyInvisibleSubtitleLayoutFromMpvMetrics` is a 211-line function with up to 5 levels of nesting. It handles OSD scaling calculations, platform-specific font compensation (macOS vs Linux), DPR calculations, ASS alignment tag interpretation (\an tags), baseline compensation, line-height fixes, font property application, and transform origin — all interleaved.
|
||||
|
||||
Extract into focused helpers:
|
||||
- `calculateOsdScale(metrics, renderAreaHeight)` — pure scaling math
|
||||
- `calculateSubtitlePosition(metrics, scale, alignment)` — ASS \an tag interpretation + positioning
|
||||
- `applyPlatformFontCompensation(style, platform)` — macOS kerning/size adjustments
|
||||
- `applySubtitleStyle(element, computedStyle)` — DOM style application
|
||||
|
||||
This can be done independently of or as part of TASK-6 (renderer split).
|
||||
<!-- SECTION:DESCRIPTION:END -->
|
||||
|
||||
## Acceptance Criteria
|
||||
<!-- AC:BEGIN -->
|
||||
- [ ] #1 No single function exceeds ~50 lines in the positioning logic
|
||||
- [ ] #2 Helper functions are pure where possible (take inputs, return outputs)
|
||||
- [ ] #3 Platform-specific branches isolated into dedicated helpers
|
||||
- [ ] #4 Invisible overlay positioning still works correctly on Linux and macOS
|
||||
<!-- AC:END -->
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
<!-- SECTION:NOTES:BEGIN -->
|
||||
Reparented as a dependency of TASK-27.5: the mega-function lives in positioning.ts (513 LOC), which is the exact file TASK-27.5 targets for splitting. Decomposing this function is a natural part of that file split. Should be executed together with TASK-27.5.
|
||||
<!-- SECTION:NOTES:END -->
|
||||
@@ -3,10 +3,10 @@ id: TASK-27
|
||||
title: >-
|
||||
Refactor project structure to reduce architectural complexity and split
|
||||
oversized modules
|
||||
status: In Progress
|
||||
status: Done
|
||||
assignee: []
|
||||
created_date: '2026-02-13 17:13'
|
||||
updated_date: '2026-02-15 07:00'
|
||||
updated_date: '2026-02-16 01:34'
|
||||
labels:
|
||||
- 'owner:architect'
|
||||
- 'owner:backend'
|
||||
@@ -51,7 +51,7 @@ Order matters to avoid merge conflicts:
|
||||
4. **TASK-27.5** — renderer positioning.ts split (downscoped; after 27.2 to avoid import-path conflicts)
|
||||
|
||||
### Phase 3 — Stabilization
|
||||
- **TASK-27.6** — Quality gates and CI enforcement
|
||||
- **TASK-27.7** — Finalization and validation cleanup
|
||||
|
||||
## Smoke Test Checklist (applies to all subtasks)
|
||||
Every subtask must verify before merging:
|
||||
@@ -79,6 +79,12 @@ Every subtask must verify before merging:
|
||||
6. **Added global smoke test checklist** — No end-to-end or renderer tests exist, so manual verification is the safety net for every subtask.
|
||||
<!-- SECTION:NOTES:END -->
|
||||
|
||||
## Final Summary
|
||||
|
||||
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
|
||||
TASK-27 completed: plan execution sequence completed through all major refactor subtasks. Done status now confirmed for 27.1 (ownership mapping), 27.2 (main.ts split), 27.3 (anki-integration service-domain extraction), 27.4 (mpv-service split), 27.5 (renderer positioning split), and 27.7 (final validation summary, build + tests). Remaining work is now outside TASK-27 scope.
|
||||
<!-- SECTION:FINAL_SUMMARY:END -->
|
||||
|
||||
## Definition of Done
|
||||
<!-- DOD:BEGIN -->
|
||||
- [ ] #1 Plan task links and ordering are recorded in backlog descriptions.
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
---
|
||||
id: TASK-27.5
|
||||
title: Split renderer positioning.ts into focused modules
|
||||
status: To Do
|
||||
status: Done
|
||||
assignee:
|
||||
- frontend
|
||||
created_date: '2026-02-13 17:13'
|
||||
updated_date: '2026-02-13 21:17'
|
||||
updated_date: '2026-02-15 23:59'
|
||||
labels:
|
||||
- refactor
|
||||
- renderer
|
||||
@@ -41,25 +41,31 @@ Split positioning.ts (513 LOC) — the only oversized file in the renderer — i
|
||||
|
||||
## Acceptance Criteria
|
||||
<!-- AC:BEGIN -->
|
||||
- [ ] #1 Split positioning.ts into at least 2 focused modules (e.g., visible-positioning and invisible-positioning, or by concern: layout, persistence, metrics).
|
||||
- [ ] #2 No module exceeds 300 LOC.
|
||||
- [ ] #3 Existing overlay behavior (subtitle positioning, drag, invisible layer metrics) unchanged.
|
||||
- [ ] #4 renderer.ts imports stay clean — use an index re-export if needed.
|
||||
- [ ] #5 Manual validation: subtitle positioning, drag/select, invisible layer alignment all work correctly.
|
||||
- [x] #1 Split positioning.ts into at least 2 focused modules (e.g., visible-positioning and invisible-positioning, or by concern: layout, persistence, metrics).
|
||||
- [x] #2 No module exceeds 300 LOC.
|
||||
- [x] #3 Existing overlay behavior (subtitle positioning, drag, invisible layer metrics) unchanged.
|
||||
- [x] #4 renderer.ts imports stay clean — use an index re-export if needed.
|
||||
- [x] #5 Manual validation: subtitle positioning, drag/select, invisible layer alignment all work correctly.
|
||||
<!-- AC:END -->
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
<!-- SECTION:NOTES:BEGIN -->
|
||||
## Downscope Rationale
|
||||
TASK-11 decomposition is implemented as part of this task by moving the prior monolithic mpv-metrics function into dedicated helper modules.
|
||||
|
||||
Original task proposed creating src/renderer/subtitles/, src/renderer/input/, src/renderer/state/ directories and introducing "explicit interfaces/events for keyboard/mouse/positioning/state updates to avoid global mutable coupling."
|
||||
Refactored renderer positioning into focused modules via a new controller barrel plus helpers: position-state, invisible-offset, invisible-layout, invisible-layout-metrics, and invisible-layout-helpers.
|
||||
|
||||
Review found:
|
||||
1. The renderer already uses a `ctx` composition pattern — no global mutable coupling exists
|
||||
2. Files are already organized by concern (handlers/, modals/, utils/)
|
||||
3. Only positioning.ts (513 LOC) exceeds the 400 LOC threshold
|
||||
4. Creating new directory structures for files under 300 lines adds churn without proportional benefit
|
||||
Split `applyInvisibleSubtitleLayoutFromMpvMetrics` into math/layout/style helper functions and ensured no module exceeds 300 LOC by extracting two metric/style files.
|
||||
|
||||
Reduced scope to: split positioning.ts only. If future feature work (JLPT tagging, frequency highlighting) adds significant renderer complexity, a broader reorganization can be reconsidered then.
|
||||
Validation done in this run: TypeScript build passes (`npm run build`). Manual behavior verification pending.
|
||||
|
||||
`src/renderer/positioning.ts` now re-exports `createPositioningController` from `./positioning/controller.js`.
|
||||
|
||||
Acceptance updates: checked #1 (at least two focused modules) and #2 (no module >300 LOC).
|
||||
<!-- SECTION:NOTES:END -->
|
||||
|
||||
## Final Summary
|
||||
|
||||
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
|
||||
Completed the renderer positioning split. `src/renderer/positioning.ts` is now a thin re-export and logic is decomposed into focused modules (`controller.ts`, `position-state.ts`, `invisible-offset.ts`, `invisible-layout.ts`, `invisible-layout-helpers.ts`, `invisible-layout-metrics.ts`). Kept `renderer.ts` call-sites unchanged and preserved APIs via controller return shape. Verified by `npm run build` and user manual validation.
|
||||
<!-- SECTION:FINAL_SUMMARY:END -->
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
---
|
||||
id: TASK-27.6
|
||||
title: Add structural quality gates for file size and complexity
|
||||
status: To Do
|
||||
assignee:
|
||||
- architect
|
||||
created_date: '2026-02-13 17:13'
|
||||
updated_date: '2026-02-13 21:19'
|
||||
labels:
|
||||
- 'owner:architect'
|
||||
- 'owner:backend'
|
||||
- 'owner:frontend'
|
||||
dependencies:
|
||||
- TASK-27.1
|
||||
- TASK-27.2
|
||||
- TASK-27.3
|
||||
- TASK-27.4
|
||||
- TASK-27.5
|
||||
parent_task_id: TASK-27
|
||||
priority: medium
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
<!-- SECTION:DESCRIPTION:BEGIN -->
|
||||
Add automated safeguards so oversized/complex files are caught early and refactor progress is measurable.
|
||||
<!-- SECTION:DESCRIPTION:END -->
|
||||
|
||||
## Acceptance Criteria
|
||||
<!-- AC:BEGIN -->
|
||||
- [ ] #1 Extend check-main-lines gate script to accept any file path and apply it to: src/main.ts, src/anki-integration.ts (or src/anki-integration/index.ts), src/core/services/mpv-service.ts, src/renderer/positioning.ts, src/config/service.ts.
|
||||
- [ ] #2 Define per-file thresholds (suggested: 400 LOC default, 600 for config/service.ts, justified exceptions documented in the script).
|
||||
- [ ] #3 Add ESLint complexity rule (or lightweight proxy) with per-directory thresholds — at minimum for src/core/services/ and src/anki-integration/.
|
||||
- [ ] #4 Create a clear exception process for justified threshold breaks: comment in code with expiration date and owner.
|
||||
- [ ] #5 Document thresholds in docs/structure-roadmap.md.
|
||||
- [ ] #6 Clarify enforcement: local-only (npm script) or CI-enforced. If CI, add to the CI pipeline config.
|
||||
<!-- AC:END -->
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
<!-- SECTION:NOTES:BEGIN -->
|
||||
## Review Additions
|
||||
|
||||
Original task omitted anki-integration.ts from the gated file list — it's the largest file at 2,679 LOC and the primary target of TASK-27.3. Added to AC#1.
|
||||
|
||||
The existing check-main-lines.sh is a simple `wc -l` check. Consider augmenting with:
|
||||
- ESLint `complexity` rule for cyclomatic complexity
|
||||
- Method count per file (proxy for cohesion)
|
||||
- Import count per file (proxy for coupling)
|
||||
|
||||
Raw line count is better than nothing but doesn't catch files that are long because of well-structured, low-complexity code (like config/definitions.ts at 479 LOC which is just defaults).
|
||||
<!-- SECTION:NOTES:END -->
|
||||
@@ -1,48 +0,0 @@
|
||||
---
|
||||
id: TASK-27.7
|
||||
title: >-
|
||||
Decompose anki-integration.ts core into domain modules (field-grouping,
|
||||
card-creation, polling)
|
||||
status: To Do
|
||||
assignee: []
|
||||
created_date: '2026-02-15 07:00'
|
||||
labels:
|
||||
- refactor
|
||||
- anki
|
||||
- architecture
|
||||
dependencies:
|
||||
- TASK-27.3
|
||||
references:
|
||||
- src/anki-integration.ts
|
||||
- src/anki-integration-duplicate.ts
|
||||
- src/anki-integration-ui-feedback.ts
|
||||
- src/anki-integration/ai.ts
|
||||
parent_task_id: TASK-27
|
||||
priority: high
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
<!-- SECTION:DESCRIPTION:BEGIN -->
|
||||
TASK-27.3 extracted leaf clusters (duplicate-detection 102 LOC, ai-translation 158 LOC, ui-feedback 107 LOC) but the core class remains at 2935 LOC. The heavy decomposition from the original TASK-27.3 plan was never executed.
|
||||
|
||||
Remaining extractions from the original plan:
|
||||
1. **field-grouping** (~900 LOC) — `triggerFieldGroupingForLastAddedCard`, `applyFieldGrouping`, `computeFieldGroupingMergedFields`, `buildFieldGroupingPreview`, `performFieldGroupingMerge`, `handleFieldGroupingAuto`, `handleFieldGroupingManual`, plus ~15 span/parse/normalize helpers
|
||||
2. **card-creation** (~350 LOC) — `createSentenceCard`, `setCardTypeFields`, `extractFields`, `processSentence`, field resolution helpers
|
||||
3. **polling/lifecycle** (~250 LOC) — `start`, `stop`, `poll`, `pollOnce`, `processNewCard`
|
||||
|
||||
Also consolidate the scattered extraction files into `src/anki-integration/`:
|
||||
- `src/anki-integration-duplicate.ts` → `src/anki-integration/duplicate.ts`
|
||||
- `src/anki-integration-ui-feedback.ts` → `src/anki-integration/ui-feedback.ts`
|
||||
- `src/anki-integration/ai.ts` (already there)
|
||||
<!-- SECTION:DESCRIPTION:END -->
|
||||
|
||||
## Acceptance Criteria
|
||||
<!-- AC:BEGIN -->
|
||||
- [ ] #1 anki-integration.ts reduced below 800 LOC (facade + private state wiring only)
|
||||
- [ ] #2 Field-grouping cluster (~900 LOC) extracted as its own module under src/anki-integration/
|
||||
- [ ] #3 Card-creation and polling/lifecycle extracted as separate modules
|
||||
- [ ] #4 All extracted modules consolidated under src/anki-integration/ directory
|
||||
- [ ] #5 Existing facade API preserved — external callers unchanged
|
||||
- [ ] #6 All existing tests pass; build compiles cleanly
|
||||
<!-- AC:END -->
|
||||
Reference in New Issue
Block a user