AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(frontend/copilot): show "Thinking…" instead of backend status lines (#15441)
Ubbeb469bf18886e
diff --git a/autogpt_platform/backend/backend/copilot/response_model.py b/autogpt_platform/backend/backend/copilot/response_model.pyindex 655aab18cb..e23d033ec4 100644--- a/autogpt_platform/backend/backend/copilot/response_model.py+++ b/autogpt_platform/backend/backend/copilot/response_model.py@@ -410,9 +410,9 @@ class StreamStatus(StreamBaseResponse):Emitted when the backend is about to enter a phase that would otherwiseleave the user staring at a silent "Thinking…" bubble — e.g. the firstLLM call, the continuation after a tool result, compacting conversation- context on retry, or activating a fallback model. The frontend reads- the latest `data-status` part on the current assistant message and uses- its `message` in place of the generic "Thinking…" copy.+ context on retry, or activating a fallback model. The copilot UI does+ not show `message` (it describes plumbing, not anything the user needs);+ it shows a plain "Thinking…" instead."""type: ResponseType = ResponseType.STATUSdiff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsxindex 0eb83a0a09..d73f8e7ea5 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx@@ -37,7 +37,6 @@ import {turnMessagesForRow,} from "./midTurnSplit";import {- getLatestAssistantStatusMessage,isBookkeepingPart,PENDING_DRAINED_PART_TYPE,} from "../../messageParts";@@ -405,11 +404,6 @@ export function ChatMessagesContainer({return false;})();- // Surface the latest `data-status` message from the live assistant when- // the Thinking indicator is up — but only if it wasn't invalidated by a- // more recent content part (in which case the model has moved on and the- // status is stale).- const latestStatusMessage = getLatestAssistantStatusMessage(messages);const isActivelyStreaming = status === "streaming" || status === "submitted";// A live compaction narrates itself via CompactionCard — the generic@@ -434,11 +428,7 @@ export function ChatMessagesContainer({activeStreamStartedAt,);const indicator = (- <ThinkingIndicator- active={showThinking}- elapsedSeconds={elapsedSeconds}- statusMessage={latestStatusMessage}- />+ <ThinkingIndicator active={showThinking} elapsedSeconds={elapsedSeconds} />);// Public viewers of a shared chat never see a live turn, so the indicator// stays out of the transcript for them wherever it would render.@@ -807,9 +797,7 @@ export function ChatMessagesContainer({<ThinkingIndicatoractiveelapsedSeconds={restoreElapsedSeconds}- statusMessage={- restoreStatusMessage ?? "Reconnecting to live stream..."- }+ statusMessage={restoreStatusMessage ?? "Reconnecting…"}/><span className="pl-6 text-xs text-slate-400">Still syncing the latest progress.diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/__tests__/ChatMessagesContainer.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/__tests__/ChatMessagesContainer.test.tsxindex 4a637834db..b77acc5de6 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/__tests__/ChatMessagesContainer.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/__tests__/ChatMessagesContainer.test.tsx@@ -228,6 +228,32 @@ describe("ChatMessagesContainer — assistant rendering", () => {expect(screen.getByTestId("thinking-indicator")).toBeDefined();});+ it("keeps the backend's status lines out of the thinking indicator", () => {+ render(+ <ChatMessagesContainer+ {...baseProps}+ status="submitted"+ messages={[+ {+ id: "assistant-status",+ role: "assistant",+ parts: [+ {+ type: "data-status",+ data: { message: "Restoring your session…" },+ },+ ],+ },+ ]}+ />,+ );++ expect(screen.getByTestId("thinking-indicator").textContent).toBe(+ "thinking",+ );+ expect(screen.queryByText("Restoring your session…")).toBeNull();+ });+it("keeps the thinking indicator out of a read-only transcript", () => {render(<ChatMessagesContainer@@ -390,19 +416,19 @@ describe("ChatMessagesContainer — loading", () => {});expect(screen.getByTestId("thinking-indicator")).toBeDefined();- expect(screen.getByText("Reconnecting to live stream...")).toBeDefined();+ expect(screen.getByText("Reconnecting…")).toBeDefined();expect(screen.getByText("Still syncing the latest progress."),).toBeDefined();});- it("prefers the backend status message in the restore fallback", () => {+ it("prefers the runtime's notice in the restore fallback", () => {render(<ChatMessagesContainer{...baseProps}isLoading={false}isRestoringActiveSession- restoreStatusMessage="Analyzing result..."+ restoreStatusMessage="Catching up…"messages={[{id: "user-1",@@ -417,7 +443,7 @@ describe("ChatMessagesContainer — loading", () => {vi.advanceTimersByTime(6_000);});- expect(screen.getByText("Analyzing result...")).toBeDefined();+ expect(screen.getByText("Catching up…")).toBeDefined();});});diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/ThinkingIndicator.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/ThinkingIndicator.tsxindex 5177d8380e..b5ee32738a 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/ThinkingIndicator.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/ThinkingIndicator.tsx@@ -9,10 +9,10 @@ interface Props {active: boolean;elapsedSeconds: number;/**- * Backend-emitted status message for the current silent gap (e.g.- * "Reading your message…", "Analyzing result…", "Optimizing conversation- * context…"). An absent message shows no label at all rather than- * inventing a generic placeholder.+ * Plain-language label for a wait the UI itself narrates (e.g. "Uploading+ * 2 files…"). Defaults to "Thinking…". The backend's own `data-status`+ * lines ("Restoring your session…", "Preparing workspace…") never reach+ * here: they describe plumbing, not anything the user needs to know.*/statusMessage?: string | null;}@@ -31,10 +31,11 @@ export function ThinkingIndicator({className="inline-flex w-fit items-center gap-2.5 text-sm text-zinc-600"><PixelGridLoader className="text-zinc-600" />- {statusMessage && (- <SwapText text={statusMessage} shimmer className="text-sm" />- )}- {!statusMessage && <span className="sr-only">Thinking…</span>}+ <SwapText+ text={statusMessage ?? "Thinking…"}+ shimmer+ className="text-sm"+ />{showTime && (<span className="font-mono text-xs tabular-nums text-zinc-400">{formatElapsed(elapsedSeconds)}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/messageParts.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/messageParts.tsindex 905dbf18a4..020f6886a0 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/messageParts.ts+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/messageParts.ts@@ -3,7 +3,7 @@ import type { UIMessage } from "ai";import { COMPACTION_DATA_PART_TYPE } from "./components/CompactionCard/helpers";import { DREAM_OPERATIONS_PART_TYPE } from "./dreamOperations";-/** Transient copy for the Thinking indicator — never rendered inline. */+/** Backend progress line ("Preparing workspace…"). Never shown to the user. */export const STATUS_PART_TYPE = "data-status";export const TOOL_DISPLAY_PART_TYPE = "data-tool-display";/**@@ -40,9 +40,10 @@ export function isBookkeepingPart(part: { type: string }): boolean {}/**- * Surface the latest backend-emitted status message for the trailing assistant- * message, if that status has not already been invalidated by newer visible- * parts. Used to show progress during restore/replay before answer text lands.+ * The latest backend-emitted status message for the trailing assistant+ * message, if newer visible parts have not already overtaken it. A non-null+ * result proves the stream is live before any answer text lands; the text+ * itself is never shown.*/export function getLatestAssistantStatusMessage(messages: UIMessage[],diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.tsindex 8167f533fc..01cd276444 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts@@ -6,7 +6,6 @@ import type { UIMessage } from "ai";import { parseAsString, useQueryState } from "nuqs";import { useEffect, useMemo, useRef, useState } from "react";import { concatWithAssistantMerge } from "./helpers/convertChatSessionToUiMessages";-import { getLatestAssistantStatusMessage } from "./messageParts";import type { WorkspaceAttachment } from "./helpers/workspaceAttachments";import {forgetHeldFollowUp,@@ -338,17 +337,8 @@ export function useCopilotPage({() => stripReplayPrefix(cachedRawMessages),[cachedRawMessages],);- const latestStatusMessage = useMemo(- () =>- isRestoringActiveSession- ? getLatestAssistantStatusMessage(messages)- : null,- [isRestoringActiveSession, messages],- );// The runtime's restore state is a passive notice; it never trims the list.- const restoreStatusMessage = runtimeStream- ? runtimeStream.restoreStatusMessage- : latestStatusMessage;+ const restoreStatusMessage = runtimeStream?.restoreStatusMessage ?? null;const displayMessages = useMemo(() => {if (!isRestoringActiveSession || runtimeStream) return messages;if (hasAssistantTail(cachedMessages)) return cachedMessages;