refactor: normalize additional startup and lifecycle wiring

This commit is contained in:
2026-02-20 01:33:42 -08:00
parent 4010fc1b04
commit 98902b6b0e
2 changed files with 20 additions and 15 deletions

View File

@@ -409,3 +409,5 @@
- [2026-02-20T09:30:02Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + targeted suites pass for `global-shortcuts*`, `mpv-osd-log*`, `jellyfin-playback-launch*`, `immersion-startup*`, `config-hot-reload-main-deps*`, `mpv-subtitle-render-metrics*`, `numeric-shortcut-runtime-main-deps*`, `initial-args*`. - [2026-02-20T09:30:02Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + targeted suites pass for `global-shortcuts*`, `mpv-osd-log*`, `jellyfin-playback-launch*`, `immersion-startup*`, `config-hot-reload-main-deps*`, `mpv-subtitle-render-metrics*`, `numeric-shortcut-runtime-main-deps*`, `initial-args*`.
- [2026-02-20T09:32:11Z] progress: completed 5-block safe normalization in `main.ts`: prebuilt deps handlers for CLI context main deps, MPV main-event bind deps, MPV runtime service factory deps, MeCab initializer deps, and subtitle dictionary prewarm deps. - [2026-02-20T09:32:11Z] progress: completed 5-block safe normalization in `main.ts`: prebuilt deps handlers for CLI context main deps, MPV main-event bind deps, MPV runtime service factory deps, MeCab initializer deps, and subtitle dictionary prewarm deps.
- [2026-02-20T09:32:11Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + targeted suites pass: `cli-command-context-main-deps`, `mpv-main-event-main-deps`, `mpv-main-event-bindings`, `mpv-client-runtime-service-main-deps`, `subtitle-tokenization-main-deps`. - [2026-02-20T09:32:11Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + targeted suites pass: `cli-command-context-main-deps`, `mpv-main-event-main-deps`, `mpv-main-event-bindings`, `mpv-client-runtime-service-main-deps`, `subtitle-tokenization-main-deps`.
- [2026-02-20T09:33:19Z] progress: completed another 5-block safe normalization in `main.ts` for lifecycle/startup wiring: prebuilt deps handlers for `onWillQuitCleanup`, `shouldRestoreWindowsOnActivate`, `restoreWindowsOnActivate`, `reloadConfig`, and `criticalConfigError`.
- [2026-02-20T09:33:19Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + targeted suites pass for `app-lifecycle-main-cleanup`, `app-lifecycle-main-activate`, `startup-config-main-deps`, and `startup-config`.

View File

@@ -1909,8 +1909,7 @@ registerProtocolUrlHandlers({
}, },
}); });
const onWillQuitCleanupHandler = createOnWillQuitCleanupHandler( const buildOnWillQuitCleanupDepsHandler = createBuildOnWillQuitCleanupDepsHandler({
createBuildOnWillQuitCleanupDepsHandler({
destroyTray: () => destroyTray(), destroyTray: () => destroyTray(),
stopConfigHotReload: () => configHotReloadRuntime.stop(), stopConfigHotReload: () => configHotReloadRuntime.stop(),
restorePreviousSecondarySubVisibility: () => restorePreviousSecondarySubVisibility(), restorePreviousSecondarySubVisibility: () => restorePreviousSecondarySubVisibility(),
@@ -1944,17 +1943,19 @@ const onWillQuitCleanupHandler = createOnWillQuitCleanupHandler(
appState.jellyfinSetupWindow = null; appState.jellyfinSetupWindow = null;
}, },
stopJellyfinRemoteSession: () => stopJellyfinRemoteSession(), stopJellyfinRemoteSession: () => stopJellyfinRemoteSession(),
})(), });
); const onWillQuitCleanupHandler = createOnWillQuitCleanupHandler(buildOnWillQuitCleanupDepsHandler());
const shouldRestoreWindowsOnActivateHandler = createShouldRestoreWindowsOnActivateHandler( const buildShouldRestoreWindowsOnActivateMainDepsHandler =
createBuildShouldRestoreWindowsOnActivateMainDepsHandler({ createBuildShouldRestoreWindowsOnActivateMainDepsHandler({
isOverlayRuntimeInitialized: () => appState.overlayRuntimeInitialized, isOverlayRuntimeInitialized: () => appState.overlayRuntimeInitialized,
getAllWindowCount: () => BrowserWindow.getAllWindows().length, getAllWindowCount: () => BrowserWindow.getAllWindows().length,
})(), });
const shouldRestoreWindowsOnActivateHandler = createShouldRestoreWindowsOnActivateHandler(
buildShouldRestoreWindowsOnActivateMainDepsHandler(),
); );
const restoreWindowsOnActivateHandler = createRestoreWindowsOnActivateHandler( const buildRestoreWindowsOnActivateMainDepsHandler =
createBuildRestoreWindowsOnActivateMainDepsHandler({ createBuildRestoreWindowsOnActivateMainDepsHandler({
createMainWindow: () => { createMainWindow: () => {
createMainWindow(); createMainWindow();
@@ -1968,11 +1969,12 @@ const restoreWindowsOnActivateHandler = createRestoreWindowsOnActivateHandler(
updateInvisibleOverlayVisibility: () => { updateInvisibleOverlayVisibility: () => {
overlayVisibilityRuntime.updateInvisibleOverlayVisibility(); overlayVisibilityRuntime.updateInvisibleOverlayVisibility();
}, },
})(), });
const restoreWindowsOnActivateHandler = createRestoreWindowsOnActivateHandler(
buildRestoreWindowsOnActivateMainDepsHandler(),
); );
const reloadConfigHandler = createReloadConfigHandler( const buildReloadConfigMainDepsHandler = createBuildReloadConfigMainDepsHandler({
createBuildReloadConfigMainDepsHandler({
reloadConfigStrict: () => configService.reloadConfigStrict(), reloadConfigStrict: () => configService.reloadConfigStrict(),
logInfo: (message) => appLogger.logInfo(message), logInfo: (message) => appLogger.logInfo(message),
logWarning: (message) => appLogger.logWarning(message), logWarning: (message) => appLogger.logWarning(message),
@@ -1984,18 +1986,19 @@ const reloadConfigHandler = createReloadConfigHandler(
showErrorBox: (title, details) => dialog.showErrorBox(title, details), showErrorBox: (title, details) => dialog.showErrorBox(title, details),
quit: () => app.quit(), quit: () => app.quit(),
}, },
})(), });
); const reloadConfigHandler = createReloadConfigHandler(buildReloadConfigMainDepsHandler());
const criticalConfigErrorHandler = createCriticalConfigErrorHandler( const buildCriticalConfigErrorMainDepsHandler = createBuildCriticalConfigErrorMainDepsHandler({
createBuildCriticalConfigErrorMainDepsHandler({
getConfigPath: () => configService.getConfigPath(), getConfigPath: () => configService.getConfigPath(),
failHandlers: { failHandlers: {
logError: (message) => logger.error(message), logError: (message) => logger.error(message),
showErrorBox: (title, message) => dialog.showErrorBox(title, message), showErrorBox: (title, message) => dialog.showErrorBox(title, message),
quit: () => app.quit(), quit: () => app.quit(),
}, },
})(), });
const criticalConfigErrorHandler = createCriticalConfigErrorHandler(
buildCriticalConfigErrorMainDepsHandler(),
); );
const buildAppReadyRuntimeMainDepsHandler = createBuildAppReadyRuntimeMainDepsHandler({ const buildAppReadyRuntimeMainDepsHandler = createBuildAppReadyRuntimeMainDepsHandler({