From 88141ab456bb7ba797ca928df8ecebac307c1a76 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Tue, 28 Apr 2026 20:46:29 +0700 Subject: [PATCH] fix(server): make /compact slash-command test mock yield session.idle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The empty event-stream mock added in #597 races with the summarize-success path: consumeEventStream sees the empty stream end immediately and emits a "stream ended before terminal event" turn_failed which gets buffered before session.run has assigned its local turnId. The buffered event replays after startTurn returns, marks settled = true, and rejects completion — but session.run skips await completion because settled is true, leaving the rejection unhandled and tripping vitest. Yield session.idle so the stream resolves the turn the same way real OpenCode SSE does. --- .../providers/opencode-agent.slash-command-timeout.test.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/server/src/server/agent/providers/opencode-agent.slash-command-timeout.test.ts b/packages/server/src/server/agent/providers/opencode-agent.slash-command-timeout.test.ts index 0670de6d4..05cb7bf6b 100644 --- a/packages/server/src/server/agent/providers/opencode-agent.slash-command-timeout.test.ts +++ b/packages/server/src/server/agent/providers/opencode-agent.slash-command-timeout.test.ts @@ -91,7 +91,12 @@ describe("OpenCodeAgentSession slash command timeout handling", () => { }, event: { subscribe: vi.fn().mockResolvedValue({ - stream: (async function* () {})(), + stream: (async function* () { + yield { + type: "session.idle", + properties: { sessionID: "session-1" }, + }; + })(), }), }, command: {