Files
SubMiner/backlog/tasks/task-7 - Extract-main.ts-global-state-into-an-AppState-container.md
2026-02-11 09:33:47 -08:00

1.5 KiB

id, title, status, assignee, created_date, labels, milestone, dependencies, references, priority
id title status assignee created_date labels milestone dependencies references priority
TASK-7 Extract main.ts global state into an AppState container To Do
2026-02-11 08:20
refactor
main
architecture
Codebase Clarity & Composability
src/main.ts
high

Description

main.ts has 30+ module-level let declarations holding all application state: mpvClient, yomitanExt, yomitanSettingsWindow, yomitanParserWindow, reconnectTimer, currentSubText, currentSubAssText, subtitlePosition, currentMediaPath, mecabTokenizer, keybindings, ankiIntegration, secondarySubMode, runtimeOptionsManager, overlayRuntimeInitialized, subsyncInProgress, shortcutsRegistered, etc.

These are mutated through closures from many different functions, making state changes hard to trace and impossible to test.

Consolidate into a typed AppState object (or small set of domain-specific state containers) that provides controlled access to state. This also enables passing state to services without building 50-property dependency objects.

Acceptance Criteria

  • #1 All mutable state consolidated into typed container(s)
  • #2 No bare let declarations at module scope for application state
  • #3 State access goes through the container rather than closures
  • #4 Dependency objects for services shrink significantly (reference the container instead)
  • #5 TypeScript compiles cleanly