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 task progress bar above chat input (flagged) (#13476)
Abhimanyu Yadavce2985e4d003
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/CopilotPage.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/CopilotPage.tsxindex 28965fc657..7079d68fb0 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/CopilotPage.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/CopilotPage.tsx@@ -3,7 +3,7 @@import { LowCreditBanner } from "@/components/layout/TopUpPrompt/LowCreditBanner/LowCreditBanner";import { DotDistortionShader } from "@/components/ui/dot-distortion-shader";import { SidebarProvider } from "@/components/ui/sidebar";-import { NAVBAR_HEIGHT_PX } from "@/lib/constants";+import { INSET_HEADER_HEIGHT_PX, NAVBAR_HEIGHT_PX } from "@/lib/constants";import { useSupabase } from "@/lib/supabase/hooks/useSupabase";import { Flag, useGetFlag } from "@/services/feature-flags/use-get-flag";import { usePlatformChrome } from "../PlatformChrome/usePlatformChrome";@@ -64,14 +64,19 @@ export function CopilotPage() {return (<SidebarProviderdefaultOpen={true}- // New layout: fill the inset's flex-1 section (its 48px header is already- // accounted for by the parent), so don't subtract the old navbar height.- // Classic layout: an explicit height is needed because `h-full` against- // <section className="flex-1"> drifts out of sync with the navbar-driven- // --preview-banner-height var during re-renders, clipping the navbar.+ // Both layouts need an explicit, viewport-bound height: the chat column+ // relies on a definite height so its inner `min-h-0` chain lets the+ // messages area (not the page) absorb growth — e.g. expanding the task+ // progress accordion above the input. The new-layout ancestors+ // (SidebarProvider `min-h-svh` → SidebarInset `flex-1` → `section flex-1`)+ // only set a *minimum* height, so `height: 100%` there resolves to+ // content height and the accordion pushes the input below the fold.+ // Subtract the inset header in the new layout; the navbar + preview+ // banner in the classic one. `svh` keeps the input visible when mobile+ // browser chrome is shown.style={showNewLayout- ? { height: "100%" }+ ? { height: `calc(100svh - ${INSET_HEADER_HEIGHT_PX}px)` }: {height: `calc(100vh - ${NAVBAR_HEIGHT_PX}px - var(--preview-banner-height, 0px))`,}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/ChatContainer.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/ChatContainer.tsxindex 33499bde1a..df7f382c65 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/ChatContainer.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/ChatContainer.tsx@@ -16,6 +16,8 @@ import { CopilotChatActionsProvider } from "../CopilotChatActionsProvider/Copiloimport { EmptySession } from "../EmptySession/EmptySession";import { UsageLimitReachedCard } from "../UsageLimits/UsageLimitReachedCard/UsageLimitReachedCard";import { useIsUsageLimitReached } from "../UsageLimits/useIsUsageLimitReached";+import { TaskProgressBar } from "../TaskProgressBar/TaskProgressBar";+import { getLatestTaskList } from "../TaskProgressBar/helpers";import { SharedChatNotice } from "./components/SharedChatNotice";import { useAutoOpenArtifacts } from "./useAutoOpenArtifacts";@@ -90,6 +92,7 @@ export const ChatContainer = ({turnStats,}: ChatContainerProps) => {const isArtifactsEnabled = useGetFlag(Flag.ARTIFACTS);+ const isTaskBarEnabled = useGetFlag(Flag.TASK_PROGRESS_BAR);useAutoOpenArtifacts({sessionId,messages,@@ -201,6 +204,14 @@ export const ChatContainer = ({</div>)}<SharedChatNotice sessionId={sessionId} />+ {isTaskBarEnabled && (+ <div className="relative z-10">+ <TaskProgressBar+ todos={getLatestTaskList(messages) ?? []}+ isStreaming={isStreaming}+ />+ </div>+ )}<Tooltip open={isLimitReached ? undefined : false}><TooltipTrigger asChild><div>diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/__tests__/ChatContainer.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/__tests__/ChatContainer.test.tsxindex 607045b2db..1b6a5e06ba 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/__tests__/ChatContainer.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/__tests__/ChatContainer.test.tsx@@ -58,35 +58,47 @@ function mockShareState(state: Partial<ChatShareStateResponse>) {);}-vi.mock("framer-motion", () => ({- LayoutGroup: ({ children }: { children: React.ReactNode }) => <>{children}</>,- motion: {- div: React.forwardRef(function MotionDiv(+vi.mock("framer-motion", () => {+ const MOTION_PROPS = [+ "initial",+ "animate",+ "exit",+ "transition",+ "layout",+ "layoutId",+ "whileHover",+ "whileTap",+ "style",+ ];+ function makeMotion(Tag: string) {+ return React.forwardRef(function MotionComponent(props: Record<string, unknown>,- ref: React.Ref<HTMLDivElement>,+ ref: React.Ref<unknown>,) {- const {- children,- initial: _initial,- animate: _animate,- transition: _transition,- ...rest- } = props as {- children?: React.ReactNode;- initial?: unknown;- animate?: unknown;- transition?: unknown;- [key: string]: unknown;- };-- return (- <div ref={ref} {...rest}>- {children}- </div>- );- }),- },-}));+ const rest: Record<string, unknown> = {};+ let children: React.ReactNode = null;+ for (const [key, value] of Object.entries(props)) {+ if (key === "children") children = value as React.ReactNode;+ else if (!MOTION_PROPS.includes(key)) rest[key] = value;+ }+ return React.createElement(Tag, { ref, ...rest }, children);+ });+ }+ return {+ LayoutGroup: ({ children }: { children: React.ReactNode }) => (+ <>{children}</>+ ),+ AnimatePresence: ({ children }: { children: React.ReactNode }) => (+ <>{children}</>+ ),+ useReducedMotion: () => false,+ motion: {+ div: makeMotion("div"),+ span: makeMotion("span"),+ button: makeMotion("button"),+ },+ };+});vi.mock("@/app/(platform)/copilot/components/ChatInput/ChatInput", () => ({ChatInput: () => <div data-testid="chat-input" />,diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsxindex 794da91763..9b04f9fa48 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsx@@ -260,7 +260,7 @@ export function ChatInput({)}<InputGroupclassName={cn(- "overflow-hidden has-[[data-slot=input-group-control]:focus-visible]:border-neutral-200 has-[[data-slot=input-group-control]:focus-visible]:ring-0",+ "overflow-hidden border-zinc-200 has-[[data-slot=input-group-control]:focus-visible]:border-neutral-200 has-[[data-slot=input-group-control]:focus-visible]:ring-0",isRecording &&"border-red-400 ring-1 ring-red-400 has-[[data-slot=input-group-control]:focus-visible]:border-red-400 has-[[data-slot=input-group-control]:focus-visible]:ring-red-400",)}diff --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 13b0f7da59..6a78d5e1c7 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@@ -41,7 +41,7 @@ import { ReasoningGroup } from "./components/ReasoningGroup";import { StepsCollapse } from "./components/StepsCollapse";import { TaskListNotice } from "./components/TaskListNotice";import { ThinkingIndicator } from "./components/ThinkingIndicator";-import { getLatestTaskList } from "../ContextPanel/components/ProgressTab/helpers";+import { getLatestTaskList } from "../TaskProgressBar/helpers";interface Props {messages: UIMessage<unknown, UIDataTypes, UITools>[];@@ -323,14 +323,18 @@ export function ChatMessagesContainer({filePattern,fileUrlBuilder,}: Props) {+ // The in-chat "progress in the sidebar" notice only applies to the old+ // sidebar surface — hide it entirely when the task bar is on.+ const isTaskBarEnabled = useGetFlag(Flag.TASK_PROGRESS_BAR);const isContextPanelEnabled = useGetFlag(Flag.ARTIFACTS);- const latestTaskList = getLatestTaskList(messages);const isChatStreaming = status === "streaming" || status === "submitted";- const hasActiveTaskList = shouldShowTaskListNotice({- isContextPanelEnabled,- isChatStreaming,- latestTaskList,- });+ const hasActiveTaskList =+ !isTaskBarEnabled &&+ shouldShowTaskListNotice({+ isContextPanelEnabled,+ isChatStreaming,+ latestTaskList: getLatestTaskList(messages),+ });// Hide the container for one frame when messages first load so// StickToBottom can scroll to the bottom before the user sees it.diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/__tests__/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/__tests__/helpers.test.tsindex 67ba5b0f64..0be4efbf7c 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/__tests__/helpers.test.ts+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/__tests__/helpers.test.ts@@ -16,7 +16,7 @@ import {} from "../helpers";import type { MessagePart } from "../helpers";import type { FileUIPart, UIDataTypes, UIMessage, UITools } from "ai";-import type { TodoItem } from "../../ContextPanel/components/ProgressTab/helpers";+import type { TodoItem } from "../../TaskProgressBar/helpers";function textPart(text: string): MessagePart {return { type: "text", text } as MessagePart;diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/helpers.tsindex b94b65de3e..3fd5edde3e 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/helpers.ts+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/helpers.ts@@ -4,7 +4,7 @@ import { parseWorkspaceURI } from "@/lib/workspace-uri";import { FileUIPart, ToolUIPart, UIDataTypes, UIMessage, UITools } from "ai";import { isCorruptedCardToolPart } from "../../helpers/toolOutput";import type { ArtifactRef } from "../../store";-import type { TodoItem } from "../ContextPanel/components/ProgressTab/helpers";+import type { TodoItem } from "../TaskProgressBar/helpers";export function shouldShowTaskListNotice({isContextPanelEnabled,diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanel.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanel.tsxindex ab117add1b..7b690d3033 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanel.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanel.tsx@@ -7,6 +7,7 @@ import {SheetTitle,} from "@/components/ui/sheet";import { cn } from "@/lib/utils";+import { Flag, useGetFlag } from "@/services/feature-flags/use-get-flag";import { XIcon } from "@phosphor-icons/react";import { MAX_CONTEXT_PANEL_WIDTH, MIN_CONTEXT_PANEL_WIDTH } from "../../store";import { PanelResizeHandle } from "../PanelResizeHandle";@@ -33,6 +34,12 @@ export function ContextPanel({ sessionId, mobile }: Props) {} = useContextPanel();const { uploaded, generated } = useSessionFiles(sessionId);const filesCount = uploaded.length + generated.length;+ // When the task bar (above the chat input) is on, the sidebar drops the+ // Progress tab and shows Files only.+ const showProgressTab = !useGetFlag(Flag.TASK_PROGRESS_BAR);+ // Clamp a persisted "progress" tab to "files" when Progress is hidden, so+ // the switcher never ends up with no selected tab.+ const effectiveTab = showProgressTab ? activeTab : "files";const tabs = (<div className="flex min-h-0 flex-1 flex-col">@@ -43,9 +50,10 @@ export function ContextPanel({ sessionId, mobile }: Props) {)}><TabSwitcher- activeTab={activeTab}+ activeTab={effectiveTab}filesCount={filesCount}onChange={setActiveTab}+ showProgressTab={showProgressTab}/>{!mobile && (<button@@ -60,8 +68,11 @@ export function ContextPanel({ sessionId, mobile }: Props) {)}</div><div className="flex min-h-0 flex-1 flex-col">- {activeTab === "progress" && <ProgressTab sessionId={sessionId} />}- {activeTab === "files" && <FilesTab sessionId={sessionId} />}+ {showProgressTab && effectiveTab === "progress" ? (+ <ProgressTab sessionId={sessionId} />+ ) : (+ <FilesTab sessionId={sessionId} />+ )}</div></div>);diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanelAutoOpen.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanelAutoOpen.tsxindex 048c691c2c..f794ed53a2 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanelAutoOpen.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanelAutoOpen.tsx@@ -1,5 +1,6 @@"use client";+import { Flag, useGetFlag } from "@/services/feature-flags/use-get-flag";import { useAutoOpenForFiles } from "./useAutoOpenForFiles";import { useAutoOpenForProgress } from "./useAutoOpenForProgress";import { useCollapseContextPanelOnSession } from "./useCollapseContextPanelOnSession";@@ -9,8 +10,10 @@ interface Props {}export function ContextPanelAutoOpen({ sessionId }: Props) {+ // The sidebar auto-opens on progress only when the task bar is off.+ const taskBarEnabled = useGetFlag(Flag.TASK_PROGRESS_BAR);useCollapseContextPanelOnSession(sessionId);useAutoOpenForFiles(sessionId);- useAutoOpenForProgress(sessionId);+ useAutoOpenForProgress(sessionId, !taskBarEnabled);return null;}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/ProgressTab/ProgressTab.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/ProgressTab/ProgressTab.tsxindex 165f610efd..a8d1275d36 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/ProgressTab/ProgressTab.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/ProgressTab/ProgressTab.tsx@@ -7,7 +7,11 @@ import {} from "@phosphor-icons/react";import { motion } from "framer-motion";import { useCopilotStreamStore } from "../../../../copilotStreamStore";-import { countCompleted, getLatestTaskList, type TodoItem } from "./helpers";+import {+ countCompleted,+ getLatestTaskList,+ type TodoItem,+} from "../../../TaskProgressBar/helpers";interface Props {sessionId: string | null;diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/ProgressTab/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/ProgressTab/helpers.tsdeleted file mode 100644index b1e49c4531..0000000000--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/ProgressTab/helpers.ts+++ /dev/null@@ -1,40 +0,0 @@-import type { UIMessage } from "ai";--export interface TodoItem {- content: string;- status: "pending" | "in_progress" | "completed";- activeForm?: string;-}--function isTodoItem(value: unknown): value is TodoItem {- if (!value || typeof value !== "object") return false;- const v = value as Record<string, unknown>;- return (- typeof v.content === "string" &&- (v.status === "pending" ||- v.status === "in_progress" ||- v.status === "completed")- );-}--export function getLatestTaskList(messages: UIMessage[]): TodoItem[] | null {- for (let i = messages.length - 1; i >= 0; i--) {- const parts = messages[i]?.parts;- if (!parts) continue;- for (let j = parts.length - 1; j >= 0; j--) {- const part = parts[j] as { type: string; input?: unknown };- if (part.type !== "tool-TodoWrite") continue;- const input = part.input;- if (!input || typeof input !== "object") continue;- const todos = (input as { todos?: unknown }).todos;- if (!Array.isArray(todos)) continue;- const filtered = todos.filter(isTodoItem);- if (filtered.length > 0) return filtered;- }- }- return null;-}--export function countCompleted(todos: TodoItem[]): number {- return todos.filter((t) => t.status === "completed").length;-}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/TabSwitcher.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/TabSwitcher.tsxindex a73d0322c9..2857a34392 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/TabSwitcher.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/TabSwitcher.tsx@@ -5,11 +5,19 @@ interface Props {activeTab: ContextPanelTab;filesCount: number;onChange: (tab: ContextPanelTab) => void;+ showProgressTab?: boolean;}-export function TabSwitcher({ activeTab, filesCount, onChange }: Props) {+export function TabSwitcher({+ activeTab,+ filesCount,+ onChange,+ showProgressTab = true,+}: Props) {const tabs: { id: ContextPanelTab; label: string }[] = [- { id: "progress", label: "Progress" },+ ...(showProgressTab+ ? [{ id: "progress" as const, label: "Progress" }]+ : []),{ id: "files", label: `Files (${filesCount})` },];diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/useAutoOpenForFiles.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/useAutoOpenForFiles.tsindex 6bbf2cec56..a3b98b2986 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/useAutoOpenForFiles.ts+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/useAutoOpenForFiles.ts@@ -21,7 +21,7 @@ function getLastGeneratedFile(generated: SessionFile[]): SessionFile | null {/*** The first time a session is found to have generated files, opens the Artifact* panel directly on the most recently generated file (unless the user has- * explicitly closed the panel). Mirrors useAutoOpenForProgress.+ * explicitly closed the panel).*/export function useAutoOpenForFiles(sessionId: string | null) {const autoOpenArtifact = useCopilotUIStore((s) => s.autoOpenArtifact);diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/useAutoOpenForProgress.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/useAutoOpenForProgress.tsindex 704b82c433..f746c7fa7f 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/useAutoOpenForProgress.ts+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/useAutoOpenForProgress.ts@@ -3,10 +3,7 @@import { useEffect, useRef } from "react";import { useCopilotStreamStore } from "../../copilotStreamStore";import { useCopilotUIStore } from "../../store";-import {- getLatestTaskList,- type TodoItem,-} from "./components/ProgressTab/helpers";+import { getLatestTaskList, type TodoItem } from "../TaskProgressBar/helpers";function hasActiveWork(todos: TodoItem[] | null): boolean {if (!todos || todos.length === 0) return false;@@ -20,7 +17,10 @@ function hasActiveWork(todos: TodoItem[] | null): boolean {* task list goes "active" (has any incomplete todo). Re-arms when the active* state flips back to inactive so a subsequent task list reopens the panel.*/-export function useAutoOpenForProgress(sessionId: string | null) {+export function useAutoOpenForProgress(+ sessionId: string | null,+ enabled = true,+) {const openContextPanelForProgress = useCopilotUIStore((s) => s.openContextPanelForProgress,);@@ -38,6 +38,7 @@ export function useAutoOpenForProgress(sessionId: string | null) {}, [sessionId]);useEffect(() => {+ if (!enabled) return;const todos = messages ? getLatestTaskList(messages) : null;const active = hasActiveWork(todos);if (active && !wasActiveRef.current) {@@ -46,5 +47,5 @@ export function useAutoOpenForProgress(sessionId: string | null) {} else if (!active && wasActiveRef.current) {wasActiveRef.current = false;}- }, [messages, openContextPanelForProgress]);+ }, [enabled, messages, openContextPanelForProgress]);}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/TaskProgressBar.stories.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/TaskProgressBar.stories.tsxnew file mode 100644index 0000000000..5e8b3cb29e--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/TaskProgressBar.stories.tsx@@ -0,0 +1,162 @@+import { TooltipProvider } from "@/components/ui/tooltip";+import type { Meta, StoryObj } from "@storybook/nextjs";+import { ChatInput } from "../ChatInput/ChatInput";+import { TaskProgressBar } from "./TaskProgressBar";+import type { TodoItem } from "./helpers";++const SAMPLE: TodoItem[] = [+ { content: "Read the uploaded spreadsheet", status: "completed" },+ { content: "Clean and normalize the rows", status: "completed" },+ {+ content: "Generate the summary chart",+ status: "in_progress",+ activeForm: "Generating the summary chart…",+ },+ { content: "Write the report", status: "pending" },+ { content: "Attach the report to the chat", status: "pending" },+];++const meta: Meta<typeof TaskProgressBar> = {+ title: "Copilot/TaskProgressBar",+ component: TaskProgressBar,+ tags: ["autodocs"],+ parameters: {+ layout: "padded",+ docs: {+ description: {+ component:+ "Compact, collapsible task-list bar meant to sit directly above the chat input. Shows the current task + completion count when collapsed; expands to the full checklist. Presentational only — the backend wiring comes in a later step.",+ },+ },+ },+ argTypes: {+ isStreaming: { control: "boolean" },+ defaultExpanded: { control: "boolean" },+ },+ decorators: [+ (Story) => (+ // Mirrors ChatContainer: the bar sits just above the chat input inside the+ // #fafafa chat column. ChatInput is shown for placement reference only.+ <TooltipProvider>+ <div className="mx-auto flex w-full max-w-3xl flex-col bg-[#fafafa] px-3 pb-2 pt-2">+ <div className="relative z-10">+ <Story />+ </div>+ <ChatInput+ onSend={() => {}}+ placeholder="What else can I help with?"+ hasSession+ />+ </div>+ </TooltipProvider>+ ),+ ],+};++export default meta;+type Story = StoryObj<typeof meta>;++export const Collapsed: Story = {+ name: "Collapsed — Streaming",+ args: {+ todos: SAMPLE,+ isStreaming: true,+ defaultExpanded: false,+ },+};++export const Expanded: Story = {+ name: "Expanded — Streaming",+ args: {+ todos: SAMPLE,+ isStreaming: true,+ defaultExpanded: true,+ },+};++export const Idle: Story = {+ name: "Idle — In-progress shown as pending",+ args: {+ todos: SAMPLE,+ isStreaming: false,+ defaultExpanded: true,+ },+ parameters: {+ docs: {+ description: {+ story:+ "When not streaming, the in-progress task renders as pending (no active spinner/bold) so an idle agent doesn't look like it's still working.",+ },+ },+ },+};++export const JustStarted: Story = {+ name: "Just started — Nothing completed",+ args: {+ todos: [+ {+ content: "Analyze the goal",+ status: "in_progress",+ activeForm: "Analyzing the goal…",+ },+ { content: "Break it into steps", status: "pending" },+ { content: "Execute each step", status: "pending" },+ ],+ isStreaming: true,+ defaultExpanded: false,+ },+};++export const AllComplete: Story = {+ name: "All tasks complete",+ args: {+ todos: SAMPLE.map((t) => ({ ...t, status: "completed" as const })),+ isStreaming: false,+ defaultExpanded: false,+ },+};++export const SingleTask: Story = {+ name: "Single task",+ args: {+ todos: [+ {+ content: "Draft the email",+ status: "in_progress",+ activeForm: "Drafting the email…",+ },+ ],+ isStreaming: true,+ defaultExpanded: true,+ },+};++export const LongList: Story = {+ name: "Long list — Scrolls when expanded",+ args: {+ todos: Array.from({ length: 12 }, (_, i) => ({+ content: `Step ${i + 1}: do the thing number ${i + 1} with a fairly long description that may truncate`,+ status: i < 4 ? "completed" : i === 4 ? "in_progress" : "pending",+ activeForm: i === 4 ? "Working on step 5…" : undefined,+ })) as TodoItem[],+ isStreaming: true,+ defaultExpanded: true,+ },+};++export const Empty: Story = {+ name: "Empty — Renders nothing",+ args: {+ todos: [],+ isStreaming: false,+ },+ parameters: {+ docs: {+ description: {+ story:+ "With no tasks the component returns null so the above-input area stays clean until Autopilot populates a list.",+ },+ },+ },+};diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/TaskProgressBar.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/TaskProgressBar.tsxnew file mode 100644index 0000000000..bf2fe456eb--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/TaskProgressBar.tsx@@ -0,0 +1,168 @@+"use client";++import { Text } from "@/components/atoms/Text/Text";+import {+ CaretDownIcon,+ ListChecksIcon,+ SealCheckIcon,+} from "@phosphor-icons/react";+import { AnimatePresence, motion, useReducedMotion } from "framer-motion";+import { useState } from "react";+import { EASE_OUT } from "./animations";+import { StatusIcon } from "./components/StatusIcon/StatusIcon";+import { TaskRow } from "./components/TaskRow/TaskRow";+import {+ getCurrentLabel,+ getCurrentTask,+ isAllComplete,+ toDisplayStatus,+ type TodoItem,+} from "./helpers";++// BlurText-style swap for the collapsed header's cycling current task only.+const BLUR_SWAP = {+ initial: { filter: "blur(10px)", opacity: 0, y: -10 },+ animate: {+ filter: ["blur(10px)", "blur(4px)", "blur(0px)"],+ opacity: [0, 0.6, 1],+ y: [-10, 3, 0],+ transition: { duration: 0.22, times: [0, 0.5, 1], ease: EASE_OUT },+ },+ exit: {+ filter: ["blur(0px)", "blur(4px)", "blur(10px)"],+ opacity: [1, 0.6, 0],+ y: [0, 4, 10],+ transition: { duration: 0.14, times: [0, 0.5, 1], ease: EASE_OUT },+ },+};++const BLUR_SWAP_REDUCED = {+ initial: false,+ animate: { opacity: 1 },+ exit: { opacity: 0, transition: { duration: 0 } },+};++interface Props {+ todos: TodoItem[];+ isStreaming?: boolean;+ defaultExpanded?: boolean;+}++export function TaskProgressBar({+ todos,+ isStreaming = false,+ defaultExpanded = false,+}: Props) {+ const [expanded, setExpanded] = useState(defaultExpanded);+ const reduceMotion = useReducedMotion();++ if (!todos || todos.length === 0) return null;++ const allDone = isAllComplete(todos);+ const current = getCurrentTask(todos, isStreaming);+ const currentIndex = current ? todos.indexOf(current) : -1;++ const reveal = reduceMotion+ ? { duration: 0 }+ : { duration: 0.22, ease: EASE_OUT };++ return (+ <div className="mx-auto w-[95%] overflow-hidden rounded-t-3xl border border-b-0 border-zinc-200 bg-neutral-100 shadow-[inset_0_1px_0_0_rgba(255,255,255,0.9),inset_0_5px_6px_-4px_rgba(255,255,255,0.7)]">+ <button+ type="button"+ onClick={() => setExpanded((v) => !v)}+ aria-expanded={expanded}+ className="flex w-full items-center gap-2 px-3 py-3 text-left"+ >+ <div className="flex min-w-0 flex-1 items-center gap-2">+ {allDone ? (+ <>+ <SealCheckIcon+ size={22}+ weight="fill"+ className="flex-shrink-0 text-[#00a656]"+ />+ <Text+ variant="body-medium"+ className="min-w-0 flex-1 truncate text-sm text-zinc-800"+ >+ All tasks complete+ </Text>+ </>+ ) : !expanded && current ? (+ <AnimatePresence mode="wait" initial={false}>+ <motion.div+ key={`current-${currentIndex}`}+ {...(reduceMotion ? BLUR_SWAP_REDUCED : BLUR_SWAP)}+ className="flex min-w-0 flex-1 items-center gap-2"+ >+ <StatusIcon+ status={toDisplayStatus(current.status, isStreaming)}+ />+ <Text+ variant="body-medium"+ className="min-w-0 flex-1 truncate text-sm text-zinc-800"+ >+ {toDisplayStatus(current.status, isStreaming) === "stopped"+ ? current.content+ : getCurrentLabel(current)}+ </Text>+ </motion.div>+ </AnimatePresence>+ ) : (+ <>+ <ListChecksIcon+ size={16}+ weight="bold"+ className="flex-shrink-0 text-zinc-500"+ />+ <Text+ variant="body-medium"+ className="min-w-0 flex-1 text-sm text-zinc-800"+ >+ Task Progress+ </Text>+ </>+ )}+ </div>++ <span className="flex-shrink-0 text-sm tabular-nums text-zinc-900">+ {allDone ? todos.length : currentIndex + 1}/{todos.length}+ </span>+ <motion.span+ animate={{ rotate: expanded ? 180 : 0 }}+ transition={+ reduceMotion ? { duration: 0 } : { duration: 0.2, ease: EASE_OUT }+ }+ className="flex-shrink-0 text-zinc-400"+ >+ <CaretDownIcon size={14} weight="bold" />+ </motion.span>+ </button>++ <AnimatePresence initial={false}>+ {expanded && (+ <motion.div+ key="list"+ initial={{ height: 0, opacity: 0 }}+ animate={{ height: "auto", opacity: 1 }}+ exit={{ height: 0, opacity: 0 }}+ transition={reveal}+ className="overflow-hidden"+ >+ <ul className="flex max-h-56 flex-col gap-1.5 overflow-y-auto px-3 pb-2.5">+ {todos.map((todo, i) => (+ <TaskRow+ key={i}+ todo={todo}+ isStreaming={isStreaming}+ reduceMotion={!!reduceMotion}+ />+ ))}+ </ul>+ </motion.div>+ )}+ </AnimatePresence>+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/__tests__/TaskProgressBar.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/__tests__/TaskProgressBar.test.tsxnew file mode 100644index 0000000000..9b861430e7--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/__tests__/TaskProgressBar.test.tsx@@ -0,0 +1,131 @@+import React from "react";+import {+ cleanup,+ fireEvent,+ render,+ screen,+} from "@/tests/integrations/test-utils";+import { afterEach, describe, expect, it, vi } from "vitest";+import { TaskProgressBar } from "../TaskProgressBar";+import type { TodoItem } from "../helpers";++vi.mock("framer-motion", () => {+ const MOTION_PROPS = [+ "initial",+ "animate",+ "exit",+ "transition",+ "layout",+ "layoutId",+ "whileHover",+ "whileTap",+ "style",+ ];+ function makeMotion(Tag: string) {+ return React.forwardRef(function MotionComponent(+ props: Record<string, unknown>,+ ref: React.Ref<unknown>,+ ) {+ const rest: Record<string, unknown> = {};+ let children: React.ReactNode = null;+ for (const [key, value] of Object.entries(props)) {+ if (key === "children") children = value as React.ReactNode;+ else if (!MOTION_PROPS.includes(key)) rest[key] = value;+ }+ return React.createElement(Tag, { ref, ...rest }, children);+ });+ }+ return {+ AnimatePresence: ({ children }: { children: React.ReactNode }) => (+ <>{children}</>+ ),+ useReducedMotion: () => false,+ motion: {+ div: makeMotion("div"),+ span: makeMotion("span"),+ },+ };+});++function todo(+ content: string,+ status: TodoItem["status"],+ activeForm?: string,+): TodoItem {+ return { content, status, activeForm };+}++afterEach(cleanup);++describe("TaskProgressBar", () => {+ it("renders nothing when there are no todos", () => {+ const { container } = render(<TaskProgressBar todos={[]} />);+ expect(container.firstChild).toBeNull();+ });++ it("shows the current task and step count when collapsed", () => {+ render(+ <TaskProgressBar+ todos={[+ todo("Step 1", "completed"),+ todo("Step 2", "in_progress", "Working on step 2"),+ todo("Step 3", "pending"),+ ]}+ isStreaming+ />,+ );+ expect(screen.getByText("Working on step 2")).toBeDefined();+ expect(screen.getByText("2/3")).toBeDefined();+ });++ it('shows "All tasks complete" when every task is done', () => {+ render(+ <TaskProgressBar+ todos={[todo("Step 1", "completed"), todo("Step 2", "completed")]}+ />,+ );+ expect(screen.getByText("All tasks complete")).toBeDefined();+ expect(screen.getByText("2/2")).toBeDefined();+ });++ it("expands to reveal every task row when the header is clicked", () => {+ render(+ <TaskProgressBar+ todos={[+ todo("First task", "completed"),+ todo("Second task", "pending"),+ ]}+ defaultExpanded={false}+ />,+ );+ const header = screen.getByRole("button", { expanded: false });+ fireEvent.click(header);+ expect(screen.getByRole("button", { expanded: true })).toBeDefined();+ expect(screen.getByText("First task")).toBeDefined();+ expect(screen.getByText("Second task")).toBeDefined();+ });++ it("marks an interrupted in-progress task as stopped when not streaming", () => {+ render(+ <TaskProgressBar+ todos={[todo("Halted step", "in_progress", "Running step")]}+ isStreaming={false}+ defaultExpanded+ />,+ );+ expect(screen.getAllByLabelText("stopped").length).toBeGreaterThan(0);+ // A stopped task shows its plain content, not the running activeForm.+ expect(screen.getByText("Halted step")).toBeDefined();+ });++ it("shows a spinner for the in-progress task while streaming", () => {+ render(+ <TaskProgressBar+ todos={[todo("Running step", "in_progress", "Running step")]}+ isStreaming+ defaultExpanded+ />,+ );+ expect(screen.getAllByLabelText("in progress").length).toBeGreaterThan(0);+ });+});diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/__tests__/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/__tests__/helpers.test.tsnew file mode 100644index 0000000000..79f4fe1045--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/__tests__/helpers.test.ts@@ -0,0 +1,132 @@+import type { UIMessage } from "ai";+import { describe, expect, it } from "vitest";+import {+ countCompleted,+ getCurrentLabel,+ getCurrentTask,+ getLatestTaskList,+ isAllComplete,+ type TodoItem,+} from "../helpers";++function todo(+ content: string,+ status: TodoItem["status"],+ activeForm?: string,+): TodoItem {+ return { content, status, activeForm };+}++function messageWithTodoWrite(todos: unknown, state?: string): UIMessage {+ return {+ id: "m1",+ role: "assistant",+ parts: [{ type: "tool-TodoWrite", state, input: { todos } }],+ } as unknown as UIMessage;+}++describe("getLatestTaskList", () => {+ it("returns null when there are no TodoWrite parts", () => {+ const messages = [+ { id: "m1", role: "assistant", parts: [{ type: "text", text: "hi" }] },+ ] as unknown as UIMessage[];+ expect(getLatestTaskList(messages)).toBeNull();+ });++ it("returns the todos from the most recent TodoWrite part", () => {+ const messages = [+ messageWithTodoWrite([todo("Old", "completed")]),+ messageWithTodoWrite([+ todo("Step 1", "completed"),+ todo("Step 2", "in_progress"),+ ]),+ ];+ const result = getLatestTaskList(messages);+ expect(result).toHaveLength(2);+ expect(result?.[0].content).toBe("Step 1");+ });++ it("skips streaming (partial) TodoWrite inputs", () => {+ const messages = [+ messageWithTodoWrite([todo("Full 1", "completed")]),+ messageWithTodoWrite([todo("Partial", "completed")], "input-streaming"),+ ];+ const result = getLatestTaskList(messages);+ expect(result?.[0].content).toBe("Full 1");+ });++ it("ignores malformed todo entries", () => {+ const messages = [+ messageWithTodoWrite([+ todo("Valid", "pending"),+ { content: "no status" },+ { status: "pending" },+ "not an object",+ ]),+ ];+ const result = getLatestTaskList(messages);+ expect(result).toHaveLength(1);+ expect(result?.[0].content).toBe("Valid");+ });++ it("returns null when todos is not an array", () => {+ expect(getLatestTaskList([messageWithTodoWrite({})])).toBeNull();+ });+});++describe("countCompleted / isAllComplete", () => {+ it("counts completed items", () => {+ const todos = [+ todo("a", "completed"),+ todo("b", "in_progress"),+ todo("c", "completed"),+ ];+ expect(countCompleted(todos)).toBe(2);+ });++ it("is complete only when every item is completed", () => {+ expect(isAllComplete([todo("a", "completed")])).toBe(true);+ expect(isAllComplete([todo("a", "completed"), todo("b", "pending")])).toBe(+ false,+ );+ expect(isAllComplete([])).toBe(false);+ });+});++describe("getCurrentTask", () => {+ const todos = [+ todo("a", "completed"),+ todo("b", "in_progress"),+ todo("c", "pending"),+ ];++ it("returns the in-progress task while streaming", () => {+ expect(getCurrentTask(todos, true)?.content).toBe("b");+ });++ it("returns the first unfinished task when not streaming", () => {+ expect(getCurrentTask(todos, false)?.content).toBe("b");+ });++ it("falls back to the last task when all are completed", () => {+ const done = [todo("a", "completed"), todo("b", "completed")];+ expect(getCurrentTask(done, false)?.content).toBe("b");+ });++ it("returns null for an empty list", () => {+ expect(getCurrentTask([], true)).toBeNull();+ });+});++describe("getCurrentLabel", () => {+ it("uses activeForm for an in-progress task with one", () => {+ expect(getCurrentLabel(todo("Do it", "in_progress", "Doing it"))).toBe(+ "Doing it",+ );+ });++ it("uses content when not in progress or no activeForm", () => {+ expect(getCurrentLabel(todo("Do it", "pending", "Doing it"))).toBe("Do it");+ expect(getCurrentLabel(todo("Do it", "in_progress"))).toBe("Do it");+ });+});diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/animations.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/animations.tsnew file mode 100644index 0000000000..402e4c21af--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/animations.ts@@ -0,0 +1,10 @@+// ease-out-quad — Emil's default for entering elements.+export const EASE_OUT = [0.25, 0.46, 0.45, 0.94] as const;++// A newly in-progress loader waits for the completing task's tick + strikethrough+// to play first, so each step reads as a sequence.+export const LOADER_DELAY = 0.3;++// Blur-bridge for the status icon swap (Emil's copy-button pattern).+export const ICON_EXIT = 0.12;+export const ICON_ENTER = 0.18;diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/components/StatusIcon/StatusIcon.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/components/StatusIcon/StatusIcon.tsxnew file mode 100644index 0000000000..4537a4ef63--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/components/StatusIcon/StatusIcon.tsx@@ -0,0 +1,47 @@+import { LoadingSpinner } from "@/components/atoms/LoadingSpinner/LoadingSpinner";+import { CheckIcon, CircleIcon, PauseCircleIcon } from "@phosphor-icons/react";+import type { DisplayStatus } from "../../helpers";++interface Props {+ status: DisplayStatus;+}++export function StatusIcon({ status }: Props) {+ if (status === "completed") {+ return (+ <CheckIcon+ size={14}+ weight="bold"+ className="text-emerald-500"+ aria-label="completed"+ />+ );+ }+ if (status === "in_progress") {+ return (+ <LoadingSpinner+ size="small"+ className="h-3.5 w-3.5 text-purple-500 [animation-duration:0.5s]"+ aria-label="in progress"+ />+ );+ }+ if (status === "stopped") {+ return (+ <PauseCircleIcon+ size={15}+ weight="fill"+ className="text-amber-500"+ aria-label="stopped"+ />+ );+ }+ return (+ <CircleIcon+ size={14}+ weight="regular"+ className="text-zinc-400"+ aria-label="pending"+ />+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/components/TaskRow/TaskRow.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/components/TaskRow/TaskRow.tsxnew file mode 100644index 0000000000..5cf7c82924--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/components/TaskRow/TaskRow.tsx@@ -0,0 +1,75 @@+import { AnimatePresence, motion } from "framer-motion";+import {+ EASE_OUT,+ ICON_ENTER,+ ICON_EXIT,+ LOADER_DELAY,+} from "../../animations";+import { toDisplayStatus, type TodoItem } from "../../helpers";+import { StatusIcon } from "../StatusIcon/StatusIcon";++interface Props {+ todo: TodoItem;+ isStreaming: boolean;+ reduceMotion: boolean;+}++export function TaskRow({ todo, isStreaming, reduceMotion }: Props) {+ const status = toDisplayStatus(todo.status, isStreaming);+ const active = status === "in_progress";+ const completed = status === "completed";+ const label = active && todo.activeForm ? todo.activeForm : todo.content;+ const textClass = completed+ ? `text-zinc-400 ${reduceMotion ? "line-through" : ""}`+ : active+ ? "font-medium text-zinc-900"+ : "text-zinc-600";++ return (+ <li className="flex items-start gap-2 text-sm">+ <span className="mt-0.5 flex-shrink-0">+ <AnimatePresence mode="wait" initial={false}>+ <motion.span+ key={status}+ className="block"+ initial={reduceMotion ? false : { opacity: 0, filter: "blur(6px)" }}+ animate={{ opacity: 1, filter: "blur(0px)" }}+ exit={+ reduceMotion+ ? { opacity: 0 }+ : {+ opacity: 0,+ filter: "blur(6px)",+ transition: {+ duration: ICON_EXIT,+ ease: EASE_OUT,+ // A pending circle only leaves when its task becomes active+ // — hold it until the previous step's tick/strike finishes.+ delay: status === "pending" ? LOADER_DELAY : 0,+ },+ }+ }+ transition={{ duration: ICON_ENTER, ease: EASE_OUT }}+ >+ <StatusIcon status={status} />+ </motion.span>+ </AnimatePresence>+ </span>+ <span className={`min-w-0 flex-1 ${textClass}`}>+ <span className="relative inline">+ {label}+ {completed && !reduceMotion && (+ <motion.span+ aria-hidden+ className="pointer-events-none absolute inset-x-0 top-1/2 h-px -translate-y-1/2 bg-zinc-400"+ initial={{ scaleX: 0 }}+ animate={{ scaleX: 1 }}+ style={{ transformOrigin: "left" }}+ transition={{ duration: 0.25, ease: EASE_OUT, delay: ICON_EXIT }}+ />+ )}+ </span>+ </span>+ </li>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/helpers.tsnew file mode 100644index 0000000000..2042e6c456--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/TaskProgressBar/helpers.ts@@ -0,0 +1,87 @@+import type { UIMessage } from "ai";++export interface TodoItem {+ content: string;+ status: "pending" | "in_progress" | "completed";+ activeForm?: string;+}++function isTodoItem(value: unknown): value is TodoItem {+ if (!value || typeof value !== "object") return false;+ const v = value as Record<string, unknown>;+ return (+ typeof v.content === "string" &&+ (v.status === "pending" ||+ v.status === "in_progress" ||+ v.status === "completed")+ );+}++// Walks the message history backwards for the most recent TodoWrite tool call+// and returns its task list (the copilot's live plan).+export function getLatestTaskList(messages: UIMessage[]): TodoItem[] | null {+ for (let i = messages.length - 1; i >= 0; i--) {+ const parts = messages[i]?.parts;+ if (!parts) continue;+ for (let j = parts.length - 1; j >= 0; j--) {+ const part = parts[j] as {+ type: string;+ state?: string;+ input?: unknown;+ };+ if (part.type !== "tool-TodoWrite") continue;+ // While a TodoWrite call's arguments are still streaming, the AI SDK+ // exposes a progressively-parsed partial input — often a truncated todos+ // array (e.g. only the first N completed items). Rendering that makes+ // the bar flash "all complete" and jump around, so wait for the full+ // input and keep showing the previous complete list until then.+ if (part.state === "input-streaming") continue;+ const input = part.input;+ if (!input || typeof input !== "object") continue;+ const todos = (input as { todos?: unknown }).todos;+ if (!Array.isArray(todos)) continue;+ const filtered = todos.filter(isTodoItem);+ if (filtered.length > 0) return filtered;+ }+ }+ return null;+}++export function countCompleted(todos: TodoItem[]): number {+ return todos.filter((t) => t.status === "completed").length;+}++export function isAllComplete(todos: TodoItem[]): boolean {+ return todos.length > 0 && countCompleted(todos) === todos.length;+}++// The task the user should focus on: the active one while streaming, otherwise+// the first unfinished item so the collapsed bar always has something to show.+export function getCurrentTask(+ todos: TodoItem[],+ isStreaming: boolean,+): TodoItem | null {+ if (isStreaming) {+ const active = todos.find((t) => t.status === "in_progress");+ if (active) return active;+ }+ const pending = todos.find((t) => t.status !== "completed");+ return pending ?? todos[todos.length - 1] ?? null;+}++export function getCurrentLabel(todo: TodoItem): string {+ if (todo.status === "in_progress" && todo.activeForm) return todo.activeForm;+ return todo.content;+}++// A task that was in_progress when the agent went idle (user Stop, end of turn,+// or error) is "stopped" — shown with a distinct amber icon instead of a spinner+// or a plain pending circle.+export type DisplayStatus = TodoItem["status"] | "stopped";++export function toDisplayStatus(+ status: TodoItem["status"],+ isStreaming: boolean,+): DisplayStatus {+ return !isStreaming && status === "in_progress" ? "stopped" : status;+}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/helpers/__tests__/convertChatSessionToUiMessages.test.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/helpers/__tests__/convertChatSessionToUiMessages.test.tsindex 94697e1c7c..860043d907 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/helpers/__tests__/convertChatSessionToUiMessages.test.ts+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/helpers/__tests__/convertChatSessionToUiMessages.test.ts@@ -420,4 +420,130 @@ describe("convertChatSessionMessagesToUiMessages — latest user marker", () =>const stats = result.stats.get(result.messages[0].id);expect(stats?.isLatestUserMessage).toBe(true);});++ describe("orphan TodoWrite recovery", () => {+ const todos = [+ { content: "Step 1", activeForm: "Doing step 1", status: "completed" },+ { content: "Step 2", activeForm: "Doing step 2", status: "completed" },+ ];++ function findTodoPart(result: {+ messages: UIMessage<unknown, UIDataTypes, UITools>[];+ }) {+ return result.messages+ .find((m) => m.role === "assistant")+ ?.parts.find((p) => p.type === "tool-TodoWrite");+ }++ it("recovers an orphan result from the backend `todos` field", () => {+ const result = convertChatSessionMessagesToUiMessages(+ SESSION_ID,+ [+ { role: "assistant", content: "on it", sequence: 0 },+ {+ role: "tool",+ content: JSON.stringify({ type: "todo_write", todos }),+ tool_call_id: "call-1",+ sequence: 1,+ },+ ],+ { isComplete: true },+ );++ const todoPart = findTodoPart(result);+ expect(todoPart).toBeDefined();+ expect(+ (todoPart as { input: { todos: unknown[] } }).input.todos,+ ).toHaveLength(2);+ });++ it("ignores an orphan result missing a `todos` array", () => {+ const result = convertChatSessionMessagesToUiMessages(+ SESSION_ID,+ [+ { role: "assistant", content: "on it", sequence: 0 },+ {+ role: "tool",+ content: JSON.stringify({ type: "todo_write", newTodos: todos }),+ tool_call_id: "call-1",+ sequence: 1,+ },+ ],+ { isComplete: true },+ );++ expect(findTodoPart(result)).toBeUndefined();+ });++ it("does not duplicate when a whitespace-padded tool_call_id matches a consumed id", () => {+ const result = convertChatSessionMessagesToUiMessages(+ SESSION_ID,+ [+ {+ role: "assistant",+ content: "on it",+ sequence: 0,+ tool_calls: [+ {+ id: "call-1",+ function: {+ name: "TodoWrite",+ arguments: JSON.stringify({ todos }),+ },+ },+ ],+ },+ {+ role: "tool",+ content: JSON.stringify({ type: "todo_write", todos }),+ tool_call_id: " call-1 ",+ sequence: 1,+ },+ ],+ { isComplete: true },+ );++ const todoParts = result.messages+ .find((m) => m.role === "assistant")+ ?.parts.filter((p) => p.type === "tool-TodoWrite");+ expect(todoParts).toHaveLength(1);+ });+ });++ describe("tool output matching", () => {+ it("attaches an output whose tool_call_id is whitespace-padded", () => {+ const result = convertChatSessionMessagesToUiMessages(+ SESSION_ID,+ [+ {+ role: "assistant",+ content: "running a tool",+ sequence: 0,+ tool_calls: [+ {+ id: "call-1",+ function: { name: "SomeTool", arguments: "{}" },+ },+ ],+ },+ {+ role: "tool",+ content: JSON.stringify({ ok: true }),+ tool_call_id: " call-1 ",+ sequence: 1,+ },+ ],+ { isComplete: false },+ );++ const toolPart = result.messages+ .find((m) => m.role === "assistant")+ ?.parts.find((p) => p.type === "tool-SomeTool") as+ | { state: string; output: unknown }+ | undefined;++ expect(toolPart?.state).toBe("output-available");+ expect(toolPart?.output).toEqual({ ok: true });+ });+ });});diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/helpers/convertChatSessionToUiMessages.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/helpers/convertChatSessionToUiMessages.tsindex 43a15b4efc..f35f4658eb 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/helpers/convertChatSessionToUiMessages.ts+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/helpers/convertChatSessionToUiMessages.ts@@ -136,6 +136,51 @@ function toToolInput(rawArguments: unknown): unknown {return {};}+/**+ * The backend sometimes persists a TodoWrite *result* without persisting the+ * assistant tool_calls row that carries its input (observed on the final+ * all-completed update of a turn). Dropping it leaves the newest surviving+ * TodoWrite input stale — an earlier "in_progress" snapshot — so the task+ * progress UI shows work still running after the turn finished. Recover the+ * list from the orphan result's ``todos`` and synthesize the missing part.+ */+function orphanTodoWriteResultToPart(+ msg: SessionChatMessage,+ consumedToolCallIds: ReadonlySet<string>,+): UIMessage<unknown, UIDataTypes, UITools>["parts"][number] | null {+ const toolCallId = msg.tool_call_id?.trim();+ if (!toolCallId || consumedToolCallIds.has(toolCallId)) {+ return null;+ }+ if (typeof msg.content !== "string") return null;+ const parsed = safeJsonParse(msg.content);+ if (!parsed || typeof parsed !== "object") return null;+ const todos = (parsed as { todos?: unknown }).todos;+ if (!Array.isArray(todos) || todos.length === 0) return null;+ return {+ type: "tool-TodoWrite",+ toolCallId,+ state: "output-available",+ input: { todos },+ output: parsed,+ } as UIMessage<unknown, UIDataTypes, UITools>["parts"][number];+}++function collectConsumedToolCallIds(+ messages: SessionChatMessage[],+): Set<string> {+ const ids = new Set<string>();+ for (const msg of messages) {+ if (!Array.isArray(msg.tool_calls)) continue;+ for (const rawToolCall of msg.tool_calls) {+ if (!rawToolCall || typeof rawToolCall !== "object") continue;+ const id = String((rawToolCall as { id?: unknown }).id ?? "").trim();+ if (id) ids.add(id);+ }+ }+ return ids;+}+// Capture trailing sequence number from a hydrated UIMessage id of the// shape ``<sessionId>-seq-<N>``. Streaming-path ids (AI SDK uuids) and// idx-based fallback ids (``-idx-<N>``) don't match — return null so the@@ -256,13 +301,15 @@ export function convertChatSessionMessagesToUiMessages(for (const msg of messages) {if (msg.role !== "tool") continue;- if (!msg.tool_call_id) continue;+ const toolCallId = msg.tool_call_id?.trim();+ if (!toolCallId) continue;if (msg.content == null) continue;- toolOutputsByCallId.set(msg.tool_call_id, msg.content);+ toolOutputsByCallId.set(toolCallId, msg.content);}const uiMessages: UIMessage<unknown, UIDataTypes, UITools>[] = [];const stats: TurnStatsMap = new Map();+ const consumedToolCallIds = collectConsumedToolCallIds(messages);function patchStats(id: string, patch: Partial<TurnStats>) {const existing = stats.get(id) ?? {};@@ -270,7 +317,29 @@ export function convertChatSessionMessagesToUiMessages(}messages.forEach((msg, idx) => {- if (msg.role === "tool") return;+ if (msg.role === "tool") {+ // Orphan TodoWrite results (no matching assistant tool_calls row) carry+ // the newest task-list state — fold a synthetic part into the previous+ // assistant bubble so progress UIs see it. TodoWrite renders as null in+ // chat, so this adds no visible bubble content.+ const orphanPart = orphanTodoWriteResultToPart(msg, consumedToolCallIds);+ if (orphanPart) {+ const prevUI = uiMessages[uiMessages.length - 1];+ if (prevUI && prevUI.role === "assistant") {+ prevUI.parts.push(orphanPart);+ } else {+ uiMessages.push({+ id:+ msg.sequence != null+ ? `${sessionId}-seq-${msg.sequence}`+ : `${sessionId}-idx-${idx}`,+ role: "assistant",+ parts: [orphanPart],+ });+ }+ }+ return;+ }if (msg.role !== "user" &&msg.role !== "assistant" &&diff --git a/autogpt_platform/frontend/src/components/layout/AppSidebar/components/RecentChats/components/RecentChatItem/RecentChatItem.tsx b/autogpt_platform/frontend/src/components/layout/AppSidebar/components/RecentChats/components/RecentChatItem/RecentChatItem.tsxindex 41ca834bcb..f863f09ea7 100644--- a/autogpt_platform/frontend/src/components/layout/AppSidebar/components/RecentChats/components/RecentChatItem/RecentChatItem.tsx+++ b/autogpt_platform/frontend/src/components/layout/AppSidebar/components/RecentChats/components/RecentChatItem/RecentChatItem.tsx@@ -114,7 +114,7 @@ export function RecentChatItem({asChildisActive={isActive}tooltip={title}- className="font-normal data-[active=true]:!bg-zinc-200 data-[active=true]:font-normal hover:!bg-zinc-200"+ className="font-normal data-[active=true]:!bg-zinc-100 data-[active=true]:font-normal hover:!bg-zinc-100"><Link href={`/copilot?sessionId=${session.id}`}>{session.is_processing ? (diff --git a/autogpt_platform/frontend/src/lib/constants.ts b/autogpt_platform/frontend/src/lib/constants.tsindex f1c9132e3e..39fa298e09 100644--- a/autogpt_platform/frontend/src/lib/constants.ts+++ b/autogpt_platform/frontend/src/lib/constants.ts@@ -14,3 +14,6 @@ export const API_KEY_HEADER_NAME = "X-API-Key";// Layoutexport const NAVBAR_HEIGHT_PX = 60;+// Height of the new-layout inset header (the `h-12` bar in PlatformChrome).+// Keep in sync with that header so viewport-bound pages can subtract it.+export const INSET_HEADER_HEIGHT_PX = 48;diff --git a/autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts b/autogpt_platform/frontend/src/services/feature-flags/use-get-flag.tsindex 6ba7455cea..a354fdc45e 100644--- a/autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts+++ b/autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts@@ -20,6 +20,7 @@ export enum Flag {AUTOGPT_NEW_LAYOUT = "autogpt-new-layout",CHAT_WORKSPACE_FILES = "chat-workspace-files",CHAT_PINNING = "chat-pinning",+ TASK_PROGRESS_BAR = "task-progress-bar",// Graphiti memory + dream-system gates. Mirror of the backend// ``Flag`` enum in ``backend/util/feature_flag.py``. Frontend reads// them when memory/dream-related UI surfaces ship (P6+ on the@@ -52,6 +53,7 @@ const defaultFlags = {[Flag.AUTOGPT_NEW_LAYOUT]: false,[Flag.CHAT_WORKSPACE_FILES]: false,[Flag.CHAT_PINNING]: false,+ [Flag.TASK_PROGRESS_BAR]: false,[Flag.GRAPHITI_MEMORY]: false,[Flag.GRAPHITI_COMMUNITIES_ENABLED]: false,[Flag.DREAM_PASS_ENABLED]: false,@@ -108,6 +110,8 @@ function readEnvOverride(flag: Flag): string | undefined {return process.env.NEXT_PUBLIC_FORCE_FLAG_CHAT_WORKSPACE_FILES;case Flag.CHAT_PINNING:return process.env.NEXT_PUBLIC_FORCE_FLAG_CHAT_PINNING;+ case Flag.TASK_PROGRESS_BAR:+ return process.env.NEXT_PUBLIC_FORCE_FLAG_TASK_PROGRESS_BAR;case Flag.GRAPHITI_MEMORY:return process.env.NEXT_PUBLIC_FORCE_FLAG_GRAPHITI_MEMORY;case Flag.GRAPHITI_COMMUNITIES_ENABLED: