refactor: extract runtime dependency builders from main

This commit is contained in:
2026-02-19 23:38:23 -08:00
parent 0d7b65ec88
commit df380ed1ca
19 changed files with 1221 additions and 212 deletions

View File

@@ -9,6 +9,16 @@
## Current Work (newest first)
- [2026-02-20T07:35:01Z] progress: extracted subtitle processing controller deps assembly into `src/main/runtime/subtitle-processing-main-deps.ts` (`createBuildSubtitleProcessingControllerMainDepsHandler`) and rewired `subtitleProcessingController` construction in `src/main.ts`.
- [2026-02-20T07:35:01Z] progress: added parity tests in `src/main/runtime/subtitle-processing-main-deps.test.ts`; `src/main.ts` now 2775 LOC.
- [2026-02-20T07:35:01Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/subtitle-processing-main-deps.test.js dist/core/services/subtitle-processing-controller.test.js dist/main/runtime/jellyfin-remote-main-deps.test.js` pass (9/9).
- [2026-02-20T07:33:56Z] progress: extracted Jellyfin remote deps assembly into `src/main/runtime/jellyfin-remote-main-deps.ts` (play/playstate/general-command/progress/stopped builders) and rewired corresponding constructor wiring in `src/main.ts` to builder-based deps.
- [2026-02-20T07:33:56Z] progress: added parity tests in `src/main/runtime/jellyfin-remote-main-deps.test.ts`; `src/main.ts` now 2770 LOC.
- [2026-02-20T07:33:56Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/jellyfin-remote-main-deps.test.js dist/main/runtime/jellyfin-remote-commands.test.js dist/main/runtime/jellyfin-remote-playback.test.js dist/main/runtime/jellyfin-remote-session-lifecycle.test.js` pass (18/18).
- [2026-02-20T07:31:59Z] progress: extracted config hot-reload dependency assembly into `src/main/runtime/config-hot-reload-main-deps.ts` (`createWatchConfigPathHandler`, `createBuildConfigHotReloadAppliedMainDepsHandler`, `createBuildConfigHotReloadRuntimeMainDepsHandler`) and rewired `configHotReloadRuntime` construction in `src/main.ts` to builder-based deps.
- [2026-02-20T07:31:59Z] progress: preserved runtime parity by keeping debounce/watch-path behavior and `createConfigHotReloadAppliedHandler` side-effects unchanged while moving inline glue code out of `src/main.ts`.
- [2026-02-20T07:31:59Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/config-hot-reload-main-deps.test.js dist/main/runtime/config-hot-reload-handlers.test.js dist/core/services/config-hot-reload.test.js` pass (12/12).
- [2026-02-20T07:31:59Z] next: continue TASK-85 by extracting next high-churn deps assembly from `src/main.ts` (candidate: startup/bootstrap or app-ready clusters) into focused `*-main-deps.ts` + parity tests.
- [2026-02-20T03:27:35Z] progress: extracted CLI context deps builder into `src/main/runtime/cli-command-context-deps.ts` (`createBuildCliCommandContextDepsHandler`) and rewired `handleCliCommand` to build deps through the helper.
- [2026-02-20T03:27:35Z] progress: extracted overlay runtime options builder into `src/main/runtime/overlay-runtime-options.ts` (`createBuildInitializeOverlayRuntimeOptionsHandler`) and rewired `initializeOverlayRuntime` `buildOptions`; extracted Yomitan extension load wrappers into `src/main/runtime/yomitan-extension-loader.ts` (`createLoadYomitanExtensionHandler`, `createEnsureYomitanExtensionLoadedHandler`) and rewired `loadYomitanExtension` + `ensureYomitanExtensionLoaded`.
- [2026-02-20T03:27:35Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/cli-command-context-deps.test.js dist/main/runtime/overlay-runtime-options.test.js dist/main/runtime/yomitan-extension-loader.test.js dist/main/runtime/tray-main-actions.test.js dist/main/runtime/overlay-window-factory.test.js dist/main/runtime/ipc-bridge-actions.test.js dist/main/runtime/overlay-main-actions.test.js dist/main/runtime/overlay-visibility-actions.test.js dist/main/runtime/mining-actions.test.js dist/main/runtime/anki-actions.test.js dist/main/runtime/overlay-shortcuts-lifecycle.test.js dist/main/runtime/numeric-shortcut-session-handlers.test.js dist/main/runtime/mpv-osd-log.test.js dist/main/runtime/global-shortcuts.test.js dist/main/runtime/yomitan-settings-opener.test.js dist/main/runtime/overlay-runtime-bootstrap.test.js dist/main/runtime/tray-lifecycle.test.js dist/main/runtime/tray-runtime.test.js dist/main/runtime/overlay-window-layout.test.js dist/main/runtime/startup-warmups.test.js dist/main/runtime/mpv-subtitle-render-metrics.test.js dist/main/runtime/mpv-client-runtime-service.test.js dist/main/runtime/mpv-client-event-bindings.test.js dist/main/runtime/cli-command-context.test.js dist/main/runtime/cli-command-prechecks.test.js dist/main/runtime/initial-args-handler.test.js dist/main/runtime/anilist-setup-window.test.js dist/main/runtime/jellyfin-setup-window.test.js dist/main/runtime/jellyfin-remote-session-lifecycle.test.js dist/main/runtime/jellyfin-cli-auth.test.js dist/main/runtime/jellyfin-cli-list.test.js dist/main/runtime/jellyfin-cli-play.test.js dist/main/runtime/jellyfin-cli-remote-announce.test.js` pass (116/116).
@@ -215,6 +225,16 @@
- `src/main/runtime/field-grouping-resolver.test.ts`
- `src/main/runtime/mpv-jellyfin-defaults.ts`
- `src/main/runtime/mpv-jellyfin-defaults.test.ts`
- `src/main/runtime/field-grouping-overlay-main-deps.ts`
- `src/main/runtime/field-grouping-overlay-main-deps.test.ts`
- `src/main/runtime/media-runtime-main-deps.ts`
- `src/main/runtime/media-runtime-main-deps.test.ts`
- `src/main/runtime/overlay-visibility-runtime-main-deps.ts`
- `src/main/runtime/overlay-visibility-runtime-main-deps.test.ts`
- `src/main/runtime/dictionary-runtime-main-deps.ts`
- `src/main/runtime/dictionary-runtime-main-deps.test.ts`
- `src/main/runtime/overlay-shortcuts-runtime-main-deps.ts`
- `src/main/runtime/overlay-shortcuts-runtime-main-deps.test.ts`
## Open Questions / Blockers
@@ -290,3 +310,20 @@
- [2026-02-20T06:56:20Z] progress: extracted `applyJellyfinMpvDefaults` and `getDefaultSocketPath` wrappers into `src/main/runtime/mpv-jellyfin-defaults.ts`; rewired both `main.ts` helper functions to thin handler delegates.
- [2026-02-20T06:56:20Z] progress: `src/main.ts` currently 2742 LOC after this slice.
- [2026-02-20T06:56:20Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/cli-command-prechecks-main-deps.test.js dist/main/runtime/cli-command-prechecks.test.js dist/main/runtime/field-grouping-resolver.test.js dist/main/runtime/mpv-jellyfin-defaults.test.js dist/main/runtime/startup-bootstrap-main-deps.test.js` pass (11/11).
- [2026-02-20T07:12:59Z] progress: extracted field-grouping overlay deps assembly into `src/main/runtime/field-grouping-overlay-main-deps.ts` and rewired `createFieldGroupingOverlayRuntime` setup in `src/main.ts` to use builder output.
- [2026-02-20T07:12:59Z] progress: resolved strict typing mismatch by parameterizing builder choice type and binding it to `KikuFieldGroupingChoice` in `main.ts`.
- [2026-02-20T07:12:59Z] progress: `src/main.ts` currently 2747 LOC after this slice.
- [2026-02-20T07:12:59Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/field-grouping-overlay-main-deps.test.js dist/core/services/field-grouping-overlay.test.js dist/main/runtime/field-grouping-resolver.test.js` pass (6/6).
- [2026-02-20T07:14:28Z] progress: extracted media runtime deps assembly into `src/main/runtime/media-runtime-main-deps.ts` and rewired `createMediaRuntimeService` setup in `src/main.ts` through the builder.
- [2026-02-20T07:14:28Z] progress: `src/main.ts` currently 2750 LOC after this slice.
- [2026-02-20T07:14:28Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/media-runtime-main-deps.test.js dist/main/media-runtime.test.js dist/main/runtime/field-grouping-overlay-main-deps.test.js` pass (2/2 from selected bundle output).
- [2026-02-20T07:16:22Z] progress: extracted overlay visibility runtime deps assembly into `src/main/runtime/overlay-visibility-runtime-main-deps.ts` and rewired `createOverlayVisibilityRuntimeService` setup in `src/main.ts` through the builder.
- [2026-02-20T07:16:22Z] progress: `src/main.ts` currently 2753 LOC after this slice.
- [2026-02-20T07:16:22Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/overlay-visibility-runtime-main-deps.test.js dist/main/overlay-visibility-runtime.test.js dist/main/runtime/media-runtime-main-deps.test.js` pass (2/2 from selected bundle output).
- [2026-02-20T07:25:54Z] progress: extracted JLPT/frequency dictionary runtime deps assembly and root-list construction into `src/main/runtime/dictionary-runtime-main-deps.ts`; rewired `createJlptDictionaryRuntimeService` + `createFrequencyDictionaryRuntimeService` setup in `src/main.ts`.
- [2026-02-20T07:25:54Z] progress: adjusted frequency roots wiring to preserve previous behavior exactly (separate frequency roots builder, no JLPT-root leakage).
- [2026-02-20T07:25:54Z] progress: `src/main.ts` currently 2747 LOC after this slice.
- [2026-02-20T07:25:54Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/dictionary-runtime-main-deps.test.js dist/main/frequency-dictionary-runtime.test.js dist/main/jlpt-runtime.test.js` pass (4/4 from selected bundle output).
- [2026-02-20T07:27:15Z] progress: extracted overlay-shortcuts runtime deps assembly into `src/main/runtime/overlay-shortcuts-runtime-main-deps.ts` and rewired `createOverlayShortcutsRuntimeService` setup in `src/main.ts` through the builder.
- [2026-02-20T07:27:15Z] progress: `src/main.ts` currently 2750 LOC after this slice.
- [2026-02-20T07:27:15Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + `node --test dist/main/runtime/overlay-shortcuts-runtime-main-deps.test.js dist/main/overlay-shortcuts-runtime.test.js dist/main/runtime/overlay-shortcuts-lifecycle.test.js` pass (5/5).