diff --git a/webui/src/components/thread/RecoveryNotice.tsx b/webui/src/components/thread/RecoveryNotice.tsx index e33a0cf89..1b5ef0709 100644 --- a/webui/src/components/thread/RecoveryNotice.tsx +++ b/webui/src/components/thread/RecoveryNotice.tsx @@ -2,7 +2,7 @@ import { ResumeIcon, } from "@/components/icons/product-icons"; import { useEffect, useState } from "react"; -import { AlertTriangle, LoaderCircle, X } from "lucide-react"; +import { AlertTriangle, X } from "lucide-react"; import { useTranslation } from "react-i18next"; import { Button } from "@/components/ui/button"; @@ -27,22 +27,20 @@ export function RecoveryNotice({ state, onContinue, onDismiss }: RecoveryNoticeP setHiddenRecoveryId(null); } }, [state.recovery_id, state.status]); - if (state.status === "recovered" || hiddenRecoveryId === state.recovery_id) return null; - const waiting = state.status === "awaiting_user" || state.status === "failed"; + // Recovery metadata stays resuming until the continued turn commits, but + // execution progress belongs to the normal running-turn UI, even after reload. + if (!waiting || hiddenRecoveryId === state.recovery_id) return null; + const contextUnavailable = state.can_continue === false; const title = state.status === "failed" ? t("recovery.failed", { defaultValue: "Task recovery failed" }) - : waiting - ? t("recovery.interrupted", { defaultValue: "Task interrupted" }) - : t("recovery.resuming", { defaultValue: "Restoring interrupted task…" }); + : t("recovery.interrupted", { defaultValue: "Task interrupted" }); const detail = state.status === "failed" || contextUnavailable ? t("recovery.failedHelp", { defaultValue: "The saved task could not be restored safely. Review it before continuing.", }) - : waiting - ? t("recovery.review", { defaultValue: "Review the task before continuing. Tools will not be replayed automatically." }) - : t("recovery.safeResume", { defaultValue: "Continuing from saved conversation context." }); + : t("recovery.review", { defaultValue: "Review the task before continuing. Tools will not be replayed automatically." }); const run = (action: "continue" | "dismiss") => { setPending(action); setError(null); @@ -59,17 +57,12 @@ export function RecoveryNotice({ state, onContinue, onDismiss }: RecoveryNoticeP return (
- {waiting ? ( - - ) : ( - - )} +

{title} @@ -81,31 +74,29 @@ export function RecoveryNotice({ state, onContinue, onDismiss }: RecoveryNoticeP {error ?? detail}

- {waiting ? ( -
+
+ + {!contextUnavailable ? ( - {!contextUnavailable ? ( - - ) : null} -
- ) : null} + ) : null} +
); } diff --git a/webui/src/tests/recovery-notice.test.tsx b/webui/src/tests/recovery-notice.test.tsx index 391f08ff3..cf1820d09 100644 --- a/webui/src/tests/recovery-notice.test.tsx +++ b/webui/src/tests/recovery-notice.test.tsx @@ -27,18 +27,40 @@ describe("RecoveryNotice", () => { expect(onContinue).toHaveBeenCalledOnce(); }); - it("uses the shared status surface and motion treatment", () => { - render( + it("keeps an active continuation hidden after remounting", async () => { + const onContinue = vi.fn().mockResolvedValue(undefined); + const onDismiss = vi.fn().mockResolvedValue(undefined); + const { unmount } = render( + , + ); + + fireEvent.click(screen.getByRole("button", { name: "Continue" })); + await waitFor(() => expect(screen.queryByRole("alert")).not.toBeInTheDocument()); + unmount(); + + const { container } = render( , + ); + + expect(container).toBeEmptyDOMElement(); + }); + + it("uses the shared alert surface and motion treatment", () => { + render( + , ); - const notice = screen.getByRole("status"); - expect(notice).toHaveAttribute("data-recovery-status", "resuming"); - expect(notice).toHaveAttribute("aria-live", "polite"); + const notice = screen.getByRole("alert"); + expect(notice).toHaveAttribute("data-recovery-status", "awaiting_user"); + expect(notice).toHaveAttribute("aria-live", "assertive"); expect(notice).toHaveClass( "max-w-[49.5rem]", "rounded-control", @@ -68,36 +90,39 @@ describe("RecoveryNotice", () => { }); }); - it("shows the decision surface again when a continuation is interrupted", async () => { - const onContinue = vi.fn().mockResolvedValue(undefined); - const { rerender } = render( - , - ); + it.each(["awaiting_user", "failed"] as const)( + "shows the decision surface again when a continuation returns to %s", + async (status) => { + const onContinue = vi.fn().mockResolvedValue(undefined); + const { rerender } = render( + , + ); - fireEvent.click(screen.getByRole("button", { name: "Continue" })); - await waitFor(() => expect(screen.queryByRole("alert")).not.toBeInTheDocument()); + fireEvent.click(screen.getByRole("button", { name: "Continue" })); + await waitFor(() => expect(screen.queryByRole("alert")).not.toBeInTheDocument()); - rerender( - , - ); - rerender( - , - ); + rerender( + , + ); + rerender( + , + ); - await waitFor(() => expect(screen.getByRole("alert")).toBeInTheDocument()); - }); + await waitFor(() => expect(screen.getByRole("alert")).toBeInTheDocument()); + }, + ); it("does not offer Continue when saved conversation context is unavailable", () => { render( diff --git a/webui/src/tests/thread-shell.test.tsx b/webui/src/tests/thread-shell.test.tsx index e6a40f8ce..09d3dd1e9 100644 --- a/webui/src/tests/thread-shell.test.tsx +++ b/webui/src/tests/thread-shell.test.tsx @@ -5478,6 +5478,31 @@ describe("ThreadShell", () => { expect(screen.getByRole("option", { name: /Other project/i })).toBeInTheDocument(); }); + it("keeps normal running controls when attaching to a resumed task", async () => { + const client = makeClient(); + render(wrap( + client, + {}} + />, + )); + + await screen.findByLabelText("Message input"); + act(() => { + client._emitChat("resuming-chat", { + event: "attached", + chat_id: "resuming-chat", + recovery_state: { recovery_id: "recovery-1", status: "resuming" }, + }); + }); + + expect(screen.queryByText("Restoring interrupted task…")).not.toBeInTheDocument(); + fireEvent.click(screen.getByRole("button", { name: "Stop response" })); + expect(client.sendMessage).toHaveBeenCalledWith("resuming-chat", "/stop"); + }); + it("allows a new turn after a completed recovery state", async () => { const client = makeClient(); render(wrap(