Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(webui): hide recovery notice while resumed tasks run
chengyongru559107172a39
diff --git a/webui/src/components/thread/RecoveryNotice.tsx b/webui/src/components/thread/RecoveryNotice.tsxindex 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 }: RecoveryNoticePsetHiddenRecoveryId(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 }: RecoveryNoticePreturn (<div- role={waiting ? "alert" : "status"}- aria-live={waiting ? "assertive" : "polite"}- aria-busy={state.status === "resuming"}+ role="alert"+ aria-live="assertive"data-recovery-status={state.status}className="mx-auto mb-2 flex w-full max-w-[49.5rem] items-center gap-3 rounded-control border border-border/70 bg-muted/35 px-3 py-2 text-sm transition-[background-color,border-color,opacity,transform] duration-200 ease-out motion-reduce:transition-none animate-in fade-in-0 slide-in-from-bottom-1 duration-200 motion-reduce:animate-none">- {waiting ? (- <AlertTriangle className="h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400" aria-hidden />- ) : (- <LoaderCircle className="h-4 w-4 shrink-0 animate-spin text-primary motion-reduce:animate-none" aria-hidden />- )}+ <AlertTriangle className="h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400" aria-hidden /><div className="min-w-0 flex-1"><p className="font-medium">{title}@@ -81,31 +74,29 @@ export function RecoveryNotice({ state, onContinue, onDismiss }: RecoveryNoticeP{error ?? detail}</p></div>- {waiting ? (- <div className="flex shrink-0 items-center gap-1.5">+ <div className="flex shrink-0 items-center gap-1.5">+ <Button+ type="button"+ size="sm"+ variant="outline"+ disabled={pending !== null}+ onClick={() => run("dismiss")}+ >+ <X className="mr-1 h-3.5 w-3.5" aria-hidden />+ {t("recovery.dismiss", { defaultValue: "Dismiss" })}+ </Button>+ {!contextUnavailable ? (<Buttontype="button"size="sm"- variant="outline"disabled={pending !== null}- onClick={() => run("dismiss")}+ onClick={() => run("continue")}>- <X className="mr-1 h-3.5 w-3.5" aria-hidden />- {t("recovery.dismiss", { defaultValue: "Dismiss" })}+ <ResumeIcon className="mr-1 h-3.5 w-3.5" aria-hidden />+ {t("recovery.continue", { defaultValue: "Continue" })}</Button>- {!contextUnavailable ? (- <Button- type="button"- size="sm"- disabled={pending !== null}- onClick={() => run("continue")}- >- <ResumeIcon className="mr-1 h-3.5 w-3.5" aria-hidden />- {t("recovery.continue", { defaultValue: "Continue" })}- </Button>- ) : null}- </div>- ) : null}+ ) : null}+ </div></div>);}diff --git a/webui/src/tests/recovery-notice.test.tsx b/webui/src/tests/recovery-notice.test.tsxindex 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(+ <RecoveryNotice state={INTERRUPTED} onContinue={onContinue} onDismiss={onDismiss} />,+ );++ fireEvent.click(screen.getByRole("button", { name: "Continue" }));+ await waitFor(() => expect(screen.queryByRole("alert")).not.toBeInTheDocument());+ unmount();++ const { container } = render(<RecoveryNoticestate={{ status: "resuming", recovery_id: "recovery-1" }}+ onContinue={onContinue}+ onDismiss={onDismiss}+ />,+ );++ expect(container).toBeEmptyDOMElement();+ });++ it("uses the shared alert surface and motion treatment", () => {+ render(+ <RecoveryNotice+ state={INTERRUPTED}onContinue={vi.fn().mockResolvedValue(undefined)}onDismiss={vi.fn().mockResolvedValue(undefined)}/>,);- 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(- <RecoveryNotice- state={INTERRUPTED}- onContinue={onContinue}- onDismiss={vi.fn().mockResolvedValue(undefined)}- />,- );-- fireEvent.click(screen.getByRole("button", { name: "Continue" }));- await waitFor(() => expect(screen.queryByRole("alert")).not.toBeInTheDocument());-- rerender(- <RecoveryNotice- state={{ status: "resuming", recovery_id: "recovery-1" }}- onContinue={onContinue}- onDismiss={vi.fn().mockResolvedValue(undefined)}- />,- );- rerender(- <RecoveryNotice- state={{ ...INTERRUPTED, reason: "loop_guard" }}- onContinue={onContinue}- onDismiss={vi.fn().mockResolvedValue(undefined)}- />,- );-- await waitFor(() => expect(screen.getByRole("alert")).toBeInTheDocument());- });+ 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(+ <RecoveryNotice+ state={INTERRUPTED}+ onContinue={onContinue}+ onDismiss={vi.fn().mockResolvedValue(undefined)}+ />,+ );++ fireEvent.click(screen.getByRole("button", { name: "Continue" }));+ await waitFor(() => expect(screen.queryByRole("alert")).not.toBeInTheDocument());++ rerender(+ <RecoveryNotice+ state={{ status: "resuming", recovery_id: "recovery-1" }}+ onContinue={onContinue}+ onDismiss={vi.fn().mockResolvedValue(undefined)}+ />,+ );+ rerender(+ <RecoveryNotice+ state={{ ...INTERRUPTED, status, reason: "loop_guard" }}+ onContinue={onContinue}+ onDismiss={vi.fn().mockResolvedValue(undefined)}+ />,+ );++ 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.tsxindex 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,+ <ThreadShell+ session={session("resuming-chat")}+ title="Resuming chat"+ onToggleSidebar={() => {}}+ />,+ ));++ 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(