Skip to content

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.

refactor(frontend/library): extract briefing tab sub-components and reorganize panel (#13213)

Ubbe7d8eee1471f1
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/AgentBriefingPanel.module.css b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/AgentBriefingPanel.module.css
deleted file mode 100644
index 8c2bd69313..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/AgentBriefingPanel.module.css
+++ /dev/null
@@ -1,44 +0,0 @@
-.glassPanel {
- position: relative;
- isolation: isolate;
-}
-
-.glassPanel::before {
- content: "";
- position: absolute;
- inset: 0;
- border-radius: inherit;
- padding: 1px;
- background: conic-gradient(
- from var(--border-angle, 0deg),
- rgba(129, 120, 228, 0.04),
- rgba(129, 120, 228, 0.14),
- rgba(168, 130, 255, 0.09),
- rgba(129, 120, 228, 0.04),
- rgba(99, 102, 241, 0.12),
- rgba(129, 120, 228, 0.04)
- );
- -webkit-mask:
- linear-gradient(#000 0 0) content-box,
- linear-gradient(#000 0 0);
- mask:
- linear-gradient(#000 0 0) content-box,
- linear-gradient(#000 0 0);
- -webkit-mask-composite: xor;
- mask-composite: exclude;
- animation: rotate-border 6s linear infinite;
- pointer-events: none;
- z-index: -1;
-}
-
-@property --border-angle {
- syntax: "<angle>";
- initial-value: 0deg;
- inherits: false;
-}
-
-@keyframes rotate-border {
- to {
- --border-angle: 360deg;
- }
-}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/AgentBriefingPanel.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/AgentBriefingPanel.tsx
index 82bf930b7b..edc3e35ce7 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/AgentBriefingPanel.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/AgentBriefingPanel.tsx
@@ -4,9 +4,8 @@ import { Text } from "@/components/atoms/Text/Text";
import type { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";
import { useState } from "react";
import type { FleetSummary, AgentStatusFilter } from "../../types";
-import { BriefingTabContent } from "./BriefingTabContent";
-import { StatsGrid } from "./StatsGrid";
-import styles from "./AgentBriefingPanel.module.css";
+import { BriefingTabContent } from "./components/BriefingTabContent/BriefingTabContent";
+import { StatsGrid } from "./components/StatsGrid/StatsGrid";
interface Props {
summary: FleetSummary;
@@ -20,7 +19,7 @@ export function AgentBriefingPanel({ summary, agents }: Props) {
return (
<div
- className={`${styles.glassPanel} min-h-[14.75rem] rounded-large bg-gradient-to-br from-indigo-50/30 via-white/90 to-purple-50/25 px-5 pb-5 pt-[1.125rem] shadow-sm backdrop-blur-md`}
+ className={`min-h-[14.75rem] rounded-large bg-gradient-to-br from-indigo-50/30 via-white/90 to-purple-50/25 px-5 pb-5 pt-[1.125rem] shadow-sm backdrop-blur-md`}
>
<Text variant="h5">Agent Briefing</Text>
<div className="mt-4 space-y-5">
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/BriefingTabContent.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/BriefingTabContent.tsx
deleted file mode 100644
index eb8726e5a6..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/BriefingTabContent.tsx
+++ /dev/null
@@ -1,264 +0,0 @@
-"use client";
-
-import type { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";
-import { useListCopilotSkills } from "@/app/api/__generated__/endpoints/skills/skills";
-import { useListCopilotFollowupSchedules } from "@/app/api/__generated__/endpoints/schedules/schedules";
-import { Button } from "@/components/atoms/Button/Button";
-import { useSitrepItems } from "../SitrepItem/useSitrepItems";
-import { SitrepItem } from "../SitrepItem/SitrepItem";
-import { useAgentStatusMap } from "../../hooks/useAgentStatus";
-import type { AgentStatusFilter } from "../../types";
-import { Text } from "@/components/atoms/Text/Text";
-import Link from "next/link";
-import { useState } from "react";
-import { CostsBreakdown } from "./CostsBreakdown/CostsBreakdown";
-
-interface Props {
- activeTab: AgentStatusFilter;
- agents: LibraryAgent[];
-}
-
-export function BriefingTabContent({ activeTab, agents }: Props) {
- if (activeTab === "all") {
- return (
- <div className="py-2">
- <CostsBreakdown agents={agents} />
- <CopilotLibrarySummary />
- </div>
- );
- }
-
- if (
- activeTab === "running" ||
- activeTab === "attention" ||
- activeTab === "completed"
- ) {
- return <ExecutionListSection activeTab={activeTab} agents={agents} />;
- }
-
- return <AgentListSection activeTab={activeTab} agents={agents} />;
-}
-
-function CopilotLibrarySummary() {
- // Discoverability is already gated by AGENT_BRIEFING at the parent
- // panel — this pill renders only inside AgentBriefingPanel, which is
- // itself flag-gated. No second flag here because the count-based
- // hide below already keeps the pill quiet for users who don't use
- // the feature.
- const { data: skillsRes } = useListCopilotSkills({
- query: { staleTime: 30_000 },
- });
- const { data: followupsRes } = useListCopilotFollowupSchedules({
- query: { staleTime: 30_000 },
- });
-
- const skillsCount =
- skillsRes && skillsRes.status === 200 ? skillsRes.data.length : 0;
- // Count only copilot follow-ups here — graph schedules (recurring
- // agent runs) are already surfaced by the briefing's own "Scheduled"
- // tab above, so folding them into this pill would double-count and
- // confuse the "Autopilot library" framing. The pill's link still
- // goes to the unified `/library/followups` page, where both kinds
- // are listed together.
- const followupCount =
- followupsRes && followupsRes.status === 200 ? followupsRes.data.length : 0;
-
- // Suppress the pill entirely when the user has no autopilot library
- // content yet — surfacing "0 skills · 0 follow-ups" is noise, not a
- // discovery affordance. The pill reappears the moment either count
- // turns positive (e.g. after a store_skill / schedule_followup tool
- // call).
- if (skillsCount === 0 && followupCount === 0) {
- return null;
- }
-
- // Per-link hide: surface only the counts that are non-zero. We
- // already returned ``null`` above when both are zero, so at least
- // one branch always renders.
- const showSkills = skillsCount > 0;
- const showFollowups = followupCount > 0;
-
- return (
- <div
- className="mt-5 flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-zinc-100 pt-3"
- data-testid="copilot-library-summary"
- >
- <Text variant="small" className="!text-zinc-500">
- Autopilot library
- </Text>
- {showSkills ? (
- <Link
- href="/library/skills"
- className="text-sm text-violet-700 hover:underline"
- data-testid="copilot-library-skills-link"
- >
- {skillsCount} skill{skillsCount === 1 ? "" : "s"}
- </Link>
- ) : null}
- {showSkills && showFollowups ? (
- <span className="text-zinc-300">•</span>
- ) : null}
- {showFollowups ? (
- <Link
- href="/library/followups"
- className="text-sm text-yellow-700 hover:underline"
- data-testid="copilot-library-followups-link"
- >
- {followupCount} follow-up{followupCount === 1 ? "" : "s"}
- </Link>
- ) : null}
- </div>
- );
-}
-
-const MAX_VISIBLE = 6;
-
-function ExecutionListSection({
- activeTab,
- agents,
-}: {
- activeTab: AgentStatusFilter;
- agents: LibraryAgent[];
-}) {
- const allItems = useSitrepItems(agents, 50);
- const [showAll, setShowAll] = useState(false);
-
- const filtered = allItems.filter((item) => {
- if (activeTab === "running") return item.priority === "running";
- if (activeTab === "attention") return item.priority === "error";
- if (activeTab === "completed") return item.priority === "success";
- return false;
- });
-
- if (filtered.length === 0) {
- return <EmptyMessage tab={activeTab} />;
- }
-
- const visible = showAll ? filtered : filtered.slice(0, MAX_VISIBLE);
- const hasMore = filtered.length > MAX_VISIBLE;
-
- return (
- <div>
- <div className="grid grid-cols-1 gap-3 lg:grid-cols-2">
- {visible.map((item) => (
- <SitrepItem key={item.id} item={item} />
- ))}
- </div>
- {hasMore && (
- <div className="mt-3 flex justify-center">
- <Button
- variant="secondary"
- size="small"
- onClick={() => setShowAll(!showAll)}
- >
- {showAll ? "Collapse" : `Show all (${filtered.length})`}
- </Button>
- </div>
- )}
- </div>
- );
-}
-
-const TAB_STATUS_LABEL: Record<string, string> = {
- listening: "Waiting for trigger event",
- scheduled: "Has a scheduled run",
- idle: "No recent activity",
-};
-
-function getAgentStatusLabel(tab: string, agent: LibraryAgent): string {
- if (tab === "scheduled" && agent.next_scheduled_run) {
- const diff = new Date(agent.next_scheduled_run).getTime() - Date.now();
- const minutes = Math.round(diff / 60_000);
- if (minutes <= 0) return "Scheduled to run soon";
- if (minutes < 60) return `Scheduled to run in ${minutes}m`;
- const hours = Math.round(minutes / 60);
- if (hours < 24) return `Scheduled to run in ${hours}h`;
- const days = Math.round(hours / 24);
- return `Scheduled to run in ${days}d`;
- }
- return TAB_STATUS_LABEL[tab] ?? "";
-}
-
-function AgentListSection({
- activeTab,
- agents,
-}: {
- activeTab: AgentStatusFilter;
- agents: LibraryAgent[];
-}) {
- const [showAll, setShowAll] = useState(false);
- const statusMap = useAgentStatusMap(agents);
-
- const filtered = agents.filter((agent) => {
- const status = statusMap.get(agent.graph_id)?.status;
- if (activeTab === "listening") return status === "listening";
- if (activeTab === "scheduled") return status === "scheduled";
- if (activeTab === "idle") return status === "idle";
- return false;
- });
-
- if (filtered.length === 0) {
- return <EmptyMessage tab={activeTab} />;
- }
-
- const status =
- activeTab === "listening"
- ? ("listening" as const)
- : activeTab === "scheduled"
- ? ("scheduled" as const)
- : ("idle" as const);
-
- const visible = showAll ? filtered : filtered.slice(0, MAX_VISIBLE);
- const hasMore = filtered.length > MAX_VISIBLE;
-
- return (
- <div>
- <div className="grid grid-cols-1 gap-3 lg:grid-cols-2">
- {visible.map((agent) => (
- <SitrepItem
- key={agent.id}
- item={{
- id: agent.id,
- agentID: agent.id,
- agentName: agent.name,
- agentImageUrl: agent.image_url,
- priority: status,
- message: getAgentStatusLabel(activeTab, agent),
- status,
- }}
- />
- ))}
- </div>
- {hasMore && (
- <div className="mt-3 flex justify-center">
- <Button
- variant="secondary"
- size="small"
- onClick={() => setShowAll(!showAll)}
- >
- {showAll ? "Collapse" : `Show all (${filtered.length})`}
- </Button>
- </div>
- )}
- </div>
- );
-}
-
-const EMPTY_MESSAGES: Record<string, string> = {
- running: "No agents running right now",
- attention: "No agents that need attention",
- completed: "No recently completed runs",
- listening: "No agents listening for events",
- scheduled: "No agents with scheduled runs",
- idle: "No idle agents",
-};
-
-function EmptyMessage({ tab }: { tab: AgentStatusFilter }) {
- return (
- <div className="flex items-center justify-center pt-4">
- <Text variant="body-medium" className="text-zinc-600">
- {EMPTY_MESSAGES[tab] ?? "No agents in this category"}
- </Text>
- </div>
- );
-}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/BriefingTabContent.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/BriefingTabContent.tsx
new file mode 100644
index 0000000000..b0d01402d4
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/BriefingTabContent.tsx
@@ -0,0 +1,43 @@
+"use client";
+
+import type { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";
+
+import { CostsBreakdown } from "../CostsBreakdown/CostsBreakdown";
+import { AgentListSection } from "./components/AgentListSection";
+import { CopilotLibrarySummary } from "./components/CopilotLibrarySummary";
+import { ExecutionListSection } from "./components/ExecutionListSection";
+import { AgentStatusFilter } from "@/app/(platform)/library/types";
+
+interface Props {
+ activeTab: AgentStatusFilter;
+ agents: LibraryAgent[];
+}
+
+export function BriefingTabContent({ activeTab, agents }: Props) {
+ if (activeTab === "all") {
+ return (
+ <div className="py-2">
+ <CostsBreakdown agents={agents} />
+ <CopilotLibrarySummary />
+ </div>
+ );
+ }
+
+ if (
+ activeTab === "running" ||
+ activeTab === "attention" ||
+ activeTab === "completed"
+ ) {
+ return (
+ <ExecutionListSection
+ key={activeTab}
+ activeTab={activeTab}
+ agents={agents}
+ />
+ );
+ }
+
+ return (
+ <AgentListSection key={activeTab} activeTab={activeTab} agents={agents} />
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/__tests__/BriefingTabContent.test.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/__tests__/BriefingTabContent.test.tsx
similarity index 99%
rename from autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/__tests__/BriefingTabContent.test.tsx
rename to autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/__tests__/BriefingTabContent.test.tsx
index 7e53c6f717..5059f6d5fe 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/__tests__/BriefingTabContent.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/__tests__/BriefingTabContent.test.tsx
@@ -196,7 +196,7 @@ describe("BriefingTabContent — CostsBreakdown", () => {
// Headline stats
expect(screen.getByText("$42.50")).toBeDefined();
- expect(screen.getByText("Most expensive runs")).toBeDefined();
+ expect(screen.getByText("Most expensive tasks")).toBeDefined();
expect(screen.getByText("Spend by agent")).toBeDefined();
// Agent names resolved via graph_id lookup
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/__tests__/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/__tests__/helpers.test.ts
new file mode 100644
index 0000000000..a5ddc6fe14
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/__tests__/helpers.test.ts
@@ -0,0 +1,81 @@
+import type { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";
+import { describe, expect, it } from "vitest";
+import { getAgentStatusLabel, getEmptyMessage } from "../helpers";
+
+function makeAgent(overrides: Partial<LibraryAgent> = {}): LibraryAgent {
+ return {
+ id: "lib-1",
+ graph_id: "g-1",
+ name: "Agent One",
+ next_scheduled_run: null,
+ ...overrides,
+ } as unknown as LibraryAgent;
+}
+
+describe("getAgentStatusLabel", () => {
+ it("returns the static label for non-scheduled tabs", () => {
+ expect(getAgentStatusLabel("listening", makeAgent())).toBe(
+ "Waiting for trigger event",
+ );
+ expect(getAgentStatusLabel("idle", makeAgent())).toBe("No recent activity");
+ });
+
+ it("returns an empty string for an unknown tab", () => {
+ expect(getAgentStatusLabel("nope", makeAgent())).toBe("");
+ });
+
+ it("falls back to the static scheduled label when no next run is set", () => {
+ expect(getAgentStatusLabel("scheduled", makeAgent())).toBe(
+ "Has a scheduled run",
+ );
+ });
+
+ it("says 'soon' once the scheduled time has passed", () => {
+ const past = new Date(Date.now() - 60_000).toISOString();
+ expect(
+ getAgentStatusLabel("scheduled", makeAgent({ next_scheduled_run: past })),
+ ).toBe("Scheduled to run soon");
+ });
+
+ it("formats minutes when the next run is under an hour away", () => {
+ const in30m = new Date(Date.now() + 30 * 60_000).toISOString();
+ expect(
+ getAgentStatusLabel(
+ "scheduled",
+ makeAgent({ next_scheduled_run: in30m }),
+ ),
+ ).toMatch(/^Scheduled to run in \d+m$/);
+ });
+
+ it("formats hours when the next run is under a day away", () => {
+ const in5h = new Date(Date.now() + 5 * 60 * 60_000).toISOString();
+ expect(
+ getAgentStatusLabel("scheduled", makeAgent({ next_scheduled_run: in5h })),
+ ).toMatch(/^Scheduled to run in \d+h$/);
+ });
+
+ it("formats days when the next run is a day or more away", () => {
+ const in3d = new Date(Date.now() + 3 * 24 * 60 * 60_000).toISOString();
+ expect(
+ getAgentStatusLabel("scheduled", makeAgent({ next_scheduled_run: in3d })),
+ ).toMatch(/^Scheduled to run in \d+d$/);
+ });
+});
+
+describe("getEmptyMessage", () => {
+ it("uses task terminology for completed and scheduled tabs", () => {
+ expect(getEmptyMessage("completed")).toBe("No recently completed tasks");
+ expect(getEmptyMessage("scheduled")).toBe("No agents with scheduled tasks");
+ });
+
+ it("returns the matching message for each known tab", () => {
+ expect(getEmptyMessage("running")).toBe("No agents running right now");
+ expect(getEmptyMessage("attention")).toBe("No agents that need attention");
+ expect(getEmptyMessage("listening")).toBe("No agents listening for events");
+ expect(getEmptyMessage("idle")).toBe("No idle agents");
+ });
+
+ it("falls back to a generic message for an unmapped tab", () => {
+ expect(getEmptyMessage("healthy")).toBe("No agents in this category");
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/__tests__/sections.test.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/__tests__/sections.test.tsx
new file mode 100644
index 0000000000..d3991ec614
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/__tests__/sections.test.tsx
@@ -0,0 +1,107 @@
+import { getGetV1ListAllExecutionsMockHandler200 } from "@/app/api/__generated__/endpoints/graphs/graphs.msw";
+import type { GraphExecutionMeta } from "@/app/api/__generated__/models/graphExecutionMeta";
+import type { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";
+import { server } from "@/mocks/mock-server";
+import {
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from "@/tests/integrations/test-utils";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { AgentListSection } from "../components/AgentListSection";
+import { ExecutionListSection } from "../components/ExecutionListSection";
+
+vi.mock("next/navigation", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("next/navigation")>();
+ return {
+ ...actual,
+ useRouter: () => ({ push: vi.fn(), replace: vi.fn(), prefetch: vi.fn() }),
+ useSearchParams: () => new URLSearchParams(),
+ usePathname: () => "/library",
+ };
+});
+
+afterEach(() => {
+ server.resetHandlers();
+});
+
+function makeAgent(overrides: Partial<LibraryAgent> = {}): LibraryAgent {
+ return {
+ id: "lib-1",
+ graph_id: "g-1",
+ name: "Agent One",
+ image_url: null,
+ has_external_trigger: false,
+ is_scheduled: false,
+ next_scheduled_run: null,
+ recommended_schedule_cron: null,
+ ...overrides,
+ } as unknown as LibraryAgent;
+}
+
+function makeRunningExecution(graphID: string, id: string): GraphExecutionMeta {
+ return {
+ id,
+ graph_id: graphID,
+ graph_version: 1,
+ status: "RUNNING",
+ started_at: new Date().toISOString(),
+ ended_at: null,
+ stats: { activity_status: "Crunching data" },
+ } as unknown as GraphExecutionMeta;
+}
+
+describe("ExecutionListSection", () => {
+ it("renders running items and toggles the full list with 'Show all'", async () => {
+ const agents = Array.from({ length: 7 }, (_, i) =>
+ makeAgent({ id: `lib-${i}`, graph_id: `g-${i}`, name: `Agent ${i}` }),
+ );
+ const executions = agents.map((a, i) =>
+ makeRunningExecution(a.graph_id, `exec-${i}`),
+ );
+ server.use(getGetV1ListAllExecutionsMockHandler200(executions));
+
+ render(<ExecutionListSection activeTab="running" agents={agents} />);
+
+ // 7 running items, but only MAX_VISIBLE (6) shown until expanded.
+ await waitFor(() => {
+ expect(screen.getAllByText("Crunching data").length).toBe(6);
+ });
+ const showAll = screen.getByRole("button", { name: /show all \(7\)/i });
+
+ fireEvent.click(showAll);
+ expect(screen.getAllByText("Crunching data").length).toBe(7);
+ expect(screen.getByRole("button", { name: /collapse/i })).toBeDefined();
+ });
+});
+
+describe("AgentListSection", () => {
+ it("lists listening agents with their status label and toggles 'Show all'", async () => {
+ const agents = Array.from({ length: 7 }, (_, i) =>
+ makeAgent({
+ id: `lib-${i}`,
+ graph_id: `g-${i}`,
+ name: `Listener ${i}`,
+ has_external_trigger: true,
+ }),
+ );
+ // No executions → status falls through to the config-derived "listening".
+ server.use(getGetV1ListAllExecutionsMockHandler200([]));
+
+ render(<AgentListSection activeTab="listening" agents={agents} />);
+
+ await waitFor(() => {
+ expect(screen.getAllByText("Waiting for trigger event").length).toBe(6);
+ });
+
+ fireEvent.click(screen.getByRole("button", { name: /show all \(7\)/i }));
+ expect(screen.getAllByText("Waiting for trigger event").length).toBe(7);
+ });
+
+ it("shows the empty message when no agent matches the tab", () => {
+ server.use(getGetV1ListAllExecutionsMockHandler200([]));
+ render(<AgentListSection activeTab="idle" agents={[]} />);
+ expect(screen.getByText("No idle agents")).toBeDefined();
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/components/AgentListSection.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/components/AgentListSection.tsx
new file mode 100644
index 0000000000..25ba00b7a5
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/components/AgentListSection.tsx
@@ -0,0 +1,76 @@
+"use client";
+
+import type { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";
+import { Button } from "@/components/atoms/Button/Button";
+import { useState } from "react";
+import { getAgentStatusLabel, MAX_VISIBLE } from "../helpers";
+import { EmptyMessage } from "./EmptyMessage";
+import { AgentStatusFilter } from "@/app/(platform)/library/types";
+import { useAgentStatusMap } from "@/app/(platform)/library/hooks/useAgentStatus";
+import { SitrepItem } from "@/app/(platform)/library/components/SitrepItem/SitrepItem";
+
+interface Props {
+ activeTab: AgentStatusFilter;
+ agents: LibraryAgent[];
+}
+
+export function AgentListSection({ activeTab, agents }: Props) {
+ const [showAll, setShowAll] = useState(false);
+ const statusMap = useAgentStatusMap(agents);
+
+ const filtered = agents.filter((agent) => {
+ const status = statusMap.get(agent.graph_id)?.status;
+ if (activeTab === "listening") return status === "listening";
+ if (activeTab === "scheduled") return status === "scheduled";
+ if (activeTab === "idle") return status === "idle";
+ return false;
+ });
+
+ if (filtered.length === 0) return <EmptyMessage tab={activeTab} />;
+
+ const status =
+ activeTab === "listening"
+ ? ("listening" as const)
+ : activeTab === "scheduled"
+ ? ("scheduled" as const)
+ : ("idle" as const);
+
+ const visible = showAll ? filtered : filtered.slice(0, MAX_VISIBLE);
+ const hasMore = filtered.length > MAX_VISIBLE;
+
+ function handleToggleShowAll() {
+ setShowAll(!showAll);
+ }
+
+ return (
+ <div>
+ <div className="grid grid-cols-1 gap-3 lg:grid-cols-2">
+ {visible.map((agent) => (
+ <SitrepItem
+ key={agent.id}
+ item={{
+ id: agent.id,
+ agentID: agent.id,
+ agentName: agent.name,
+ agentImageUrl: agent.image_url,
+ priority: status,
+ message: getAgentStatusLabel(activeTab, agent),
+ status,
+ }}
+ />
+ ))}
+ </div>
+ {hasMore ? (
+ <div className="mt-3 flex justify-center">
+ <Button
+ variant="secondary"
+ size="small"
+ onClick={handleToggleShowAll}
+ >
+ {showAll ? "Collapse" : `Show all (${filtered.length})`}
+ </Button>
+ </div>
+ ) : null}
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/components/CopilotLibrarySummary.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/components/CopilotLibrarySummary.tsx
new file mode 100644
index 0000000000..5c0183936c
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/components/CopilotLibrarySummary.tsx
@@ -0,0 +1,76 @@
+"use client";
+
+import { useListCopilotSkills } from "@/app/api/__generated__/endpoints/skills/skills";
+import { useListCopilotFollowupSchedules } from "@/app/api/__generated__/endpoints/schedules/schedules";
+import { Text } from "@/components/atoms/Text/Text";
+import Link from "next/link";
+
+export function CopilotLibrarySummary() {
+ // Discoverability is already gated by AGENT_BRIEFING at the parent
+ // panel — this pill renders only inside AgentBriefingPanel, which is
+ // itself flag-gated. No second flag here because the count-based
+ // hide below already keeps the pill quiet for users who don't use
+ // the feature.
+ const { data: skillsRes } = useListCopilotSkills({
+ query: { staleTime: 30_000 },
+ });
+ const { data: followupsRes } = useListCopilotFollowupSchedules({
+ query: { staleTime: 30_000 },
+ });
+
+ const skillsCount =
+ skillsRes && skillsRes.status === 200 ? skillsRes.data.length : 0;
+ // Count only copilot follow-ups here — graph schedules (recurring
+ // agent runs) are already surfaced by the briefing's own "Scheduled"
+ // tab above, so folding them into this pill would double-count and
+ // confuse the "Autopilot library" framing. The pill's link still
+ // goes to the unified `/library/followups` page, where both kinds
+ // are listed together.
+ const followupCount =
+ followupsRes && followupsRes.status === 200 ? followupsRes.data.length : 0;
+
+ // Suppress the pill entirely when the user has no autopilot library
+ // content yet — surfacing "0 skills · 0 follow-ups" is noise, not a
+ // discovery affordance. The pill reappears the moment either count
+ // turns positive (e.g. after a store_skill / schedule_followup tool
+ // call).
+ if (skillsCount === 0 && followupCount === 0) return null;
+
+ // Per-link hide: surface only the counts that are non-zero. We
+ // already returned ``null`` above when both are zero, so at least
+ // one branch always renders.
+ const showSkills = skillsCount > 0;
+ const showFollowups = followupCount > 0;
+
+ return (
+ <div
+ className="mt-5 flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-zinc-100 pt-3"
+ data-testid="copilot-library-summary"
+ >
+ <Text variant="small" className="!text-zinc-500">
+ Autopilot library
+ </Text>
+ {showSkills ? (
+ <Link
+ href="/library/skills"
+ className="text-sm text-violet-700 hover:underline"
+ data-testid="copilot-library-skills-link"
+ >
+ {skillsCount} skill{skillsCount === 1 ? "" : "s"}
+ </Link>
+ ) : null}
+ {showSkills && showFollowups ? (
+ <span className="text-zinc-300">•</span>
+ ) : null}
+ {showFollowups ? (
+ <Link
+ href="/library/followups"
+ className="text-sm text-yellow-700 hover:underline"
+ data-testid="copilot-library-followups-link"
+ >
+ {followupCount} follow-up{followupCount === 1 ? "" : "s"}
+ </Link>
+ ) : null}
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/components/EmptyMessage.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/components/EmptyMessage.tsx
new file mode 100644
index 0000000000..af573bda43
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/components/EmptyMessage.tsx
@@ -0,0 +1,19 @@
+"use client";
+
+import { Text } from "@/components/atoms/Text/Text";
+import type { AgentStatusFilter } from "@/app/(platform)/library/types";
+import { getEmptyMessage } from "../helpers";
+
+interface Props {
+ tab: AgentStatusFilter;
+}
+
+export function EmptyMessage({ tab }: Props) {
+ return (
+ <div className="flex items-center justify-center pt-4">
+ <Text variant="body-medium" className="text-zinc-600">
+ {getEmptyMessage(tab)}
+ </Text>
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/components/ExecutionListSection.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/components/ExecutionListSection.tsx
new file mode 100644
index 0000000000..bab195f21e
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/components/ExecutionListSection.tsx
@@ -0,0 +1,57 @@
+"use client";
+
+import type { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";
+import { Button } from "@/components/atoms/Button/Button";
+import { useState } from "react";
+import { useSitrepItems } from "@/app/(platform)/library/components/SitrepItem/useSitrepItems";
+import { SitrepItem } from "@/app/(platform)/library/components/SitrepItem/SitrepItem";
+import type { AgentStatusFilter } from "@/app/(platform)/library/types";
+import { MAX_VISIBLE } from "../helpers";
+import { EmptyMessage } from "./EmptyMessage";
+
+interface Props {
+ activeTab: AgentStatusFilter;
+ agents: LibraryAgent[];
+}
+
+export function ExecutionListSection({ activeTab, agents }: Props) {
+ const allItems = useSitrepItems(agents, agents.length);
+ const [showAll, setShowAll] = useState(false);
+
+ const filtered = allItems.filter((item) => {
+ if (activeTab === "running") return item.priority === "running";
+ if (activeTab === "attention") return item.priority === "error";
+ if (activeTab === "completed") return item.priority === "success";
+ return false;
+ });
+
+ if (filtered.length === 0) return <EmptyMessage tab={activeTab} />;
+
+ const visible = showAll ? filtered : filtered.slice(0, MAX_VISIBLE);
+ const hasMore = filtered.length > MAX_VISIBLE;
+
+ function handleToggleShowAll() {
+ setShowAll(!showAll);
+ }
+
+ return (
+ <div>
+ <div className="grid grid-cols-1 gap-3 lg:grid-cols-2">
+ {visible.map((item) => (
+ <SitrepItem key={item.id} item={item} />
+ ))}
+ </div>
+ {hasMore ? (
+ <div className="mt-3 flex justify-center">
+ <Button
+ variant="secondary"
+ size="small"
+ onClick={handleToggleShowAll}
+ >
+ {showAll ? "Collapse" : `Show all (${filtered.length})`}
+ </Button>
+ </div>
+ ) : null}
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/helpers.ts
new file mode 100644
index 0000000000..d280d9c87a
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/helpers.ts
@@ -0,0 +1,37 @@
+import type { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";
+import type { AgentStatusFilter } from "@/app/(platform)/library/types";
+
+export const MAX_VISIBLE = 6;
+
+const TAB_STATUS_LABEL: Record<string, string> = {
+ listening: "Waiting for trigger event",
+ scheduled: "Has a scheduled run",
+ idle: "No recent activity",
+};
+
+export function getAgentStatusLabel(tab: string, agent: LibraryAgent): string {
+ if (tab === "scheduled" && agent.next_scheduled_run) {
+ const diff = new Date(agent.next_scheduled_run).getTime() - Date.now();
+ const minutes = Math.round(diff / 60_000);
+ if (minutes <= 0) return "Scheduled to run soon";
+ if (minutes < 60) return `Scheduled to run in ${minutes}m`;
+ const hours = Math.round(minutes / 60);
+ if (hours < 24) return `Scheduled to run in ${hours}h`;
+ const days = Math.round(hours / 24);
+ return `Scheduled to run in ${days}d`;
+ }
+ return TAB_STATUS_LABEL[tab] ?? "";
+}
+
+const EMPTY_MESSAGES: Record<string, string> = {
+ running: "No agents running right now",
+ attention: "No agents that need attention",
+ completed: "No recently completed tasks",
+ listening: "No agents listening for events",
+ scheduled: "No agents with scheduled tasks",
+ idle: "No idle agents",
+};
+
+export function getEmptyMessage(tab: AgentStatusFilter): string {
+ return EMPTY_MESSAGES[tab] ?? "No agents in this category";
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/CostsBreakdown/CostsBreakdown.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/CostsBreakdown/CostsBreakdown.tsx
similarity index 98%
rename from autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/CostsBreakdown/CostsBreakdown.tsx
rename to autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/CostsBreakdown/CostsBreakdown.tsx
index 10c4bf7f74..03f558aa02 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/CostsBreakdown/CostsBreakdown.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/CostsBreakdown/CostsBreakdown.tsx
@@ -111,9 +111,9 @@ function ExpandedBody({
label: "Total this month",
value: formatCents(summary.total_cents),
},
- { label: "Runs", value: String(summary.run_count) },
+ { label: "Tasks", value: String(summary.run_count) },
{
- label: "Avg / run",
+ label: "Avg / task",
value: formatCents(Math.round(avgCostCents)),
},
{
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/CostsBreakdown/__tests__/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/CostsBreakdown/__tests__/helpers.test.ts
similarity index 100%
rename from autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/CostsBreakdown/__tests__/helpers.test.ts
rename to autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/CostsBreakdown/__tests__/helpers.test.ts
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/CostsBreakdown/components/SpendByAgentList.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/CostsBreakdown/components/SpendByAgentList.tsx
similarity index 100%
rename from autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/CostsBreakdown/components/SpendByAgentList.tsx
rename to autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/CostsBreakdown/components/SpendByAgentList.tsx
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/CostsBreakdown/components/TopRunsList.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/CostsBreakdown/components/TopRunsList.tsx
similarity index 98%
rename from autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/CostsBreakdown/components/TopRunsList.tsx
rename to autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/CostsBreakdown/components/TopRunsList.tsx
index 7cc81e0c20..64197b8da6 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/CostsBreakdown/components/TopRunsList.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/CostsBreakdown/components/TopRunsList.tsx
@@ -25,7 +25,7 @@ export function TopRunsList({ runs, agentLookup }: Props) {
return (
<section className="flex flex-col gap-2 lg:mt-[1rem]">
<Text variant="body-medium" className="text-neutral-800 lg:mb-[.5rem]">
- Most expensive runs
+ Most expensive tasks
</Text>
<ul className="flex flex-col divide-y divide-zinc-100 rounded-medium border border-zinc-100 bg-white">
{visible.map((run) => {
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/CostsBreakdown/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/CostsBreakdown/helpers.ts
similarity index 100%
rename from autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/CostsBreakdown/helpers.ts
rename to autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/CostsBreakdown/helpers.ts
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/CostsBreakdown/useCostsBreakdown.ts b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/CostsBreakdown/useCostsBreakdown.ts
similarity index 100%
rename from autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/CostsBreakdown/useCostsBreakdown.ts
rename to autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/CostsBreakdown/useCostsBreakdown.ts
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/StatsGrid.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/StatsGrid/StatsGrid.tsx
similarity index 97%
rename from autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/StatsGrid.tsx
rename to autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/StatsGrid/StatsGrid.tsx
index 49444bc7fd..08b70b8e37 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/StatsGrid.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/StatsGrid/StatsGrid.tsx
@@ -5,7 +5,7 @@ import { OverflowText } from "@/components/atoms/OverflowText/OverflowText";
import { Emoji } from "@/components/atoms/Emoji/Emoji";
import { cn } from "@/lib/utils";
import { formatCents } from "@/app/(platform)/copilot/components/usageHelpers";
-import type { FleetSummary, AgentStatusFilter } from "../../types";
+import type { FleetSummary, AgentStatusFilter } from "../../../../types";
interface Props {
summary: FleetSummary;
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/SitrepItem.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/SitrepItem.tsx
index 54bcd59cb0..23acdb5bd7 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/SitrepItem.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/SitrepItem.tsx
@@ -18,6 +18,7 @@ import { useRouter } from "next/navigation";
import type { SitrepItemData, SitrepPriority } from "../../types";
import { ContextualActionButton } from "../ContextualActionButton/ContextualActionButton";
import styles from "./SitrepItem.module.css";
+import { buildAutoPilotPrompt } from "./helpers";
interface Props {
item: SitrepItemData;
@@ -154,22 +155,3 @@ export function SitrepItem({ item }: Props) {
</div>
);
}
-
-function buildAutoPilotPrompt(item: SitrepItemData): string {
- switch (item.priority) {
- case "error":
- return `What happened with ${item.agentName}? It says "${item.message}" — can you check the logs and tell me what to fix?`;
- case "running":
- return `Give me a status update on the ${item.agentName} run — what has it found so far?`;
- case "stale":
- return `${item.agentName} hasn't run recently. Should I keep it or update and re-run it?`;
- case "success":
- return `Show me what ${item.agentName} found in its last run — summarize the results and any key takeaways.`;
- case "listening":
- return `What is ${item.agentName} listening for? Give me a summary of its trigger configuration.`;
- case "scheduled":
- return `When is ${item.agentName} scheduled to run next?`;
- case "idle":
- return `${item.agentName} has been idle. Should I keep it or update and re-run it?`;
- }
-}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/SitrepList.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/SitrepList.tsx
deleted file mode 100644
index 5ebf5bfd94..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/SitrepList.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-"use client";
-
-import { Text } from "@/components/atoms/Text/Text";
-import { ClockCounterClockwise } from "@phosphor-icons/react";
-import type { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";
-import { useSitrepItems } from "./useSitrepItems";
-import { SitrepItem } from "./SitrepItem";
-
-interface Props {
- agents: LibraryAgent[];
- maxItems?: number;
-}
-
-export function SitrepList({ agents, maxItems = 10 }: Props) {
- const items = useSitrepItems(agents, maxItems);
-
- if (items.length === 0) return null;
-
- return (
- <div>
- <div className="mb-2 flex items-center gap-1.5">
- <ClockCounterClockwise size={16} className="text-zinc-700" />
- <Text variant="body-medium" className="text-zinc-700">
- Recent tasks
- </Text>
- </div>
- <div className="grid grid-cols-1 gap-1 lg:grid-cols-2">
- {items.map((item) => (
- <SitrepItem key={item.id} item={item} />
- ))}
- </div>
- </div>
- );
-}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/__tests__/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/__tests__/helpers.test.ts
new file mode 100644
index 0000000000..c5163d50a8
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/__tests__/helpers.test.ts
@@ -0,0 +1,63 @@
+import type { SitrepItemData, SitrepPriority } from "../../../types";
+import { describe, expect, it } from "vitest";
+import { buildAutoPilotPrompt } from "../helpers";
+
+function makeItem(
+ priority: SitrepPriority,
+ overrides: Partial<SitrepItemData> = {},
+): SitrepItemData {
+ return {
+ id: "1",
+ agentID: "a-1",
+ agentName: "Weather Bot",
+ priority,
+ message: "Something happened",
+ status: "idle",
+ ...overrides,
+ };
+}
+
+describe("buildAutoPilotPrompt", () => {
+ it("asks to investigate logs and quotes the error message", () => {
+ const prompt = buildAutoPilotPrompt(
+ makeItem("error", { message: "Boom at step 3" }),
+ );
+ expect(prompt).toContain("Weather Bot");
+ expect(prompt).toContain("Boom at step 3");
+ expect(prompt.toLowerCase()).toContain("logs");
+ });
+
+ it("asks for a status update on running agents", () => {
+ expect(buildAutoPilotPrompt(makeItem("running"))).toContain(
+ "status update",
+ );
+ });
+
+ it("offers to keep, update, or re-run stale agents", () => {
+ expect(buildAutoPilotPrompt(makeItem("stale"))).toContain(
+ "hasn't run recently",
+ );
+ });
+
+ it("summarizes results for successful runs", () => {
+ expect(buildAutoPilotPrompt(makeItem("success")).toLowerCase()).toContain(
+ "summarize",
+ );
+ });
+
+ it("summarizes the trigger configuration for listening agents", () => {
+ expect(buildAutoPilotPrompt(makeItem("listening")).toLowerCase()).toContain(
+ "listening for",
+ );
+ });
+
+ it("asks when a scheduled agent runs next", () => {
+ expect(buildAutoPilotPrompt(makeItem("scheduled")).toLowerCase()).toContain(
+ "scheduled to run next",
+ );
+ });
+
+ it("offers to keep, update, or re-run idle agents", () => {
+ expect(buildAutoPilotPrompt(makeItem("idle"))).toContain("has been idle");
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/helpers.ts
new file mode 100644
index 0000000000..6817ada6b9
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/helpers.ts
@@ -0,0 +1,20 @@
+import { SitrepItemData } from "../../types";
+
+export function buildAutoPilotPrompt(item: SitrepItemData): string {
+ switch (item.priority) {
+ case "error":
+ return `What happened with ${item.agentName}? It says "${item.message}" — can you check the logs and tell me what to fix?`;
+ case "running":
+ return `Give me a status update on the ${item.agentName} run — what has it found so far?`;
+ case "stale":
+ return `${item.agentName} hasn't run recently. Should I keep it or update and re-run it?`;
+ case "success":
+ return `Show me what ${item.agentName} found in its last run — summarize the results and any key takeaways.`;
+ case "listening":
+ return `What is ${item.agentName} listening for? Give me a summary of its trigger configuration.`;
+ case "scheduled":
+ return `When is ${item.agentName} scheduled to run next?`;
+ case "idle":
+ return `${item.agentName} has been idle. Should I keep it or update and re-run it?`;
+ }
+}