Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

test(plan): anchor the startup view assertion to the restore loop

Tioit-Wangd50673e8c118
diff --git a/apps/desktop/test/plan-mode-source-contract.test.mjs b/apps/desktop/test/plan-mode-source-contract.test.mjs
index 67c0d5f11..c23b3af9e 100644
--- a/apps/desktop/test/plan-mode-source-contract.test.mjs
+++ b/apps/desktop/test/plan-mode-source-contract.test.mjs
@@ -188,8 +188,11 @@ test("the startup artifact restore resolves launchable views first", () => {
assert.ok(bootstrapStart > -1, "bootstrap is declared in the store source");
const bootstrap = storeSource.slice(bootstrapStart);
const resolvedViews = bootstrap.indexOf("await get().refreshPluginViews();");
+ // The same loop shape also runs once before the restore, so search from the
+ // refresh rather than from the top of `bootstrap`.
const restoreLoop = bootstrap.indexOf(
"for (const proposal of activePendingPlans)",
+ resolvedViews,
);
assert.ok(resolvedViews > -1, "bootstrap resolves the launchable views");
@@ -198,7 +201,7 @@ test("the startup artifact restore resolves launchable views first", () => {
"the view list resolves before the pending-plan restore loop",
);
assert.ok(
- bootstrap.indexOf("openPlanArtifact(") > restoreLoop,
+ bootstrap.indexOf("openPlanArtifact(", resolvedViews) > restoreLoop,
"no artifact opens before that loop",
);
// Every slice call site forwards the live list, so a stub list cannot hide