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.

feat(frontend): show chat document count and expert files (#15029)

Ubbe9fbd2450aee3
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/expert-integrations.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/expert-integrations.test.tsx
index 8837fbe8fa..4e946201bc 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/expert-integrations.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/expert-integrations.test.tsx
@@ -43,7 +43,7 @@ function credential(provider: string): ExpertCredentialRef {
function resetPanel() {
useCopilotUIStore.setState((s) => ({
- integrationsPanelExpert: null,
+ contextPanelExpert: null,
artifactPanel: {
...s.artifactPanel,
isOpen: false,
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/store.test.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/store.test.ts
index a320d2a7b8..6b47644768 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/store.test.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/store.test.ts
@@ -529,7 +529,7 @@ describe("lastArtifact session scoping", () => {
useCopilotUIStore.getState().closeArtifactPanel();
useCopilotUIStore.getState().clearLastArtifact();
const s = useCopilotUIStore.getState();
- expect(s.integrationsPanelExpert).toBeNull();
+ expect(s.contextPanelExpert).toBeNull();
expect(s.artifactPanel.activeTab).toBe("files");
});
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.tsx
index 9d5d3781b6..868241c4a3 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
@@ -12,6 +12,7 @@ import {
MAX_CONTEXT_PANEL_WIDTH,
MIN_CONTEXT_PANEL_WIDTH,
type ContextPanelTab,
+ useCopilotUIStore,
} from "../../store";
import { PanelResizeHandle } from "../PanelResizeHandle";
import { WorkspaceFileCards } from "../WorkspaceFileCards/WorkspaceFileCards";
@@ -36,6 +37,7 @@ const TAB_TITLES: Record<ContextPanelTab, string> = {
};
export function ContextPanel({ sessionId, mobile }: Props) {
+ const expert = useCopilotUIStore((s) => s.contextPanelExpert);
const {
activeTab,
showExpanded,
@@ -55,7 +57,7 @@ export function ContextPanel({ sessionId, mobile }: Props) {
{activeTab === "integrations" ? (
<IntegrationsTab />
) : sessionId ? (
- <WorkspaceFileCards sessionId={sessionId} />
+ <WorkspaceFileCards sessionId={sessionId} expert={expert} />
) : null}
</div>
)}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanelToggle.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanelToggle.tsx
index e3d728b030..d21460c871 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanelToggle.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/ContextPanelToggle.tsx
@@ -2,16 +2,18 @@
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
-import { useCopilotUIStore, type IntegrationsPanelExpert } from "../../store";
+import { useCopilotUIStore, type ContextPanelExpert } from "../../store";
import { ComputerIcon, LicenseDraftIcon } from "@hugeicons/core-free-icons";
import { Icon } from "@/components/atoms/Icon/Icon";
import { useIsMobile } from "../../useIsMobile";
import { IntegrationsToggle } from "./components/IntegrationsToggle/IntegrationsToggle";
+import { useSessionFiles } from "./components/FilesTab/useSessionFiles";
+import { useEffect } from "react";
interface Props {
sessionId?: string | null;
/** The chat's live expert, whose integrations lead the controls. */
- expert?: IntegrationsPanelExpert | null;
+ expert?: ContextPanelExpert | null;
}
// Sized and stroked like the sidebar's nav icons so the chat's top-right
@@ -25,6 +27,14 @@ const toggleClass =
* own "Turn on screen" button lives on that face, so it must be reachable
* before any desktop exists. */
export function ContextPanelToggle({ sessionId = null, expert = null }: Props) {
+ const { deliverables, documentCount: liveDocumentCount } =
+ useSessionFiles(sessionId);
+ const documentCount = Math.max(deliverables.length, liveDocumentCount);
+ const expertId = expert?.id ?? null;
+ const expertName = expert?.name ?? null;
+ const setContextPanelExpert = useCopilotUIStore(
+ (s) => s.setContextPanelExpert,
+ );
const isFilesOpen = useCopilotUIStore(
(s) =>
s.artifactPanel.isOpen &&
@@ -45,6 +55,12 @@ export function ContextPanelToggle({ sessionId = null, expert = null }: Props) {
// The mobile sheet has no computer face to open.
const showComputerToggle = !!sessionId && !isMobile;
+ useEffect(() => {
+ setContextPanelExpert(
+ expertId && expertName ? { id: expertId, name: expertName } : null,
+ );
+ }, [expertId, expertName, setContextPanelExpert]);
+
function handleComputerToggle() {
// Back to whatever the computer was covering: the preview, the tab, or
// nothing at all.
@@ -83,14 +99,28 @@ export function ContextPanelToggle({ sessionId = null, expert = null }: Props) {
variant="ghost"
size="icon"
onClick={() => toggleContextPanelTab("files")}
- aria-label={isFilesOpen ? "Hide files" : "Open files"}
+ aria-label={`${isFilesOpen ? "Hide" : "Open"} files${
+ documentCount > 0
+ ? ` (${documentCount} ${documentCount === 1 ? "document" : "documents"})`
+ : ""
+ }`}
aria-pressed={isFilesOpen}
- className={cn(toggleClass, "size-8", isFilesOpen && "bg-zinc-100")}
+ className={cn(
+ toggleClass,
+ "h-8",
+ documentCount > 0 ? "w-auto gap-1 px-2" : "w-8",
+ isFilesOpen && "bg-zinc-100",
+ )}
>
<Icon
icon={LicenseDraftIcon}
className="!size-4 text-sidebar-foreground/90"
/>
+ {documentCount > 0 && (
+ <span className="text-xs font-medium tabular-nums text-sidebar-foreground/90">
+ {documentCount}
+ </span>
+ )}
</Button>
</div>
);
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/__tests__/ContextPanel.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/__tests__/ContextPanel.test.tsx
index 36fe974750..856a4be8e2 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/__tests__/ContextPanel.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/__tests__/ContextPanel.test.tsx
@@ -23,6 +23,7 @@ beforeEach(() => {
}),
);
useCopilotUIStore.setState((s) => ({
+ contextPanelExpert: null,
artifactPanel: {
...s.artifactPanel,
isOpen: true,
@@ -57,7 +58,7 @@ describe("ContextPanel", () => {
test("docks for the integrations tab with the expert's integrations", async () => {
server.use(getListExpertCredentialsMockHandler([]));
useCopilotUIStore.setState((s) => ({
- integrationsPanelExpert: { id: "expert-maria", name: "Maria" },
+ contextPanelExpert: { id: "expert-maria", name: "Maria" },
artifactPanel: { ...s.artifactPanel, activeTab: "integrations" },
}));
render(<ContextPanel sessionId="session-1" />);
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/__tests__/ContextPanelToggle.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/__tests__/ContextPanelToggle.test.tsx
index 69caac5f30..261422d960 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/__tests__/ContextPanelToggle.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/__tests__/ContextPanelToggle.test.tsx
@@ -1,7 +1,14 @@
import { getListWorkspaceFilesMockHandler200 } from "@/app/api/__generated__/endpoints/workspace/workspace.msw";
import { server } from "@/mocks/mock-server";
-import { fireEvent, render, screen } from "@/tests/integrations/test-utils";
+import {
+ act,
+ fireEvent,
+ render,
+ screen,
+} from "@/tests/integrations/test-utils";
+import { http, HttpResponse } from "msw";
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
+import { useCopilotStreamStore } from "../../../copilotStreamStore";
import { useCopilotUIStore } from "../../../store";
import { ContextPanelToggle } from "../ContextPanelToggle";
@@ -57,6 +64,8 @@ beforeEach(() => {
isComputerOpen: false,
computer: null,
});
+ useCopilotUIStore.setState({ contextPanelExpert: null });
+ useCopilotStreamStore.setState({ messageSnapshots: {} });
});
afterEach(() => {
@@ -71,9 +80,107 @@ afterEach(() => {
isComputerOpen: false,
computer: null,
});
+ useCopilotUIStore.setState({ contextPanelExpert: null });
+ useCopilotStreamStore.setState({ messageSnapshots: {} });
});
describe("ContextPanelToggle files button", () => {
+ test("shares the chat expert with the file panel", async () => {
+ render(
+ <ContextPanelToggle
+ sessionId="s1"
+ expert={{ id: "expert-maria", name: "Maria" }}
+ />,
+ );
+
+ await vi.waitFor(() =>
+ expect(useCopilotUIStore.getState().contextPanelExpert).toEqual({
+ id: "expert-maria",
+ name: "Maria",
+ }),
+ );
+ });
+
+ test("shows the number of documents generated in the chat", async () => {
+ const documentId = "aaaaaaaa-0000-0000-0000-000000000001";
+ const uploadId = "bbbbbbbb-0000-0000-0000-000000000002";
+ let hasGeneratedDocument = false;
+ server.use(
+ http.get("*/api/workspace/files", () =>
+ HttpResponse.json({
+ files: hasGeneratedDocument
+ ? [
+ {
+ id: documentId,
+ name: "brief.md",
+ path: "/sessions/s1/brief.md",
+ mime_type: "text/markdown",
+ size_bytes: 128,
+ origin: "generated",
+ created_at: "2026-09-29T10:00:00Z",
+ },
+ {
+ id: uploadId,
+ name: "source.pdf",
+ path: "/sessions/s1/source.pdf",
+ mime_type: "application/pdf",
+ size_bytes: 256,
+ origin: "uploaded",
+ created_at: "2026-09-29T09:00:00Z",
+ },
+ {
+ id: "cccccccc-0000-0000-0000-000000000003",
+ name: "tool.json",
+ path: "/sessions/s1/tool-results/tool.json",
+ mime_type: "application/json",
+ size_bytes: 64,
+ metadata: { purpose: "tool-output" },
+ origin: "generated",
+ created_at: "2026-09-29T08:00:00Z",
+ },
+ ]
+ : [],
+ offset: 0,
+ has_more: false,
+ }),
+ ),
+ );
+
+ render(<ContextPanelToggle sessionId="s1" />);
+ expect(await screen.findByLabelText("Open files")).toBeDefined();
+
+ hasGeneratedDocument = true;
+ act(() => {
+ useCopilotStreamStore.getState().setMessageSnapshot("s1", [
+ {
+ id: "assistant-message",
+ role: "assistant",
+ parts: [
+ {
+ type: "text",
+ text: `Here is [the brief](workspace://${documentId}) and [the same brief](workspace://${documentId}).`,
+ },
+ ],
+ },
+ {
+ id: "user-message",
+ role: "user",
+ parts: [
+ {
+ type: "file",
+ mediaType: "application/pdf",
+ filename: "source.pdf",
+ url: `/api/proxy/api/workspace/files/${uploadId}/download`,
+ },
+ ],
+ },
+ ]);
+ });
+
+ const button = await screen.findByLabelText("Open files (1 document)");
+ expect(button.textContent).toBe("1");
+ });
+
test("opens the files tab of the side panel", () => {
render(<ContextPanelToggle sessionId="s1" />);
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/FilesTab/useSessionFiles.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/FilesTab/useSessionFiles.ts
index 4bfc2f0f18..45b502bdd2 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/FilesTab/useSessionFiles.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/FilesTab/useSessionFiles.ts
@@ -1,6 +1,9 @@
"use client";
-import { useListWorkspaceFiles } from "@/app/api/__generated__/endpoints/workspace/workspace";
+import {
+ getListWorkspaceFilesQueryKey,
+ useListWorkspaceFiles,
+} from "@/app/api/__generated__/endpoints/workspace/workspace";
import type { ListFilesResponse } from "@/app/api/__generated__/models/listFilesResponse";
import type { WorkspaceFileItem } from "@/app/api/__generated__/models/workspaceFileItem";
import { useMemo } from "react";
@@ -17,31 +20,35 @@ export function useSessionFiles(sessionId: string | null) {
const messages = useCopilotStreamStore((s) =>
sessionId ? s.messageSnapshots[sessionId] : undefined,
);
-
- const query = useListWorkspaceFiles(
- { session_id: sessionId ?? undefined },
- {
- query: {
- enabled: !!sessionId,
- select: (res) => res.data as ListFilesResponse,
- },
- },
- );
-
- // The chip and the artifacts button both read this on every render, and
- // `messageSnapshots` is rewritten with a fresh array per streamed token —
- // so without memoising, scanning every message part (and compiling a
- // RegExp per matched workspace URI) would run at token cadence.
- const { uploaded, generated, deliverables, files } = useMemo(() => {
+ const { documentCount, fileIdToMessageId } = useMemo(() => {
+ const documentIds = new Set<string>();
const fileIdToMessageId = new Map<string, string>();
for (const message of messages ?? []) {
for (const artifact of getMessageArtifacts(message)) {
if (!fileIdToMessageId.has(artifact.id)) {
fileIdToMessageId.set(artifact.id, message.id);
}
+ if (message.role === "assistant") documentIds.add(artifact.id);
}
}
+ return { documentCount: documentIds.size, fileIdToMessageId };
+ }, [messages]);
+ const params = { session_id: sessionId ?? undefined };
+
+ const query = useListWorkspaceFiles(params, {
+ query: {
+ enabled: !!sessionId,
+ queryKey: [...getListWorkspaceFilesQueryKey(params), documentCount],
+ placeholderData: (previous) => previous,
+ select: (res) => res.data as ListFilesResponse,
+ },
+ });
+ // The chip and the artifacts button both read this on every render, and
+ // `messageSnapshots` is rewritten with a fresh array per streamed token —
+ // so without memoising, scanning every message part (and compiling a
+ // RegExp per matched workspace URI) would run at token cadence.
+ const { uploaded, generated, deliverables, files } = useMemo(() => {
const files: SessionFile[] = (query.data?.files ?? []).map((item) => ({
item,
messageID: fileIdToMessageId.get(item.id) ?? null,
@@ -55,9 +62,10 @@ export function useSessionFiles(sessionId: string | null) {
(f) => !isUploadedFile(f.item) && !isInternalToolOutput(f.item),
),
};
- }, [messages, query.data]);
+ }, [fileIdToMessageId, query.data]);
return {
+ documentCount,
uploaded,
generated,
deliverables,
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/IntegrationsTab/IntegrationsTab.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/IntegrationsTab/IntegrationsTab.tsx
index 6ce8c8ec9e..61282f7e15 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/IntegrationsTab/IntegrationsTab.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/IntegrationsTab/IntegrationsTab.tsx
@@ -7,7 +7,7 @@ import { useCopilotUIStore } from "../../../../store";
/** The chat's expert's integrations, with the same add / use existing /
* remove actions as the Integrations tab on the expert's page. */
export function IntegrationsTab() {
- const expert = useCopilotUIStore((s) => s.integrationsPanelExpert);
+ const expert = useCopilotUIStore((s) => s.contextPanelExpert);
if (!expert) return null;
return (
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/IntegrationsToggle/IntegrationsToggle.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/IntegrationsToggle/IntegrationsToggle.tsx
index 07dc73df4d..08552df284 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/IntegrationsToggle/IntegrationsToggle.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ContextPanel/components/IntegrationsToggle/IntegrationsToggle.tsx
@@ -11,16 +11,13 @@ import {
import { Icon } from "@/components/atoms/Icon/Icon";
import { IntegrationLogo } from "@/components/molecules/IntegrationLogo/IntegrationLogo";
import { cn } from "@/lib/utils";
-import {
- useCopilotUIStore,
- type IntegrationsPanelExpert,
-} from "../../../../store";
+import { useCopilotUIStore, type ContextPanelExpert } from "../../../../store";
import { useExpertIntegrations } from "./useExpertIntegrations";
const VISIBLE_LOGOS = 2;
interface Props {
- expert: IntegrationsPanelExpert;
+ expert: ContextPanelExpert;
className?: string;
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/WorkspaceFileCards.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/WorkspaceFileCards.tsx
index 61ce679a6b..eac34fb770 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/WorkspaceFileCards.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/WorkspaceFileCards.tsx
@@ -3,21 +3,26 @@
import { Download01Icon, File02Icon } from "@hugeicons/core-free-icons";
import { Button } from "@/components/atoms/Button/Button";
import { Icon } from "@/components/atoms/Icon/Icon";
+import type { ContextPanelExpert } from "../../store";
+import { DeleteFileDialog } from "../ContextPanel/components/FilesTab/components/DeleteFileDialog";
import { SessionActivityCard } from "./components/SessionActivityCard";
import { StackSection } from "./components/StackSection";
import { WorkspaceFilesContent } from "./components/WorkspaceFilesContent";
+import { useExpertDocuments } from "./useExpertDocuments";
import { useSessionActivity } from "./useSessionActivity";
import { useWorkspaceFileCards } from "./useWorkspaceFileCards";
interface Props {
sessionId: string;
+ expert?: ContextPanelExpert | null;
}
/** The chat's files, then the runs and schedules it set in motion — the
* files tab of the docked side panel. */
-export function WorkspaceFileCards({ sessionId }: Props) {
+export function WorkspaceFileCards({ sessionId, expert = null }: Props) {
const {
files,
+ documentCount: sessionDocumentCount,
isLoading,
isError,
isDeleting,
@@ -29,16 +34,22 @@ export function WorkspaceFileCards({ sessionId }: Props) {
handleConfirmDelete,
handleDownloadAll,
} = useWorkspaceFileCards(sessionId);
+ const {
+ documents: expertDocuments,
+ isLoading: isExpertDocumentsLoading,
+ isError: isExpertDocumentsError,
+ } = useExpertDocuments(expert?.id ?? null, sessionDocumentCount);
// The files section only shows once there's something in it (or something
// to report); a chat with nothing at all gets one empty state.
const showFilesCard = isLoading || isError || files.length > 0;
const { runs, schedules } = useSessionActivity(sessionId);
const hasActivity = runs.length > 0 || schedules.length > 0;
+ const hasExpertSection = Boolean(expert);
return (
<div className="flex flex-col gap-3">
- {!showFilesCard && !hasActivity && (
+ {!showFilesCard && !hasActivity && !hasExpertSection && (
<div className="rounded-3xl bg-white/90 px-4 py-3 backdrop-blur smooth-shadow-ring-sm">
<p className="py-2 text-center text-sm text-zinc-400">
Nothing here yet.
@@ -69,20 +80,41 @@ export function WorkspaceFileCards({ sessionId }: Props) {
files={files}
isLoading={isLoading}
isError={isError}
- isDeleting={isDeleting}
isZipping={isZipping}
- pendingDelete={pendingDelete}
onOpen={handleOpen}
onDownload={handleDownload}
onRequestDelete={setPendingDelete}
- onConfirmDelete={handleConfirmDelete}
- onCancelDelete={() => setPendingDelete(null)}
onDownloadAll={handleDownloadAll}
showHeader={false}
/>
</StackSection>
)}
+ {expert && (
+ <StackSection
+ title={`All ${expert.name}'s documents`}
+ icon={File02Icon}
+ >
+ <WorkspaceFilesContent
+ files={expertDocuments}
+ isLoading={isExpertDocumentsLoading}
+ isError={isExpertDocumentsError}
+ isZipping={false}
+ onOpen={handleOpen}
+ onDownload={handleDownload}
+ onRequestDelete={setPendingDelete}
+ onDownloadAll={() => undefined}
+ emptyMessage={`${expert.name} hasn't created any documents yet.`}
+ showHeader={false}
+ />
+ </StackSection>
+ )}
<SessionActivityCard sessionId={sessionId} />
+ <DeleteFileDialog
+ fileName={pendingDelete?.item.name ?? null}
+ isDeleting={isDeleting}
+ onConfirm={handleConfirmDelete}
+ onCancel={() => setPendingDelete(null)}
+ />
</div>
);
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/__tests__/WorkspaceFileCards.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/__tests__/WorkspaceFileCards.test.tsx
index b5908b762b..ac325ab05d 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/__tests__/WorkspaceFileCards.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/__tests__/WorkspaceFileCards.test.tsx
@@ -148,6 +148,61 @@ describe("WorkspaceFileCards", () => {
expect(screen.getByLabelText("Download all")).toBeDefined();
});
+ it("lists generated documents from all of the expert's chats", async () => {
+ const expertRequests: URLSearchParams[] = [];
+ server.use(
+ http.get("*/api/workspace/files", ({ request }) => {
+ const params = new URL(request.url).searchParams;
+ if (params.get("expert_id") !== "expert-maria") {
+ return HttpResponse.json(listResponse());
+ }
+ expertRequests.push(params);
+ return HttpResponse.json({
+ files: [
+ ...Array.from({ length: 5 }, (_, index) => ({
+ id: `expert-document-${index}`,
+ name: `maria-${index + 1}.md`,
+ path: `/sessions/maria-${index}/document.md`,
+ mime_type: "text/markdown",
+ size_bytes: 128,
+ origin: "generated" as const,
+ created_at: "2026-09-29T10:00:00Z",
+ expert_id: "expert-maria",
+ })),
+ {
+ id: "expert-tool-output",
+ name: "raw.json",
+ path: "/sessions/maria/tool-results/raw.json",
+ mime_type: "application/json",
+ size_bytes: 64,
+ metadata: { purpose: "tool-output" },
+ origin: "generated" as const,
+ created_at: "2026-09-29T09:00:00Z",
+ expert_id: "expert-maria",
+ },
+ ],
+ offset: 0,
+ has_more: false,
+ });
+ }),
+ );
+
+ render(
+ <WorkspaceFileCards
+ sessionId={SESSION}
+ expert={{ id: "expert-maria", name: "Maria" }}
+ />,
+ );
+
+ expect(await screen.findByText("All Maria's documents")).toBeDefined();
+ expect(await screen.findByText("maria-1.md")).toBeDefined();
+ expect(screen.getByText("View more (1)")).toBeDefined();
+ expect(screen.queryByText("raw.json")).toBeNull();
+ expect(expertRequests).toHaveLength(1);
+ expect(expertRequests[0].get("origin")).toBe("generated");
+ expect(expertRequests[0].get("limit")).toBe("200");
+ });
+
it("opens a file as an artifact preview on click", async () => {
render(<WorkspaceFileCards sessionId={SESSION} />);
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/WorkspaceFilesContent.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/WorkspaceFilesContent.tsx
index 4629f92e3c..38a1cd3ec8 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/WorkspaceFilesContent.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/WorkspaceFilesContent.tsx
@@ -5,7 +5,6 @@ import { useState } from "react";
import { Button } from "@/components/atoms/Button/Button";
import { Icon } from "@/components/atoms/Icon/Icon";
import { Skeleton } from "@/components/ui/skeleton";
-import { DeleteFileDialog } from "../../ContextPanel/components/FilesTab/components/DeleteFileDialog";
import type { SessionFile } from "../../ContextPanel/components/FilesTab/useSessionFiles";
import { WorkspaceFileCard } from "./WorkspaceFileCard";
@@ -13,15 +12,12 @@ export interface WorkspaceFilesContentProps {
files: SessionFile[];
isLoading: boolean;
isError: boolean;
- isDeleting: boolean;
isZipping: boolean;
- pendingDelete: SessionFile | null;
onOpen: (file: SessionFile) => void;
onDownload: (file: SessionFile) => void;
onRequestDelete: (file: SessionFile) => void;
- onConfirmDelete: () => void;
- onCancelDelete: () => void;
onDownloadAll: () => void;
+ emptyMessage?: string;
/** The floating stack hoists the title out of the card (see
* ``StackSection``); the popover keeps it inline. */
showHeader?: boolean;
@@ -31,15 +27,12 @@ export function WorkspaceFilesContent({
files,
isLoading,
isError,
- isDeleting,
isZipping,
- pendingDelete,
onOpen,
onDownload,
onRequestDelete,
- onConfirmDelete,
- onCancelDelete,
onDownloadAll,
+ emptyMessage,
showHeader = true,
}: WorkspaceFilesContentProps) {
return (
@@ -70,12 +63,7 @@ export function WorkspaceFilesContent({
onOpen={onOpen}
onDownload={onDownload}
onRequestDelete={onRequestDelete}
- />
- <DeleteFileDialog
- fileName={pendingDelete?.item.name ?? null}
- isDeleting={isDeleting}
- onConfirm={onConfirmDelete}
- onCancel={onCancelDelete}
+ emptyMessage={emptyMessage}
/>
</>
);
@@ -88,6 +76,7 @@ interface BodyProps {
onOpen: (file: SessionFile) => void;
onDownload: (file: SessionFile) => void;
onRequestDelete: (file: SessionFile) => void;
+ emptyMessage?: string;
}
const COLLAPSED_FILE_COUNT = 4;
@@ -99,6 +88,7 @@ function Body({
onOpen,
onDownload,
onRequestDelete,
+ emptyMessage,
}: BodyProps) {
const [showAll, setShowAll] = useState(false);
@@ -120,7 +110,8 @@ function Body({
if (files.length === 0) {
return (
<p className="py-2 text-[13px] text-zinc-400">
- No files yet. Upload one or ask an expert to create something.
+ {emptyMessage ??
+ "No files yet. Upload one or ask an expert to create something."}
</p>
);
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/useExpertDocuments.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/useExpertDocuments.ts
new file mode 100644
index 0000000000..31c1cc1270
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/useExpertDocuments.ts
@@ -0,0 +1,46 @@
+"use client";
+
+import {
+ getListWorkspaceFilesQueryKey,
+ useListWorkspaceFiles,
+} from "@/app/api/__generated__/endpoints/workspace/workspace";
+import type { ListFilesResponse } from "@/app/api/__generated__/models/listFilesResponse";
+import { useMemo } from "react";
+import { isInternalToolOutput } from "../ContextPanel/components/FilesTab/helpers";
+import type { SessionFile } from "../ContextPanel/components/FilesTab/useSessionFiles";
+
+export function useExpertDocuments(
+ expertId: string | null,
+ sessionDocumentCount: number,
+) {
+ const params = {
+ expert_id: expertId ?? undefined,
+ origin: "generated" as const,
+ limit: 200,
+ };
+ const query = useListWorkspaceFiles(params, {
+ query: {
+ enabled: Boolean(expertId),
+ queryKey: [
+ ...getListWorkspaceFilesQueryKey(params),
+ sessionDocumentCount,
+ ],
+ placeholderData: (previous) => previous,
+ select: (res) => res.data as ListFilesResponse,
+ },
+ });
+
+ const documents = useMemo(
+ () =>
+ (query.data?.files ?? [])
+ .filter((item) => !isInternalToolOutput(item))
+ .map<SessionFile>((item) => ({ item, messageID: null })),
+ [query.data],
+ );
+
+ return {
+ documents,
+ isLoading: query.isLoading && Boolean(expertId),
+ isError: query.isError,
+ };
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/useWorkspaceFileCards.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/useWorkspaceFileCards.ts
index e4c12e96ed..58ab17eab6 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/useWorkspaceFileCards.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/useWorkspaceFileCards.ts
@@ -24,7 +24,7 @@ export function useWorkspaceFileCards(sessionId: string | null) {
// Session-scoped on purpose: the card is this chat's drawer — only files
// uploaded to or created in this session. The artifacts side panel carries
// the workspace-wide library.
- const { uploaded, generated, isLoading, isError } =
+ const { uploaded, generated, documentCount, isLoading, isError } =
useSessionFiles(sessionId);
const [pendingDelete, setPendingDelete] = useState<SessionFile | null>(null);
const [isZipping, setIsZipping] = useState(false);
@@ -83,6 +83,7 @@ export function useWorkspaceFileCards(sessionId: string | null) {
return {
files,
+ documentCount,
isLoading,
isError,
isDeleting,
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts
index f07f23c0a9..31832120b1 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts
@@ -103,8 +103,8 @@ export type CopilotLlmAuthSelection =
* artifacts library, or the chat's expert's integrations. */
export type ContextPanelTab = "files" | "artifacts" | "integrations";
-/** The expert whose integrations the panel lists. */
-export interface IntegrationsPanelExpert {
+/** The expert whose files and integrations the context panel lists. */
+export interface ContextPanelExpert {
id: string;
name: string;
}
@@ -232,9 +232,10 @@ interface CopilotUIState {
toggleContextPanel: () => void;
/** Opens the panel on `tab`, or closes it if that tab is already showing. */
toggleContextPanelTab: (tab: ContextPanelTab) => void;
- integrationsPanelExpert: IntegrationsPanelExpert | null;
+ contextPanelExpert: ContextPanelExpert | null;
+ setContextPanelExpert: (expert: ContextPanelExpert | null) => void;
/** The integrations tab for `expert`, toggled like any other tab. */
- toggleIntegrationsPanel: (expert: IntegrationsPanelExpert) => void;
+ toggleIntegrationsPanel: (expert: ContextPanelExpert) => void;
/** Forget the remembered preview — called on session entry so a new chat
* can never restore the previous chat's artifact. */
clearLastArtifact: () => void;
@@ -568,8 +569,8 @@ export const useCopilotUIStore = create<CopilotUIState>((set, get) => ({
}),
clearLastArtifact: () =>
set((state) => ({
- // The integrations tab belongs to the previous chat's expert.
- integrationsPanelExpert: null,
+ // Expert-wide panel sections belong to the previous chat's expert.
+ contextPanelExpert: null,
artifactPanel: {
...state.artifactPanel,
activeTab:
@@ -617,9 +618,10 @@ export const useCopilotUIStore = create<CopilotUIState>((set, get) => ({
},
};
}),
- integrationsPanelExpert: null,
+ contextPanelExpert: null,
+ setContextPanelExpert: (expert) => set({ contextPanelExpert: expert }),
toggleIntegrationsPanel: (expert) => {
- set({ integrationsPanelExpert: expert });
+ set({ contextPanelExpert: expert });
get().toggleContextPanelTab("integrations");
},
openContextPanelForFiles: () => {
@@ -739,7 +741,7 @@ export const useCopilotUIStore = create<CopilotUIState>((set, get) => ({
isSearchOpen: false,
isNotificationsEnabled: false,
isSoundEnabled: true,
- integrationsPanelExpert: null,
+ contextPanelExpert: null,
artifactPanel: {
isOpen: false,
activeArtifact: null,