Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

gui: remove orphaned artifacts drawer

Pranav Pba3163e468d1
diff --git a/gui/src/components/ConversationPanel.tsx b/gui/src/components/ConversationPanel.tsx
index ea5dd03c..cadeb687 100644
--- a/gui/src/components/ConversationPanel.tsx
+++ b/gui/src/components/ConversationPanel.tsx
@@ -2,9 +2,6 @@ import { useCallback, useMemo, useState } from "react";
import { useSidebarVisible } from "@/app/sidebarVisibilityContext";
import { ChatThread } from "@/components/chat/ChatThread";
-import { ArtifactsDrawer } from "@/components/artifacts/ArtifactsDrawer";
-import { useArtifactsDrawer } from "@/components/artifacts/artifactsDrawerStore";
-import { useChatArtifacts } from "@/components/artifacts/useChatArtifacts";
import { ConversationPanelAlerts } from "@/components/conversation-panel/ConversationPanelAlerts";
import { ConversationPanelHeader } from "@/components/conversation-panel/ConversationPanelHeader";
import { ConversationSurface } from "@/components/conversation-panel/ConversationSurface";
@@ -52,9 +49,6 @@ export function ConversationPanel({
const commandResults =
commandResultState.key === bindingKey ? commandResultState.results : [];
const isSidebarVisible = useSidebarVisible();
- const artifacts = useChatArtifacts(messages);
- const { isOpen: isArtifactsOpen, close: closeArtifacts } =
- useArtifactsDrawer(binding);
// Full-window panels (drag-enabled) sit under the traffic lights when the
// sidebar is collapsed, so reserve the titlebar inset then.
const shouldReserveTitlebarInset =
@@ -132,12 +126,6 @@ export function ConversationPanel({
/>
</>
)}
-
- <ArtifactsDrawer
- open={isArtifactsOpen}
- artifacts={artifacts}
- onClose={closeArtifacts}
- />
</ConversationSurface>
);
}
diff --git a/gui/src/components/artifacts/ArtifactCard.tsx b/gui/src/components/artifacts/ArtifactCard.tsx
deleted file mode 100644
index 6b820e91..00000000
--- a/gui/src/components/artifacts/ArtifactCard.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import { DownloadIcon, FileTextIcon } from "lucide-react";
-
-import type { ChatArtifact } from "./useChatArtifacts";
-
-function describeKind(ext: string): string {
- if (ext === "") {
- return "File";
- }
- return "Document";
-}
-
-export function ArtifactCard({
- artifact,
- onOpen,
-}: {
- artifact: ChatArtifact;
- onOpen: (path: string) => void;
-}) {
- const kindLabel = describeKind(artifact.ext);
- const extLabel = artifact.ext ? artifact.ext.toUpperCase() : null;
-
- return (
- <button
- type="button"
- onClick={() => onOpen(artifact.path)}
- title={artifact.path}
- className="group/artifact flex w-full items-center gap-3 rounded-xl border border-border bg-card/50 p-3 text-left transition-colors hover:border-[color:var(--accent)] hover:bg-card"
- >
- {/* Stacked-paper thumbnail */}
- <div className="relative size-12 shrink-0">
- <div className="absolute inset-0 translate-x-1 -rotate-6 rounded-md border border-border bg-muted/60" />
- <div className="absolute inset-0 flex items-center justify-center rounded-md border border-border bg-muted">
- <FileTextIcon className="size-5 text-muted-foreground" />
- </div>
- </div>
-
- <div className="min-w-0 flex-1">
- <div className="truncate text-sm font-medium text-foreground">
- {artifact.name}
- </div>
- <div className="truncate text-xs text-muted-foreground">
- {kindLabel}
- {extLabel ? ` · ${extLabel}` : null}
- </div>
- </div>
-
- <DownloadIcon className="size-4 shrink-0 text-muted-foreground transition-colors group-hover/artifact:text-foreground" />
- </button>
- );
-}
diff --git a/gui/src/components/artifacts/ArtifactsButton.tsx b/gui/src/components/artifacts/ArtifactsButton.tsx
deleted file mode 100644
index f5b8e1bc..00000000
--- a/gui/src/components/artifacts/ArtifactsButton.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { FileTextIcon } from "lucide-react";
-
-import { Button } from "@/components/ui/Button";
-import { cn } from "@/utils/cn";
-
-export function ArtifactsButton({
- artifactCount,
- isOpen,
- onToggle,
-}: {
- artifactCount: number;
- isOpen: boolean;
- onToggle: () => void;
-}) {
- const hasArtifacts = artifactCount > 0;
-
- return (
- <Button
- variant="outline"
- size="icon-sm"
- aria-label="Artifacts"
- aria-pressed={isOpen}
- title={
- hasArtifacts
- ? `Artifacts (${artifactCount})`
- : "Artifacts"
- }
- className={cn(
- "relative",
- isOpen &&
- "border-[color:var(--accent)] bg-[color:color-mix(in_oklab,var(--accent)_12%,transparent)] text-foreground",
- )}
- onClick={onToggle}
- >
- <FileTextIcon />
- {hasArtifacts ? (
- <span className="absolute -top-0.5 -right-0.5 size-2 rounded-full bg-[color:var(--success)] ring-2 ring-[color:var(--pane-surface)]" />
- ) : null}
- </Button>
- );
-}
diff --git a/gui/src/components/artifacts/ArtifactsDrawer.tsx b/gui/src/components/artifacts/ArtifactsDrawer.tsx
deleted file mode 100644
index 82d2b805..00000000
--- a/gui/src/components/artifacts/ArtifactsDrawer.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-import { FileTextIcon, XIcon } from "lucide-react";
-
-import { Button } from "@/components/ui/Button";
-import { openPathDefault } from "@/services/desktop/client";
-import { cn } from "@/utils/cn";
-import { ArtifactCard } from "./ArtifactCard";
-import type { ChatArtifact } from "./useChatArtifacts";
-
-function handleOpenArtifact(path: string) {
- void openPathDefault(path).catch((error) => {
- console.error("Failed to open artifact", error);
- });
-}
-
-export function ArtifactsDrawer({
- open,
- artifacts,
- onClose,
-}: {
- open: boolean;
- artifacts: ChatArtifact[];
- onClose: () => void;
-}) {
- return (
- <aside
- aria-hidden={!open}
- className={cn(
- "absolute inset-y-0 right-0 z-30 flex w-[340px] max-w-[85%] flex-col border-l border-[color:var(--pane-border)] shadow-[0_20px_45px_-20px_var(--pane-shadow)] transition-transform duration-200 ease-out",
- open ? "translate-x-0" : "pointer-events-none translate-x-full",
- )}
- style={{ backgroundColor: "var(--pane-surface)" }}
- >
- <header className="flex h-9.5 shrink-0 items-center justify-between border-b border-black/5 px-4 dark:border-white/5">
- <span className="text-sm font-medium text-foreground">Artifacts</span>
- <Button
- variant="ghost"
- size="icon-sm"
- aria-label="Close artifacts"
- onClick={onClose}
- >
- <XIcon className="size-3.5" />
- </Button>
- </header>
-
- <div className="min-h-0 flex-1 overflow-y-auto p-3">
- {artifacts.length === 0 ? (
- <div className="flex h-full flex-col items-center justify-center gap-2 px-6 text-center">
- <FileTextIcon className="size-6 text-muted-foreground/60" />
- <p className="text-xs text-muted-foreground">
- Files the assistant creates or edits in this chat will appear here.
- </p>
- </div>
- ) : (
- <div className="flex flex-col gap-2">
- {artifacts.map((artifact) => (
- <ArtifactCard
- key={artifact.path}
- artifact={artifact}
- onOpen={handleOpenArtifact}
- />
- ))}
- </div>
- )}
- </div>
- </aside>
- );
-}
diff --git a/gui/src/components/artifacts/artifactsDrawerStore.ts b/gui/src/components/artifacts/artifactsDrawerStore.ts
deleted file mode 100644
index 259ff3af..00000000
--- a/gui/src/components/artifacts/artifactsDrawerStore.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import { create } from "zustand";
-
-import type { ChatBinding } from "@/services/desktop/types/contracts";
-
-interface ArtifactsDrawerState {
- openByKey: Record<string, boolean>;
- toggle: (key: string) => void;
- setOpen: (key: string, open: boolean) => void;
-}
-
-const useArtifactsDrawerStore = create<ArtifactsDrawerState>((set) => ({
- openByKey: {},
- toggle: (key) =>
- set((state) => ({
- openByKey: { ...state.openByKey, [key]: !state.openByKey[key] },
- })),
- setOpen: (key, open) =>
- set((state) => ({
- openByKey: { ...state.openByKey, [key]: open },
- })),
-}));
-
-function keyFor(binding?: ChatBinding | null): string {
- return binding == null
- ? "__global__"
- : `${binding.workspacePath}::${binding.conversationId}`;
-}
-
-/**
- * Per-conversation artifacts drawer open-state, shared between the standard
- * panel header and the dockview tab header (which live in separate subtrees).
- */
-export function useArtifactsDrawer(binding?: ChatBinding | null) {
- const key = keyFor(binding);
- const isOpen = useArtifactsDrawerStore((state) => state.openByKey[key] ?? false);
- const toggle = useArtifactsDrawerStore((state) => state.toggle);
- const setOpen = useArtifactsDrawerStore((state) => state.setOpen);
-
- return {
- isOpen,
- toggle: () => toggle(key),
- close: () => setOpen(key, false),
- };
-}
diff --git a/gui/src/components/artifacts/useChatArtifacts.ts b/gui/src/components/artifacts/useChatArtifacts.ts
deleted file mode 100644
index 397e8bd3..00000000
--- a/gui/src/components/artifacts/useChatArtifacts.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import { useMemo } from "react";
-
-import type { TranscriptMessage } from "@/services/desktop/types/contracts";
-import { basename } from "@/components/attachments/attachmentTypes";
-
-export interface ChatArtifact {
- path: string;
- name: string;
- ext: string;
-}
-
-function extensionOf(name: string): string {
- const dotIndex = name.lastIndexOf(".");
- if (dotIndex <= 0 || dotIndex === name.length - 1) {
- return "";
- }
- return name.slice(dotIndex + 1).toLowerCase();
-}
-
-function pathFromMessage(message: TranscriptMessage): string | null {
- if (message.kind === "tool_start" && message.detail.kind === "file_update") {
- return message.detail.path;
- }
- if (
- message.kind === "tool_end" &&
- message.detail != null &&
- message.detail.kind === "file_diff"
- ) {
- return message.detail.path;
- }
- return null;
-}
-
-/**
- * Derives the files the agent wrote/modified in this chat from the message
- * stream (read-only — no harness change). Deduped by path, most recently
- * touched first.
- */
-export function useChatArtifacts(messages: TranscriptMessage[]): ChatArtifact[] {
- return useMemo(() => {
- if (import.meta.env.DEV) {
- console.debug(
- "[artifacts] message kinds",
- messages.map((message) =>
- message.kind === "tool_start" || message.kind === "tool_end"
- ? `${message.kind}:${message.name}:${
- message.kind === "tool_start"
- ? message.detail.kind
- : (message.detail?.kind ?? "null")
- }`
- : message.kind,
- ),
- );
- }
-
- const byPath = new Map<string, ChatArtifact>();
-
- for (const message of messages) {
- const path = pathFromMessage(message);
- if (path == null) {
- continue;
- }
-
- const name = basename(path);
- // Re-insert so the most recently touched path moves to the end.
- byPath.delete(path);
- byPath.set(path, { path, name, ext: extensionOf(name) });
- }
-
- return Array.from(byPath.values()).reverse();
- }, [messages]);
-}