From 81265d08c9a953952bbd34755d90433380030217 Mon Sep 17 00:00:00 2001 From: ethan Date: Tue, 2 Dec 2025 16:32:25 +1100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20fix:=20interrupt=20stream=20when?= =?UTF-8?q?=20workspace=20is=20deleted?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a workspace is deleted while an agent is streaming, stop the stream during AgentSession.dispose() to prevent it from continuing in the background. Uses fire-and-forget semantics since disposal shouldn't block, and abandons the partial since the workspace is being deleted anyway. --- bun.lock | 1 + src/node/services/agentSession.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/bun.lock b/bun.lock index 899b1121ae..d75d88c206 100644 --- a/bun.lock +++ b/bun.lock @@ -1,5 +1,6 @@ { "lockfileVersion": 1, + "configVersion": 0, "workspaces": { "": { "name": "@coder/cmux", diff --git a/src/node/services/agentSession.ts b/src/node/services/agentSession.ts index 942d5105f6..a2cf0a78ec 100644 --- a/src/node/services/agentSession.ts +++ b/src/node/services/agentSession.ts @@ -92,6 +92,10 @@ export class AgentSession { return; } this.disposed = true; + + // Stop any active stream (fire and forget - disposal shouldn't block) + void this.aiService.stopStream(this.workspaceId, /* abandonPartial */ true); + for (const { event, handler } of this.aiListeners) { this.aiService.off(event, handler as never); }