From ae868b7b18dfbd5e6a2422c8005501b57c52e15a Mon Sep 17 00:00:00 2001 From: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com> Date: Fri, 5 Jun 2026 09:48:39 +0000 Subject: [PATCH] fix(clawsweeper): address review for gitcrawl-1599-fix-register-abortcontroller-for-agent-rpc-runs-so-chat-abort-wo (2) --- ui/src/ui/app-chat.ts | 9 +++++-- ui/src/ui/controllers/chat.test.ts | 41 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/ui/src/ui/app-chat.ts b/ui/src/ui/app-chat.ts index b539fdc2995d..6035c16bb440 100644 --- a/ui/src/ui/app-chat.ts +++ b/ui/src/ui/app-chat.ts @@ -266,16 +266,21 @@ function chatRunWatchdogResultIsTerminal( result: ChatRunWatchdogWaitResult | null | undefined, ): boolean { const status = chatRunWatchdogStatus(result); + if (status === "pending") { + return false; + } if (status !== "timeout" && status !== "timed_out") { return true; } + if (result?.pendingError === true) { + return false; + } return ( result?.endedAt != null || result?.error != null || result?.stopReason != null || result?.livenessState != null || - result?.yielded === true || - result?.pendingError === true + result?.yielded === true ); } diff --git a/ui/src/ui/controllers/chat.test.ts b/ui/src/ui/controllers/chat.test.ts index d8c1bae28d58..9aeb2964c345 100644 --- a/ui/src/ui/controllers/chat.test.ts +++ b/ui/src/ui/controllers/chat.test.ts @@ -2259,6 +2259,47 @@ describe("chat run watchdog", () => { } }); + it("keeps retry-grace timeout snapshots active without flushing queued chat", async () => { + vi.useFakeTimers(); + try { + const { resetChatRunWatchdog, scheduleChatRunWatchdog } = await import("../app-chat.ts"); + const request = vi.fn(async (method: string) => { + if (method === "agent.wait") { + return { + status: "timeout", + runId: "run-1", + error: "agent still starting", + pendingError: true, + }; + } + throw new Error(`unexpected method: ${method}`); + }); + const host = createWatchdogHost(request); + + scheduleChatRunWatchdog(host as never); + await vi.advanceTimersByTimeAsync(15_000); + + expect(host.chatRunId).toBe("run-1"); + expect(host.chatQueue).toHaveLength(1); + expect(request).toHaveBeenCalledWith("agent.wait", { + runId: "run-1", + timeoutMs: 50, + }); + expect(request).not.toHaveBeenCalledWith( + "chat.send", + expect.objectContaining({ message: "continue" }), + ); + expect(request).not.toHaveBeenCalledWith( + "chat.history", + expect.objectContaining({ sessionKey: "main" }), + ); + + resetChatRunWatchdog(host as never); + } finally { + vi.useRealTimers(); + } + }); + it("does not surface transient probe failures as chat errors", async () => { vi.useFakeTimers(); const warn = vi.spyOn(console, "warn").mockImplementation(() => undefined);