Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(agentic-ide): stop a right-click from selecting a terminal

Ruben Lütke3b852dd73de1
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
index 20391de8b7..a5fba39000 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
@@ -21,10 +21,19 @@ vi.mock("@/store/events", () => ({
vi.mock("@/lib/agenticIdeApi", () => ({
addTerminal: vi.fn(),
+ attachToTerminal: vi.fn(),
closeTerminal: vi.fn(),
closeTerminals: vi.fn(),
composePrompt: vi.fn(),
+ // Polled by the grid so the pane headers keep saying what their agents are
+ // doing. Resolves empty by default; the recap tests give it real rows.
+ fetchTerminalRecaps: vi.fn(async () => ({
+ workspace_id: "ide_test",
+ terminals: [],
+ })),
promptTerminal: vi.fn(),
+ // Reached from the toolbar's settings panel, which the grid always renders.
+ setIdeActiveAccount: vi.fn(),
}));
// The grid follows the app theme for its terminal colours; these tests render
@@ -44,6 +53,8 @@ vi.mock("./AgenticTerminal", () => ({
maximized,
splitDisabled,
restartToken,
+ recap,
+ recapDetail,
onRestart,
agents,
onToggleMaximize,
@@ -54,6 +65,8 @@ vi.mock("./AgenticTerminal", () => ({
maximized?: boolean;
splitDisabled?: boolean;
restartToken?: number;
+ recap?: string;
+ recapDetail?: string;
onRestart?: () => void;
agents?: Array<{ name: string }>;
onToggleMaximize?: () => void;
@@ -65,6 +78,8 @@ vi.mock("./AgenticTerminal", () => ({
data-maximized={maximized ? "yes" : "no"}
data-agents={(agents ?? []).map((a) => a.name).join(",")}
data-restart-token={String(restartToken ?? 0)}
+ data-recap={recap ?? ""}
+ data-recap-detail={recapDetail ?? ""}
>
{name}
<button data-testid={`pane-maximize-${name}`} onClick={onToggleMaximize}>
@@ -186,6 +201,24 @@ beforeEach(() => {
files: [],
submitted: true,
});
+ vi.mocked(api.attachToTerminal).mockResolvedValue({
+ terminal: "Mika",
+ references: ["@.jarvis/drops/shot.png"],
+ files: ["shot.png"],
+ copied: 1,
+ submitted: false,
+ delivered: false,
+ analysis: [
+ {
+ name: "shot.png",
+ reference: "@.jarvis/drops/shot.png",
+ kind: "image",
+ detail: "A login dialog whose submit button overflows its container.",
+ described_by: "vision",
+ note: "",
+ },
+ ],
+ });
});
afterEach(() => {
@@ -270,6 +303,50 @@ describe("pane actions", () => {
);
});
+ it("keeps a plain terminal out of the prompt bar's targets", () => {
+ // A plain terminal is a shell prompt: Jarvis does not type into one, so
+ // offering it as a target would promise a delivery that is always refused.
+ const session = sessionWith([
+ ["Mika", 0],
+ ["Nova", 1],
+ ]);
+ session.terminals[1] = {
+ ...session.terminals[1],
+ agent: "shell",
+ display_name: "Plain Terminal",
+ accepts_prompts: false,
+ };
+ renderGrid(session);
+
+ expect(screen.getByRole("button", { name: /^Mika/ })).toBeTruthy();
+ expect(screen.queryByRole("button", { name: /^Nova live$/ })).toBeNull();
+ // The agent pane, not the shell, is what the prompt goes to.
+ expect(screen.getByPlaceholderText(/instruction for Mika/i)).toBeTruthy();
+ });
+
+ it("does not make a new plain terminal the prompt target", async () => {
+ const next = sessionWith([
+ ["Mika", 0],
+ ["Aria", 1],
+ ["Nova", 2],
+ ]);
+ next.terminals[1] = {
+ ...next.terminals[1],
+ agent: "shell",
+ display_name: "Plain Terminal",
+ accepts_prompts: false,
+ };
+ vi.mocked(api.addTerminal).mockResolvedValue(next);
+ renderGrid();
+
+ fireEvent.click(screen.getByTestId("pane-split-right-Mika"));
+
+ await waitFor(() => expect(api.addTerminal).toHaveBeenCalled());
+ // The prompt bar stays pointed at the agent it was on — a shell pane that
+ // stole the target would silently swallow the next instruction.
+ expect(screen.getByPlaceholderText(/instruction for Mika/i)).toBeTruthy();
+ });
+
it("reports a refused split instead of pretending it worked", async () => {
vi.mocked(api.addTerminal).mockRejectedValue(
new Error("This workspace already has the maximum of 12 terminals."),
@@ -473,18 +550,32 @@ describe("selecting several terminals", () => {
expect(screen.getByText("Selected: 0")).toBeTruthy();
});
- it("right-clicking a pane enters selection mode and marks it immediately", () => {
+ it("never enters selection mode on a right-click", () => {
renderGrid();
- fireEvent.contextMenu(screen.getByTestId("pane-cell-Nova"));
+ // The pane keeps the right button for the app-wide Cut/Copy/Paste menu, so
+ // the event must also survive untouched rather than being swallowed here.
+ const reached = fireEvent.contextMenu(screen.getByTestId("pane-cell-Nova"));
+ expect(reached).toBe(true);
expect(
screen.getByTestId("terminal-selection-toggle").getAttribute("aria-pressed"),
- ).toBe("true");
+ ).toBe("false");
+ expect(screen.queryByTestId("terminal-selection-actions")).toBeNull();
+ expect(screen.queryByTestId("select-terminal-Nova")).toBeNull();
+ });
+
+ it("does nothing at all on a right-click while selection mode is on", () => {
+ renderGrid();
+ fireEvent.click(screen.getByTestId("terminal-selection-toggle"));
+
+ const reached = fireEvent.contextMenu(screen.getByTestId("select-terminal-Nova"));
+
+ expect(reached).toBe(false);
expect(
screen.getByTestId("select-terminal-Nova").getAttribute("aria-pressed"),
- ).toBe("true");
- expect(screen.getByText("Selected: 1")).toBeTruthy();
+ ).toBe("false");
+ expect(screen.getByText("Selected: 0")).toBeTruthy();
});
it("select all marks every terminal with one click", () => {
@@ -556,7 +647,8 @@ describe("selecting several terminals", () => {
it("keeps every selected terminal open when confirmation is cancelled", async () => {
renderGrid();
- fireEvent.contextMenu(screen.getByTestId("pane-cell-Mika"));
+ fireEvent.click(screen.getByTestId("terminal-selection-toggle"));
+ fireEvent.click(screen.getByTestId("select-terminal-Mika"));
fireEvent.click(screen.getByTestId("close-selected-terminals"));
fireEvent.click(screen.getByRole("button", { name: "Keep them open" }));
@@ -681,7 +773,9 @@ describe("the prompt bar composes before it sends", () => {
type("run the tests");
await waitFor(() => expect(screen.getByTestId("prompt-preview")).toBeTruthy());
- expect(api.composePrompt).toHaveBeenCalledWith("Mika", "run the tests");
+ // The third argument is the dropped-file list — empty here, because this
+ // instruction was typed with nothing attached.
+ expect(api.composePrompt).toHaveBeenCalledWith("Mika", "run the tests", []);
expect(api.promptTerminal).not.toHaveBeenCalled();
});
@@ -693,7 +787,13 @@ describe("the prompt bar composes before it sends", () => {
fireEvent.click(screen.getByTestId("prompt-preview-send"));
await waitFor(() =>
- expect(api.promptTerminal).toHaveBeenCalledWith("Mika", "## Task\nRun the tests."),
+ expect(api.promptTerminal).toHaveBeenCalledWith(
+ "Mika",
+ "## Task\nRun the tests.",
+ // Nothing carried alongside: the composed text already contains
+ // whatever was dropped, so sending it again would duplicate it.
+ { attachments: [] },
+ ),
);
});
@@ -705,7 +805,9 @@ describe("the prompt bar composes before it sends", () => {
fireEvent.click(screen.getByTestId("prompt-preview-verbatim"));
await waitFor(() =>
- expect(api.promptTerminal).toHaveBeenCalledWith("Mika", "run the tests"),
+ expect(api.promptTerminal).toHaveBeenCalledWith("Mika", "run the tests", {
+ attachments: [],
+ }),
);
});
@@ -729,11 +831,159 @@ describe("the prompt bar composes before it sends", () => {
type("run the tests");
await waitFor(() =>
- expect(api.promptTerminal).toHaveBeenCalledWith("Mika", "run the tests"),
+ expect(api.promptTerminal).toHaveBeenCalledWith("Mika", "run the tests", {
+ attachments: [],
+ }),
);
});
});
+/*
+ * Dropping a screenshot on the prompt bar.
+ *
+ * This is the gesture the whole feature exists for, and its failure mode is
+ * quiet: a user drops a picture of a broken layout, types "fix this", and the
+ * agent — which frequently cannot open an image at all — receives a path and a
+ * pronoun. So what is pinned here is that the CONTENTS of the file reach the
+ * composition, not merely that a drop was accepted.
+ */
+describe("dropping files on the prompt bar", () => {
+ /** A DataTransfer stand-in; jsdom cannot construct a real one. */
+ function transfer(types: string[]) {
+ return {
+ types,
+ files: [],
+ items: [],
+ dropEffect: "none",
+ getData: (kind: string) =>
+ kind === "text/uri-list" ? "file:///C:/work/shot.png" : "",
+ } as unknown as DataTransfer;
+ }
+
+ const drop = (types: string[] = ["Files"]) =>
+ fireEvent.drop(screen.getByTestId("agentic-composer"), {
+ dataTransfer: transfer(types),
+ });
+
+ it("reads the dropped file instead of typing its path into the pane", async () => {
+ renderGrid();
+
+ drop();
+
+ await waitFor(() => expect(api.attachToTerminal).toHaveBeenCalled());
+ const [name, payload] = vi.mocked(api.attachToTerminal).mock.calls[0];
+ expect(name).toBe("Mika");
+ expect(payload.analyze).toBe(true);
+ // Held rather than typed: the user is still writing the sentence that
+ // explains the file, and it goes in with that sentence.
+ expect(payload.deliver).toBe(false);
+ expect(payload.paths).toEqual(["C:/work/shot.png"]);
+ });
+
+ it("shows what was read out of the file, not just its name", async () => {
+ renderGrid();
+
+ drop();
+
+ await waitFor(() => expect(screen.getByTestId("agentic-attachments")).toBeTruthy());
+ const strip = screen.getByTestId("agentic-attachments");
+ expect(strip.textContent).toContain("shot.png");
+ expect(strip.textContent).toContain("described");
+ });
+
+ it("carries the analysis into the composition", async () => {
+ renderGrid();
+ drop();
+ await waitFor(() => expect(screen.getByTestId("agentic-attachments")).toBeTruthy());
+
+ const box = screen.getByPlaceholderText(/instruction for Mika/i);
+ fireEvent.change(box, { target: { value: "fix this" } });
+ fireEvent.keyDown(box, { key: "Enter" });
+
+ await waitFor(() => expect(api.composePrompt).toHaveBeenCalled());
+ const attachments = vi.mocked(api.composePrompt).mock.calls[0][2];
+ expect(attachments).toHaveLength(1);
+ expect(attachments?.[0].detail).toContain("submit button overflows");
+ });
+
+ it("keeps the attachment when the user backs out of the rewrite", async () => {
+ // Discarding a proposed wording is not a reason to lose the dropped file.
+ renderGrid();
+ drop();
+ await waitFor(() => expect(screen.getByTestId("agentic-attachments")).toBeTruthy());
+
+ const box = screen.getByPlaceholderText(/instruction for Mika/i);
+ fireEvent.change(box, { target: { value: "fix this" } });
+ fireEvent.keyDown(box, { key: "Enter" });
+ await waitFor(() => expect(screen.getByTestId("prompt-preview")).toBeTruthy());
+
+ fireEvent.click(screen.getByTestId("prompt-preview-cancel"));
+
+ expect(screen.getByTestId("agentic-attachments").textContent).toContain("shot.png");
+ });
+
+ it("lets an attachment be taken back off", async () => {
+ renderGrid();
+ drop();
+ await waitFor(() => expect(screen.getByTestId("agentic-attachments")).toBeTruthy());
+
+ fireEvent.click(screen.getByTestId("agentic-attachment-remove-shot.png"));
+
+ expect(screen.queryByTestId("agentic-attachment-shot.png")).toBeNull();
+ });
+
+ it("clears the attachments once they have been sent", async () => {
+ renderGrid();
+ drop();
+ await waitFor(() => expect(screen.getByTestId("agentic-attachments")).toBeTruthy());
+
+ const box = screen.getByPlaceholderText(/instruction for Mika/i);
+ fireEvent.change(box, { target: { value: "fix this" } });
+ fireEvent.keyDown(box, { key: "Enter" });
+ await waitFor(() => expect(screen.getByTestId("prompt-preview")).toBeTruthy());
+ fireEvent.click(screen.getByTestId("prompt-preview-send"));
+
+ // Otherwise the next, unrelated instruction would silently carry the old
+ // screenshot along with it.
+ await waitFor(() => expect(screen.queryByTestId("agentic-attachments")).toBeNull());
+ });
+
+ it("ignores a drag carrying only selected text", async () => {
+ renderGrid();
+
+ drop(["text/plain"]);
+
+ expect(api.attachToTerminal).not.toHaveBeenCalled();
+ });
+
+ it("reports an analysis that came back empty rather than pretending", async () => {
+ vi.mocked(api.attachToTerminal).mockResolvedValue({
+ terminal: "Mika",
+ references: [],
+ files: [],
+ copied: 0,
+ submitted: false,
+ delivered: false,
+ analysis: [],
+ });
+ renderGrid();
+
+ drop();
+
+ await waitFor(() => expect(pushToast).toHaveBeenCalled());
+ expect(pushToast.mock.calls[0][0]).toBe("warning");
+ });
+
+ it("surfaces a failed attach instead of losing the drop silently", async () => {
+ vi.mocked(api.attachToTerminal).mockRejectedValue(new Error("pane is gone"));
+ renderGrid();
+
+ drop();
+
+ await waitFor(() => expect(pushToast).toHaveBeenCalledWith("error", "pane is gone"));
+ });
+});
+
/*
* The seam between the terminals and the prompt bar.
*
@@ -850,3 +1100,61 @@ describe("a workspace with far more panes than the window fits", () => {
expect(screen.getAllByTestId(/^pane-cell-/)).toHaveLength(100);
});
});
+
+/*
+ * The pane headers say what each session is doing, and that sentence goes stale
+ * in seconds. So the grid polls for it — separately from the workspace state,
+ * which changes only when a pane is opened, closed or moved.
+ */
+describe("session recaps", () => {
+ it("asks the backend what its own workspace's panes are doing", async () => {
+ renderGrid();
+
+ await waitFor(() =>
+ expect(api.fetchTerminalRecaps).toHaveBeenCalledWith("ide_test"),
+ );
+ });
+
+ it("hands each pane the recap that came back for it", async () => {
+ vi.mocked(api.fetchTerminalRecaps).mockResolvedValue({
+ workspace_id: "ide_test",
+ terminals: [
+ {
+ key: "mika",
+ name: "Mika",
+ status: "live",
+ recap: "Running pytest tests/unit/test_login.py",
+ recap_detail:
+ 'Last asked to: "Fix the failing login test". Working now: Running pytest.',
+ },
+ ],
+ });
+
+ renderGrid();
+
+ await waitFor(() =>
+ expect(screen.getByTestId("pane-Mika").dataset.recap).toBe(
+ "Running pytest tests/unit/test_login.py",
+ ),
+ );
+ expect(screen.getByTestId("pane-Mika").dataset.recapDetail).toContain(
+ "Fix the failing login test",
+ );
+ });
+
+ it("falls back to the recap the workspace state carried", async () => {
+ // Nothing polled yet (and nothing ever will, here) — a pane must still open
+ // with a sentence in its header rather than with a blank that fills in.
+ vi.mocked(api.fetchTerminalRecaps).mockRejectedValue(new Error("offline"));
+ const session = sessionWith([["Mika", 0]]);
+ session.terminals[0].recap = "Waiting for its first instruction.";
+
+ renderGrid(session);
+
+ await waitFor(() =>
+ expect(screen.getByTestId("pane-Mika").dataset.recap).toBe(
+ "Waiting for its first instruction.",
+ ),
+ );
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
index 1cf1a287db..cff7c3deec 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
@@ -16,8 +16,11 @@ import {
Brain,
Check,
ChevronUp,
+ FileText,
FolderGit2,
+ Image as ImageIcon,
ListChecks,
+ Loader2,
Minus,
Moon,
Plus,
@@ -48,14 +51,29 @@ import {
paneGrid,
} from "./layout";
import { PromptPreview } from "./PromptPreview";
+import { WorkspaceSettings } from "./WorkspaceSettings";
+import { usePaneFileDrag } from "./paneFileDrag";
+import {
+ extractPaneDrop,
+ extractPasteFiles,
+ isEmptyPayload,
+ nameClipboardFile,
+ type PaneDropPayload,
+} from "./paneDrop";
import {
addTerminal,
+ attachToTerminal,
closeTerminal,
closeTerminals,
composePrompt,
+ fetchTerminalRecaps,
promptTerminal,
type ComposedPreview,
+ type DropAttachment,
+ type IdeAccountState,
+ type IdeState,
type SessionState,
+ type TerminalRecap,
} from "@/lib/agenticIdeApi";
interface AgenticGridProps {
@@ -70,11 +88,30 @@ interface AgenticGridProps {
agents?: SplitAgentChoice[];
/** Adding or closing a pane changes the workspace — the owner re-reads it. */
onSessionChanged?: (session: SessionState) => void;
+ /**
+ * Which subscription new terminals open on, per coding CLI. Drives the
+ * settings panel; an empty list simply leaves it with nothing to show.
+ */
+ accounts?: IdeAccountState[];
+ /** The settings panel changed the workspace state — the owner applies it. */
+ onStateChanged?: (state: IdeState) => void;
}
const FONT_MIN = 10;
const FONT_MAX = 20;
+/**
+ * How often the pane headers re-read what their agents are doing.
+ *
+ * A recap is a glanceable label, not a live log — five seconds is well below
+ * the time it takes to look across a grid, and slow enough that a dozen panes
+ * cost one cheap request per pane per minute. The read is deliberately the
+ * small `/recaps` one rather than the full workspace state (see the API
+ * client), and it is skipped entirely while the window is in the background:
+ * nobody is glancing at a header they cannot see.
+ */
+const RECAP_POLL_MS = 5000;
+
/*
* How tall the prompt bar is — dragged by its top edge, and remembered.
*
@@ -139,6 +176,21 @@ function writeStored(key: string, value: string): void {
}
}
+/**
+ * May Jarvis type into this pane?
+ *
+ * False for a plain terminal: that pane is a live SHELL prompt, so a line typed
+ * into it from the outside would not be read by an agent — it would run as a
+ * command. The prompt bar therefore never offers one as a target, and clicking
+ * one does not steal the target from the agent you were writing to.
+ *
+ * Undefined means a backend that predates the flag, where every pane was an
+ * agent — so absent reads as "yes", never as "no".
+ */
+function takesPrompts(term: { accepts_prompts?: boolean }): boolean {
+ return term.accepts_prompts !== false;
+}
+
function storedAppearance(): TerminalAppearance | null {
return readStored(APPEARANCE_KEY, (raw) =>
raw === "light" || raw === "dark" ? raw : null,
@@ -161,6 +213,8 @@ export function AgenticGrid({
maxTerminals = 12,
agents,
onSessionChanged,
+ accounts = [],
+ onStateChanged,
}: AgenticGridProps) {
const t = useT();
const pushToast = useEventStore((s) => s.pushToast);
@@ -186,8 +240,15 @@ export function AgenticGrid({
setFontSizeState(next);
writeStored(FONT_KEY, String(next));
}, []);
- const [target, setTarget] = useState(session.terminals[0]?.name ?? "");
+ const [target, setTarget] = useState(
+ session.terminals.find(takesPrompts)?.name ?? "",
+ );
const [statuses, setStatuses] = useState<Record<string, { status: PaneStatus; detail?: string }>>({});
+ // What each pane is doing, by call-sign, as the header shows it. Kept beside
+ // the session rather than inside it because it changes on a completely
+ // different clock: the layout changes when a pane is opened or closed, a
+ // recap whenever an agent prints a line.
+ const [recaps, setRecaps] = useState<Record<string, TerminalRecap>>({});
const [prompt, setPrompt] = useState("");
const [sending, setSending] = useState(false);
// The composed prompt waiting for the user's approval, and the wording they
@@ -237,16 +298,44 @@ export function AgenticGrid({
});
}, []);
- const markTerminal = useCallback((name: string) => {
- setMaximized(null);
- setSelectionMode(true);
- setSelectedTerminals((current) => {
- if (current.has(name)) return current;
- const next = new Set(current);
- next.add(name);
- return next;
- });
- }, []);
+ /*
+ * Keep the pane headers current.
+ *
+ * Bound to the workspace ID, so switching tabs starts a fresh poll for the
+ * workspace now on screen instead of continuing to describe the one behind
+ * it. A failed read keeps whatever the headers already say: the backend
+ * warming up, or a workspace closed in another window, is not a reason to
+ * blank eight labels — and the recap is a convenience, never the pane.
+ */
+ useEffect(() => {
+ let cancelled = false;
+ const pull = async () => {
+ if (typeof document !== "undefined" && document.hidden) return;
+ try {
+ const answer = await fetchTerminalRecaps(session.id);
+ if (cancelled) return;
+ setRecaps(
+ Object.fromEntries(answer.terminals.map((term) => [term.name, term])),
+ );
+ } catch {
+ /* keep the last recaps — a stale sentence beats an empty header */
+ }
+ };
+ void pull();
+ const timer = window.setInterval(() => void pull(), RECAP_POLL_MS);
+ // A window coming back to the foreground has skipped every tick it spent
+ // hidden, so its headers are as old as the time away. Catch up at once
+ // rather than showing minute-old work for another five seconds.
+ const onVisible = () => {
+ if (!document.hidden) void pull();
+ };
+ document.addEventListener("visibilitychange", onVisible);
+ return () => {
+ cancelled = true;
+ window.clearInterval(timer);
+ document.removeEventListener("visibilitychange", onVisible);
+ };
+ }, [session.id]);
// A terminal can disappear because another client closed it. Keep the local
// selection honest instead of leaving an invisible name selected.
@@ -363,7 +452,10 @@ export function AgenticGrid({
// A fresh pane should receive the next prompt — that is why it was opened.
const known = new Set(session.terminals.map((t) => t.name));
const added = next.terminals.find((t) => !known.has(t.name));
- if (added) setTarget(added.name);
+ // ...unless it is a plain terminal — that one is typed into by hand, and
+ // stealing the target would silently redirect the next prompt into a pane
+ // that refuses it.
+ if (added && takesPrompts(added)) setTarget(added.name);
} catch (e) {
pushToast("error", (e as Error).message);
} finally {
@@ -378,7 +470,7 @@ export function AgenticGrid({
setPendingClose(null);
if (maximized === name) setMaximized(null);
onSessionChanged?.(next);
- if (target === name) setTarget(next.terminals[0]?.name ?? "");
+ if (target === name) setTarget(next.terminals.find(takesPrompts)?.name ?? "");
} catch (e) {
pushToast("error", (e as Error).message);
} finally {
@@ -396,7 +488,7 @@ export function AgenticGrid({
const remaining = new Set(result.session.terminals.map((term) => term.name));
if (maximized && !remaining.has(maximized)) setMaximized(null);
if (target && !remaining.has(target)) {
- setTarget(result.session.terminals[0]?.name ?? "");
+ setTarget(result.session.terminals.find(takesPrompts)?.name ?? "");
}
if (result.failed.length === 0) setSelectionMode(false);
else {
@@ -419,14 +511,78 @@ export function AgenticGrid({
setStatuses((prev) => ({ ...prev, [name]: { status, detail } }));
}, []);
+ /*
+ * Files dropped onto the PROMPT BAR, and what is in them.
+ *
+ * A drop on a pane and a drop here mean different things. The pane types a
+ * path, which is right for "read this file" — the agent opens it. But a
+ * screenshot is the case where that breaks down: several of the coding CLIs
+ * cannot open an image at all, so the user drops a picture of a broken
+ * layout, types "fix this", and the agent receives a path and a pronoun.
+ *
+ * So a drop here is READ first — described if it is an image, extracted if it
+ * is a document — and the result rides along into the composition. The file
+ * is still saved and still referenced; the description is the floor under it,
+ * not a replacement for it.
+ */
+ const [attachments, setAttachments] = useState<DropAttachment[]>([]);
+ const [analyzing, setAnalyzing] = useState(0);
+
+ const attach = useCallback(
+ async (payload: PaneDropPayload) => {
+ if (isEmptyPayload(payload)) return;
+ if (!target) {
+ pushToast("warning", "Pick a terminal first — a dropped file belongs to one.");
+ return;
+ }
+ setAnalyzing((n) => n + 1);
+ try {
+ const result = await attachToTerminal(target, {
+ ...payload,
+ analyze: true,
+ // Held, not typed: the user is still writing the sentence that says
+ // what to do with it, and it goes in with that sentence.
+ deliver: false,
+ });
+ const found = result.analysis ?? [];
+ if (found.length === 0) {
+ pushToast("warning", "That drop carried nothing this prompt could use.");
+ return;
+ }
+ setAttachments((prev) => [...prev, ...found]);
+ } catch (e) {
+ pushToast("error", (e as Error).message);
+ } finally {
+ setAnalyzing((n) => Math.max(0, n - 1));
+ }
+ },
+ [target],
+ );
+
+ const { dragging, handlers: dragHandlers } = usePaneFileDrag(
+ useCallback(
+ (dt: DataTransfer) => {
+ // Read BEFORE any await — a DataTransfer empties the moment this
+ // handler returns (see ./paneDrop).
+ void attach(extractPaneDrop(dt));
+ },
+ [attach],
+ ),
+ );
+
+ const dropAttachment = useCallback((name: string) => {
+ setAttachments((prev) => prev.filter((a) => a.name !== name));
+ }, []);
+
/** Type `text` into `target` and report honestly if it was not accepted. */
- const deliver = async (text: string) => {
+ const deliver = async (text: string, carry: DropAttachment[] = []) => {
setSending(true);
try {
- const result = await promptTerminal(target, text);
+ const result = await promptTerminal(target, text, { attachments: carry });
setPreview(null);
setPreviewSource("");
setPrompt("");
+ setAttachments([]);
// The text is typed either way — but if the agent did not accept it, say
// so instead of leaving the user to wonder why nothing happened.
if (result && result.submitted === false) {
@@ -458,16 +614,18 @@ export function AgenticGrid({
if (!text || !target) return;
setSending(true);
try {
- const composed = await composePrompt(target, text);
+ const composed = await composePrompt(target, text, attachments);
if (composed.composed && composed.composed !== text) {
setPreviewSource(text);
setPreview(composed);
return;
}
- await deliver(text);
+ // The composed text already contains the attachments, so it carries none
+ // of its own; this branch did not compose, so they still have to travel.
+ await deliver(text, attachments);
} catch (e) {
pushToast("warning", `Could not prepare the prompt: ${(e as Error).message}`);
- await deliver(text);
+ await deliver(text, attachments);
} finally {
setSending(false);
}
@@ -565,6 +723,14 @@ export function AgenticGrid({
</button>
</div>
+ {/* Which subscription the next terminal spends, and the way to change
+ it without leaving the workspace. */}
+ <WorkspaceSettings
+ accounts={accounts}
+ onStateChanged={onStateChanged}
+ busy={busy || working}
+ />
+
<button
ref={selectionToggleRef}
type="button"
@@ -709,11 +875,6 @@ export function AgenticGrid({
"ring-2 ring-primary ring-offset-2 ring-offset-background",
maximized !== null && !isMaximized && "hidden",
)}
- onContextMenu={(event) => {
- event.preventDefault();
- event.stopPropagation();
- markTerminal(term.name);
- }}
style={
isMaximized
? { gridColumn: "1 / -1", gridRow: "1 / -1" }
@@ -727,6 +888,13 @@ export function AgenticGrid({
name={term.name}
workspaceId={session.id}
displayName={term.display_name}
+ // The polled recap when one has arrived, the one the workspace
+ // state carried until then — so a pane opens with a sentence in
+ // its header rather than with a blank that fills in later.
+ recap={recaps[term.name]?.recap ?? term.recap}
+ recapDetail={
+ recaps[term.name]?.recap_detail ?? term.recap_detail
+ }
// Only the panes that are NOT on the default login carry a
// badge. Labelling every pane "Default Claude Code login" would
// be noise for the many; labelling the odd one out is the whole
@@ -742,7 +910,9 @@ export function AgenticGrid({
maximized={isMaximized}
splitDisabled={atLimit || busy || working}
agents={agents}
- onFocus={() => setTarget(term.name)}
+ onFocus={() => {
+ if (takesPrompts(term)) setTarget(term.name);
+ }}
onStatus={(status, detail) => setStatus(term.name, status, detail)}
onToggleMaximize={() =>
setMaximized((current) => (current === term.name ? null : term.name))
@@ -770,10 +940,14 @@ export function AgenticGrid({
)
}
onClick={() => toggleTerminalSelection(term.name)}
+ // Selection mode owns the right mouse button and does nothing
+ // with it. Marking a pane on right-click was too easy to
+ // trigger by accident, and letting the event through would
+ // open the app-wide Cut/Copy/Paste menu over an overlay that
+ // has no text to copy. Left-click marks; right-click is inert.
onContextMenu={(event) => {
event.preventDefault();
event.stopPropagation();
- markTerminal(term.name);
}}
className={cn(
"absolute inset-0 z-20 cursor-pointer rounded-xl transition-colors",
@@ -882,13 +1056,38 @@ export function AgenticGrid({
<div
data-testid="agentic-composer"
style={{ height: composerHeight }}
- className="flex shrink-0 flex-col overflow-hidden px-4 py-3"
+ {...dragHandlers}
+ onPaste={(event) => {
+ // Clipboard IMAGES only. Pasted text belongs to the textarea, and
+ // intercepting it would break ordinary paste into the prompt.
+ const images = extractPasteFiles(event.clipboardData).map((f) =>
+ nameClipboardFile(f, target || "prompt"),
+ );
+ if (images.length === 0) return;
+ event.preventDefault();
+ void attach({ paths: [], files: images });
+ }}
+ className={cn(
+ "relative flex shrink-0 flex-col overflow-hidden px-4 py-3 transition-colors",
+ dragging && "bg-primary/5 ring-1 ring-inset ring-primary/50",
+ )}
>
+ {dragging && (
+ <div
+ data-testid="agentic-composer-dropzone"
+ className="pointer-events-none absolute inset-2 z-10 flex items-center justify-center rounded-lg border-2 border-dashed border-primary/60 bg-background/80 text-xs font-medium text-primary"
+ >
+ Drop a screenshot or document — {target || "the agent"} gets what is in it
+ </div>
+ )}
<div className="mb-2 flex max-h-24 shrink-0 flex-wrap items-center gap-2 overflow-y-auto scrollbar-jarvis">
<span className="text-[11px] uppercase tracking-wider text-muted-foreground">
Send to
</span>
- {session.terminals.map((term) => {
+ {/* Agent panes only. A plain terminal is a shell prompt — it is
+ typed into by hand, so listing it here would offer a target that
+ refuses every instruction sent to it. */}
+ {session.terminals.filter(takesPrompts).map((term) => {
const state = statuses[term.name];
return (
<button
@@ -909,6 +1108,13 @@ export function AgenticGrid({
);
})}
</div>
+ {(attachments.length > 0 || analyzing > 0) && (
+ <AttachmentStrip
+ attachments={attachments}
+ analyzing={analyzing}
+ onRemove={dropAttachment}
+ />
+ )}
{preview && (
<div className="mb-2 shrink-0 overflow-y-auto scrollbar-jarvis">
<PromptPreview
@@ -916,10 +1122,15 @@ export function AgenticGrid({
composed={preview.composed}
files={preview.files}
composedBy={preview.composed_by}
+ attachments={attachments}
+ // The composed text already contains the attachments; the
+ // verbatim path does not, so only that one carries them.
onSend={() => void deliver(preview.composed)}
- onSendVerbatim={() => void deliver(previewSource)}
+ onSendVerbatim={() => void deliver(previewSource, attachments)}
onCancel={() => {
- // Give the user their own words back rather than dropping them.
+ // Give the user their own words back rather than dropping
+ // them. The attachments stay too — backing out of a rewrite
+ // is not a reason to lose the file they dropped.
setPrompt(previewSource);
setPreview(null);
setPreviewSource("");
@@ -973,6 +1184,86 @@ export function AgenticGrid({
);
}
+/**
+ * The files waiting to go in with the next prompt.
+ *
+ * Each chip says what was actually LEARNED from the file, not just that one was
+ * attached. That distinction is the whole feature: "screenshot.png" tells the
+ * user nothing about whether the agent will be able to see it, while "described"
+ * and "not described" are the two outcomes they need to be able to tell apart
+ * before they press Send — and the second one happens for real, on any install
+ * whose providers cannot see images.
+ */
+function AttachmentStrip({
+ attachments,
+ analyzing,
+ onRemove,
+}: {
+ attachments: DropAttachment[];
+ analyzing: number;
+ onRemove: (name: string) => void;
+}) {
+ return (
+ <div
+ data-testid="agentic-attachments"
+ className="mb-2 flex max-h-20 shrink-0 flex-wrap items-center gap-1.5 overflow-y-auto scrollbar-jarvis"
+ >
+ {attachments.map((item) => {
+ const read = item.described_by !== "none" && item.detail.length > 0;
+ return (
+ <span
+ key={item.name}
+ data-testid={`agentic-attachment-${item.name}`}
+ title={
+ read
+ ? `${item.detail.slice(0, 400)}${item.detail.length > 400 ? "…" : ""}`
+ : item.note || "Attached as a file."
+ }
+ className={cn(
+ "flex items-center gap-1.5 rounded-md border px-2 py-1 text-[11px]",
+ read
+ ? "border-primary/40 bg-primary/10 text-foreground"
+ : "border-border text-muted-foreground",
+ )}
+ >
+ {item.kind === "image" ? (
+ <ImageIcon className="h-3 w-3 shrink-0" />
+ ) : (
+ <FileText className="h-3 w-3 shrink-0" />
+ )}
+ <span className="max-w-[12rem] truncate font-mono">{item.name}</span>
+ <span className="shrink-0 text-[10px] text-muted-foreground">
+ {read
+ ? item.described_by === "vision"
+ ? "described"
+ : "text read"
+ : "not described"}
+ </span>
+ <button
+ type="button"
+ aria-label={`Remove ${item.name}`}
+ data-testid={`agentic-attachment-remove-${item.name}`}
+ onClick={() => onRemove(item.name)}
+ className="shrink-0 rounded text-muted-foreground hover:text-destructive"
+ >
+ <X className="h-3 w-3" />
+ </button>
+ </span>
+ );
+ })}
+ {analyzing > 0 && (
+ <span
+ data-testid="agentic-attachment-working"
+ className="flex items-center gap-1.5 rounded-md border border-dashed border-border px-2 py-1 text-[11px] text-muted-foreground"
+ >
+ <Loader2 className="h-3 w-3 animate-spin" />
+ Reading {analyzing === 1 ? "the dropped file" : `${analyzing} dropped files`}…
+ </span>
+ )}
+ </div>
+ );
+}
+
function ConfirmSelectionClose({
names,
busy,
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 502aab0fa5..2a146f760a 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -3347,7 +3347,7 @@
"selection": {
"start": "Terminals auswählen",
"finish": "Auswahl beenden",
- "hint": "Terminal-Fenster zum Auswählen anklicken. Ein Rechtsklick wählt ein Fenster sofort aus.",
+ "hint": "Terminal-Fenster auswählen. Zuerst einschalten, dann die gewünschten Fenster anklicken.",
"selected_count": "Ausgewählt: {0}",
"select_all": "Alle auswählen",
"clear_all": "Auswahl leeren",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 87771e13f4..13380fa457 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -3333,7 +3333,7 @@
"selection": {
"start": "Select terminals",
"finish": "Done selecting",
- "hint": "Select terminal panes. Right-click any pane to select it immediately.",
+ "hint": "Select terminal panes. Turn this on first, then click the panes you want.",
"selected_count": "Selected: {0}",
"select_all": "Select all",
"clear_all": "Clear selection",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index dd311f62c5..ad956ea9c2 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -3332,7 +3332,7 @@
"selection": {
"start": "Seleccionar terminales",
"finish": "Terminar selección",
- "hint": "Haz clic en los paneles para seleccionarlos. Haz clic derecho en cualquier panel para seleccionarlo inmediatamente.",
+ "hint": "Selecciona paneles de terminal. Actívalo primero y luego haz clic en los paneles que quieras.",
"selected_count": "Seleccionados: {0}",
"select_all": "Seleccionar todos",
"clear_all": "Borrar selección",