Skip to content

Commit 81265d0

Browse files
committed
🤖 fix: interrupt stream when workspace is deleted
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.
1 parent 372f0d9 commit 81265d0

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

bun.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"lockfileVersion": 1,
3+
"configVersion": 0,
34
"workspaces": {
45
"": {
56
"name": "@coder/cmux",

src/node/services/agentSession.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ export class AgentSession {
9292
return;
9393
}
9494
this.disposed = true;
95+
96+
// Stop any active stream (fire and forget - disposal shouldn't block)
97+
void this.aiService.stopStream(this.workspaceId, /* abandonPartial */ true);
98+
9599
for (const { event, handler } of this.aiListeners) {
96100
this.aiService.off(event, handler as never);
97101
}

0 commit comments

Comments
 (0)