mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-27 18:22:41 -08:00
refactor: extract ipc runtime handler wiring
This commit is contained in:
@@ -6,7 +6,7 @@ Read first. Keep concise.
|
|||||||
| ------------ | -------------- | ---------------------------------------------------- | --------- | ------------------------------------- | ---------------------- |
|
| ------------ | -------------- | ---------------------------------------------------- | --------- | ------------------------------------- | ---------------------- |
|
||||||
| `codex-generate-minecard-image-20260220T112900Z-vsxr` | `codex-generate-minecard-image` | `Generate media fallbacks (GIF) from assets/minecard.webm and wire README/docs fallback markup` | `done` | `docs/subagents/agents/codex-generate-minecard-image-20260220T112900Z-vsxr.md` | `2026-02-20T11:35:30Z` |
|
| `codex-generate-minecard-image-20260220T112900Z-vsxr` | `codex-generate-minecard-image` | `Generate media fallbacks (GIF) from assets/minecard.webm and wire README/docs fallback markup` | `done` | `docs/subagents/agents/codex-generate-minecard-image-20260220T112900Z-vsxr.md` | `2026-02-20T11:35:30Z` |
|
||||||
| `codex-main` | `planner-exec` | `Fix frequency/N+1 regression in plugin --start flow` | `in_progress` | `docs/subagents/agents/codex-main.md` | `2026-02-19T19:36:46Z` |
|
| `codex-main` | `planner-exec` | `Fix frequency/N+1 regression in plugin --start flow` | `in_progress` | `docs/subagents/agents/codex-main.md` | `2026-02-19T19:36:46Z` |
|
||||||
| `codex-task85-20260219T233711Z-46hc` | `codex-task85` | `Resume TASK-85 maintainability refactor from latest handoff point` | `in_progress` | `docs/subagents/agents/codex-task85-20260219T233711Z-46hc.md` | `2026-02-20T10:02:30Z` |
|
| `codex-task85-20260219T233711Z-46hc` | `codex-task85` | `Resume TASK-85 maintainability refactor from latest handoff point` | `in_progress` | `docs/subagents/agents/codex-task85-20260219T233711Z-46hc.md` | `2026-02-20T10:04:27Z` |
|
||||||
| `codex-config-validation-20260219T172015Z-iiyf` | `codex-config-validation` | `Find root cause of config validation error for ~/.config/SubMiner/config.jsonc` | `completed` | `docs/subagents/agents/codex-config-validation-20260219T172015Z-iiyf.md` | `2026-02-19T17:26:17Z` |
|
| `codex-config-validation-20260219T172015Z-iiyf` | `codex-config-validation` | `Find root cause of config validation error for ~/.config/SubMiner/config.jsonc` | `completed` | `docs/subagents/agents/codex-config-validation-20260219T172015Z-iiyf.md` | `2026-02-19T17:26:17Z` |
|
||||||
| `codex-task85-20260219T233711Z-46hc` | `codex-task85` | `Resume TASK-85 maintainability refactor from latest handoff point` | `in_progress` | `docs/subagents/agents/codex-task85-20260219T233711Z-46hc.md` | `2026-02-20T02:56:34Z` |
|
| `codex-task85-20260219T233711Z-46hc` | `codex-task85` | `Resume TASK-85 maintainability refactor from latest handoff point` | `in_progress` | `docs/subagents/agents/codex-task85-20260219T233711Z-46hc.md` | `2026-02-20T02:56:34Z` |
|
||||||
| `codex-anilist-deeplink-20260219T233926Z` | `anilist-deeplink` | `Fix external subminer:// AniList callback handling from browser` | `done` | `docs/subagents/agents/codex-anilist-deeplink-20260219T233926Z.md` | `2026-02-19T23:59:21Z` |
|
| `codex-anilist-deeplink-20260219T233926Z` | `anilist-deeplink` | `Fix external subminer:// AniList callback handling from browser` | `done` | `docs/subagents/agents/codex-anilist-deeplink-20260219T233926Z.md` | `2026-02-19T23:59:21Z` |
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
|
|
||||||
## Current Work (newest first)
|
## Current Work (newest first)
|
||||||
|
|
||||||
|
- [2026-02-20T10:04:27Z] progress: extracted IPC bridge composition from `src/main.ts` into `src/main/runtime/ipc-runtime-handlers.ts`; `main.ts` now builds `handleMpvCommandFromIpc` and `runSubsyncManualFromIpc` via one `createIpcRuntimeHandlers(...)` factory.
|
||||||
|
- [2026-02-20T10:04:27Z] progress: added `src/main/runtime/ipc-runtime-handlers.test.ts` for composed IPC handler wiring behavior.
|
||||||
|
- [2026-02-20T10:04:27Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + focused suites pass for `ipc-runtime-handlers*`, `ipc-bridge-actions*`, `cli-command-context*`, `yomitan-extension-runtime*`, and `overlay-visibility-runtime*` (11/11).
|
||||||
|
- [2026-02-20T10:04:27Z] scope: staging only `src/main.ts`, new IPC runtime module/tests, and subagent bookkeeping.
|
||||||
- [2026-02-20T10:02:30Z] progress: extracted overlay visibility action composition from `src/main.ts` into new runtime module `src/main/runtime/overlay-visibility-runtime.ts`; `main.ts` now consumes a single `createOverlayVisibilityRuntime(...)` factory for set/toggle overlay handlers.
|
- [2026-02-20T10:02:30Z] progress: extracted overlay visibility action composition from `src/main.ts` into new runtime module `src/main/runtime/overlay-visibility-runtime.ts`; `main.ts` now consumes a single `createOverlayVisibilityRuntime(...)` factory for set/toggle overlay handlers.
|
||||||
- [2026-02-20T10:02:30Z] progress: added `src/main/runtime/overlay-visibility-runtime.test.ts` to lock behavior of composed set/toggle/setOverlay/toggleOverlay wiring.
|
- [2026-02-20T10:02:30Z] progress: added `src/main/runtime/overlay-visibility-runtime.test.ts` to lock behavior of composed set/toggle/setOverlay/toggleOverlay wiring.
|
||||||
- [2026-02-20T10:02:30Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + focused suites pass for `overlay-visibility-runtime*`, `overlay-visibility-actions*`, `overlay-runtime-bootstrap*`, `overlay-window-layout*`, and `cli-command-context*` (16/16).
|
- [2026-02-20T10:02:30Z] test: `bun run build` pass (expected macOS helper Swift cache fallback) + focused suites pass for `overlay-visibility-runtime*`, `overlay-visibility-actions*`, `overlay-runtime-bootstrap*`, `overlay-window-layout*`, and `cli-command-context*` (16/16).
|
||||||
|
|||||||
39
src/main.ts
39
src/main.ts
@@ -380,14 +380,7 @@ import {
|
|||||||
createBuildSendToActiveOverlayWindowMainDepsHandler,
|
createBuildSendToActiveOverlayWindowMainDepsHandler,
|
||||||
createBuildSetOverlayDebugVisualizationEnabledMainDepsHandler,
|
createBuildSetOverlayDebugVisualizationEnabledMainDepsHandler,
|
||||||
} from './main/runtime/overlay-runtime-main-actions-main-deps';
|
} from './main/runtime/overlay-runtime-main-actions-main-deps';
|
||||||
import {
|
import { createIpcRuntimeHandlers } from './main/runtime/ipc-runtime-handlers';
|
||||||
createHandleMpvCommandFromIpcHandler,
|
|
||||||
createRunSubsyncManualFromIpcHandler,
|
|
||||||
} from './main/runtime/ipc-bridge-actions';
|
|
||||||
import {
|
|
||||||
createBuildHandleMpvCommandFromIpcMainDepsHandler,
|
|
||||||
createBuildRunSubsyncManualFromIpcMainDepsHandler,
|
|
||||||
} from './main/runtime/ipc-bridge-actions-main-deps';
|
|
||||||
import { createBuildMpvCommandFromIpcRuntimeMainDepsHandler } from './main/runtime/ipc-mpv-command-main-deps';
|
import { createBuildMpvCommandFromIpcRuntimeMainDepsHandler } from './main/runtime/ipc-mpv-command-main-deps';
|
||||||
import {
|
import {
|
||||||
createCreateInvisibleWindowHandler,
|
createCreateInvisibleWindowHandler,
|
||||||
@@ -2957,27 +2950,17 @@ const buildMpvCommandFromIpcRuntimeMainDepsHandler =
|
|||||||
hasRuntimeOptionsManager: () => appState.runtimeOptionsManager !== null,
|
hasRuntimeOptionsManager: () => appState.runtimeOptionsManager !== null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const buildHandleMpvCommandFromIpcMainDepsHandler =
|
|
||||||
createBuildHandleMpvCommandFromIpcMainDepsHandler({
|
|
||||||
handleMpvCommandFromIpcRuntime,
|
|
||||||
buildMpvCommandDeps: () => mpvCommandFromIpcRuntimeMainDeps,
|
|
||||||
});
|
|
||||||
const mpvCommandFromIpcRuntimeMainDeps = buildMpvCommandFromIpcRuntimeMainDepsHandler();
|
const mpvCommandFromIpcRuntimeMainDeps = buildMpvCommandFromIpcRuntimeMainDepsHandler();
|
||||||
const handleMpvCommandFromIpcMainDeps =
|
const { handleMpvCommandFromIpc: handleMpvCommandFromIpcHandler, runSubsyncManualFromIpc: runSubsyncManualFromIpcHandler } =
|
||||||
buildHandleMpvCommandFromIpcMainDepsHandler();
|
createIpcRuntimeHandlers<SubsyncManualRunRequest, Awaited<ReturnType<typeof subsyncRuntime.runManualFromIpc>>>({
|
||||||
const handleMpvCommandFromIpcHandler = createHandleMpvCommandFromIpcHandler(
|
handleMpvCommandFromIpcDeps: {
|
||||||
handleMpvCommandFromIpcMainDeps,
|
handleMpvCommandFromIpcRuntime,
|
||||||
);
|
buildMpvCommandDeps: () => mpvCommandFromIpcRuntimeMainDeps,
|
||||||
|
},
|
||||||
const buildRunSubsyncManualFromIpcMainDepsHandler =
|
runSubsyncManualFromIpcDeps: {
|
||||||
createBuildRunSubsyncManualFromIpcMainDepsHandler({
|
runManualFromIpc: (request) => subsyncRuntime.runManualFromIpc(request),
|
||||||
runManualFromIpc: (request: SubsyncManualRunRequest) => subsyncRuntime.runManualFromIpc(request),
|
},
|
||||||
});
|
});
|
||||||
const runSubsyncManualFromIpcMainDeps =
|
|
||||||
buildRunSubsyncManualFromIpcMainDepsHandler();
|
|
||||||
const runSubsyncManualFromIpcHandler = createRunSubsyncManualFromIpcHandler(
|
|
||||||
runSubsyncManualFromIpcMainDeps,
|
|
||||||
);
|
|
||||||
const buildCliCommandContextMainDepsHandler = createBuildCliCommandContextMainDepsHandler({
|
const buildCliCommandContextMainDepsHandler = createBuildCliCommandContextMainDepsHandler({
|
||||||
appState,
|
appState,
|
||||||
texthookerService,
|
texthookerService,
|
||||||
|
|||||||
38
src/main/runtime/ipc-runtime-handlers.test.ts
Normal file
38
src/main/runtime/ipc-runtime-handlers.test.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
import { createIpcRuntimeHandlers } from './ipc-runtime-handlers';
|
||||||
|
|
||||||
|
test('ipc runtime handlers wire command and subsync handlers through built deps', async () => {
|
||||||
|
let receivedCommand: (string | number)[] | null = null;
|
||||||
|
let receivedCommandDeps: { tag: string } | null = null;
|
||||||
|
let buildMpvCommandDepsCalls = 0;
|
||||||
|
let receivedSubsyncRequest: { id: string } | null = null;
|
||||||
|
|
||||||
|
const runtime = createIpcRuntimeHandlers({
|
||||||
|
handleMpvCommandFromIpcDeps: {
|
||||||
|
handleMpvCommandFromIpcRuntime: (command, deps) => {
|
||||||
|
receivedCommand = command;
|
||||||
|
receivedCommandDeps = deps as unknown as { tag: string };
|
||||||
|
},
|
||||||
|
buildMpvCommandDeps: () => {
|
||||||
|
buildMpvCommandDepsCalls += 1;
|
||||||
|
return { tag: 'mpv-deps' } as never;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
runSubsyncManualFromIpcDeps: {
|
||||||
|
runManualFromIpc: async (request: { id: string }) => {
|
||||||
|
receivedSubsyncRequest = request;
|
||||||
|
return { ok: true, id: request.id };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
runtime.handleMpvCommandFromIpc(['set_property', 'pause', 'yes']);
|
||||||
|
assert.deepEqual(receivedCommand, ['set_property', 'pause', 'yes']);
|
||||||
|
assert.deepEqual(receivedCommandDeps, { tag: 'mpv-deps' });
|
||||||
|
assert.equal(buildMpvCommandDepsCalls, 1);
|
||||||
|
|
||||||
|
const response = await runtime.runSubsyncManualFromIpc({ id: 'abc' });
|
||||||
|
assert.deepEqual(receivedSubsyncRequest, { id: 'abc' });
|
||||||
|
assert.deepEqual(response, { ok: true, id: 'abc' });
|
||||||
|
});
|
||||||
37
src/main/runtime/ipc-runtime-handlers.ts
Normal file
37
src/main/runtime/ipc-runtime-handlers.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { createHandleMpvCommandFromIpcHandler, createRunSubsyncManualFromIpcHandler } from './ipc-bridge-actions';
|
||||||
|
import {
|
||||||
|
createBuildHandleMpvCommandFromIpcMainDepsHandler,
|
||||||
|
createBuildRunSubsyncManualFromIpcMainDepsHandler,
|
||||||
|
} from './ipc-bridge-actions-main-deps';
|
||||||
|
|
||||||
|
type HandleMpvCommandFromIpcMainDeps = Parameters<
|
||||||
|
typeof createBuildHandleMpvCommandFromIpcMainDepsHandler
|
||||||
|
>[0];
|
||||||
|
type RunSubsyncManualFromIpcMainDeps<TRequest, TResult> = Parameters<
|
||||||
|
typeof createBuildRunSubsyncManualFromIpcMainDepsHandler<TRequest, TResult>
|
||||||
|
>[0];
|
||||||
|
|
||||||
|
export function createIpcRuntimeHandlers<TRequest, TResult>(deps: {
|
||||||
|
handleMpvCommandFromIpcDeps: HandleMpvCommandFromIpcMainDeps;
|
||||||
|
runSubsyncManualFromIpcDeps: RunSubsyncManualFromIpcMainDeps<TRequest, TResult>;
|
||||||
|
}) {
|
||||||
|
const handleMpvCommandFromIpcMainDeps = createBuildHandleMpvCommandFromIpcMainDepsHandler(
|
||||||
|
deps.handleMpvCommandFromIpcDeps,
|
||||||
|
)();
|
||||||
|
const handleMpvCommandFromIpc = createHandleMpvCommandFromIpcHandler(
|
||||||
|
handleMpvCommandFromIpcMainDeps,
|
||||||
|
);
|
||||||
|
|
||||||
|
const runSubsyncManualFromIpcMainDeps =
|
||||||
|
createBuildRunSubsyncManualFromIpcMainDepsHandler<TRequest, TResult>(
|
||||||
|
deps.runSubsyncManualFromIpcDeps,
|
||||||
|
)();
|
||||||
|
const runSubsyncManualFromIpc = createRunSubsyncManualFromIpcHandler<TRequest, TResult>(
|
||||||
|
runSubsyncManualFromIpcMainDeps,
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
handleMpvCommandFromIpc,
|
||||||
|
runSubsyncManualFromIpc,
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user