fix(agent): preserve streamed replies after model failures (#6494)

* fix(agent): preserve streamed replies after model failures

* test(webui): settle lazy imports and async settings saves

* test(agent): synchronize estimation checks at the operation boundary

* docs(webui): explain retained replies after stream failures
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-27 16:22:33 +08:00
1 parent b6536bfc5e
commit 219c8bb2bc
31 files changed
+462 -27

No files matched your search

+29
View File
@@ -154,3 +154,32 @@ describe("RecoveryNotice", () => {
expect(screen.getByRole("button", { name: "Continue" })).toBeEnabled();
});
});
it("shows a saved reply without treating the failed request as completed", async () => {
const onContinue = vi.fn().mockResolvedValue(undefined);
const onDismiss = vi.fn().mockResolvedValue(undefined);
const { rerender } = render(
<RecoveryNotice
state={{ ...INTERRUPTED, reason: "model_request_failed", failure_error_kind: "connection", reply_preserved: true }}
onContinue={onContinue}
onDismiss={onDismiss}
/>,
);
expect(screen.getByRole("alert")).toHaveTextContent("Model connection failed");
expect(screen.getByRole("alert")).toHaveTextContent("Reply saved. You can continue.");
fireEvent.click(screen.getByRole("button", { name: "Continue" }));
await waitFor(() => expect(screen.queryByRole("alert")).not.toBeInTheDocument());
expect(onContinue).toHaveBeenCalledOnce();
rerender(
<RecoveryNotice
state={{ ...INTERRUPTED, recovery_id: "no-output", reason: "model_request_failed", failure_error_kind: "connection" }}
onContinue={onContinue}
onDismiss={onDismiss}
/>,
);
expect(screen.getByRole("alert")).toHaveTextContent("Model connection failed");
expect(screen.getByRole("alert")).toHaveTextContent("Try again later or choose another model.");
});