refactor(core): normalize service naming across app runtime

This commit is contained in:
2026-02-17 19:00:27 -08:00
parent e38a1c945e
commit 1233e3630f
87 changed files with 2813 additions and 1636 deletions

View File

@@ -9,22 +9,31 @@ function makeDeps(overrides: Partial<AppReadyRuntimeDeps> = {}) {
resolveKeybindings: () => calls.push("resolveKeybindings"),
createMpvClient: () => calls.push("createMpvClient"),
reloadConfig: () => calls.push("reloadConfig"),
getResolvedConfig: () => ({ websocket: { enabled: "auto" }, secondarySub: {} }),
getResolvedConfig: () => ({
websocket: { enabled: "auto" },
secondarySub: {},
}),
getConfigWarnings: () => [],
logConfigWarning: () => calls.push("logConfigWarning"),
setLogLevel: (level, source) => calls.push(`setLogLevel:${level}:${source}`),
setLogLevel: (level, source) =>
calls.push(`setLogLevel:${level}:${source}`),
initRuntimeOptionsManager: () => calls.push("initRuntimeOptionsManager"),
setSecondarySubMode: (mode) => calls.push(`setSecondarySubMode:${mode}`),
defaultSecondarySubMode: "hover",
defaultWebsocketPort: 9001,
hasMpvWebsocketPlugin: () => true,
startSubtitleWebsocket: (port) => calls.push(`startSubtitleWebsocket:${port}`),
startSubtitleWebsocket: (port) =>
calls.push(`startSubtitleWebsocket:${port}`),
log: (message) => calls.push(`log:${message}`),
createMecabTokenizerAndCheck: async () => {
calls.push("createMecabTokenizerAndCheck");
},
createSubtitleTimingTracker: () => calls.push("createSubtitleTimingTracker"),
createSubtitleTimingTracker: () =>
calls.push("createSubtitleTimingTracker"),
createImmersionTracker: () => calls.push("createImmersionTracker"),
startJellyfinRemoteSession: async () => {
calls.push("startJellyfinRemoteSession");
},
loadYomitanExtension: async () => {
calls.push("loadYomitanExtension");
},
@@ -45,16 +54,37 @@ test("runAppReadyRuntime starts websocket in auto mode when plugin missing", asy
assert.ok(calls.includes("startSubtitleWebsocket:9001"));
assert.ok(calls.includes("initializeOverlayRuntime"));
assert.ok(calls.includes("createImmersionTracker"));
assert.ok(calls.includes("startJellyfinRemoteSession"));
assert.ok(
calls.includes("log:Runtime ready: invoking createImmersionTracker."),
);
});
test("runAppReadyRuntimeService logs when createImmersionTracker dependency is missing", async () => {
test("runAppReadyRuntime skips Jellyfin remote startup when dependency is not wired", async () => {
const { deps, calls } = makeDeps({
startJellyfinRemoteSession: undefined,
});
await runAppReadyRuntime(deps);
assert.equal(calls.includes("startJellyfinRemoteSession"), false);
assert.ok(calls.includes("createMecabTokenizerAndCheck"));
assert.ok(calls.includes("createMpvClient"));
assert.ok(calls.includes("createSubtitleTimingTracker"));
assert.ok(calls.includes("handleInitialArgs"));
assert.ok(
calls.includes("initializeOverlayRuntime") ||
calls.includes(
"log:Overlay runtime deferred: waiting for explicit overlay command.",
),
);
});
test("runAppReadyRuntime logs when createImmersionTracker dependency is missing", async () => {
const { deps, calls } = makeDeps({
createImmersionTracker: undefined,
});
await runAppReadyRuntimeService(deps);
await runAppReadyRuntime(deps);
assert.ok(
calls.includes(
"log:Runtime ready: createImmersionTracker dependency is missing.",
@@ -62,14 +92,14 @@ test("runAppReadyRuntimeService logs when createImmersionTracker dependency is m
);
});
test("runAppReadyRuntimeService logs and continues when createImmersionTracker throws", async () => {
test("runAppReadyRuntime logs and continues when createImmersionTracker throws", async () => {
const { deps, calls } = makeDeps({
createImmersionTracker: () => {
calls.push("createImmersionTracker");
throw new Error("immersion init failed");
},
});
await runAppReadyRuntimeService(deps);
await runAppReadyRuntime(deps);
assert.ok(calls.includes("createImmersionTracker"));
assert.ok(
calls.includes(