From eacf84fd675efee53b437eac3ba773ebf13d2f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Tue, 27 Oct 2026 21:55:14 +0000 Subject: [PATCH] tests: a job's note kept for a closed session, without the race "keeps its note until the session is resumed" started `sleep 0.5` and counted on the turn taking less than that before /new. On a loaded machine (load 7 on two cores) the turn took longer, the job ended while the session was still open, and its note went in as a turn instead of waiting. The command now waits for a file written after /new. Co-Authored-By: Claude Opus 5.5 --- tests/jobs.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/jobs.test.ts b/tests/jobs.test.ts index 1654ec1..b9a4d7e 100644 --- a/tests/jobs.test.ts +++ b/tests/jobs.test.ts @@ -164,7 +164,8 @@ describe("in an app", () => { const store = new Store(join(dir(), "s.db")) const a = app( [ - { chunks: [toolCall(0, "t1", "bash", JSON.stringify({ command: "sleep 0.5; echo late", background: true, description: "later" }))] }, + // It ends once the session is no longer open (the file below), however slow the turn was. + { chunks: [toolCall(0, "t1", "bash", JSON.stringify({ command: "until [ -e go ]; do sleep 0.05; done; echo late", background: true, description: "later" }))] }, { chunks: [delta({ content: "Running." })] }, { chunks: [delta({ content: "Back, and it finished." })] }, ], @@ -173,6 +174,7 @@ describe("in an app", () => { const first = a.engine.sessionId! await a.turns.prompt("start it") a.newSession() + writeFileSync(join(a.project.root, "go"), "") const job = await ended(a.registry, first, "job1") expect(job.note).toContain("late") expect(a.registry.get(first, "job1")!.note).toStartWith(MARKS.command)