Files
SubMiner/backlog/tasks/task-27.5 - Split-renderer-positioning.ts-into-focused-modules.md
sudacode 3e445aee9e 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.
2026-02-15 17:48:08 -08:00

3.4 KiB

id, title, status, assignee, created_date, updated_date, labels, dependencies, references, documentation, parent_task_id, priority
id title status assignee created_date updated_date labels dependencies references documentation parent_task_id priority
TASK-27.5 Split renderer positioning.ts into focused modules Done
frontend
2026-02-13 17:13 2026-02-15 23:59
refactor
renderer
TASK-27.1
src/renderer/renderer.ts
src/renderer/subtitle-render.ts
src/renderer/positioning.ts
src/renderer/handlers/keyboard.ts
src/renderer/handlers/mouse.ts
docs/architecture.md
TASK-27 low

Description

Split positioning.ts (513 LOC) — the only oversized file in the renderer — into focused modules. The rest of the renderer structure is already well-organized and does not need reorganization.

Current Renderer State (already good)

  • renderer.ts (241 lines) — pure composition, well-factored
  • state.ts (132 lines), context.ts (14 lines), subtitle-render.ts (206 lines) — reasonable sizes
  • handlers/keyboard.ts (238 lines), handlers/mouse.ts (271 lines) — focused
  • modals/ — 4 modal implementations, each self-contained
  • Communication already uses explicit ctx pattern and function parameters, not globals

What Actually Needs Work

positioning.ts mixes visible overlay positioning, invisible overlay positioning, MPV subtitle render metrics layout, and position persistence. These are distinct concerns that should be separate modules.

Acceptance Criteria

  • #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.

Implementation Notes

TASK-11 decomposition is implemented as part of this task by moving the prior monolithic mpv-metrics function into dedicated helper modules.

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.

Split applyInvisibleSubtitleLayoutFromMpvMetrics into math/layout/style helper functions and ensured no module exceeds 300 LOC by extracting two metric/style files.

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).

Final Summary

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.