Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Make the agent a docked tool pane and declare pane width defaults

Bittia23ac97bd7e3
diff --git a/src/components/workspace/AgentDock.test.tsx b/src/components/workspace/AgentDock.test.tsx
index c8d25f8..1795188 100644
--- a/src/components/workspace/AgentDock.test.tsx
+++ b/src/components/workspace/AgentDock.test.tsx
@@ -1,10 +1,10 @@
// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
-import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { createProjectConfig, type ProjectRecord } from "../../lib/project";
-import { AGENT_TURN_EVENT, runAgentTurn, type AgentTurnEventPayload, type ProviderStatus } from "../../lib/runtime";
+import { AGENT_TURN_EVENT, cancelAgentTurn, runAgentTurn, type AgentTurnEventPayload, type ProviderStatus } from "../../lib/runtime";
import { AgentDock, readableProviderOutput } from "./AgentDock";
let eventHandler: ((event: { payload: AgentTurnEventPayload }) => void) | undefined;
@@ -50,53 +50,46 @@ afterEach(() => {
});
describe("Slop output panel", () => {
- it("shows only the provider light when compact and moves a name-only selector into the Agent controls", async () => {
+ it("is a docked pane with a header, a provider picker and a one-line empty state", async () => {
const available: ProviderStatus[] = [
providers[0],
{ id: "claude", label: "Claude Code", state: "ready", executable: "claude", version: "test", detail: "Ready" },
];
- const view = (expanded: boolean) => <AgentDock context="this project" record={project()} providers={available} expanded={expanded} onPromptStart={() => undefined} onCommands={async () => undefined} />;
- const app = render(view(false));
+ const onClose = vi.fn();
+ render(<AgentDock context="this project" record={project()} providers={available} onPromptStart={() => undefined} onCommands={async () => undefined} onClose={onClose} />);
await act(async () => { await Promise.resolve(); });
+ expect(screen.getByRole("heading", { name: "Agent" })).toBeInTheDocument();
+ expect(screen.queryByRole("heading", { name: "What should we create today?" })).not.toBeInTheDocument();
+ expect(screen.getByRole("log", { name: "Slop output" })).toHaveTextContent("Ask Slop to write scenes");
expect(screen.getByRole("img", { name: "Codex status: Ready" })).toBeInTheDocument();
- expect(screen.queryByRole("combobox", { name: "Agent provider" })).not.toBeInTheDocument();
- expect(screen.queryByText("Codex")).not.toBeInTheDocument();
-
- app.rerender(view(true));
- expect(screen.getByRole("heading", { name: "What should we create today?" })).toBeInTheDocument();
- expect(screen.queryByText("No activity yet. Send a prompt to start.")).not.toBeInTheDocument();
const selector = screen.getByRole("combobox", { name: "Agent provider" });
fireEvent.click(selector);
expect(screen.getAllByRole("option").map((option) => option.textContent)).toEqual(["Codex", "Claude Code"]);
- expect(selector.closest(".agent-dock__actions")).not.toBeNull();
fireEvent.click(screen.getByRole("option", { name: "Claude Code" }));
expect(selector).toHaveTextContent("Claude Code");
expect(screen.queryByRole("listbox")).not.toBeInTheDocument();
expect(screen.getByRole("img", { name: "Claude Code status: Ready" })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole("button", { name: "Close agent" }));
+ expect(onClose).toHaveBeenCalledOnce();
});
- it("supports keyboard selection and dismisses the provider menu without submitting a prompt", async () => {
+ it("hides the close button when the workspace gives it nothing to close", async () => {
+ render(<AgentDock context="this project" record={project()} providers={providers} expanded onPromptStart={() => undefined} onCommands={async () => undefined} />);
+ await act(async () => { await Promise.resolve(); });
+ expect(screen.queryByRole("button", { name: "Close agent" })).not.toBeInTheDocument();
+ });
+
+ it("changes provider from the keyboard without submitting a prompt", async () => {
const available: ProviderStatus[] = [providers[0], { ...providers[0], id: "claude", label: "Claude Code" }];
render(<AgentDock context="this project" record={project()} providers={available} expanded onPromptStart={() => undefined} onCommands={async () => undefined} />);
await act(async () => { await Promise.resolve(); });
const selector = screen.getByRole("combobox", { name: "Agent provider" });
selector.focus();
fireEvent.keyDown(selector, { key: "ArrowDown" });
- fireEvent.keyDown(selector, { key: "End" });
- expect(selector).toHaveAttribute("aria-activedescendant", screen.getByRole("option", { name: "Claude Code" }).id);
- fireEvent.keyDown(selector, { key: "Enter" });
expect(selector).toHaveTextContent("Claude Code");
expect(selector).toHaveFocus();
expect(runAgentTurn).not.toHaveBeenCalled();
- fireEvent.click(selector);
- fireEvent.keyDown(selector, { key: "Home" });
- fireEvent.keyDown(selector, { key: "Escape" });
- expect(selector).toHaveTextContent("Claude Code");
- expect(screen.queryByRole("listbox")).not.toBeInTheDocument();
- fireEvent.click(selector);
- fireEvent.pointerDown(document.body);
- expect(screen.queryByRole("listbox")).not.toBeInTheDocument();
});
it("hands an accepted command batch to the workspace before completing the turn", async () => {
@@ -118,53 +111,59 @@ describe("Slop output panel", () => {
expect(onPromptStart).toHaveBeenCalledTimes(1);
});
- it("uses the Agent page as its expanded view and requests it when a turn starts", async () => {
+ it("shows the running turn with a progress ring, stops it with Esc, and recalls the last prompt with Up", async () => {
let finish!: (value: Awaited<ReturnType<typeof runAgentTurn>>) => void;
vi.mocked(runAgentTurn).mockImplementation(() => new Promise((resolve) => { finish = resolve; }));
- const record = project();
const onPromptStart = vi.fn();
- const view = (expanded: boolean) => <AgentDock context="this generation queue" record={record} providers={providers} expanded={expanded} onPromptStart={onPromptStart} onCommands={async () => undefined} />;
- const app = render(view(false));
+ render(<AgentDock context="this generation queue" record={project()} providers={providers} onPromptStart={onPromptStart} onCommands={async () => undefined} />);
await act(async () => { await Promise.resolve(); });
- expect(screen.queryByRole("log", { name: "Slop output" })).not.toBeInTheDocument();
- expect(screen.queryByRole("button", { name: /Slop output/ })).not.toBeInTheDocument();
- expect(screen.queryByRole("combobox", { name: "Agent provider" })).not.toBeInTheDocument();
- expect(screen.getByRole("img", { name: "Codex status: Ready" })).toBeInTheDocument();
- expect(screen.getByRole("textbox", { name: "Ask Slop about this generation queue" })).toHaveAttribute("rows", "1");
-
- fireEvent.change(screen.getByRole("textbox", { name: "Ask Slop about this generation queue" }), { target: { value: "Create four shots" } });
- fireEvent.click(screen.getByRole("button", { name: "Send to Slop" }));
+ const field = screen.getByRole("textbox", { name: "Ask Slop about this generation queue" });
+ fireEvent.change(field, { target: { value: "Create four shots" } });
+ fireEvent.keyDown(field, { key: "Enter" });
await waitFor(() => expect(runAgentTurn).toHaveBeenCalled());
expect(onPromptStart).toHaveBeenCalledTimes(1);
- app.rerender(view(true));
const log = screen.getByRole("log", { name: "Slop output" });
- expect(screen.getByRole("heading", { name: "Agent" })).toBeInTheDocument();
expect(screen.getByRole("img", { name: "Codex status: Processing" })).toHaveClass("agent-provider--ready");
- expect(screen.getByRole("textbox", { name: "Ask Slop about this generation queue" })).toHaveAttribute("rows", "2");
- expect(screen.getByRole("combobox", { name: "Agent provider" })).toHaveTextContent("Codex");
- expect(screen.getByRole("combobox", { name: "Agent provider" })).not.toHaveTextContent("Ready");
- expect(log).toHaveTextContent("Create four shots");
- expect(log).not.toHaveTextContent("Sending this request to Codex");
- expect(screen.queryByRole("status")).not.toBeInTheDocument();
expect(screen.getByRole("combobox", { name: "Agent provider" })).toBeDisabled();
- expect(screen.getByLabelText("Waiting for the next agent response")).toBeInTheDocument();
+ expect(log).toHaveTextContent("Create four shots");
+ expect(within(log).getByText("You")).toBeInTheDocument();
+ const waiting = screen.getByLabelText("Waiting for the next agent response");
+ expect(within(waiting).getByRole("progressbar", { name: "Thinking" })).toBeInTheDocument();
Object.defineProperty(log, "scrollHeight", { configurable: true, value: 900 });
const requestId = vi.mocked(runAgentTurn).mock.calls[0][3];
act(() => eventHandler?.({ payload: { requestId, event: { type: "message", text: "{\"type\":\"item.completed\",\"item\":{\"type\":\"agent_message\",\"text\":\"{\\\"op\\\":\\\"scene.remove\\\",\\\"id\\\":\\\"old-scene\\\"}\\n{\\\"op\\\":\\\"commit\\\",\\\"summary\\\":\\\"Drafted the scene.\\\"}\"}}" } } }));
act(() => eventHandler?.({ payload: { requestId, event: { type: "validation", round: 1, maxRounds: 3, text: "Shot 4 starts at 18 seconds." } } }));
- expect(screen.getByRole("log", { name: "Slop output" })).toHaveTextContent("Drafted the scene.");
- expect(screen.getByRole("log", { name: "Slop output" })).toHaveTextContent("Correction 1 of 3: Shot 4 starts at 18 seconds.");
+ expect(log).toHaveTextContent("Drafted the scene.");
+ expect(log).toHaveTextContent("Correction 1 of 3: Shot 4 starts at 18 seconds.");
expect(screen.getByLabelText("Waiting for the next agent response")).toBe(log.lastElementChild);
expect(log.scrollTop).toBe(900);
- expect(screen.queryByRole("status")).not.toBeInTheDocument();
+
+ fireEvent.keyDown(screen.getByRole("button", { name: "Cancel agent turn" }), { key: "Escape" });
+ expect(cancelAgentTurn).toHaveBeenCalledWith(requestId);
await act(async () => finish({ result: { kind: "answer", content: "Done" }, events: [], messages: [] }));
- expect(screen.getByRole("img", { name: "Codex status: Ready" })).not.toHaveClass("agent-provider-light--busy");
+ expect(screen.getByRole("img", { name: "Codex status: Ready" })).toBeInTheDocument();
expect(screen.getByRole("combobox", { name: "Agent provider" })).toBeEnabled();
expect(screen.queryByLabelText("Waiting for the next agent response")).not.toBeInTheDocument();
+ expect(field).toHaveValue("");
+ fireEvent.keyDown(field, { key: "ArrowUp" });
+ expect(field).toHaveValue("Create four shots");
+ });
+
+ it("clears the conversation from the pane header", async () => {
+ vi.mocked(runAgentTurn).mockRejectedValue(new Error("Nope."));
+ render(<AgentDock context="this project" record={project()} providers={providers} onPromptStart={() => undefined} onCommands={async () => undefined} />);
+ await act(async () => { await Promise.resolve(); });
+ const clear = screen.getByRole("button", { name: "Clear conversation" });
+ expect(clear).toBeDisabled();
+ fireEvent.change(screen.getByRole("textbox", { name: "Ask Slop about this project" }), { target: { value: "Hi" } });
+ fireEvent.click(screen.getByRole("button", { name: "Send to Slop" }));
+ await screen.findByText(/Nope/);
+ fireEvent.click(clear);
+ expect(screen.queryByText(/Nope/)).not.toBeInTheDocument();
});
it("keeps a follow-up visible when the provider times out", async () => {
diff --git a/src/components/workspace/AgentDock.tsx b/src/components/workspace/AgentDock.tsx
index 879edc4..74f9151 100644
--- a/src/components/workspace/AgentDock.tsx
+++ b/src/components/workspace/AgentDock.tsx
@@ -1,6 +1,6 @@
import { listen } from "@tauri-apps/api/event";
-import { ArrowUp, Check, ChevronDown, LoaderCircle } from "lucide-react";
-import { useEffect, useId, useMemo, useRef, useState } from "react";
+import { ArrowUp, Eraser, Square, X } from "lucide-react";
+import { useEffect, useMemo, useRef, useState } from "react";
import { describeDiagnosticError, errorContext, writeDiagnostic } from "../../lib/diagnostics";
import { isTauri } from "../../lib/persistence";
import {
@@ -16,19 +16,30 @@ import {
import { loadAgentProvider, saveAgentProvider } from "../../lib/settings";
import type { ProjectRecord } from "../../lib/project";
import type { AgentMessage } from "../../lib/project";
+import { ComboBox, PaneHeader, ProgressRing, tooltipProps } from "../ui";
interface AgentActivity {
kind: "output" | "diagnostic" | "validation";
text: string;
}
-export function AgentDock({ context, record, providers, expanded, onPromptStart, onCommands }: {
+/** The agent as a docked tool pane: a 32px header (title, provider, clear,
+ * close), the conversation, and a flush text box with a send button.
+ *
+ * The pane container — its placement, splitter and show/hide — belongs to the
+ * workspace. `onClose` wires the header's close button to it; without it the
+ * button is not shown. `expanded` is accepted for compatibility and no longer
+ * changes the layout: the pane is always the full conversation. */
+export function AgentDock({ context, record, providers, onPromptStart, onCommands, onClose }: {
context: string;
record: ProjectRecord;
providers: ProviderStatus[];
- expanded: boolean;
+ /** @deprecated The dock is always a pane now; kept so callers need not change. */
+ expanded?: boolean;
onPromptStart: () => void;
onCommands: (commands: ProjectCommand[]) => Promise<void>;
+ /** Hide the pane (the header's × button). */
+ onClose?: () => void;
}) {
const configured = loadAgentProvider() ?? record.config.providerSettings.agent?.options.selectedProvider;
const initial = providers.some((item) => item.id === configured)
@@ -36,21 +47,26 @@ export function AgentDock({ context, record, providers, expanded, onPromptStart,
: providers.find((item) => item.state === "ready")?.id ?? "claude";
const [provider, setProvider] = useState<ProviderId>(initial);
const [prompt, setPrompt] = useState("");
+ const [lastPrompt, setLastPrompt] = useState<string | null>(null);
const [requestId, setRequestId] = useState<string | null>(null);
const [error, setError] = useState<string | null>(null);
const [activity, setActivity] = useState<AgentActivity[]>([]);
const [pendingPrompt, setPendingPrompt] = useState<string | null>(null);
const [sessionMessages, setSessionMessages] = useState<AgentMessage[]>([]);
- const [hasStarted, setHasStarted] = useState(false);
const activeRequest = useRef<string | null>(null);
const conversation = useRef<HTMLDivElement | null>(null);
+ const field = useRef<HTMLTextAreaElement | null>(null);
+ const cancelButton = useRef<HTMLButtonElement | null>(null);
const selected = providers.find((item) => item.id === provider);
const ready = selected?.state === "ready";
const messages = useMemo(() => sessionMessages.slice(-4), [sessionMessages]);
+ const empty = !messages.length && !pendingPrompt && !activity.length && !error && !requestId;
useEffect(() => {
setSessionMessages([]);
- setHasStarted(false);
+ setActivity([]);
+ setError(null);
+ setPendingPrompt(null);
}, [record.config.id]);
/* One listener lives for the dock's lifetime. A request id filters out any
@@ -80,14 +96,20 @@ export function AgentDock({ context, record, providers, expanded, onPromptStart,
useEffect(() => {
const panel = conversation.current;
- if (expanded && panel) panel.scrollTop = panel.scrollHeight;
- }, [activity, messages, error, expanded, pendingPrompt]);
+ if (panel) panel.scrollTop = panel.scrollHeight;
+ }, [activity, messages, error, pendingPrompt, requestId]);
+
+ /* The text box is disabled while a turn runs; keep the focus in the pane
+ (on the stop button) so Esc still reaches it. */
+ useEffect(() => {
+ if (requestId && document.activeElement === field.current) cancelButton.current?.focus();
+ }, [requestId]);
const blockedDetail = selected && !ready
? [selected.detail, providerNextStep(selected)].filter(Boolean).join(" ")
: null;
const placeholder = ready
- ? record.config.generationType === "image" ? "Ask Slop to compose an image, describe objects, or refine the layout…" : `Ask Slop to write a new scene from a prompt, refine ${context}, or make an edit…`
+ ? record.config.generationType === "image" ? "Ask Slop to compose an image or refine the layout" : `Ask Slop about ${context}`
: blockedDetail ?? "No agent provider is available";
const providerStatusLabel = requestId && selected
? `${selected.label} status: Processing`
@@ -98,13 +120,13 @@ export function AgentDock({ context, record, providers, expanded, onPromptStart,
const send = async () => {
const clean = prompt.trim();
if (!clean || !ready || requestId) return;
- setHasStarted(true);
onPromptStart();
const id = crypto.randomUUID();
activeRequest.current = id;
setRequestId(id);
setError(null);
setPendingPrompt(clean);
+ setLastPrompt(clean);
setActivity([]);
try {
const response = await runAgentTurn(record, provider, clean, id, sessionMessages);
@@ -119,150 +141,99 @@ export function AgentDock({ context, record, providers, expanded, onPromptStart,
} finally {
activeRequest.current = null;
setRequestId(null);
+ requestAnimationFrame(() => field.current?.focus());
}
};
-
- return (
- <div className={`agent-dock-wrap${expanded ? " agent-dock-wrap--expanded" : ""}${expanded && !hasStarted ? " agent-dock-wrap--welcome" : ""}`}>
- {expanded && !hasStarted && <h1 className="agent-welcome-title">What should we create today?</h1>}
- {expanded && hasStarted && <div className="agent-expanded-content">
- <h1 className="sr-only">Agent</h1>
- <div ref={conversation} className="agent-conversation" role="log" aria-label="Slop output" aria-live="polite">
- {messages.map((message) => <p key={message.id} className={`agent-conversation__${message.role}`}><b>{message.role === "user" ? "You" : "Slop"}</b><span>{message.content}</span></p>)}
- {pendingPrompt && <p className="agent-conversation__user agent-conversation__pending"><b>You</b><span>{pendingPrompt}</span></p>}
- {activity.map((item, index) => <p key={`${item.kind}-${index}`} className={`agent-conversation__${item.kind}`}>
- <b>{activityLabel(item.kind)}</b><span>{item.text}</span>
- </p>)}
- {error && <p className="agent-conversation__error"><b>Slop</b><span>Couldn’t finish that request. {error}</span></p>}
- {requestId && <p className="agent-conversation__waiting" aria-label="Waiting for the next agent response">
- <b>Slop</b><span className="agent-conversation__waiting-dots" aria-hidden="true"><i /><i /><i /></span>
- </p>}
- </div>
- </div>}
- <div className="agent-dock-row">
- <form className="agent-dock" onSubmit={(event) => { event.preventDefault(); void send(); }}>
- {!expanded && <span className={`agent-provider-light agent-provider--${selected?.state ?? "unknown"}`} role="img" aria-label={providerStatusLabel}><i /></span>}
- <textarea
- aria-label={`Ask Slop about ${context}`}
- rows={expanded ? 2 : 1}
- value={prompt}
- onChange={(event) => setPrompt(event.target.value)}
- onKeyDown={(event) => {
- if (event.key !== "Enter" || event.shiftKey || event.nativeEvent.isComposing) return;
- event.preventDefault();
- event.currentTarget.form?.requestSubmit();
- }}
- placeholder={placeholder}
- title={placeholder}
- disabled={!ready || Boolean(requestId)}
- />
- <div className="agent-dock__actions">
- {expanded && <AgentProviderSelector providers={providers} provider={provider} busy={Boolean(requestId)} statusLabel={providerStatusLabel} detail={blockedDetail} onChange={(next) => { setProvider(next); saveAgentProvider(next); }} />}
- {requestId
- ? <button type="button" className="agent-cancel" onClick={() => void cancelAgentTurn(requestId)} aria-label="Cancel agent turn"><LoaderCircle className="agent-busy" size={16} aria-hidden="true" /></button>
- : <button type="submit" disabled={!prompt.trim() || !ready} aria-label="Send to Slop" title={ready ? "Send to Slop — or press Enter" : blockedDetail ?? "No agent provider is available"}><ArrowUp size={16} /></button>}
- </div>
- </form>
- </div>
- </div>
- );
-}
-
-function AgentProviderSelector({ providers, provider, busy, statusLabel, detail, onChange }: {
- providers: ProviderStatus[];
- provider: ProviderId;
- busy: boolean;
- statusLabel: string;
- detail: string | null;
- onChange: (provider: ProviderId) => void;
-}) {
- const [open, setOpen] = useState(false);
- const [activeIndex, setActiveIndex] = useState(0);
- const root = useRef<HTMLDivElement>(null);
- const listId = useId();
- const selected = providers.find((item) => item.id === provider);
- const expanded = open && !busy;
-
- useEffect(() => {
- if (busy) setOpen(false);
- }, [busy]);
-
- useEffect(() => {
- if (!expanded) return;
- const close = (event: PointerEvent) => {
- if (!root.current?.contains(event.target as Node)) setOpen(false);
- };
- document.addEventListener("pointerdown", close);
- return () => document.removeEventListener("pointerdown", close);
- }, [expanded]);
-
- const show = () => {
- setActiveIndex(Math.max(0, providers.findIndex((item) => item.id === provider)));
- setOpen(true);
- };
- const pick = (item: ProviderStatus) => {
- if (busy) return;
- onChange(item.id);
- setOpen(false);
+ const cancel = () => { if (requestId) void cancelAgentTurn(requestId); };
+ const clear = () => {
+ setSessionMessages([]);
+ setActivity([]);
+ setError(null);
+ setPendingPrompt(null);
};
- return <div ref={root} className="agent-provider" title={detail ?? undefined}>
- <button
- type="button"
- className="agent-provider__trigger"
- role="combobox"
- aria-label="Agent provider"
- aria-expanded={expanded}
- aria-haspopup="listbox"
- aria-controls={expanded ? listId : undefined}
- aria-activedescendant={expanded && providers[activeIndex] ? `${listId}-${activeIndex}` : undefined}
- disabled={busy}
- onClick={() => expanded ? setOpen(false) : show()}
- onBlur={() => setOpen(false)}
+ return (
+ <div
+ className="agent-dock"
onKeyDown={(event) => {
- if (event.key === "ArrowDown" || event.key === "ArrowUp") {
+ // Esc stops a running turn, from anywhere in the pane.
+ if (event.key === "Escape" && requestId && !event.defaultPrevented) {
event.preventDefault();
- if (!expanded) show();
- else if (providers.length) setActiveIndex((index) => (index + (event.key === "ArrowDown" ? 1 : -1) + providers.length) % providers.length);
- } else if (expanded && (event.key === "Home" || event.key === "End")) {
- event.preventDefault();
- setActiveIndex(event.key === "Home" ? 0 : providers.length - 1);
- } else if (expanded && (event.key === "Enter" || event.key === " ")) {
- event.preventDefault();
- if (providers[activeIndex]) pick(providers[activeIndex]);
- } else if (event.key === "Escape" && expanded) {
- event.preventDefault();
- event.stopPropagation();
- setOpen(false);
- } else if (event.key === "Tab") setOpen(false);
+ cancel();
+ }
}}
>
- <span className={`agent-provider-light agent-provider--${selected?.state ?? "unknown"}`} role="img" aria-label={statusLabel}><i /></span>
- <span className="agent-provider__name">{selected?.label ?? "Choose LLM"}</span>
- <ChevronDown size={14} aria-hidden="true" />
- </button>
- {expanded && <div id={listId} className="agent-provider__options" role="listbox" aria-label="Agent providers">
- {providers.map((item, index) => <div
- key={item.id}
- id={`${listId}-${index}`}
- role="option"
- aria-selected={item.id === provider}
- className={`agent-provider__option${index === activeIndex ? " agent-provider__option--active" : ""}`}
- onMouseDown={(event) => event.preventDefault()}
- onMouseMove={() => setActiveIndex(index)}
- onClick={() => pick(item)}
- >
- <span className={`agent-provider-light agent-provider--${item.state}`} aria-hidden="true"><i /></span>
- <span>{item.label}</span>
- {item.id === provider && <Check size={14} aria-hidden="true" />}
- </div>)}
- </div>}
- </div>;
+ <PaneHeader
+ title="Agent"
+ className="agent-dock__header"
+ actions={<>
+ <span className={`agent-provider-light agent-provider--${selected?.state ?? "unknown"}`} role="img" aria-label={providerStatusLabel} data-tooltip={blockedDetail ?? providerStatusLabel}><i /></span>
+ <ComboBox
+ className="agent-provider"
+ aria-label="Agent provider"
+ value={provider}
+ disabled={Boolean(requestId) || !providers.length}
+ placeholder="Choose LLM"
+ options={providers.map((item) => ({
+ value: item.id,
+ label: item.label,
+ icon: <span className={`agent-provider-light agent-provider--${item.state}`}><i /></span>,
+ description: item.state === "ready" ? undefined : providerStateLabel(item.state),
+ }))}
+ onChange={(next) => { setProvider(next as ProviderId); saveAgentProvider(next as ProviderId); }}
+ />
+ <button type="button" className="icon-button agent-dock__action" aria-label="Clear conversation" {...tooltipProps("Clear conversation")} disabled={Boolean(requestId) || empty} onClick={clear}><Eraser size={16} aria-hidden="true" /></button>
+ {onClose && <button type="button" className="icon-button agent-dock__action" aria-label="Close agent" {...tooltipProps("Close")} onClick={onClose}><X size={16} aria-hidden="true" /></button>}
+ </>}
+ />
+ <div ref={conversation} className="agent-conversation" role="log" aria-label="Slop output" aria-live="polite">
+ {empty && <p className="agent-conversation__empty">Ask Slop to write scenes from a prompt, refine shots or edit {context}.</p>}
+ {messages.map((message) => <p key={message.id} className={`agent-conversation__${message.role}`}><b>{message.role === "user" ? "You" : "Slop"}</b><span>{message.content}</span></p>)}
+ {pendingPrompt && <p className="agent-conversation__user agent-conversation__pending"><b>You</b><span>{pendingPrompt}</span></p>}
+ {activity.map((item, index) => <p key={`${item.kind}-${index}`} className={`agent-conversation__${item.kind}`}>
+ <b>{activityLabel(item.kind)}</b><span>{item.text}</span>
+ </p>)}
+ {error && <p className="agent-conversation__error"><b>Slop</b><span>Couldn’t finish that request. {error}</span></p>}
+ {requestId && <p className="agent-conversation__waiting" aria-label="Waiting for the next agent response">
+ <b>Slop</b><span className="agent-conversation__thinking"><ProgressRing size={16} aria-label="Thinking" /><span aria-hidden="true">Thinking…</span></span>
+ </p>}
+ </div>
+ <form className="agent-composer" onSubmit={(event) => { event.preventDefault(); void send(); }}>
+ <textarea
+ ref={field}
+ className="text-field agent-composer__field"
+ aria-label={`Ask Slop about ${context}`}
+ aria-keyshortcuts="Enter Shift+Enter ArrowUp Escape"
+ rows={2}
+ value={prompt}
+ onChange={(event) => setPrompt(event.target.value)}
+ onKeyDown={(event) => {
+ if (event.nativeEvent.isComposing) return;
+ // Up in an empty box brings back the last prompt, like a shell.
+ if (event.key === "ArrowUp" && !prompt && lastPrompt) {
+ event.preventDefault();
+ setPrompt(lastPrompt);
+ return;
+ }
+ if (event.key !== "Enter" || event.shiftKey) return;
+ event.preventDefault();
+ event.currentTarget.form?.requestSubmit();
+ }}
+ placeholder={placeholder}
+ data-tooltip={ready ? undefined : placeholder}
+ disabled={!ready || Boolean(requestId)}
+ />
+ {requestId
+ ? <button ref={cancelButton} type="button" className="agent-composer__send agent-cancel" onClick={cancel} aria-label="Cancel agent turn" aria-keyshortcuts="Escape" {...tooltipProps("Stop", "Esc")}><Square size={14} aria-hidden="true" /></button>
+ : <button type="submit" className="agent-composer__send" disabled={!prompt.trim() || !ready} aria-label="Send to Slop" aria-keyshortcuts="Enter" {...tooltipProps(ready ? "Send" : blockedDetail ?? "No agent provider is available", ready ? "Enter" : undefined)}><ArrowUp size={16} aria-hidden="true" /></button>}
+ </form>
+ </div>
+ );
}
const activityLabel = (kind: AgentActivity["kind"]): string => {
switch (kind) {
- case "output": return "LLM";
+ case "output": return "Slop";
case "validation": return "Validator";
case "diagnostic": return "Error";
}
diff --git a/src/styles/agent-dock.css b/src/styles/agent-dock.css
index 9c8fe3a..9eca4d5 100644
--- a/src/styles/agent-dock.css
+++ b/src/styles/agent-dock.css
@@ -1,316 +1,46 @@
/* ============================================================================
- agent-dock.css — the agent dock, its provider selector and conversation.
- Split out of workspace.css.
+ agent-dock.css — the agent as a docked tool pane: a 32px pane header
+ (title, provider status and ComboBox, clear, close), the conversation, and a
+ flush text box with a send button. No glass, shadow, glow or halo: it is a
+ pane like the inspectors, sitting on the same layer. The pane container
+ (placement, splitter, show/hide) is the workspace's (.project-agent-pane).
========================================================================== */
-/* --- Agent dock ------------------------------------------------------------ */
-
-.project-agent-row {
- position: relative;
- z-index: 30;
- min-width: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: var(--space-3) var(--space-5);
- height: calc(var(--control-lg) + var(--space-5) + 1px);
- border-top: 1px solid var(--line-solid);
- background: var(--panel);
- transition: height var(--motion-panel) var(--ease-decelerate);
-}
-
-/* The Agent tab owns the workspace below the project top bar. Its height is
- stable; additional output scrolls inside it instead of repeatedly resizing
- the editor behind it. Use the app background here so the space around the
- conversation does not become a second grey panel. */
-.project-agent-row--page {
- height: calc(100vh - var(--topbar-height));
- height: calc(100dvh - var(--topbar-height));
- min-height: 0;
- align-items: stretch;
- border-top-color: transparent;
- background: var(--bg);
- box-shadow: none;
-}
-
-/* The settings launcher is fixed over the bottom-left corner, which is this
- row. The dock stays CENTRED and gives up width instead of shifting right —
- an off-centre dock reads as a layout bug, a narrower one does not. 256px is
- twice the launcher's widest measure, so the reserve is symmetric. */
-.agent-dock-wrap {
- position: relative;
- width: min(880px, calc(100% - 256px));
- display: flex;
- min-height: var(--control-lg);
- flex-direction: column;
- justify-content: flex-end;
-}
-
-.agent-dock-wrap--expanded {
+.agent-dock {
height: 100%;
+ min-width: 0;
min-height: 0;
-}
-
-/* Before the first turn, equal flexible tracks above and below the composer
- put the prompt itself at the page's vertical centre. The welcome heading
- lives at the foot of the upper track, so it does not push the prompt down.
- After submit, this modifier disappears and the existing flex layout
- naturally pins the composer beneath the conversation. */
-.agent-dock-wrap--welcome {
- display: grid;
- grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
- justify-content: stretch;
-}
-
-.agent-dock-wrap--welcome .agent-welcome-title {
- grid-row: 1;
- align-self: end;
- margin-bottom: var(--space-5);
-}
-
-.agent-dock-wrap--welcome .agent-dock-row {
- grid-row: 2;
-}
-
-.agent-welcome-title {
- margin: 0;
- color: var(--text-primary);
- font-size: var(--text-2xl);
- font-weight: var(--weight-semibold);
- line-height: var(--leading-tight);
- text-align: center;
-}
-
-.agent-expanded-content {
- min-height: 0;
- flex: 0 1 0;
display: flex;
flex-direction: column;
- overflow: hidden;
- opacity: 0;
- visibility: hidden;
- transform: translateY(6px);
- transition:
- flex-grow var(--motion-panel) var(--ease-decelerate),
- opacity var(--motion-normal) linear,
- transform var(--motion-panel) var(--ease-decelerate),
- visibility 0s linear var(--motion-panel);
-}
-
-.agent-dock-wrap--expanded .agent-expanded-content {
- flex-grow: 1;
- opacity: 1;
- visibility: visible;
- transform: translateY(0);
- transition-delay: 0s;
+ background: var(--layer);
}
-.agent-dock-row {
- min-width: 0;
+.agent-dock__header {
flex: 0 0 auto;
- display: flex;
- align-items: center;
- gap: var(--space-2);
-}
-
-.agent-dock {
- height: var(--control-lg);
- min-width: 0;
- flex: 1 1 auto;
- display: flex;
- align-items: center;
- gap: var(--space-3);
- padding: 0 var(--space-2) 0 var(--space-3);
- border: 1px solid var(--stroke-control);
- border-bottom-color: var(--stroke-strong);
- border-radius: var(--radius-lg);
- background: var(--dock-bg);
-}
-
-/* The dock is a text field: focus is the Fluent TextBox underline (a 2px
- accent bottom edge, drawn as border + 1px inset so nothing shifts), never
- a halo. */
-.agent-dock:focus-within {
- border-bottom-color: var(--field-focus-line);
- box-shadow: inset 0 -1px 0 var(--field-focus-line);
+ border-bottom: 1px solid var(--line);
}
-/* The full Agent composer has three visual rows: two for the prompt and one
- for controls. The compact dock remains one line tall everywhere else. */
-.agent-dock-wrap--expanded .agent-dock {
- height: auto;
- min-height: 103px;
- display: grid;
- grid-template-columns: minmax(0, 1fr);
- grid-template-rows: 45px var(--control-sm);
- gap: var(--space-2);
- padding-block: var(--space-2);
-}
-
-/* The placeholder carries real guidance (and, when Slop is blocked, the reason
- plus the fix), so it must taper off with an ellipsis instead of being sliced
- through the middle of a word. The full text stays in the field's title. */
-.agent-dock textarea {
+.agent-dock__header .ui-pane-header__actions {
min-width: 0;
- flex: 1 1 0;
- height: 1.5em;
- padding: 0;
- border: 0;
- outline: 0;
- box-shadow: none; /* .agent-dock draws the underline */
- color: var(--text-primary);
- background: none;
- font-family: inherit;
- font-size: var(--text-base);
- line-height: var(--leading-normal);
- resize: none;
- overflow-y: hidden;
- text-overflow: ellipsis;
-}
-
-.agent-dock-wrap--expanded .agent-dock textarea {
- width: 100%;
- height: 100%;
- padding: var(--space-2) var(--space-3);
- overflow-y: auto;
-}
-
-.agent-dock textarea::placeholder {
- color: var(--text-faint);
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.agent-dock__actions {
- min-width: 0;
- flex: 0 0 auto;
display: flex;
align-items: center;
- gap: var(--space-2);
- justify-content: flex-end;
-}
-
-.agent-dock-wrap--expanded .agent-dock__actions {
- justify-self: end;
+ gap: 2px;
}
-.agent-dock button {
+.agent-dock__action.icon-button {
width: var(--control-sm);
height: var(--control-sm);
- flex: 0 0 auto;
- display: grid;
- place-items: center;
- padding: 0;
- border: 1px solid var(--dock-send-border);
- border-radius: var(--radius-sm);
- color: var(--on-accent);
- background: var(--accent-fill);
-}
-
-.agent-dock button:disabled {
- color: var(--text-faint);
- border-color: var(--line-solid);
- background: var(--panel-3);
-}
-
-.agent-dock .agent-cancel {
- border-color: var(--danger-line-strong);
- color: var(--danger);
- background: var(--danger-soft);
}
-.agent-busy {
- flex: 0 0 auto;
- color: var(--danger);
- animation: spin 1.2s linear infinite;
-}
-
-/* --- Provider selector ----------------------------------------------------- */
-
-.agent-provider {
- position: relative;
- flex: 0 0 auto;
-}
-
-.agent-dock .agent-provider__trigger {
+/* A compact provider picker in the header. */
+.ui-combo.agent-provider {
+ min-width: 0;
width: auto;
- max-width: 250px;
+ max-width: 160px;
+ height: var(--control-sm);
min-height: var(--control-sm);
- display: flex;
- align-items: center;
- gap: var(--space-2);
- padding: 0 var(--space-2);
- border: 1px solid var(--line);
- border-radius: var(--radius-sm);
- color: var(--text-secondary);
- background: var(--wash-1);
- box-shadow: none;
- font-size: var(--text-sm);
- font-weight: var(--weight-semibold);
-}
-
-.agent-dock .agent-provider__trigger:hover:not(:disabled),
-.agent-dock .agent-provider__trigger[aria-expanded="true"] {
- border-color: var(--line-hover);
- color: var(--text-primary);
- background: var(--wash-2);
-}
-
-.agent-provider__name {
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.agent-provider__trigger > svg {
- flex: 0 0 auto;
- color: var(--text-muted);
-}
-
-.agent-dock .agent-provider__trigger:disabled {
- color: var(--text-faint);
- background: var(--panel-3);
-}
-
-.agent-provider__trigger:disabled .agent-provider__name,
-.agent-provider__trigger:disabled > svg {
- opacity: 0.6;
-}
-
-.agent-provider__options {
- position: absolute;
- right: 0;
- bottom: calc(100% + var(--space-2));
- z-index: 30;
- min-width: 180px;
- padding: var(--space-1);
- border: 1px solid var(--stroke-surface);
- border-radius: var(--radius-lg);
- background: var(--acrylic);
- backdrop-filter: var(--acrylic-filter);
- box-shadow: var(--shadow-sm);
-}
-
-.agent-provider__option {
- display: grid;
- grid-template-columns: 8px minmax(0, 1fr) 14px;
- align-items: center;
- gap: var(--space-2);
- min-height: var(--control-md);
- padding: var(--space-2) var(--space-3);
- border-radius: var(--radius-sm);
- color: var(--text-secondary);
- font-size: var(--text-sm);
-}
-
-.agent-provider__option[aria-selected="true"] {
- color: var(--accent-bright);
-}
-
-.agent-provider__option--active {
- background: var(--wash-2);
+ margin-left: var(--space-1);
+ font-size: var(--text-xs);
}
.agent-provider-light {
@@ -330,53 +60,39 @@
}
/* Provider state is real information — every state gets a truthful colour. */
-.agent-provider--ready i {
- background: var(--success);
-}
+.agent-provider--ready i { background: var(--success); }
.agent-provider--authRequired i,
.agent-provider--notInstalled i {
background: var(--warning);
}
-.agent-provider--unavailable i {
- background: var(--danger);
-}
+.agent-provider--unavailable i { background: var(--danger); }
.agent-provider--disabled i,
.agent-provider--unknown i {
background: var(--text-faint);
}
-/* --- Conversation overlay -------------------------------------------------- */
+/* --- Conversation ------------------------------------------------------------ */
.agent-conversation {
user-select: text;
min-height: 0;
flex: 1 1 auto;
- overflow: auto;
- margin-bottom: var(--space-3);
- padding: var(--space-2);
- border: 1px solid var(--stroke-surface);
- border-radius: var(--radius-lg);
- /* A flyout over the workspace, so it is one of the few surfaces allowed
- acrylic (tokens.css rule 11). */
- background: var(--acrylic);
- box-shadow: var(--shadow-sm);
- backdrop-filter: var(--acrylic-filter);
-}
-
-.agent-dock-wrap--expanded .agent-conversation {
- background: var(--bg);
+ display: flex;
+ flex-direction: column;
+ gap: var(--space-3);
+ overflow-y: auto;
+ padding: var(--space-2) var(--space-3);
}
.agent-conversation p {
- display: grid;
- grid-template-columns: 80px minmax(0, 1fr);
- gap: var(--space-3);
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
margin: 0;
- padding: var(--space-3);
- color: var(--text-secondary);
+ color: var(--text-primary);
font-size: var(--text-base);
line-height: var(--leading-normal);
}
@@ -387,85 +103,100 @@
overflow-wrap: anywhere;
}
-.agent-conversation p + p {
- border-top: 1px solid var(--line);
-}
-
+/* Speaker labels: 12px semibold, sentence case, secondary ink. */
.agent-conversation b {
- color: var(--accent-bright);
+ color: var(--text-secondary);
font-size: var(--text-xs);
font-weight: var(--weight-semibold);
- line-height: var(--leading-normal);
+ line-height: var(--leading-snug);
}
-.agent-conversation__user b {
- color: var(--text-muted);
+.agent-conversation__pending > span {
+ color: var(--text-secondary);
}
-.agent-conversation__assistant b {
- color: var(--accent-bright);
+.agent-conversation__validation > span {
+ color: var(--warning);
}
-.agent-conversation__output b {
- color: var(--accent-bright);
+.agent-conversation__diagnostic > span,
+.agent-conversation__error > span {
+ color: var(--danger);
}
-.agent-conversation__validation,
-.agent-conversation__validation b {
- color: var(--warning);
+.agent-conversation p.agent-conversation__empty {
+ color: var(--text-muted);
+ font-size: var(--text-xs);
}
-.agent-conversation__system,
-.agent-conversation__empty {
- color: var(--text-muted);
+.agent-conversation__thinking {
+ display: inline-flex;
+ align-items: center;
+ gap: var(--space-2);
+ color: var(--text-secondary);
+ font-size: var(--text-xs);
}
-.agent-conversation__error,
-.agent-conversation__error b {
- color: var(--danger) !important;
+/* --- Composer -------------------------------------------------------------------
+ A flush TextBox (4px corners, the accent underline on focus) with the send
+ button beside it. */
+
+.agent-composer {
+ flex: 0 0 auto;
+ display: flex;
+ align-items: flex-end;
+ gap: var(--space-1);
+ padding: var(--space-2);
+ border-top: 1px solid var(--line);
}
-/* "Waiting for a reply" is a 16px Fluent ProgressRing, not three bouncing
- dots. The markup still renders the three <i>s; they are hidden and the
- ring is drawn by the wrapper itself, the same arc as .progress-ring. */
-.agent-conversation__waiting-dots {
- min-height: 1.5em;
- display: inline-flex;
- align-items: center;
- color: var(--accent-bright);
+.agent-composer__field.text-field {
+ min-width: 0;
+ flex: 1 1 auto;
+ height: auto;
+ min-height: 56px;
+ max-height: 200px;
+ padding: 6px var(--space-2);
+ font-family: inherit;
+ line-height: var(--leading-normal);
+ resize: vertical;
}
-.agent-conversation__waiting-dots::before {
- content: "";
- width: 16px;
- height: 16px;
- border: 2px solid transparent;
- border-top-color: currentColor;
- border-right-color: currentColor;
- border-radius: 50%;
- animation: spin 0.9s linear infinite;
+.agent-composer__field::placeholder {
+ color: var(--text-muted);
}
-.agent-conversation__waiting-dots i {
- display: none;
+.agent-composer__send {
+ width: var(--icon-button);
+ height: var(--icon-button);
+ flex: 0 0 auto;
+ display: grid;
+ place-items: center;
+ padding: 0;
+ border: 1px solid var(--button-primary-stroke);
+ border-bottom-color: var(--button-primary-stroke-bottom);
+ border-radius: var(--radius-sm);
+ color: var(--on-accent);
+ background: var(--button-primary-bg);
+ transition: var(--transition-control);
}
-@media (prefers-reduced-motion: reduce) {
- .project-agent-row,
- .agent-expanded-content {
- transition: none;
- }
+.agent-composer__send:hover:not(:disabled) {
+ background: var(--button-primary-hover);
+}
- /* Keep processing feedback moving even when decorative motion is reduced.
- These override the global reduced-motion animation reset in base.css. */
- .agent-busy {
- animation-duration: 1.2s !important;
- animation-iteration-count: infinite !important;
- }
+.agent-composer__send:disabled {
+ border-color: transparent;
+ color: var(--button-primary-off-ink);
+ background: var(--button-primary-off-bg);
+}
- .agent-conversation__waiting-dots::before {
- animation-duration: 0.9s !important;
- animation-iteration-count: infinite !important;
- }
+.agent-composer__send.agent-cancel {
+ border-color: var(--stroke-control);
+ color: var(--text-primary);
+ background: var(--fill-control);
}
+.agent-composer__send.agent-cancel:hover {
+ background: var(--fill-control-hover);
+}
diff --git a/src/styles/generator.css b/src/styles/generator.css
index 380427b..69a74c4 100644
--- a/src/styles/generator.css
+++ b/src/styles/generator.css
@@ -13,10 +13,11 @@
breakpoints any more: a narrow window narrows the board, and the splitter
is how the inspector gets out of the way. */
.generator-view {
+ --pane-generator-inspector: 380px; /* usePaneSize sets the real width inline */
height: 100%;
min-height: 0;
display: grid;
- grid-template-columns: minmax(0, 1fr) auto var(--pane-generator-inspector, 380px);
+ grid-template-columns: minmax(0, 1fr) auto var(--pane-generator-inspector);
background: var(--layer);
}
diff --git a/src/styles/image-editor.css b/src/styles/image-editor.css
index b91403e..8b7432c 100644
--- a/src/styles/image-editor.css
+++ b/src/styles/image-editor.css
@@ -6,7 +6,7 @@
========================================================================== */
.project-content--editor { padding: 0; overflow: hidden; }
-.image-editor { display: grid; grid-template-columns: var(--pane-image-tree, 240px) auto minmax(0, 1fr) auto var(--pane-image-inspector, 300px); height: 100%; min-height: 0; background: var(--layer); }
+.image-editor { --pane-image-tree: 240px; --pane-image-inspector: 300px; display: grid; grid-template-columns: var(--pane-image-tree) auto minmax(0, 1fr) auto var(--pane-image-inspector); height: 100%; min-height: 0; background: var(--layer); }
.image-tree, .image-inspector { min-width: 0; min-height: 0; overflow: auto; background: var(--panel); }
.image-tree { display: flex; flex-direction: column; }
.image-tree > .ui-pane-header, .image-inspector > .ui-pane-header { flex-shrink: 0; border-bottom: 1px solid var(--line); }
diff --git a/src/styles/references.css b/src/styles/references.css
index afaaa62..38e3f98 100644
--- a/src/styles/references.css
+++ b/src/styles/references.css
@@ -12,10 +12,11 @@
user's (usePaneSize → --pane-references-inspector); there are no width
breakpoints, so a narrow window narrows the library instead. */
.references-view {
+ --pane-references-inspector: 380px; /* usePaneSize sets the real width inline */
height: 100%;
min-height: 0;
display: grid;
- grid-template-columns: minmax(0, 1fr) auto var(--pane-references-inspector, 380px);
+ grid-template-columns: minmax(0, 1fr) auto var(--pane-references-inspector);
background: var(--layer);
}