From 02eb1c5b30579218dd617f714b417c4d7f8ef29e Mon Sep 17 00:00:00 2001 From: gsxdsm Date: Tue, 5 May 2026 09:08:51 -0700 Subject: [PATCH] fix(chat): revert cancelGeneration-on-disconnect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit req.on("close") was firing for healthy SSE connections in this Node/Express setup, which cancelled the in-flight agent the client was still listening to and made even msg #1 fail after a fresh reload. Keep the beginGeneration (no dispose) change from the same commit — that one's correct. --- packages/dashboard/src/routes/register-chat-routes.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/packages/dashboard/src/routes/register-chat-routes.ts b/packages/dashboard/src/routes/register-chat-routes.ts index c2e7f20c9..1f3d26ea3 100644 --- a/packages/dashboard/src/routes/register-chat-routes.ts +++ b/packages/dashboard/src/routes/register-chat-routes.ts @@ -560,15 +560,6 @@ export function registerChatRoutes(ctx: ApiRoutesContext, deps: ChatRouteDeps): // Handle client disconnect req.on("close", () => { unsubscribe(); - // If the response hasn't been ended (i.e. the generation was still - // streaming when the browser disconnected — tab close, navigation, - // network drop), cancel the agent so it doesn't keep running with - // nobody listening. Otherwise the next request for this session sees a - // stale `activeGenerations` entry and races against the lingering - // agent for the same CLI session file. - if (!res.writableEnded) { - chatManager.cancelGeneration(sessionId); - } }); // Send heartbeat every 30s to keep connection alive