From b5b7073584e6ebcbe5f9c812db0af4e3e022afa6 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Sun, 22 Mar 2026 22:04:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B4=BB=E8=B7=83=E7=9A=84?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E4=B8=AD=E4=BC=9A=E8=AF=9D=E5=9C=A8=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E4=BC=9A=E8=AF=9Dtab=E5=90=8E=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E8=A2=AB=E8=87=AA=E5=8A=A8=E5=9B=9E=E6=94=B6=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/use-connection-lifecycle.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hooks/use-connection-lifecycle.ts b/src/hooks/use-connection-lifecycle.ts index 6dfe0ae..e98d168 100644 --- a/src/hooks/use-connection-lifecycle.ts +++ b/src/hooks/use-connection-lifecycle.ts @@ -266,9 +266,14 @@ export function useConnectionLifecycle({ // Clean up on unmount (e.g. tab closed): disconnect the ACP connection // so it doesn't leak, and remove lingering tasks. + // However, if the agent is actively prompting (generating a response), + // keep it alive so it can finish in the background — the idle sweep + // will clean it up once it transitions back to "connected". useEffect(() => { return () => { - connDisconnectRef.current().catch(() => {}) + if (statusRef.current !== "prompting") { + connDisconnectRef.current().catch(() => {}) + } if (taskIdRef.current) { removeTask(taskIdRef.current) }