Skip to content

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

Python

gui: Codex-style diffs pane + bottom terminal with slide animations

Pranav Pbc76afe36177
diff --git a/gui/src/components/workspace-board/AuxiliaryPaneShell.tsx b/gui/src/components/workspace-board/AuxiliaryPaneShell.tsx
new file mode 100644
index 00000000..6710427f
--- /dev/null
+++ b/gui/src/components/workspace-board/AuxiliaryPaneShell.tsx
@@ -0,0 +1,104 @@
+import { useEffect, useRef, useState, type ReactNode } from "react";
+import type { DockviewPanelApi } from "dockview-react";
+
+import { cn } from "@/utils/cn";
+
+import { PANE_CLOSE_REQUEST_EVENT_NAME } from "./layout";
+
+export type PaneSlideDirection = "right" | "bottom";
+
+interface AuxiliaryPaneShellProps {
+ api: DockviewPanelApi;
+ paneId: string;
+ direction: PaneSlideDirection;
+ children: ReactNode;
+}
+
+const ENTER_ANIMATION: Record<PaneSlideDirection, string> = {
+ right: "slide-in-from-right-4",
+ bottom: "slide-in-from-bottom-4",
+};
+
+const EXIT_ANIMATION: Record<PaneSlideDirection, string> = {
+ right: "slide-out-to-right-4",
+ bottom: "slide-out-to-bottom-4",
+};
+
+// Fallback close delay (ms) used if the exit animation never reports completion
+// (e.g. under `prefers-reduced-motion`, where the animation may not run).
+const EXIT_FALLBACK_MS = 220;
+
+/**
+ * Wraps an auxiliary dock pane (preview / changes / terminal) so it slides in on
+ * mount and slides out on close. Side panes slide along the x-axis; the bottom
+ * terminal slides along the y-axis. Closing is driven by a window event
+ * ({@link PANE_CLOSE_REQUEST_EVENT_NAME}) so the pane can animate out before
+ * `api.close()` removes it from the layout.
+ */
+export function AuxiliaryPaneShell({
+ api,
+ paneId,
+ direction,
+ children,
+}: AuxiliaryPaneShellProps) {
+ const [closing, setClosing] = useState(false);
+ const closedRef = useRef(false);
+
+ function closeOnce() {
+ if (closedRef.current) {
+ return;
+ }
+ closedRef.current = true;
+ api.close();
+ }
+
+ useEffect(() => {
+ function handleCloseRequest(event: Event) {
+ const detail = (event as CustomEvent<{ paneId?: string }>).detail;
+ if (detail?.paneId === paneId) {
+ setClosing(true);
+ }
+ }
+
+ window.addEventListener(PANE_CLOSE_REQUEST_EVENT_NAME, handleCloseRequest);
+ return () => {
+ window.removeEventListener(PANE_CLOSE_REQUEST_EVENT_NAME, handleCloseRequest);
+ };
+ }, [paneId]);
+
+ useEffect(() => {
+ if (!closing) {
+ return;
+ }
+ const timer = window.setTimeout(closeOnce, EXIT_FALLBACK_MS);
+ return () => {
+ window.clearTimeout(timer);
+ };
+ // closeOnce is idempotent; we intentionally only re-run when `closing` flips.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [closing]);
+
+ return (
+ <div
+ className={cn(
+ "h-full w-full",
+ closing
+ ? cn(
+ "animate-out fade-out-0 fill-mode-forwards duration-150",
+ EXIT_ANIMATION[direction],
+ )
+ : cn("animate-in fade-in-0 duration-200", ENTER_ANIMATION[direction]),
+ )}
+ onAnimationEnd={(event) => {
+ if (event.target !== event.currentTarget) {
+ return;
+ }
+ if (closing) {
+ closeOnce();
+ }
+ }}
+ >
+ {children}
+ </div>
+ );
+}
diff --git a/gui/src/components/workspace-board/ChangesPane.tsx b/gui/src/components/workspace-board/ChangesPane.tsx
index 75ce4440..5a51ddac 100644
--- a/gui/src/components/workspace-board/ChangesPane.tsx
+++ b/gui/src/components/workspace-board/ChangesPane.tsx
@@ -3,6 +3,7 @@ import type { IDockviewPanelProps } from "dockview-react";
import {
ChevronDownIcon,
ChevronRight,
+ ExternalLinkIcon,
FileText,
GitCommitHorizontalIcon,
UploadIcon,
@@ -18,14 +19,8 @@ import {
import { usePreferredOpenTarget } from "@/components/conversation-panel/hooks/usePreferredOpenTarget";
import { useConversationHeaderState } from "@/components/conversation-panel/hooks/useConversationHeaderState";
import { CommitChangesDialog } from "@/components/conversation-panel/CommitChangesDialog";
-import {
- getFileDiffDisplayName,
- getFileDiffDisplayPath,
-} from "@/components/chat/activity-results/utils/fileDiff";
-import {
- fileChangeBadge,
- formatFileChangeLabel,
-} from "@/components/chat/activity-results/utils/fileChangeLabel";
+import { getFileDiffDisplayName } from "@/components/chat/activity-results/utils/fileDiff";
+import { formatFileChangeLabel } from "@/components/chat/activity-results/utils/fileChangeLabel";
import {
resolveRenderableFileDiff,
type ResolvedFileDiff,
@@ -63,13 +58,12 @@ function PlaceholderBody({
}) {
const { title, detail } = formatFileChangeLabel(operation, byteCount);
return (
- <div className="flex items-center gap-1.5 px-2 py-1.5 text-xs text-muted-foreground">
- <span className="font-medium text-foreground/80">{title}</span>
+ <div className="px-4 py-3 text-center text-xs text-muted-foreground">
+ <span className="text-foreground/70">{title}</span>
{detail != null ? (
- <>
- <span className="text-muted-foreground/40">·</span>
- <span className="font-mono text-[11px]">{detail}</span>
- </>
+ <span className="ml-1.5 font-mono text-[11px] text-muted-foreground/70">
+ {detail}
+ </span>
) : null}
</div>
);
@@ -78,7 +72,6 @@ function PlaceholderBody({
interface ChangeRowProps {
change: SessionFileChange;
resolved: ResolvedFileDiff | null;
- workspacePath: string;
canOpenInEditor: boolean;
onOpenInEditor: (path: string) => void;
}
@@ -86,24 +79,21 @@ interface ChangeRowProps {
function ChangeRow({
change,
resolved,
- workspacePath,
canOpenInEditor,
onOpenInEditor,
}: ChangeRowProps) {
const [open, setOpen] = useState(true);
const displayName = getFileDiffDisplayName(change.path);
- const displayPath = getFileDiffDisplayPath(change.path, workspacePath);
- const badge = fileChangeBadge(change.operation, change.editCount);
const stats = resolved?.status === "diff" ? resolved : null;
return (
<Collapsible
open={open}
onOpenChange={setOpen}
- className="overflow-hidden rounded-lg border border-border bg-card shadow-[var(--elevation-xs)] ring-1 ring-foreground/[0.04] transition-shadow hover:shadow-[var(--elevation-sm)]"
+ className="group border-b border-border last:border-b-0"
>
- <div className="flex items-center gap-2 bg-muted/40 pr-2">
- <CollapsibleTrigger className="flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left">
+ <div className="flex items-center gap-2 bg-muted/40 pr-2 transition-colors hover:bg-muted/60">
+ <CollapsibleTrigger className="flex min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left">
<ChevronRight
strokeWidth={2}
className={cn(
@@ -111,14 +101,10 @@ function ChangeRow({
open && "rotate-90",
)}
/>
+ <FileText className="size-3.5 shrink-0 text-muted-foreground" />
<span className="truncate font-mono text-xs font-medium text-foreground">
{displayName}
</span>
- {badge != null ? (
- <span className="shrink-0 rounded-full border border-border px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider text-muted-foreground">
- {badge}
- </span>
- ) : null}
<span className="ml-auto shrink-0 font-mono text-xs tabular-nums">
{stats != null ? (
<span className="inline-flex items-center gap-2">
@@ -135,28 +121,25 @@ function ChangeRow({
type="button"
title="Open in editor"
onClick={() => onOpenInEditor(change.path)}
- className="shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
+ className="shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-all hover:bg-muted hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"
>
- <FileText className="size-3.5" />
+ <ExternalLinkIcon className="size-3.5" />
</button>
) : null}
</div>
<CollapsibleContent className="cgd-collapse">
- <div className="border-t border-border px-2 py-2">
+ <div className="border-t border-border">
{resolved == null ? (
- <div className="px-2 py-3 text-xs text-muted-foreground">Loading diff…</div>
+ <div className="px-3 py-3 text-xs text-muted-foreground">Loading diff…</div>
) : resolved.status === "diff" ? (
<PatchDiff
patch={resolved.patch}
- className="block max-w-full overflow-hidden text-xs/relaxed"
+ className="block max-w-full overflow-hidden text-xs"
options={{ lineDiffType: "word", showFileHeader: false }}
/>
) : (
<PlaceholderBody operation={resolved.operation} byteCount={resolved.byteCount} />
)}
- <div className="px-2 pt-2">
- <code className="font-mono text-[11px] text-muted-foreground">{displayPath}</code>
- </div>
</div>
</CollapsibleContent>
</Collapsible>
@@ -252,8 +235,8 @@ export function ChangesPane({
};
return (
- <PaneSurface className="overflow-auto animate-in fade-in-0 slide-in-from-right-2 duration-200">
- <div className="sticky top-0 z-10 flex items-center justify-between gap-3 border-b border-border bg-background/70 px-4 py-2.5 text-xs backdrop-blur-md">
+ <PaneSurface className="overflow-auto">
+ <div className="sticky top-0 z-10 flex items-center justify-between gap-3 border-b border-border bg-background/70 px-4 py-2 text-xs backdrop-blur-md">
<div className="flex min-w-0 flex-col gap-0.5">
{repoName != null || branchName != null ? (
<span className="inline-flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-muted-foreground">
@@ -291,7 +274,7 @@ export function ChangesPane({
onClick={openCommitDialog}
>
<GitCommitHorizontalIcon data-icon="inline-start" />
- Commit
+ Commit or push
</Button>
<DropdownMenu>
<DropdownMenuTrigger
@@ -329,13 +312,12 @@ export function ChangesPane({
File edits made during this conversation will appear here.
</div>
) : (
- <div className="flex flex-col gap-2 p-3">
+ <div className="flex flex-col">
{changes.map((change) => (
<ChangeRow
key={change.path}
change={change}
resolved={resolvedByPath[change.path] ?? null}
- workspacePath={params.workspacePath}
canOpenInEditor={canOpenInEditor}
onOpenInEditor={handleOpenInEditor}
/>
diff --git a/gui/src/components/workspace-board/ChatTile.tsx b/gui/src/components/workspace-board/ChatTile.tsx
index b8341d61..9ac38ee3 100644
--- a/gui/src/components/workspace-board/ChatTile.tsx
+++ b/gui/src/components/workspace-board/ChatTile.tsx
@@ -28,12 +28,14 @@ import { Button } from "@/components/ui/Button";
import { ButtonGroup } from "@/components/ui/ButtonGroup";
import * as desktopClient from "@/services/desktop/client";
+import { AuxiliaryPaneShell } from "./AuxiliaryPaneShell";
import { ChangesPane } from "./ChangesPane";
import { PlaceholderPane } from "./PlaceholderPane";
import { TerminalPane } from "./TerminalPane";
import {
CHAT_PANE_ID,
createTerminalSessionId,
+ dispatchPaneCloseRequest,
dispatchTerminalRestartRequest,
INNER_CHAT_COMPONENT,
INNER_PLACEHOLDER_COMPONENT,
@@ -157,7 +159,7 @@ export function ChatTile({
}
const handleClose = () => {
- activePanel.api.close();
+ dispatchPaneCloseRequest(`${binding.conversationId}:${activePanel.id}`);
};
if (kind === "preview" || kind === "changes") {
@@ -235,19 +237,27 @@ export function ChatTile({
[INNER_PLACEHOLDER_COMPONENT]: function AuxiliaryPane(
props: IDockviewPanelProps<PlaceholderPaneParams>,
) {
- if (props.params.kind === "terminal") {
- return (
+ const kind = props.params.kind;
+ const content =
+ kind === "terminal" ? (
<TerminalPane
{...(props as IDockviewPanelProps<TerminalPaneParams>)}
/>
+ ) : kind === "changes" ? (
+ <ChangesPane {...props} />
+ ) : (
+ <PlaceholderPane {...props} />
);
- }
- if (props.params.kind === "changes") {
- return <ChangesPane {...props} />;
- }
-
- return <PlaceholderPane {...props} />;
+ return (
+ <AuxiliaryPaneShell
+ api={props.api}
+ paneId={`${props.params.conversationId}:${props.api.id}`}
+ direction={kind === "terminal" ? "bottom" : "right"}
+ >
+ {content}
+ </AuxiliaryPaneShell>
+ );
},
}),
[binding, canCloseChat, handleOpenPane, onCloseChat],
diff --git a/gui/src/components/workspace-board/chatTileLayout.ts b/gui/src/components/workspace-board/chatTileLayout.ts
index b49e54e3..f6ecabeb 100644
--- a/gui/src/components/workspace-board/chatTileLayout.ts
+++ b/gui/src/components/workspace-board/chatTileLayout.ts
@@ -1,4 +1,5 @@
import type {
+ AddPanelPositionOptions,
DockviewApi,
DockviewGroupPanel,
IDockviewPanel,
@@ -11,7 +12,6 @@ import {
CHAT_PANE_ID,
INNER_CHAT_COMPONENT,
INNER_PLACEHOLDER_COMPONENT,
- PREVIEW_PANE_ID,
TERMINAL_PANE_ID,
} from "./layout";
import type { PlaceholderPaneParams } from "./types/layout";
@@ -91,14 +91,15 @@ export function openChatTilePane(
return;
}
- const previewPanel = api.getPanel(PREVIEW_PANE_ID);
const panelTitle =
kind === "preview" ? "Preview" : kind === "changes" ? "Changes" : "Terminal";
- // Preview/Changes open to the right of chat; terminal stacks below the preview.
- const referencePanel =
- kind === "terminal" && previewPanel != null ? previewPanel : chatPanel;
- const direction =
- kind === "terminal" ? (previewPanel != null ? "below" : "right") : "right";
+ // The terminal opens as a full-width horizontal pane along the bottom (positioned
+ // relative to the whole grid, so it spans beneath chat and any side panes).
+ // Preview/Changes open to the right of chat.
+ const position: AddPanelPositionOptions =
+ kind === "terminal"
+ ? { direction: "below" }
+ : { direction: "right", referencePanel: chatPanel };
api.addPanel<PlaceholderPaneParams>({
id: panelId,
@@ -110,10 +111,7 @@ export function openChatTilePane(
kind,
label: panelTitle,
},
- position: {
- direction,
- referencePanel,
- },
+ position,
});
applyChatTileLayoutConstraints(api);
diff --git a/gui/src/components/workspace-board/layout.ts b/gui/src/components/workspace-board/layout.ts
index b87048bb..264b96bc 100644
--- a/gui/src/components/workspace-board/layout.ts
+++ b/gui/src/components/workspace-board/layout.ts
@@ -14,6 +14,7 @@ export const PREVIEW_PANE_ID = "preview";
export const TERMINAL_PANE_ID = "terminal";
export const CHANGES_PANE_ID = "changes";
export const TERMINAL_RESTART_EVENT_NAME = "codegraff://terminal-restart-request";
+export const PANE_CLOSE_REQUEST_EVENT_NAME = "codegraff://pane-close-request";
let activeDraggedChatBinding: ChatBinding | null = null;
@@ -47,6 +48,18 @@ export function dispatchTerminalRestartRequest(terminalId: string): void {
);
}
+/**
+ * Request that an auxiliary pane close. The pane component listens for this so it
+ * can play a slide-out animation before actually removing itself from the layout.
+ */
+export function dispatchPaneCloseRequest(paneId: string): void {
+ window.dispatchEvent(
+ new CustomEvent(PANE_CLOSE_REQUEST_EVENT_NAME, {
+ detail: { paneId },
+ }),
+ );
+}
+
export function parseDockviewLayoutJson(
layoutJson: string | null | undefined,
): SerializedDockview | null {
diff --git a/packages/diffs/src/style.css b/packages/diffs/src/style.css
index 8cdcc6b7..5847b442 100644
--- a/packages/diffs/src/style.css
+++ b/packages/diffs/src/style.css
@@ -29,7 +29,7 @@
color: var(--cgd-fg);
font-family: var(--cgd-font);
font-size: 12px;
- line-height: 1.55;
+ line-height: 1.45;
-moz-tab-size: 2;
tab-size: 2;
}