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 expert documents as Files-page rows (#15033)

Ubbe14fd37413f3e
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 eac34fb770..4b99a7e8b2 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
@@ -58,7 +58,7 @@ export function WorkspaceFileCards({ sessionId, expert = null }: Props) {
)}
{showFilesCard && (
<StackSection
- title="Files"
+ title="Files in this chat"
icon={File02Icon}
count={files.length || undefined}
action={
@@ -93,6 +93,7 @@ export function WorkspaceFileCards({ sessionId, expert = null }: Props) {
<StackSection
title={`All ${expert.name}'s documents`}
icon={File02Icon}
+ plain
>
<WorkspaceFilesContent
files={expertDocuments}
@@ -105,6 +106,7 @@ export function WorkspaceFileCards({ sessionId, expert = null }: Props) {
onDownloadAll={() => undefined}
emptyMessage={`${expert.name} hasn't created any documents yet.`}
showHeader={false}
+ rowStyle="detailed"
/>
</StackSection>
)}
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 ac325ab05d..5a93ce9c98 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
@@ -144,7 +144,7 @@ describe("WorkspaceFileCards", () => {
expect(await screen.findByText("uploaded.png")).toBeDefined();
expect(screen.getByText("result.csv")).toBeDefined();
- expect(screen.getByText(/^Files \(2\)/)).toBeDefined();
+ expect(screen.getByText(/^Files in this chat \(2\)/)).toBeDefined();
expect(screen.getByLabelText("Download all")).toBeDefined();
});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/FileRowActions.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/FileRowActions.tsx
new file mode 100644
index 0000000000..d06452c8b7
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/FileRowActions.tsx
@@ -0,0 +1,46 @@
+"use client";
+
+import { Delete02Icon, Download01Icon } from "@hugeicons/core-free-icons";
+import { Button } from "@/components/atoms/Button/Button";
+import { Icon } from "@/components/atoms/Icon/Icon";
+import { isUploadedFile } from "../../ContextPanel/components/FilesTab/helpers";
+import type { SessionFile } from "../../ContextPanel/components/FilesTab/useSessionFiles";
+
+interface Props {
+ file: SessionFile;
+ onDownload: (file: SessionFile) => void;
+ onRequestDelete: (file: SessionFile) => void;
+}
+
+/** Actions stay mounted for keyboard users and only fade in on hover, so the
+ * row reads as plain text until you reach for it. Touch devices never hover,
+ * so there they stay visible. */
+export function FileRowActions({ file, onDownload, onRequestDelete }: Props) {
+ const { item } = file;
+ const canDelete = !isUploadedFile(item);
+
+ return (
+ <div className="flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100 [@media(hover:none)]:opacity-100">
+ <Button
+ variant="ghost"
+ size="icon"
+ onClick={() => onDownload(file)}
+ aria-label={`Download ${item.name}`}
+ className="size-7 rounded-lg !p-0 text-zinc-500"
+ >
+ <Icon icon={Download01Icon} size={14} />
+ </Button>
+ {canDelete && (
+ <Button
+ variant="ghost"
+ size="icon"
+ onClick={() => onRequestDelete(file)}
+ aria-label={`Delete ${item.name}`}
+ className="size-7 rounded-lg !p-0 text-zinc-500"
+ >
+ <Icon icon={Delete02Icon} size={14} />
+ </Button>
+ )}
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/StackSection.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/StackSection.tsx
index 824c96d65c..ffd0395824 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/StackSection.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/StackSection.tsx
@@ -10,6 +10,8 @@ interface Props {
icon: IconSvgElement;
count?: number;
action?: ReactNode;
+ /** Drop the card so the content sits on the panel, like the Files page. */
+ plain?: boolean;
children: ReactNode;
}
@@ -18,7 +20,14 @@ interface Props {
* card, mirroring the home briefing tiles (``HomeTile``). Keeping the title
* out of the card is what separates one section from the next.
*/
-export function StackSection({ title, icon, count, action, children }: Props) {
+export function StackSection({
+ title,
+ icon,
+ count,
+ action,
+ plain = false,
+ children,
+}: Props) {
return (
<section className="flex min-w-0 flex-col">
{/* px-3 matches the card's own padding, so the title starts exactly
@@ -31,9 +40,13 @@ export function StackSection({ title, icon, count, action, children }: Props) {
</Text>
{action && <div className="ml-auto flex items-center">{action}</div>}
</div>
- <div className="rounded-lg bg-white/90 px-3 py-1 backdrop-blur smooth-shadow-ring-sm">
- {children}
- </div>
+ {plain ? (
+ <div className="px-3">{children}</div>
+ ) : (
+ <div className="rounded-lg bg-white/90 px-3 py-1 backdrop-blur smooth-shadow-ring-sm">
+ {children}
+ </div>
+ )}
</section>
);
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/WorkspaceFileCard.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/WorkspaceFileCard.tsx
index c72ebaf3aa..edcfaec72b 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/WorkspaceFileCard.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/WorkspaceFileCard.tsx
@@ -1,11 +1,9 @@
"use client";
-import { Delete02Icon, Download01Icon } from "@hugeicons/core-free-icons";
-import { Button } from "@/components/atoms/Button/Button";
import { Icon } from "@/components/atoms/Icon/Icon";
import { classifyArtifact } from "../../ArtifactPanel/helpers";
-import { isUploadedFile } from "../../ContextPanel/components/FilesTab/helpers";
import type { SessionFile } from "../../ContextPanel/components/FilesTab/useSessionFiles";
+import { FileRowActions } from "./FileRowActions";
interface Props {
file: SessionFile;
@@ -22,7 +20,6 @@ export function WorkspaceFileCard({
}: Props) {
const { item } = file;
const fileIcon = classifyArtifact(item.mime_type ?? null, item.name).icon;
- const canDelete = !isUploadedFile(item);
return (
<div className="group relative -mx-2.5 flex items-center gap-3 rounded-xl px-2.5 py-1.5 transition-colors hover:bg-zinc-50">
@@ -39,31 +36,11 @@ export function WorkspaceFileCard({
{item.name}
</span>
</button>
- {/* Actions stay mounted for keyboard users and only fade in on hover, so
- the row reads as plain text until you reach for it. Touch devices
- never hover, so there they stay visible. */}
- <div className="flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100 [@media(hover:none)]:opacity-100">
- <Button
- variant="ghost"
- size="icon"
- onClick={() => onDownload(file)}
- aria-label={`Download ${item.name}`}
- className="size-7 rounded-lg !p-0 text-zinc-500"
- >
- <Icon icon={Download01Icon} size={14} />
- </Button>
- {canDelete && (
- <Button
- variant="ghost"
- size="icon"
- onClick={() => onRequestDelete(file)}
- aria-label={`Delete ${item.name}`}
- className="size-7 rounded-lg !p-0 text-zinc-500"
- >
- <Icon icon={Delete02Icon} size={14} />
- </Button>
- )}
- </div>
+ <FileRowActions
+ file={file}
+ onDownload={onDownload}
+ onRequestDelete={onRequestDelete}
+ />
</div>
);
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/WorkspaceFileRow.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/WorkspaceFileRow.tsx
new file mode 100644
index 0000000000..579663eeb4
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/WorkspaceFileCards/components/WorkspaceFileRow.tsx
@@ -0,0 +1,65 @@
+"use client";
+
+import { FileThumbnail } from "@/app/(platform)/artifacts/components/ArtifactsList/ArtifactsTable/FileThumbnail";
+import {
+ formatDayLabel,
+ formatFileSize,
+ formatFullDate,
+} from "@/app/(platform)/artifacts/components/ArtifactsList/helpers";
+import { Text } from "@/components/atoms/Text/Text";
+import type { SessionFile } from "../../ContextPanel/components/FilesTab/useSessionFiles";
+import { FileRowActions } from "./FileRowActions";
+
+interface Props {
+ file: SessionFile;
+ onOpen: (file: SessionFile) => void;
+ onDownload: (file: SessionFile) => void;
+ onRequestDelete: (file: SessionFile) => void;
+}
+
+/** A Files-page style row (thumbnail, name, date and size) sized for the
+ * side panel. */
+export function WorkspaceFileRow({
+ file,
+ onOpen,
+ onDownload,
+ onRequestDelete,
+}: Props) {
+ const { item } = file;
+
+ return (
+ <div className="group flex items-center gap-3 px-3 py-2 transition-colors hover:bg-zinc-100/70">
+ <button
+ type="button"
+ onClick={() => onOpen(file)}
+ title={item.name}
+ className="flex min-w-0 flex-1 items-center gap-3 text-left"
+ >
+ <FileThumbnail file={item} />
+ <span className="flex min-w-0 flex-col">
+ <Text
+ variant="body-medium"
+ as="span"
+ className="truncate text-zinc-900"
+ >
+ {item.name}
+ </Text>
+ <Text
+ variant="small"
+ as="span"
+ className="text-zinc-500"
+ title={formatFullDate(item.created_at)}
+ >
+ {formatDayLabel(item.created_at)} ·{" "}
+ {formatFileSize(item.size_bytes)}
+ </Text>
+ </span>
+ </button>
+ <FileRowActions
+ file={file}
+ onDownload={onDownload}
+ onRequestDelete={onRequestDelete}
+ />
+ </div>
+ );
+}
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 38a1cd3ec8..5ad4feca4c 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
@@ -7,6 +7,7 @@ import { Icon } from "@/components/atoms/Icon/Icon";
import { Skeleton } from "@/components/ui/skeleton";
import type { SessionFile } from "../../ContextPanel/components/FilesTab/useSessionFiles";
import { WorkspaceFileCard } from "./WorkspaceFileCard";
+import { WorkspaceFileRow } from "./WorkspaceFileRow";
export interface WorkspaceFilesContentProps {
files: SessionFile[];
@@ -21,6 +22,8 @@ export interface WorkspaceFilesContentProps {
/** The floating stack hoists the title out of the card (see
* ``StackSection``); the popover keeps it inline. */
showHeader?: boolean;
+ /** ``detailed`` shows Files-page rows with a thumbnail, date and size. */
+ rowStyle?: "compact" | "detailed";
}
export function WorkspaceFilesContent({
@@ -34,6 +37,7 @@ export function WorkspaceFilesContent({
onDownloadAll,
emptyMessage,
showHeader = true,
+ rowStyle = "compact",
}: WorkspaceFilesContentProps) {
return (
<>
@@ -64,6 +68,7 @@ export function WorkspaceFilesContent({
onDownload={onDownload}
onRequestDelete={onRequestDelete}
emptyMessage={emptyMessage}
+ rowStyle={rowStyle}
/>
</>
);
@@ -77,6 +82,7 @@ interface BodyProps {
onDownload: (file: SessionFile) => void;
onRequestDelete: (file: SessionFile) => void;
emptyMessage?: string;
+ rowStyle: "compact" | "detailed";
}
const COLLAPSED_FILE_COUNT = 4;
@@ -89,6 +95,7 @@ function Body({
onDownload,
onRequestDelete,
emptyMessage,
+ rowStyle,
}: BodyProps) {
const [showAll, setShowAll] = useState(false);
@@ -121,19 +128,33 @@ function Body({
return (
<>
- {/* Rows bleed their hover highlight past the text with negative margins,
- so the scroller widens to match — otherwise it clips them. */}
- <div className="-mx-2.5 grid max-h-72 gap-0.5 overflow-y-auto px-2.5 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-zinc-200">
- {visibleFiles.map((file) => (
- <WorkspaceFileCard
- key={file.item.id}
- file={file}
- onOpen={onOpen}
- onDownload={onDownload}
- onRequestDelete={onRequestDelete}
- />
- ))}
- </div>
+ {rowStyle === "detailed" ? (
+ <div className="-mx-3 grid max-h-80 divide-y divide-zinc-200/70 overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-zinc-200">
+ {visibleFiles.map((file) => (
+ <WorkspaceFileRow
+ key={file.item.id}
+ file={file}
+ onOpen={onOpen}
+ onDownload={onDownload}
+ onRequestDelete={onRequestDelete}
+ />
+ ))}
+ </div>
+ ) : (
+ // Rows bleed their hover highlight past the text with negative
+ // margins, so the scroller widens to match — otherwise it clips them.
+ <div className="-mx-2.5 grid max-h-72 gap-0.5 overflow-y-auto px-2.5 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-zinc-200">
+ {visibleFiles.map((file) => (
+ <WorkspaceFileCard
+ key={file.item.id}
+ file={file}
+ onOpen={onOpen}
+ onDownload={onDownload}
+ onRequestDelete={onRequestDelete}
+ />
+ ))}
+ </div>
+ )}
{files.length > COLLAPSED_FILE_COUNT && (
<button
type="button"