Refactor startup lifecycle into service features

This commit is contained in:
vorotamoroz
2026-09-03 12:20:05 +00:00
parent 3b2d5aa5af
commit 338aecd888
30 changed files with 2184 additions and 963 deletions
+35
View File
@@ -4,8 +4,41 @@ import {
inspectObsidianServiceContextContract,
} from "../runner/liveSyncWorkflow.ts";
import { startObsidianLiveSyncSession, type ObsidianLiveSyncSession } from "../runner/session.ts";
import { withObsidianPage } from "../runner/ui.ts";
import { createTemporaryVault } from "../runner/vault.ts";
const BASIC_COMMAND_IDS = [
"livesync-replicate",
"livesync-dump",
"livesync-toggle",
"livesync-suspendall",
"livesync-scan-files",
"livesync-runbatch",
"livesync-abortsync",
] as const;
type ObsidianCommandHost = typeof globalThis & {
app?: { commands?: { commands?: Record<string, unknown> } };
};
async function assertMenuFeaturesAreComposed(remoteDebuggingPort: number): Promise<void> {
await withObsidianPage(remoteDebuggingPort, async (page) => {
const registered = await page.evaluate((commandIds) => {
const commands = (globalThis as ObsidianCommandHost).app?.commands?.commands ?? {};
return commandIds.filter((id) => commands[`obsidian-livesync:${id}`] !== undefined);
}, BASIC_COMMAND_IDS);
if (registered.length !== BASIC_COMMAND_IDS.length) {
const missing = BASIC_COMMAND_IDS.filter((id) => !registered.includes(id));
throw new Error(`Extracted basic commands were not composed: ${missing.join(", ")}`);
}
const ribbonCount = await page.locator(".livesync-ribbon-replicate").count();
if (ribbonCount !== 1) {
throw new Error(`Expected one extracted replication ribbon action, found ${ribbonCount}.`);
}
});
}
async function main(): Promise<void> {
const binary = requireObsidianBinary();
const cli = discoverObsidianCli();
@@ -34,6 +67,8 @@ async function main(): Promise<void> {
console.log(
`Obsidian service Context contract passed: ${contextContract.contextType}, ${contextContract.serviceContextMismatches.length} mismatches.`
);
await assertMenuFeaturesAreComposed(session.remoteDebuggingPort);
console.log("Extracted basic commands and replication ribbon were composed exactly once.");
await new Promise((resolve) => setTimeout(resolve, Number(process.env.E2E_OBSIDIAN_SMOKE_TIMEOUT_MS ?? 1000)));
console.log("Obsidian stayed alive after the plug-in readiness check.");
} finally {