Skip to content

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

test(sidebar): await bootstrap snapshot after recovery

vastsa398f6d6388d9
diff --git a/apps/desktop/test/session-running-bootstrap.test.mjs b/apps/desktop/test/session-running-bootstrap.test.mjs
index 54b8bc54c..30ba3acab 100644
--- a/apps/desktop/test/session-running-bootstrap.test.mjs
+++ b/apps/desktop/test/session-running-bootstrap.test.mjs
@@ -57,8 +57,11 @@ test("reopening restores running badges and the selected session before another
test("a completion arriving during bootstrap wins over the earlier running snapshot", async () => {
const h = harness();
let release;
- h.api.listSessions = () => new Promise((resolve) => { release = resolve; });
+ let markStarted;
+ const started = new Promise(resolve => { markStarted = resolve; });
+ h.api.listSessions = () => new Promise((resolve) => { release = resolve; markStarted(); });
const pending = h.useAppStore.getState().bootstrap();
+ await started;
const first = release;
h.api.listSessions = async () => h.snapshot;
h.useAppStore.getState().handleAgentEvent({
@@ -72,8 +75,11 @@ test("a completion arriving during bootstrap wins over the earlier running snaps
test("a new live run is retained when the bootstrap snapshot did not contain it", async () => {
const h = harness([]);
let release;
- h.api.listSessions = () => new Promise((resolve) => { release = resolve; });
+ let markStarted;
+ const started = new Promise(resolve => { markStarted = resolve; });
+ h.api.listSessions = () => new Promise((resolve) => { release = resolve; markStarted(); });
const pending = h.useAppStore.getState().bootstrap();
+ await started;
h.useAppStore.getState().handleAgentEvent({
sessionId: "running", ts: 1, event: { type: "agent_start" },
});
diff --git a/apps/desktop/test/startup-watchdog.test.mjs b/apps/desktop/test/startup-watchdog.test.mjs
index a6f2fb640..c6ca0956f 100644
--- a/apps/desktop/test/startup-watchdog.test.mjs
+++ b/apps/desktop/test/startup-watchdog.test.mjs
@@ -270,8 +270,8 @@ test("a superseded startup attempt cannot publish over the retry", () => {
assert.match(store, /const generation = \+\+bootstrapGeneration;/);
assert.equal(
(store.match(/if \(generation !== bootstrapGeneration\) return;/g) ?? []).length,
- 2,
- "both the success and the failure path must refuse to publish",
+ 3,
+ "sidebar recovery, success and failure must refuse stale publication",
);
});