mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-27 18:22:41 -08:00
chore(main): extract app lifecycle/startup builders into main modules
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
---
|
||||
id: TASK-27.1
|
||||
title: Map component ownership boundaries and migration path before file splitting
|
||||
status: To Do
|
||||
status: Done
|
||||
assignee:
|
||||
- backend
|
||||
created_date: '2026-02-13 17:13'
|
||||
updated_date: '2026-02-13 21:09'
|
||||
updated_date: '2026-02-14 08:43'
|
||||
labels:
|
||||
- refactor
|
||||
- documentation
|
||||
@@ -13,7 +13,7 @@ dependencies: []
|
||||
references:
|
||||
- docs/architecture.md
|
||||
documentation:
|
||||
- docs/architecture.md
|
||||
- docs/structure-roadmap.md
|
||||
parent_task_id: TASK-27
|
||||
priority: high
|
||||
---
|
||||
@@ -43,4 +43,6 @@ This is a documentation-only task — no code changes. Its output (docs/structur
|
||||
Original task called for named maintainer owners per component, risk-gated migration sequences, and success metrics per slice. This is heavyweight for a solo project where the developer already knows the codebase intimately.
|
||||
|
||||
Reduced to: file inventory, API contracts, sequence + risks, and a shared smoke test checklist. The review analysis (in TASK-27 notes) already covers much of what this task would produce — this task captures it in a durable docs file.
|
||||
|
||||
Generated docs/structure-roadmap.md with file inventory, task-specific API contracts, split sequence, known risks, and smoke checklist to unlock TASK-27 subtasks.
|
||||
<!-- SECTION:NOTES:END -->
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
---
|
||||
id: TASK-27.2
|
||||
title: Split main.ts into composition-root modules
|
||||
status: To Do
|
||||
status: In Progress
|
||||
assignee:
|
||||
- backend
|
||||
created_date: '2026-02-13 17:13'
|
||||
updated_date: '2026-02-14 02:23'
|
||||
updated_date: '2026-02-14 09:41'
|
||||
labels:
|
||||
- 'owner:backend'
|
||||
- 'owner:architect'
|
||||
@@ -52,4 +52,24 @@ TASK-9 (remove trivial wrappers) and TASK-10 (naming conventions) have been depr
|
||||
- When main.ts is split into composition-root modules, trivial wrappers will naturally be eliminated or inlined at each module boundary.
|
||||
- Naming conventions should be standardized per-module as they are extracted, not as a separate global pass.
|
||||
Refer to TASK-9 and TASK-10 acceptance criteria as checklists during execution of this task.
|
||||
|
||||
Deferred until TASK-7 validation and TASK-27.3 completion to avoid import-order/state scattering during composition-root extraction.
|
||||
|
||||
Started `TASK-27.2` with a small composition-root extraction in `src/main.ts`: extracted `createMpvClientRuntimeService()` from inline `createMpvClient` deps object to reduce bootstrap-local complexity and prepare for module split (`main.ts` still owns state and startup sequencing remains unchanged).
|
||||
|
||||
Added `createCliCommandRuntimeServiceDeps()` helper in `src/main.ts` and routed `handleCliCommand` through it, preserving existing `createCliCommandDepsRuntimeService` wiring while reducing inline dependency composition churn.
|
||||
|
||||
Refactored `handleMpvCommandFromIpc` to use `createMpvCommandRuntimeServiceDeps()` helper, removing inline dependency object and keeping command dispatch behavior unchanged.
|
||||
|
||||
Added `createAppLifecycleRuntimeDeps()` helper in `src/main.ts` and moved the full inline app-lifecycle dependency graph into it, so startup wiring now delegates to `createAppLifecycleDepsRuntimeService(createAppLifecycleRuntimeDeps())` and the composition root is further decoupled from lifecycle behavior.
|
||||
|
||||
Extracted startup bootstrap composition in `src/main.ts` by adding `createStartupBootstrapRuntimeDeps()`, replacing the inline `runStartupBootstrapRuntimeService({...})` object with a factory for parse/startup logging/config/bootstrap wiring.
|
||||
|
||||
Fixed TS strict errors introduced by factory extractions by adding explicit runtime dependency interface annotations to factory helpers (`createStartupBootstrapRuntimeDeps`, `createAppLifecycleRuntimeDeps`, `createCliCommandRuntimeServiceDeps`, `createMpvCommandRuntimeServiceDeps`, `createMainIpcRuntimeServiceDeps`, `createAnkiJimakuIpcRuntimeServiceDeps`) and by typing `jimakuFetchJson` wrapper generically to satisfy `AnkiJimakuIpcRuntimeOptions`.
|
||||
|
||||
Extracted app-ready startup dependency object into `createAppReadyRuntimeDeps(): AppReadyRuntimeDeps`, moving the inline `runAppReadyRuntimeService({...})` payload out of `createAppLifecycleRuntimeDeps()` while preserving behavior.
|
||||
|
||||
Added `SubsyncRuntimeDeps` typing to `getSubsyncRuntimeDeps()` for clearer composition-root contracts around subsync IPC/dependency wiring (`runSubsyncManualFromIpcRuntimeService`/`triggerSubsyncFromConfigRuntimeService` path).
|
||||
|
||||
Extracted additional composition-root dependency composition for IPC command handlers into src/main/dependencies.ts: createCliCommandRuntimeServiceDeps(...) and createMpvCommandRuntimeServiceDeps(...). main.ts now inlines stateful callbacks into these shared builders while preserving behavior. Next step should be extracting startup/app-ready/lifecycle/overlay wiring into dedicated modules under src/main/.
|
||||
<!-- SECTION:NOTES:END -->
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
---
|
||||
id: TASK-27.4
|
||||
title: 'Split mpv-service.ts into protocol, transport, property, and facade layers'
|
||||
status: To Do
|
||||
status: In Progress
|
||||
assignee:
|
||||
- backend
|
||||
created_date: '2026-02-13 17:13'
|
||||
updated_date: '2026-02-13 21:15'
|
||||
updated_date: '2026-02-14 21:19'
|
||||
labels:
|
||||
- 'owner:backend'
|
||||
dependencies:
|
||||
@@ -61,4 +61,14 @@ TASK-27.4 is TASK-8 + physical file splitting. Running them as separate tasks wo
|
||||
|
||||
## Dependency Note
|
||||
Original plan listed TASK-8 as a dependency. Since TASK-8's scope is now absorbed here, the only remaining dependency is TASK-27.1 (inventory/contracts map).
|
||||
|
||||
Started prep: reviewed mpv-service coupling and prepared sequence for protocol/application split; no code split performed yet due current focus on keeping 27.2/27.3 sequencing compatible.
|
||||
|
||||
Known compatibility constraint: TASK-27.4 should proceed only after main.ts AppState migration is stable and after the app-level overlay/subsync/anki behavior contracts are preserved.
|
||||
|
||||
Milestone progress: extracted protocol buffer parsing into `src/core/services/mpv-protocol.ts`; `src/core/services/mpv-service.ts` now uses `splitMpvMessagesFromBuffer` in `processBuffer` and still delegates full message handling to existing handler. This is a small Phase B step toward protocol/dispatch separation.
|
||||
|
||||
Protocol extraction completed: full `MpvMessage` handling moved into `src/core/services/mpv-protocol.ts` via `splitMpvMessagesFromBuffer` + `dispatchMpvProtocolMessage`; `MpvIpcClient` now delegates all message parsing/dispatch through `MpvProtocolHandleMessageDeps` and resolves pending requests through `tryResolvePendingRequest`. `main.ts` wiring remains unchanged.
|
||||
|
||||
Updated `docs/structure-roadmap.md` expected mpv flow snapshot to reflect protocol parse/dispatch extraction (`splitMpvMessagesFromBuffer` + `dispatchMpvProtocolMessage`) and façade delegation path via `MpvProtocolHandleMessageDeps`.
|
||||
<!-- SECTION:NOTES:END -->
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
---
|
||||
id: TASK-7
|
||||
title: Extract main.ts global state into an AppState container
|
||||
status: To Do
|
||||
status: In Progress
|
||||
assignee: []
|
||||
created_date: '2026-02-11 08:20'
|
||||
updated_date: '2026-02-14 08:45'
|
||||
labels:
|
||||
- refactor
|
||||
- main
|
||||
@@ -33,3 +34,11 @@ Consolidate into a typed AppState object (or small set of domain-specific state
|
||||
- [ ] #4 Dependency objects for services shrink significantly (reference the container instead)
|
||||
- [ ] #5 TypeScript compiles cleanly
|
||||
<!-- AC:END -->
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
<!-- SECTION:NOTES:BEGIN -->
|
||||
Started centralizing module-level application state in `src/main.ts` via `appState` container and routing most state reads/writes through it. Initial rewrite completed; behavior verification pending and dependency-surface shrink pass still needed.
|
||||
|
||||
Implemented Task-7 state migration to `appState` in main.ts and removed module-scope mutable state declarations; fixed a broken regression where several appState references were left as bare expressions in object literals (e.g., `appState.autoStartOverlay`), restoring valid typed dependency construction.
|
||||
<!-- SECTION:NOTES:END -->
|
||||
|
||||
Reference in New Issue
Block a user