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): match artifact panel to Claude reference (#14934)

Ubbe9a4a0e5bf132
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/CopilotPage.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/CopilotPage.tsx
index 1c73137543..4116b54e20 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/CopilotPage.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/CopilotPage.tsx
@@ -168,9 +168,7 @@ function MainArea({
</FileDropZone>
</div>
{!isMobile && sessionId && <ContextPanel sessionId={sessionId} />}
- {!isMobile && sessionId && (
- <ArtifactPanel hasExternalClose sessionId={sessionId} />
- )}
+ {!isMobile && sessionId && <ArtifactPanel sessionId={sessionId} />}
</div>
);
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/ArtifactPanel.stories.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/ArtifactPanel.stories.tsx
index a723f450a8..ddf9f926fe 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/ArtifactPanel.stories.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/ArtifactPanel.stories.tsx
@@ -1,7 +1,8 @@
+import { TooltipProvider } from "@/components/atoms/Tooltip/BaseTooltip";
import type { Meta, StoryObj } from "@storybook/nextjs";
import { http, HttpResponse } from "msw";
import { ArtifactPanel } from "./ArtifactPanel";
-import { useCopilotUIStore } from "../../store";
+import { DEFAULT_ARTIFACT_PANEL_WIDTH, useCopilotUIStore } from "../../store";
import type { ArtifactRef } from "../../store";
const PROXY_BASE = "/api/proxy/api/workspace/files";
@@ -19,6 +20,7 @@ function makeArtifact(overrides?: Partial<ArtifactRef>): ArtifactRef {
function openPanelWith(artifact: ArtifactRef) {
useCopilotUIStore.setState({
+ artifactPanelWidth: DEFAULT_ARTIFACT_PANEL_WIDTH,
artifactPanel: {
isOpen: true,
activeArtifact: artifact,
@@ -41,18 +43,20 @@ const meta: Meta<typeof ArtifactPanel> = {
docs: {
description: {
component:
- "Side panel for previewing workspace artifacts. Supports resize, navigation history, and a collapsed context rail. Bug: panel auto-opens on chat switch instead of staying collapsed.",
+ "Rounded artifact preview with file actions, fullscreen, resize, and navigation history.",
},
},
},
decorators: [
(Story) => (
- <div className="flex h-[600px] w-full">
- <div className="flex-1 bg-zinc-50 p-8">
- <p className="text-sm text-zinc-500">Chat area</p>
+ <TooltipProvider>
+ <div className="flex h-[800px] w-full bg-sidebar">
+ <div className="flex-1 bg-zinc-50 p-8">
+ <p className="text-sm text-zinc-500">Chat area</p>
+ </div>
+ <Story />
</div>
- <Story />
- </div>
+ </TooltipProvider>
),
],
};
@@ -112,7 +116,7 @@ export const OpenWithHTMLArtifact: Story = {
};
export const OpenWithImageArtifact: Story = {
- name: "Open — Image (Bug: No Loading State)",
+ name: "Open — Image",
decorators: [
(Story) => {
openPanelWith(
@@ -131,7 +135,7 @@ export const OpenWithImageArtifact: Story = {
handlers: [
http.get(`${PROXY_BASE}/img-panel/download`, () => {
return HttpResponse.text(
- '<svg xmlns="http://www.w3.org/2000/svg" width="500" height="300"><rect width="500" height="300" fill="#dbeafe"/><text x="250" y="150" text-anchor="middle" fill="#1e40af" font-size="20">Image Preview (no skeleton)</text></svg>',
+ '<svg xmlns="http://www.w3.org/2000/svg" width="500" height="300"><rect width="500" height="300" fill="#dbeafe"/><text x="250" y="150" text-anchor="middle" fill="#1e40af" font-size="20">Image preview</text></svg>',
{ headers: { "Content-Type": "image/svg+xml" } },
);
}),
@@ -140,7 +144,7 @@ export const OpenWithImageArtifact: Story = {
docs: {
description: {
story:
- "**BUG:** Image artifacts render with a bare `<img>` tag — no loading skeleton or error handling. Compare with text/HTML artifacts which show a proper skeleton while loading.",
+ "Image artifacts show a skeleton while loading and a retry action if loading fails.",
},
},
},
@@ -206,3 +210,28 @@ export const Closed: Story = {
},
},
};
+
+export const NarrowWithLongTitle: Story = {
+ ...OpenWithHTMLArtifact,
+ name: "Narrow — Long title and view controls",
+ args: { sessionId: "storybook-session" },
+ decorators: [
+ (Story) => {
+ openPanelWith(
+ makeArtifact({
+ id: "html-panel",
+ title: "Daily journal September through December 2026.html",
+ sourceUrl: `${PROXY_BASE}/html-panel/download`,
+ }),
+ );
+ useCopilotUIStore.setState({ artifactPanelWidth: 400 });
+ return <Story />;
+ },
+ ],
+};
+
+export const Mobile: Story = {
+ ...OpenWithHTMLArtifact,
+ name: "Mobile — Preview drawer",
+ args: { mobile: true },
+};
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/ArtifactPanel.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/ArtifactPanel.tsx
index 9b1067fc77..c4cca2ec30 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/ArtifactPanel.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/ArtifactPanel.tsx
@@ -5,10 +5,11 @@ import { useEffect, useRef, useState } from "react";
import { Drawer } from "vaul";
import { MIN_ARTIFACT_PANEL_WIDTH, PANEL_RESERVED_WIDTH } from "../../store";
import { PanelResizeHandle } from "../PanelResizeHandle";
-import { ArtifactContent } from "./components/ArtifactContent";
+import { ArtifactPreview } from "./components/ArtifactPreview";
import { ArtifactPanelHeader } from "./components/ArtifactPanelHeader";
import { ComputerPanelContent } from "./components/ComputerPanelContent";
import { useArtifactPanel } from "./useArtifactPanel";
+import { useArtifactFullscreen } from "./useArtifactFullscreen";
// Matched to the context panel so the two side rails move as one system.
const PANEL_EASE: [number, number, number, number] = [0.32, 0.72, 0, 1];
@@ -18,19 +19,16 @@ interface Props {
mobile?: boolean;
/** Enables the Computer face: the chat whose sandboxes the panel can show. */
sessionId?: string | null;
- /** The desktop copilot chat renders its own sidebar-right close control;
- * standalone hosts (share viewer, tour, mobile drawer) do not, so their
- * header keeps its Close button. */
- hasExternalClose?: boolean;
}
-export function ArtifactPanel({ mobile, hasExternalClose, sessionId }: Props) {
+export function ArtifactPanel({ mobile, sessionId }: Props) {
const {
activeArtifact,
history,
isSourceView,
classification,
setIsSourceView,
+ closeArtifactPanel,
clearArtifactPreview,
goBackArtifact,
showFilesTab,
@@ -43,6 +41,13 @@ export function ArtifactPanel({ mobile, hasExternalClose, sessionId }: Props) {
isComputerOpen,
setArtifactPanelMode,
} = useArtifactPanel();
+ const {
+ fullscreenRef,
+ isFullscreen,
+ canFullscreen,
+ toggleFullscreen,
+ exitFullscreen,
+ } = useArtifactFullscreen();
const showComputer = !!sessionId && mode === "computer" && isComputerOpen;
// Hold the last live artifact so both the mobile drawer and the desktop
@@ -110,7 +115,7 @@ export function ArtifactPanel({ mobile, hasExternalClose, sessionId }: Props) {
aria-hidden="true"
/>
<Drawer.Content
- className="fixed right-0 top-0 z-[70] flex h-full w-full flex-col bg-white shadow-xl outline-none"
+ className="fixed right-0 top-0 z-[70] flex h-full w-full flex-col overflow-hidden bg-card shadow-xl outline-none"
style={{ userSelect: "text" }}
aria-describedby={undefined}
>
@@ -131,7 +136,7 @@ export function ArtifactPanel({ mobile, hasExternalClose, sessionId }: Props) {
onOpenFiles={showFilesTab}
onSourceToggle={setIsSourceView}
/>
- <ArtifactContent
+ <ArtifactPreview
artifact={shown.artifact}
isSourceView={isSourceView}
classification={shown.classification}
@@ -161,6 +166,32 @@ export function ArtifactPanel({ mobile, hasExternalClose, sessionId }: Props) {
? { duration: 0 }
: { duration: PANEL_DURATION, ease: PANEL_EASE };
+ function closeDesktopPanel() {
+ if (sessionId) {
+ closeArtifactPanel();
+ return;
+ }
+ clearArtifactPreview();
+ }
+
+ function runAfterFullscreenExit(action: () => void) {
+ if (document.fullscreenElement !== fullscreenRef.current) {
+ action();
+ return;
+ }
+ void exitFullscreen().then((didExit) => {
+ if (didExit) action();
+ });
+ }
+
+ function handleDesktopClose() {
+ runAfterFullscreenExit(closeDesktopPanel);
+ }
+
+ function handleOpenFiles() {
+ runAfterFullscreenExit(showFilesTab);
+ }
+
return (
<AnimatePresence initial={false}>
{showDesktopPanel && (shown || showComputer) && (
@@ -172,7 +203,7 @@ export function ArtifactPanel({ mobile, hasExternalClose, sessionId }: Props) {
exit={{ width: 0, opacity: 0 }}
transition={transition}
style={{ userSelect: "text" }}
- className="relative h-full shrink-0 border-l border-l-[#80808017] bg-sidebar"
+ className="relative h-full shrink-0 bg-sidebar"
>
{/* Sibling of the clip, not a child of it: the handle straddles the
border, so clipping it here would halve the drag target. */}
@@ -182,12 +213,17 @@ export function ArtifactPanel({ mobile, hasExternalClose, sessionId }: Props) {
onResizingChange={setIsResizing}
minWidth={MIN_ARTIFACT_PANEL_WIDTH}
/>
- <div className="h-full overflow-hidden">
+ <div className="h-full overflow-hidden p-2 pl-1">
{/* Fixed inner width so the header and content keep their final
layout while the shell widens — nothing reflows mid-tween. */}
<div
- style={{ width: renderedWidth }}
- className="flex h-full min-h-0 flex-col overflow-hidden"
+ ref={fullscreenRef}
+ style={{
+ width: isFullscreen
+ ? "100%"
+ : `calc(${renderedWidth}px - 0.75rem)`,
+ }}
+ className="flex h-full min-h-0 flex-col overflow-hidden rounded-xl border border-border bg-card shadow-sm [&:fullscreen]:rounded-none [&:fullscreen]:border-0"
>
<ArtifactPanelHeader
artifact={
@@ -203,22 +239,25 @@ export function ArtifactPanel({ mobile, hasExternalClose, sessionId }: Props) {
mode={showComputer ? "computer" : "artifact"}
showModeSwitch={!!sessionId}
onModeChange={setArtifactPanelMode}
- hasExternalClose={hasExternalClose}
+ isFullscreen={isFullscreen}
+ onToggleFullscreen={
+ canFullscreen ? toggleFullscreen : undefined
+ }
canGoBack={history.length > 0}
isSourceView={isSourceView}
hasSourceToggle={shown?.classification.hasSourceToggle ?? false}
canCopy={canCopy}
onBack={goBackArtifact}
- onClose={clearArtifactPreview}
+ onClose={handleDesktopClose}
onCopy={handleCopy}
onDownload={handleDownload}
- onOpenFiles={showFilesTab}
+ onOpenFiles={handleOpenFiles}
onSourceToggle={setIsSourceView}
/>
{showComputer && sessionId ? (
<ComputerPanelContent sessionId={sessionId} />
) : shown ? (
- <ArtifactContent
+ <ArtifactPreview
artifact={shown.artifact}
isSourceView={isSourceView}
classification={shown.classification}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/__tests__/ArtifactPanel.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/__tests__/ArtifactPanel.test.tsx
index 2e57331d1d..0a5941ed95 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/__tests__/ArtifactPanel.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/__tests__/ArtifactPanel.test.tsx
@@ -1,10 +1,12 @@
import {
act,
cleanup,
+ fireEvent,
render,
screen,
waitFor,
} from "@/tests/integrations/test-utils";
+import { toast } from "@/components/molecules/Toast/use-toast";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import type { ArtifactRef } from "../../../store";
import {
@@ -14,6 +16,11 @@ import {
} from "../../../store";
import { ArtifactPanel } from "../ArtifactPanel";
+vi.mock("@/components/molecules/Toast/use-toast", () => ({
+ toast: vi.fn(),
+ useToast: () => ({ toast: vi.fn(), dismiss: vi.fn() }),
+}));
+
const ARTIFACT_ID = "11111111-0000-0000-0000-000000000000";
const ARTIFACT_SOURCE_URL = `/api/proxy/api/workspace/files/${ARTIFACT_ID}/download`;
@@ -58,6 +65,16 @@ describe("ArtifactPanel (desktop) width clamping", () => {
let offsetWidthSpy: ReturnType<typeof vi.spyOn>;
beforeEach(() => {
+ vi.mocked(toast).mockReset();
+ Object.defineProperties(document, {
+ fullscreenEnabled: { configurable: true, get: () => true },
+ fullscreenElement: { configurable: true, get: () => null },
+ exitFullscreen: { configurable: true, value: vi.fn() },
+ });
+ Object.defineProperty(HTMLElement.prototype, "requestFullscreen", {
+ configurable: true,
+ value: vi.fn(),
+ });
ResizeObserverMock.instances = [];
vi.stubGlobal("ResizeObserver", ResizeObserverMock);
// The text artifact fetches its content from the download proxy URL,
@@ -91,8 +108,12 @@ describe("ArtifactPanel (desktop) width clamping", () => {
afterEach(() => {
cleanup();
offsetWidthSpy?.mockRestore();
- vi.clearAllMocks();
+ vi.restoreAllMocks();
vi.unstubAllGlobals();
+ Reflect.deleteProperty(document, "fullscreenEnabled");
+ Reflect.deleteProperty(document, "fullscreenElement");
+ Reflect.deleteProperty(document, "exitFullscreen");
+ Reflect.deleteProperty(HTMLElement.prototype, "requestFullscreen");
});
it("shrinks below the stored width when the row leaves less space", async () => {
@@ -143,14 +164,169 @@ describe("ArtifactPanel (desktop) width clamping", () => {
expect(screen.getByRole("button", { name: "Close" })).toBeDefined();
});
- it("drops the header Close button when the host closes it externally", async () => {
- offsetWidthSpy = vi
- .spyOn(HTMLElement.prototype, "offsetWidth", "get")
- .mockReturnValue(2000);
+ it("closes the preview from its header", async () => {
+ render(<ArtifactPanel />);
+ fireEvent.click(await screen.findByRole("button", { name: "Close" }));
+ expect(
+ useCopilotUIStore.getState().artifactPanel.activeArtifact,
+ ).toBeNull();
+ await waitFor(() => {
+ expect(document.querySelector("[data-artifact-panel]")).toBeNull();
+ });
+ });
- render(<ArtifactPanel hasExternalClose />);
+ it("closes the docked chat panel without opening the files card", async () => {
+ render(<ArtifactPanel sessionId="session-1" />);
+ fireEvent.click(await screen.findByRole("button", { name: "Close" }));
+
+ expect(useCopilotUIStore.getState().artifactPanel).toMatchObject({
+ isOpen: false,
+ activeArtifact: null,
+ });
+ });
+
+ it("enters and exits fullscreen without changing the saved panel width", async () => {
+ vi.spyOn(document, "fullscreenEnabled", "get").mockReturnValue(true);
+ const fullscreenElement = vi
+ .spyOn(document, "fullscreenElement", "get")
+ .mockReturnValue(null);
+ const requestFullscreen = vi
+ .spyOn(HTMLElement.prototype, "requestFullscreen")
+ .mockImplementation(async function (this: HTMLElement) {
+ fullscreenElement.mockReturnValue(this);
+ document.dispatchEvent(new Event("fullscreenchange"));
+ });
+ const exitFullscreen = vi
+ .spyOn(document, "exitFullscreen")
+ .mockImplementation(async () => {
+ fullscreenElement.mockReturnValue(null);
+ document.dispatchEvent(new Event("fullscreenchange"));
+ });
+
+ render(<ArtifactPanel />);
+ fireEvent.click(
+ await screen.findByRole("button", { name: "Enter fullscreen" }),
+ );
+ expect(requestFullscreen).toHaveBeenCalledOnce();
+ const fullscreenPanel = requestFullscreen.mock.instances[0];
+ if (!(fullscreenPanel instanceof HTMLElement)) {
+ throw new Error("fullscreen panel not rendered");
+ }
+ expect(fullscreenPanel.style.width).toBe("100%");
+ fireEvent.click(
+ await screen.findByRole("button", { name: "Exit fullscreen" }),
+ );
+ expect(exitFullscreen).toHaveBeenCalledOnce();
+ expect(
+ await screen.findByRole("button", { name: "Enter fullscreen" }),
+ ).toBeDefined();
+ expect(fullscreenPanel.style.width).toContain(
+ `${DEFAULT_ARTIFACT_PANEL_WIDTH}px`,
+ );
+ expect(useCopilotUIStore.getState().artifactPanelWidth).toBe(
+ DEFAULT_ARTIFACT_PANEL_WIDTH,
+ );
+ });
+
+ it("exits fullscreen before opening the files card", async () => {
+ const fullscreenElement = vi
+ .spyOn(document, "fullscreenElement", "get")
+ .mockReturnValue(null);
+ vi.spyOn(HTMLElement.prototype, "requestFullscreen").mockImplementation(
+ async function (this: HTMLElement) {
+ fullscreenElement.mockReturnValue(this);
+ document.dispatchEvent(new Event("fullscreenchange"));
+ },
+ );
+ let finishExit: (() => void) | undefined;
+ const exitFullscreen = vi
+ .spyOn(document, "exitFullscreen")
+ .mockImplementation(
+ () =>
+ new Promise<void>((resolve) => {
+ finishExit = () => {
+ fullscreenElement.mockReturnValue(null);
+ document.dispatchEvent(new Event("fullscreenchange"));
+ resolve();
+ };
+ }),
+ );
+
+ render(<ArtifactPanel sessionId="session-1" />);
+ fireEvent.click(
+ await screen.findByRole("button", { name: "Enter fullscreen" }),
+ );
+ fireEvent.click(screen.getByRole("button", { name: "All files" }));
+ expect(exitFullscreen).toHaveBeenCalledOnce();
+ expect(
+ useCopilotUIStore.getState().artifactPanel.activeArtifact,
+ ).not.toBeNull();
+
+ await act(async () => finishExit?.());
+
+ expect(useCopilotUIStore.getState().artifactPanel).toMatchObject({
+ isOpen: true,
+ activeTab: "files",
+ activeArtifact: null,
+ });
+ });
+
+ it("shows an error toast when entering fullscreen fails", async () => {
+ vi.spyOn(HTMLElement.prototype, "requestFullscreen").mockRejectedValue(
+ new Error("fullscreen rejected"),
+ );
+
+ render(<ArtifactPanel />);
+ fireEvent.click(
+ await screen.findByRole("button", { name: "Enter fullscreen" }),
+ );
+
+ await waitFor(() => {
+ expect(toast).toHaveBeenCalledWith({
+ title: "Couldn't change fullscreen mode",
+ variant: "destructive",
+ });
+ });
+ });
+
+ it("keeps the artifact open when exiting fullscreen fails", async () => {
+ const fullscreenElement = vi
+ .spyOn(document, "fullscreenElement", "get")
+ .mockReturnValue(null);
+ vi.spyOn(HTMLElement.prototype, "requestFullscreen").mockImplementation(
+ async function (this: HTMLElement) {
+ fullscreenElement.mockReturnValue(this);
+ document.dispatchEvent(new Event("fullscreenchange"));
+ },
+ );
+ vi.spyOn(document, "exitFullscreen").mockRejectedValue(
+ new Error("fullscreen exit rejected"),
+ );
+
+ render(<ArtifactPanel sessionId="session-1" />);
+ fireEvent.click(
+ await screen.findByRole("button", { name: "Enter fullscreen" }),
+ );
+ fireEvent.click(screen.getByRole("button", { name: "All files" }));
+
+ await waitFor(() => {
+ expect(toast).toHaveBeenCalledWith({
+ title: "Couldn't change fullscreen mode",
+ variant: "destructive",
+ });
+ });
+ expect(
+ useCopilotUIStore.getState().artifactPanel.activeArtifact,
+ ).not.toBeNull();
+ });
+
+ it("hides fullscreen when the browser does not support it", async () => {
+ vi.spyOn(document, "fullscreenEnabled", "get").mockReturnValue(false);
+ render(<ArtifactPanel />);
expect(await screen.findByText("notes.txt")).toBeDefined();
- expect(screen.queryByRole("button", { name: "Close" })).toBeNull();
+ expect(
+ screen.queryByRole("button", { name: "Enter fullscreen" }),
+ ).toBeNull();
});
});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactPanelHeader.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactPanelHeader.tsx
index e41a01d3e9..319eaa8335 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactPanelHeader.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactPanelHeader.tsx
@@ -5,7 +5,6 @@ import {
TooltipContent,
TooltipTrigger,
} from "@/components/atoms/Tooltip/BaseTooltip";
-import { cn } from "@/lib/utils";
import type { ArtifactPanelMode, ArtifactRef } from "../../../store";
import type { ArtifactClassification } from "../helpers";
import { PanelModeSwitch } from "./PanelModeSwitch";
@@ -17,6 +16,8 @@ import {
Copy01Icon,
Download01Icon,
Folder01Icon,
+ ArrowExpandDiagonal01Icon,
+ ArrowShrinkIcon,
} from "@hugeicons/core-free-icons";
import { Icon } from "@/components/atoms/Icon/Icon";
@@ -39,10 +40,8 @@ interface Props {
onDownload: () => void;
onOpenFiles: () => void;
onSourceToggle: (isSource: boolean) => void;
- /** True when a control outside the panel (the chat's sidebar-right
- * toggle) already closes it — standalone hosts (share viewer, tour,
- * mobile drawer) have no such control and keep the header Close. */
- hasExternalClose?: boolean;
+ isFullscreen?: boolean;
+ onToggleFullscreen?: () => void;
}
function HeaderButton({
@@ -61,7 +60,7 @@ function HeaderButton({
type="button"
onClick={onClick}
aria-label={title}
- className="rounded p-1.5 text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-700"
+ className="flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
>
{children}
</button>
@@ -84,94 +83,93 @@ export function ArtifactPanelHeader({
onDownload,
onOpenFiles,
onSourceToggle,
- hasExternalClose = false,
+ isFullscreen = false,
+ onToggleFullscreen,
mode = "artifact",
showModeSwitch = false,
onModeChange,
}: Props) {
const isComputer = mode === "computer" || artifact == null;
- // An expert is not a workspace file: nothing to download, and "All files"
- // would strand the user in the wrong tab.
const isFile = !isComputer && !artifact?.expert;
- // Height matches the chat thread header (36px avatar + py-2 + border) so
- // the two top bars share one seam across the panel split.
+ const hasViewControls =
+ (showModeSwitch && onModeChange) || (!isComputer && hasSourceToggle);
+
return (
- <div className="sticky top-0 z-10 flex h-[53px] items-center gap-2 border-b border-b-[#80808017] bg-sidebar px-3">
- {/* Left section */}
- <div className="flex min-w-0 flex-1 items-center gap-2">
+ <header className="shrink-0 border-b border-border bg-card">
+ <div className="flex h-12 items-center gap-2 px-3 sm:px-4">
{!isComputer && canGoBack && (
<HeaderButton onClick={onBack} title="Back">
- <Icon icon={ArrowLeft02Icon} size={16} />
+ <Icon icon={ArrowLeft02Icon} size={18} />
</HeaderButton>
)}
- {isComputer || !artifact || !classification ? (
- <>
- <Icon
- icon={ComputerIcon}
- size={16}
- className="shrink-0 text-zinc-400"
- />
- <span className="truncate text-sm font-medium text-zinc-900">
- Computer
- </span>
- </>
- ) : (
- <>
- <Icon
- icon={classification.icon}
- size={16}
- className="shrink-0 text-zinc-400"
- />
- <span className="truncate text-sm font-medium text-zinc-900">
- {artifact.title}
- </span>
- <span
- className={cn(
- "shrink-0 rounded-full px-2 py-0.5 text-xs font-medium",
- artifact.origin === "user-upload"
- ? "bg-blue-50 text-blue-600"
- : "bg-violet-50 text-violet-600",
+ <div className="flex min-w-0 flex-1 items-center gap-1.5 text-sm text-muted-foreground">
+ {isComputer ? (
+ <>
+ <Icon icon={ComputerIcon} size={18} className="shrink-0" />
+ <span className="truncate">Computer</span>
+ </>
+ ) : (
+ <>
+ <span className="truncate" title={artifact?.title}>
+ {artifact?.title}
+ </span>
+ {classification && (
+ <span className="shrink-0">· {classification.label}</span>
)}
+ </>
+ )}
+ </div>
+ <div className="flex shrink-0 items-center gap-0.5">
+ {!isComputer && canCopy && (
+ <HeaderButton onClick={onCopy} title="Copy">
+ <Icon icon={Copy01Icon} size={18} />
+ </HeaderButton>
+ )}
+ {isFile && (
+ <>
+ <HeaderButton onClick={onOpenFiles} title="All files">
+ <Icon icon={Folder01Icon} size={18} />
+ </HeaderButton>
+ <HeaderButton onClick={onDownload} title="Download">
+ <Icon icon={Download01Icon} size={18} />
+ </HeaderButton>
+ </>
+ )}
+ {onToggleFullscreen && (
+ <HeaderButton
+ onClick={onToggleFullscreen}
+ title={isFullscreen ? "Exit fullscreen" : "Enter fullscreen"}
>
- {classification.label}
- </span>
- </>
- )}
- </div>
-
- {/* Right section */}
- <div className="flex items-center gap-1">
- {showModeSwitch && onModeChange && (
- <PanelModeSwitch
- mode={isComputer ? "computer" : "artifact"}
- hasArtifact={artifact != null}
- onChange={onModeChange}
- />
- )}
- {!isComputer && hasSourceToggle && (
- <SourceToggle isSourceView={isSourceView} onToggle={onSourceToggle} />
- )}
- {!isComputer && canCopy && (
- <HeaderButton onClick={onCopy} title="Copy">
- <Icon icon={Copy01Icon} size={16} />
- </HeaderButton>
- )}
- {isFile && (
- <HeaderButton onClick={onDownload} title="Download">
- <Icon icon={Download01Icon} size={16} />
- </HeaderButton>
- )}
- {isFile && (
- <HeaderButton onClick={onOpenFiles} title="All files">
- <Icon icon={Folder01Icon} size={16} />
- </HeaderButton>
- )}
- {!hasExternalClose && (
+ <Icon
+ icon={
+ isFullscreen ? ArrowShrinkIcon : ArrowExpandDiagonal01Icon
+ }
+ size={18}
+ />
+ </HeaderButton>
+ )}
<HeaderButton onClick={onClose} title="Close">
- <Icon icon={Cancel01Icon} size={16} />
+ <Icon icon={Cancel01Icon} size={18} />
</HeaderButton>
- )}
+ </div>
</div>
- </div>
+ {hasViewControls && (
+ <div className="flex flex-wrap items-center justify-between gap-2 px-3 pb-2 sm:px-4">
+ {showModeSwitch && onModeChange && (
+ <PanelModeSwitch
+ mode={isComputer ? "computer" : "artifact"}
+ hasArtifact={artifact != null}
+ onChange={onModeChange}
+ />
+ )}
+ {!isComputer && hasSourceToggle && (
+ <SourceToggle
+ isSourceView={isSourceView}
+ onToggle={onSourceToggle}
+ />
+ )}
+ </div>
+ )}
+ </header>
);
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactPreview.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactPreview.tsx
new file mode 100644
index 0000000000..f2518e7463
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactPreview.tsx
@@ -0,0 +1,12 @@
+import type { ComponentProps } from "react";
+import { ArtifactContent } from "./ArtifactContent";
+
+export function ArtifactPreview(props: ComponentProps<typeof ArtifactContent>) {
+ return (
+ <div className="flex min-h-0 flex-1 bg-muted/70 p-3 sm:p-4">
+ <div className="flex min-w-0 flex-1 flex-col overflow-hidden bg-card shadow-sm">
+ <ArtifactContent {...props} />
+ </div>
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/useArtifactFullscreen.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/useArtifactFullscreen.ts
new file mode 100644
index 0000000000..7c63fd447c
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/useArtifactFullscreen.ts
@@ -0,0 +1,66 @@
+"use client";
+
+import { toast } from "@/components/molecules/Toast/use-toast";
+import { useEffect, useRef, useState } from "react";
+
+export function useArtifactFullscreen() {
+ const fullscreenRef = useRef<HTMLDivElement>(null);
+ const [isFullscreen, setIsFullscreen] = useState(false);
+ const [canFullscreen, setCanFullscreen] = useState(false);
+
+ useEffect(() => {
+ setCanFullscreen(!!document.fullscreenEnabled);
+ function handleFullscreenChange() {
+ setIsFullscreen(
+ !!fullscreenRef.current &&
+ document.fullscreenElement === fullscreenRef.current,
+ );
+ }
+ document.addEventListener("fullscreenchange", handleFullscreenChange);
+ return () => {
+ document.removeEventListener("fullscreenchange", handleFullscreenChange);
+ };
+ }, []);
+
+ async function exitFullscreen() {
+ if (
+ !fullscreenRef.current ||
+ document.fullscreenElement !== fullscreenRef.current
+ )
+ return true;
+ try {
+ await document.exitFullscreen();
+ return true;
+ } catch {
+ toast({
+ title: "Couldn't change fullscreen mode",
+ variant: "destructive",
+ });
+ return false;
+ }
+ }
+
+ async function toggleFullscreen() {
+ if (!fullscreenRef.current) return;
+ if (document.fullscreenElement === fullscreenRef.current) {
+ await exitFullscreen();
+ return;
+ }
+ try {
+ await fullscreenRef.current.requestFullscreen();
+ } catch {
+ toast({
+ title: "Couldn't change fullscreen mode",
+ variant: "destructive",
+ });
+ }
+ }
+
+ return {
+ fullscreenRef,
+ isFullscreen,
+ canFullscreen,
+ toggleFullscreen,
+ exitFullscreen,
+ };
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/useArtifactPanel.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/useArtifactPanel.ts
index af28a710ba..1eb280be53 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/useArtifactPanel.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/useArtifactPanel.ts
@@ -9,6 +9,7 @@ import { classifyArtifactRef } from "./helpers";
export function useArtifactPanel() {
const artifactPanel = useCopilotUIStore((s) => s.artifactPanel);
+ const closeArtifactPanel = useCopilotUIStore((s) => s.closeArtifactPanel);
const clearArtifactPreview = useCopilotUIStore((s) => s.clearArtifactPreview);
const goBackArtifact = useCopilotUIStore((s) => s.goBackArtifact);
const showFilesTab = useCopilotUIStore((s) => s.showFilesTab);
@@ -85,6 +86,7 @@ export function useArtifactPanel() {
isSourceView,
classification,
setIsSourceView,
+ closeArtifactPanel,
clearArtifactPreview,
goBackArtifact,
showFilesTab,
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 af6c6b0360..3a7f7d8339 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
@@ -63,8 +63,8 @@ export function ContextPanelToggle({ sessionId = null }: Props) {
const isArtifactsOpen = isOpen && activeTab === "artifacts";
// An open artifact preview and the artifacts tab are both the document
// face of the right sidebar, so the toggle reads active for either and is
- // the one control that closes them — the panel carries no close button.
- // With the computer face on top, the artifact underneath is not showing.
+ // another control that closes them alongside the panel header. With the
+ // computer face on top, the artifact underneath is not showing.
const isDocumentOpen = !isComputerOpen && (hasArtifact || isArtifactsOpen);
const isRightSidebarOpen = isDocumentOpen || isComputerOpen;
// The mobile sheet has no computer face to open.