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.

feat(ide): add spacious visual workspace setup

rubenluetke10-beep1250949990cc
diff --git a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceAgentSetup.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceAgentSetup.test.tsx
new file mode 100644
index 0000000000..dfd3f6e945
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceAgentSetup.test.tsx
@@ -0,0 +1,81 @@
+import { useState } from "react";
+import { cleanup, fireEvent, render, screen, within } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import type { AgentStatus } from "@/lib/agenticIdeApi";
+import { WorkspaceAgentSetup } from "./WorkspaceAgentSetup";
+
+const agents: AgentStatus[] = [
+ { name: "claude", display_name: "Claude Code", installed: true, version: null, install_command: null },
+ { name: "codex", display_name: "Codex", installed: true, version: null, install_command: null },
+];
+
+function Setup() {
+ const [sessions, setSessions] = useState(["claude"]);
+ return <><WorkspaceAgentSetup agents={agents} sessions={sessions} onChange={setSessions} />
+ <output data-testid="plan">{sessions.join(",")}</output></>;
+}
+
+afterEach(cleanup);
+
+describe("Workspace agent selection", () => {
+ it("chooses a logo tile and expands that choice with the count buttons", () => {
+ render(<Setup />);
+ const codex = screen.getByRole("button", { name: "Codex" });
+ expect(within(codex).getByTestId("agent-mark-codex").getAttribute("data-logo")).toBe("/provider-logos/openai.svg");
+ fireEvent.click(codex);
+ fireEvent.click(screen.getByRole("button", { name: "6 sessions" }));
+ expect(screen.getByTestId("plan").textContent).toBe(Array(6).fill("codex").join(","));
+ expect(codex.getAttribute("aria-pressed")).toBe("true");
+ expect(screen.queryByRole("combobox")).toBeNull();
+ });
+
+ it("edits a single session and preserves the rest when resizing the lineup", () => {
+ render(<Setup />);
+ fireEvent.click(screen.getByRole("button", { name: "3 sessions" }));
+ fireEvent.click(screen.getByRole("button", { name: "Edit session 2: Claude Code" }));
+ fireEvent.click(screen.getByRole("button", { name: "Codex" }));
+ expect(screen.getByTestId("plan").textContent).toBe("claude,codex,claude");
+ fireEvent.click(screen.getByRole("button", { name: "4 sessions" }));
+ expect(screen.getByTestId("plan").textContent).toBe("claude,codex,claude,codex");
+ fireEvent.click(screen.getByRole("button", { name: "2 sessions" }));
+ expect(screen.getByTestId("plan").textContent).toBe("claude,codex");
+ fireEvent.click(screen.getByRole("button", { name: "All sessions" }));
+ fireEvent.click(screen.getByRole("button", { name: "Codex" }));
+ expect(screen.getByTestId("plan").textContent).toBe("codex,codex");
+ });
+
+ it("clears a removed editing target and never offers more than eight sessions", () => {
+ render(<Setup />);
+ fireEvent.click(screen.getByRole("button", { name: "8 sessions" }));
+ fireEvent.click(screen.getByRole("button", { name: "Edit session 8: Claude Code" }));
+ fireEvent.click(screen.getByRole("button", { name: "1 session" }));
+ fireEvent.click(screen.getByRole("button", { name: "Codex" }));
+ expect(screen.getByTestId("plan").textContent).toBe("codex");
+ expect(screen.queryByRole("button", { name: "9 sessions" })).toBeNull();
+ });
+
+ it("fills an unassigned seat when discovery arrives without replacing existing picks", () => {
+ const change = vi.fn();
+ const { rerender } = render(<WorkspaceAgentSetup agents={[]} sessions={[""]} onChange={change} />);
+ expect(change).not.toHaveBeenCalled();
+ rerender(<WorkspaceAgentSetup agents={agents} sessions={["codex", ""]} onChange={change} />);
+ expect(change).toHaveBeenLastCalledWith(["codex", "claude"]);
+ });
+
+ it("forgets an editing target removed by an external lineup reset", () => {
+ const change = vi.fn();
+ const { rerender } = render(<WorkspaceAgentSetup agents={agents} sessions={Array(8).fill("claude")} onChange={change} />);
+ fireEvent.click(screen.getByRole("button", { name: "Edit session 8: Claude Code" }));
+ rerender(<WorkspaceAgentSetup agents={agents} sessions={["claude"]} onChange={change} />);
+ fireEvent.click(screen.getByRole("button", { name: "Codex" }));
+ expect(change).toHaveBeenLastCalledWith(["codex"]);
+ });
+
+ it("does not change the launch plan while it is being submitted", () => {
+ const change = vi.fn();
+ render(<WorkspaceAgentSetup agents={agents} sessions={["claude"]} disabled onChange={change} />);
+ fireEvent.click(screen.getByRole("button", { name: "Codex" }));
+ fireEvent.click(screen.getByRole("button", { name: "8 sessions" }));
+ expect(change).not.toHaveBeenCalled();
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceAgentSetup.tsx b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceAgentSetup.tsx
new file mode 100644
index 0000000000..ef2fe2fb8d
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceAgentSetup.tsx
@@ -0,0 +1,117 @@
+import { useEffect, useState } from "react";
+import { Check } from "lucide-react";
+import type { AgentStatus } from "@/lib/agenticIdeApi";
+import { cn } from "@/lib/utils";
+import { AgentMark } from "./AgentMark";
+
+interface Props {
+ agents: AgentStatus[];
+ sessions: string[];
+ onChange: (sessions: string[]) => void;
+ disabled?: boolean;
+}
+
+/** One launch plan: choose an agent for everyone, then customize individual seats. */
+export function WorkspaceAgentSetup({ agents, sessions, onChange, disabled = false }: Props) {
+ const [editingSeat, setEditing] = useState<number | null>(null);
+ const editing = editingSeat !== null && editingSeat < sessions.length ? editingSeat : null;
+ const firstAgent = agents[0]?.name ?? "";
+ const selectedAgent = editing !== null
+ ? sessions[editing]
+ : sessions.every((agent) => agent === sessions[0]) ? sessions[0] : undefined;
+ const counts = new Map<string, number>();
+ sessions.forEach((agent) => counts.set(agent, (counts.get(agent) ?? 0) + 1));
+
+ useEffect(() => {
+ if (editingSeat !== null && editingSeat >= sessions.length) setEditing(null);
+ }, [editingSeat, sessions.length]);
+
+ useEffect(() => {
+ // The dialog can open before launchability discovery completes. Fill only
+ // unassigned seats; never replace a user's existing agent choice.
+ if (firstAgent && sessions.some((agent) => !agent) && !disabled) {
+ onChange(sessions.map((agent) => agent || firstAgent));
+ }
+ }, [firstAgent, sessions, onChange, disabled]);
+
+ const chooseAgent = (agent: string) => {
+ onChange(sessions.map((current, index) => editing === null || index === editing ? agent : current));
+ };
+ const chooseCount = (count: number) => {
+ const fillAgent = selectedAgent || sessions[0] || firstAgent;
+ onChange(Array.from({ length: count }, (_, index) => sessions[index] ?? fillAgent));
+ if (editing !== null && editing >= count) setEditing(null);
+ };
+ const selection = "border-ring/70 bg-muted ring-1 ring-ring/20";
+ const idle = "border-border bg-background/40 hover:border-foreground/30 hover:bg-muted/60";
+
+ return <div className="space-y-6">
+ <section aria-label="Coding agents">
+ <div className="mb-3 flex items-center justify-between gap-3">
+ <h3 className="text-xs font-semibold uppercase tracking-[0.14em] text-muted-foreground">Agent</h3>
+ <div className="flex items-center gap-2 text-xs">
+ <span className="text-muted-foreground" aria-live="polite">
+ {editing === null ? "Choose for all sessions" : `Editing session ${editing + 1}`}
+ </span>
+ {editing !== null && <button type="button" disabled={disabled} onClick={() => setEditing(null)}
+ className="rounded-md border border-border px-2 py-1 hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
+ All sessions
+ </button>}
+ </div>
+ </div>
+ <div className="grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3">
+ {agents.map((agent) => {
+ const selected = agent.name === selectedAgent;
+ const count = counts.get(agent.name) ?? 0;
+ return <button key={agent.name} type="button" aria-label={agent.display_name}
+ aria-pressed={selected} disabled={disabled} onClick={() => chooseAgent(agent.name)}
+ className={cn("flex min-h-14 min-w-0 items-center gap-3 rounded-xl border px-4 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50", selected ? selection : idle)}>
+ <AgentMark agent={agent.name} label={agent.display_name} logoUrl={agent.logo_url}
+ variant="plain" className="h-6 w-6 opacity-100" />
+ <span className="min-w-0 flex-1 truncate text-sm font-medium">{agent.display_name}</span>
+ {count > 0 && <span aria-hidden="true" className="text-xs tabular-nums text-muted-foreground">×{count}</span>}
+ {selected && <Check aria-hidden="true" className="h-4 w-4 shrink-0" />}
+ </button>;
+ })}
+ </div>
+ {agents.length === 0 && <p className="rounded-lg border border-border p-4 text-sm text-muted-foreground">
+ No coding agents available. Connect a coding agent in CLIs to continue.
+ </p>}
+ </section>
+
+ <section aria-label="Number of sessions">
+ <h3 className="mb-3 text-xs font-semibold uppercase tracking-[0.14em] text-muted-foreground">How many sessions?</h3>
+ <div className="flex flex-wrap items-center gap-2">
+ {Array.from({ length: 8 }, (_, index) => index + 1).map((count) => <button
+ key={count} type="button" aria-label={`${count} ${count === 1 ? "session" : "sessions"}`}
+ aria-pressed={sessions.length === count} disabled={disabled || !firstAgent}
+ onClick={() => chooseCount(count)}
+ className={cn("flex h-11 w-11 items-center justify-center rounded-lg border text-sm font-semibold tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40", sessions.length === count ? selection : idle)}>
+ {count}
+ </button>)}
+ <span className="ml-2 text-xs text-muted-foreground">Up to 8 per workspace</span>
+ </div>
+ </section>
+
+ <section aria-label="Session lineup">
+ <div className="mb-3 flex flex-wrap items-center justify-between gap-2">
+ <h3 className="text-xs font-semibold uppercase tracking-[0.14em] text-muted-foreground">Will launch</h3>
+ <span className="text-xs text-muted-foreground">Click a session to choose a different agent</span>
+ </div>
+ <div className="grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-4">
+ {sessions.map((name, index) => {
+ const agent = agents.find((entry) => entry.name === name);
+ const label = agent?.display_name ?? "Choose an agent";
+ return <button key={index} type="button" aria-label={`Edit session ${index + 1}: ${label}`}
+ aria-pressed={editing === index} disabled={disabled || !firstAgent}
+ onClick={() => setEditing((current) => current === index ? null : index)}
+ className={cn("flex min-h-12 min-w-0 items-center gap-2 rounded-lg border px-3 py-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50", editing === index ? selection : idle)}>
+ <span className="w-3 shrink-0 text-xs tabular-nums text-muted-foreground">{index + 1}</span>
+ <AgentMark agent={name} label={label} logoUrl={agent?.logo_url} variant="plain" />
+ <span className="truncate text-xs font-medium" title={label}>{label}</span>
+ </button>;
+ })}
+ </div>
+ </section>
+ </div>;
+}
diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
index 1f87abb347..fd62a03820 100644
--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
@@ -48,17 +48,39 @@ describe("Agentic IDE project flow", () => {
it("creates a workspace with an explicit project and per-session agents", async () => {
api.fetchIdeProjects.mockResolvedValue({ projects: [project], active_project_id: null, active_workspace_id: null, max_terminals: 8 });
api.fetchIdeAgents.mockResolvedValue({ terminal_available: true, max_terminals: 8, suggested_names: [], agents: [agent,
+ { ...agent, name: "claude", display_name: "Claude Code" },
{ ...agent, name: "harness", display_name: "Browser Harness", accepts_prompts: false }] });
api.startIdeSession.mockResolvedValue(emptyState);
render(<AgenticIdeView />);
await screen.findByText("Choose a workspace");
act(() => useIdeProjectsStore.getState().newWorkspace("p1"));
await screen.findByRole("dialog", { name: "New workspace" });
- expect(screen.queryByRole("option", { name: "Browser Harness" })).toBeNull();
- fireEvent.change(screen.getByLabelText("Sessions"), { target: { value: "2" } });
+ expect(screen.queryByRole("button", { name: "Browser Harness" })).toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: "2 sessions" }));
+ fireEvent.click(screen.getByRole("button", { name: "Edit session 2: Codex" }));
+ fireEvent.click(screen.getByRole("button", { name: "Claude Code" }));
fireEvent.change(screen.getByLabelText("Name (optional)"), { target: { value: "Installer" } });
fireEvent.click(screen.getByRole("button", { name: "Create workspace" }));
- await waitFor(() => expect(api.startIdeSession).toHaveBeenCalledWith("/code/app", [{ agent: "codex" }, { agent: "codex" }], { projectId: "p1", name: "Installer" }));
+ await waitFor(() => expect(api.startIdeSession).toHaveBeenCalledWith("/code/app", [{ agent: "codex" }, { agent: "claude" }], { projectId: "p1", name: "Installer" }));
+ await waitFor(() => expect(screen.queryByRole("dialog", { name: "New workspace" })).toBeNull());
+ });
+
+ it("keeps the launch dialog open while creation is in flight", async () => {
+ api.fetchIdeProjects.mockResolvedValue({ projects: [project], active_project_id: null, active_workspace_id: null, max_terminals: 8 });
+ let finish!: (state: typeof emptyState) => void;
+ api.startIdeSession.mockImplementation(() => new Promise((resolve) => { finish = resolve; }));
+ render(<AgenticIdeView />);
+ await screen.findByText("Choose a workspace");
+ act(() => useIdeProjectsStore.getState().newWorkspace("p1"));
+ fireEvent.click(await screen.findByRole("button", { name: "Create workspace" }));
+ await screen.findByRole("button", { name: "Starting…" });
+ fireEvent.keyDown(document, { key: "Escape" });
+ const dialog = screen.getByRole("dialog", { name: "New workspace" });
+ fireEvent.mouseDown(dialog.parentElement!);
+ expect(screen.getByRole("dialog", { name: "New workspace" })).toBe(dialog);
+ expect((screen.getByRole("button", { name: "Cancel" }) as HTMLButtonElement).disabled).toBe(true);
+ expect((screen.getByRole("button", { name: "Close" }) as HTMLButtonElement).disabled).toBe(true);
+ await act(async () => finish(emptyState));
await waitFor(() => expect(screen.queryByRole("dialog", { name: "New workspace" })).toBeNull());
});
diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
index 0c80a6a609..877d4fcb81 100644
--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
@@ -3,6 +3,7 @@ import { FolderPlus, Loader2, Mic, Moon, MoreHorizontal, Plus, Sun, X, ZoomIn, Z
import { FolderPicker } from "@/components/agentic/FolderPicker";
import { VoiceBubble, storedVoiceBubbleOpen, storeVoiceBubbleOpen } from "@/components/agentic/VoiceBubble";
import { WorkspaceTerminalGrid } from "@/components/agentic/WorkspaceTerminalGrid";
+import { WorkspaceAgentSetup } from "@/components/agentic/WorkspaceAgentSetup";
import { useEventStore } from "@/store/events";
import { useIdeChatStore } from "@/store/ideChat";
import { useIdeProjectsStore } from "@/store/ideProjects";
@@ -65,6 +66,7 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
const onKeyDown = (event: KeyboardEvent) => {
if (event.key === "Escape") {
event.preventDefault();
+ if (workspaceProject && busy) { event.stopPropagation(); return; }
setProjectDialog(false); setWorkspaceProject(null); setRenameOpen(false);
return;
}
@@ -77,7 +79,7 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
};
document.addEventListener("keydown", onKeyDown, true);
return () => { document.removeEventListener("keydown", onKeyDown, true); previous?.focus(); };
- }, [dialogOpen, projectDialog, workspaceProject, renameOpen]);
+ }, [dialogOpen, projectDialog, workspaceProject, renameOpen, busy]);
const refresh = useCallback(async (allowDuringActivation = false) => {
if (activationRunning.current && !allowDuringActivation) return;
@@ -266,15 +268,34 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
</section>
</div>}
- {workspaceProject && <div className="fixed inset-0 z-[80] flex items-center justify-center bg-background/75 p-4 backdrop-blur-sm" role="presentation" onMouseDown={(event) => { if (event.target === event.currentTarget) setWorkspaceProject(null); }}>
- <section data-ide-dialog tabIndex={-1} role="dialog" aria-modal="true" aria-label="New workspace" className="w-full max-w-md rounded-xl border border-border bg-card p-5 shadow-2xl">
- <div className="mb-4 flex items-center justify-between"><h2 className="text-base font-semibold">New workspace</h2><button type="button" aria-label="Close" onClick={() => setWorkspaceProject(null)}><X className="h-4 w-4" /></button></div>
- <p className="mb-4 truncate text-xs text-muted-foreground" title={workspaceProject.path}>{workspaceProject.name} · {workspaceProject.path}</p>
- <label className="block text-xs text-muted-foreground">Name (optional)<input value={workspaceName} onChange={(event) => setWorkspaceName(event.target.value)} placeholder="Workspace" className="mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground" /></label>
- <label className="mt-3 block text-xs text-muted-foreground">Sessions<select value={workspaceAgents.length} onChange={(event) => setWorkspaceAgents((old) => Array.from({ length: Number(event.target.value) }, (_, index) => old[index] ?? installed[0]?.name ?? ""))} className="mt-1 w-full rounded-md border border-input bg-background px-2 py-2 text-sm text-foreground">{[1, 2, 3, 4, 5, 6, 7, 8].map((count) => <option value={count} key={count}>{count}</option>)}</select></label>
- <div className="mt-3 max-h-48 space-y-2 overflow-auto">{workspaceAgents.map((agent, index) => <label key={index} className="flex items-center gap-3 text-xs text-muted-foreground"><span className="w-16 shrink-0">Agent {index + 1}</span><select value={agent} onChange={(event) => setWorkspaceAgents((old) => old.map((value, at) => at === index ? event.target.value : value))} className="min-w-0 flex-1 rounded-md border border-input bg-background px-2 py-2 text-sm text-foreground">{installed.map((choice) => <option value={choice.name} key={choice.name}>{choice.display_name}</option>)}</select></label>)}</div>
- {installed.length === 0 && <p className="mt-3 text-xs text-destructive">Install a coding agent from CLIs before creating a workspace.</p>}
- <div className="mt-5 flex justify-end gap-2"><button type="button" onClick={() => setWorkspaceProject(null)} className="rounded-md px-3 py-1.5 text-sm text-muted-foreground hover:bg-accent">Cancel</button><button type="button" disabled={busy || installed.length === 0} onClick={createWorkspace} className="rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground disabled:opacity-50">Create workspace</button></div>
+ {workspaceProject && <div className="fixed inset-0 z-[80] flex items-center justify-center bg-background/75 p-4 backdrop-blur-sm" role="presentation" onMouseDown={(event) => { if (!busy && event.target === event.currentTarget) setWorkspaceProject(null); }}>
+ <section data-ide-dialog tabIndex={-1} role="dialog" aria-modal="true" aria-label="New workspace" aria-busy={busy}
+ className="flex max-h-[90vh] w-full max-w-4xl flex-col overflow-hidden rounded-2xl border border-border bg-card shadow-2xl">
+ <header className="shrink-0 px-6 pb-5 pt-6 sm:px-8 sm:pt-7">
+ <div className="flex items-center justify-between gap-4">
+ <h2 className="text-xl font-semibold tracking-tight">New workspace</h2>
+ <button type="button" aria-label="Close" disabled={busy} onClick={() => setWorkspaceProject(null)}
+ className="rounded-lg p-2 text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"><X className="h-5 w-5" /></button>
+ </div>
+ <p className="mt-1 truncate text-sm text-muted-foreground" title={workspaceProject.path}>
+ <span className="text-foreground">{workspaceProject.name}</span><span className="mx-2 opacity-50">/</span>{workspaceProject.path}
+ </p>
+ </header>
+ <div className="min-h-0 space-y-6 overflow-y-auto px-6 pb-6 sm:px-8">
+ <label className="block text-xs font-medium text-muted-foreground">Name (optional)
+ <input value={workspaceName} disabled={busy} onChange={(event) => setWorkspaceName(event.target.value)}
+ placeholder="Workspace" className="mt-2 h-11 w-full rounded-lg border border-input bg-background/60 px-3 text-sm text-foreground outline-none focus:border-ring focus:ring-1 focus:ring-ring/30" />
+ </label>
+ <WorkspaceAgentSetup agents={installed} sessions={workspaceAgents} onChange={setWorkspaceAgents} disabled={busy} />
+ </div>
+ <footer className="flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-border bg-muted/20 px-6 py-4 sm:px-8">
+ <span className="text-xs text-muted-foreground" aria-live="polite">{workspaceAgents.length} {workspaceAgents.length === 1 ? "session" : "sessions"} · {new Set(workspaceAgents.filter(Boolean)).size} {new Set(workspaceAgents.filter(Boolean)).size === 1 ? "agent" : "agents"}</span>
+ <div className="flex gap-2">
+ <button type="button" disabled={busy} onClick={() => setWorkspaceProject(null)} className="rounded-lg px-4 py-2.5 text-sm text-muted-foreground hover:bg-muted disabled:opacity-50">Cancel</button>
+ <button type="button" disabled={busy || workspaceAgents.length === 0 || workspaceAgents.some((name) => !installed.some((agent) => agent.name === name))}
+ onClick={createWorkspace} className="rounded-lg bg-primary px-4 py-2.5 text-sm font-medium text-primary-foreground disabled:opacity-50">{busy ? "Starting…" : "Create workspace"}</button>
+ </div>
+ </footer>
</section>
</div>}
{renameOpen && <div className="fixed inset-0 z-[80] flex items-center justify-center bg-background/75 p-4 backdrop-blur-sm" role="presentation" onMouseDown={(event) => { if (event.target === event.currentTarget) setRenameOpen(false); }}>