Skip to content

Commit f1a6cae

Browse files
🤖 fix: interrupt stream when workspace is deleted (#835)
When a workspace is deleted while an agent is streaming, the stream wasn't being interrupted and would continue running in the background. ## Fix Stop any active stream in `AgentSession.dispose()` before cleaning up listeners. This ensures streams are always stopped when the session is disposed, regardless of the disposal trigger. Uses fire-and-forget semantics since disposal shouldn't block, and abandons the partial since the workspace is being deleted anyway. --- _Generated with `mux`_
1 parent 2820a98 commit f1a6cae

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)