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): choose where a new agent runs when adding it

rubenluetke10-beepb647ee6be26b
diff --git a/jarvis/ui/web/frontend/src/components/agentic/RunOnPicker.tsx b/jarvis/ui/web/frontend/src/components/agentic/RunOnPicker.tsx
index a011a4ba3c..cacc596c7d 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/RunOnPicker.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/RunOnPicker.tsx
@@ -1,39 +1,68 @@
/**
- * "Runs on" — where a new workspace's agents run: this computer, or one of the
- * connected computers (a VPS, a local VM; see the Computers section). On a
- * computer the agents live in tmux there and keep working while this PC is
- * off; the folder is copied there when the workspace opens.
+ * "Runs on" — where new agents run: this computer, or one of the connected
+ * computers (a VPS, a local VM; see the Computers section). On a computer the
+ * agents live in tmux there and keep working while this PC is off; the folder
+ * is copied there first (new files that look like secrets stay here).
*/
+import { useEffect } from "react";
import { Laptop, Server } from "lucide-react";
-import { useComputerChoices } from "@/hooks/useComputers";
+import { useComputerChoiceList } from "@/hooks/useComputers";
import { useEventStore } from "@/store/events";
import { cn } from "@/lib/utils";
+const RUN_ON_KEY = "jarvis.agenticIde.runOn.";
+
+/** The computer last chosen for a project's new workspaces; storage may be blocked. */
+export function storedRunOn(projectId: string | undefined): string | null {
+ if (!projectId) return null;
+ try { return localStorage.getItem(RUN_ON_KEY + projectId) || null; } catch { return null; }
+}
+export function storeRunOn(projectId: string | undefined, computerId: string | null): void {
+ if (!projectId) return;
+ try {
+ if (computerId) localStorage.setItem(RUN_ON_KEY + projectId, computerId);
+ else localStorage.removeItem(RUN_ON_KEY + projectId);
+ } catch { /* a convenience only */ }
+}
+
+function detailFor(status: string): string {
+ if (status === "online") return "Keeps running while this PC is off";
+ if (status === "unknown") return "Not checked yet";
+ return "Not reachable right now";
+}
+
export function RunOnPicker({
value,
onChange,
disabled,
+ hideWhenNone = false,
}: {
value: string | null;
onChange: (computerId: string | null) => void;
disabled?: boolean;
+ /** Show nothing (instead of a "Connect a server" hint) when no computer is connected. */
+ hideWhenNone?: boolean;
}) {
- const computers = useComputerChoices();
+ const { computers, loaded } = useComputerChoiceList();
const setActiveSection = useEventStore((state) => state.setActiveSection);
+ const usable = computers.filter((computer) => computer.health.status !== "provisioning");
const options = [
{ id: null as string | null, name: "This computer", detail: "Stops when this PC sleeps or shuts down", online: true, icon: Laptop },
- ...computers
- .filter((computer) => computer.health.status !== "provisioning")
- .map((computer) => ({
- id: computer.id as string | null,
- name: computer.name,
- detail: computer.health.status === "online"
- ? "Keeps running while this PC is off"
- : "Not reachable right now",
- online: computer.health.status === "online",
- icon: Server,
- })),
+ ...usable.map((computer) => ({
+ id: computer.id as string | null,
+ name: computer.name,
+ detail: detailFor(computer.health.status),
+ online: computer.health.status === "online",
+ icon: Server,
+ })),
];
+ // A remembered computer that has been removed since falls back to this PC,
+ // rather than leaving no choice selected and failing on create.
+ const missing = loaded && value !== null && !usable.some((computer) => computer.id === value);
+ useEffect(() => { if (missing) onChange(null); }, [missing, onChange]);
+
+ if (hideWhenNone && usable.length === 0) return null;
+ const chosen = usable.find((computer) => computer.id === value);
return (
<fieldset data-testid="ide-run-on" disabled={disabled}>
<legend className="text-xs font-medium text-muted-foreground">Runs on</legend>
@@ -72,7 +101,13 @@ export function RunOnPicker({
);
})}
</div>
- {computers.length === 0 && (
+ {chosen && (
+ <p data-testid="ide-run-on-note" className="mt-2 text-xs text-muted-foreground">
+ The folder is copied to {chosen.name} first, uncommitted changes included. Files like .env
+ and private keys stay on this PC. The coding CLI must be installed there.
+ </p>
+ )}
+ {usable.length === 0 && (
<p className="mt-2 text-xs text-muted-foreground">
Want agents that keep working while this PC is off?{" "}
<button type="button" onClick={() => setActiveSection("computers")}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneSocket.ts b/jarvis/ui/web/frontend/src/components/agentic/paneSocket.ts
index 2dd795a4a1..f43a5d88fb 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/paneSocket.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/paneSocket.ts
@@ -439,7 +439,9 @@ export function openPaneSocket(
// restart plays out, patient afterwards — a workspace restored a quarter
// of an hour later still finds its panes waiting.
waits += 1;
- handlers.onTrouble("Waiting for the workspace to come back…", true);
+ // The server's own sentence when it gave one ("Copying the folder to
+ // vps…" while a pane is set up on a computer); otherwise the restart case.
+ handlers.onTrouble(serverReason || "Waiting for the workspace to come back…", true);
// Before settling into the slow knock, ask once whether the world still
// looks the way this pane thinks it does. A workspace that opened while
// the panes were waiting announces itself, but a pane that has already
diff --git a/jarvis/ui/web/frontend/src/hooks/useComputers.ts b/jarvis/ui/web/frontend/src/hooks/useComputers.ts
index bb5577af1d..747f56dac7 100644
--- a/jarvis/ui/web/frontend/src/hooks/useComputers.ts
+++ b/jarvis/ui/web/frontend/src/hooks/useComputers.ts
@@ -125,7 +125,13 @@ export function useRemoveComputer() {
* an older backend, a test without the route — is simply "no computers".
*/
export function useComputerChoices(): Computer[] {
+ return useComputerChoiceList().computers;
+}
+
+/** The same list, plus whether the one fetch has settled (either way). */
+export function useComputerChoiceList(): { computers: Computer[]; loaded: boolean } {
const [rows, setRows] = useState<Computer[]>([]);
+ const [loaded, setLoaded] = useState(false);
useEffect(() => {
let alive = true;
try {
@@ -134,13 +140,17 @@ export function useComputerChoices(): Computer[] {
.then((list) => {
if (alive && Array.isArray(list)) setRows(list);
})
- .catch(() => undefined);
+ .catch(() => undefined)
+ .finally(() => {
+ if (alive) setLoaded(true);
+ });
} catch {
/* fetch unavailable: no computers */
+ setLoaded(true);
}
return () => {
alive = false;
};
}, []);
- return rows;
+ return { computers: rows, loaded };
}
diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
index 5b46f51f5b..0c24996a4c 100644
--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
@@ -1183,7 +1183,13 @@ export async function resolveDroppedFolder(payload: {
export async function startIdeSession(
folder: string,
terminals: TerminalPlan[],
- options: { projectId?: string; name?: string; computerId?: string } = {},
+ options: {
+ projectId?: string;
+ name?: string;
+ computerId?: string;
+ /** Told the backend's one-line report, e.g. which files stayed on this PC. */
+ onMessage?: (message: string) => void;
+ } = {},
): Promise<IdeState> {
const res = await fetch("/api/agentic-ide/session", {
method: "POST",
@@ -1198,7 +1204,8 @@ export async function startIdeSession(
}),
});
if (!res.ok) throw new Error(await detail(res));
- const body = (await res.json()) as { session: SessionState; state: IdeState };
+ const body = (await res.json()) as { session: SessionState; state: IdeState; message?: string };
+ if (body.message) options.onMessage?.(body.message);
// `state` is authoritative; `session` alone is kept as the fallback for a
// backend that predates the workspace bar.
return (
@@ -1348,14 +1355,20 @@ export async function addTerminal(payload: {
model?: string;
effort?: string;
permission_mode?: string;
-}): Promise<SessionState> {
+ /**
+ * Where the new pane runs: a connected computer's id, or null for this PC.
+ * Omitted, it runs where its anchor (or the whole workspace) runs.
+ */
+ computer_id?: string | null;
+}, options: { onMessage?: (message: string) => void } = {}): Promise<SessionState> {
const res = await fetch("/api/agentic-ide/terminals", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
if (!res.ok) throw new Error(await detail(res));
- const body = (await res.json()) as { state: IdeState };
+ const body = (await res.json()) as { state: IdeState; message?: string };
+ if (body.message) options.onMessage?.(body.message);
if (!body.state.session)
throw new Error("The workspace closed while adding a terminal.");
return body.state.session;
diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
index 53881cc137..b941b009d4 100644
--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
@@ -12,6 +12,11 @@ const api = vi.hoisted(() => ({
syncAgenticIdeSurface: vi.fn(() => Promise.resolve()),
}));
const openProject = vi.hoisted(() => vi.fn());
+const computers = vi.hoisted(() => ({ list: vi.fn() }));
+vi.mock("@/lib/computersApi", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("@/lib/computersApi")>();
+ return { ...actual, computersApi: { ...actual.computersApi, list: computers.list } };
+});
const git = vi.hoisted(() => ({ inspectGit: vi.fn(), prepareGit: vi.fn() }));
vi.mock("@/lib/gitApi", async (importOriginal) => ({ ...(await importOriginal<object>()), ...git }));
vi.mock("@/lib/agenticIdeApi", () => api);
@@ -41,6 +46,7 @@ beforeEach(() => {
api.fetchIdeAgents.mockResolvedValue({ terminal_available: true, max_terminals: 8, suggested_names: [], agents: [agent] });
useIdeProjectsStore.setState({ projects: [], activeWorkspaceId: null, pendingWorkspaceId: null, refreshRequest: null, action: null });
git.inspectGit.mockResolvedValue(repoInfo);
+ computers.list.mockResolvedValue([]);
});
afterEach(cleanup);
@@ -75,7 +81,7 @@ describe("Agentic IDE project flow", () => {
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: "claude" }], { projectId: "p1", name: "Installer" }));
+ await waitFor(() => expect(api.startIdeSession).toHaveBeenCalledWith("/code/app", [{ agent: "codex" }, { agent: "claude" }], { projectId: "p1", name: "Installer", onMessage: expect.any(Function) }));
await waitFor(() => expect(screen.queryByRole("dialog", { name: "New workspace" })).toBeNull());
});
@@ -93,7 +99,7 @@ describe("Agentic IDE project flow", () => {
expect((within(dialog).getByLabelText("Branch name") as HTMLInputElement).value).toBe("agent/brave-river-0001");
fireEvent.click(screen.getByRole("button", { name: "Create workspace" }));
await waitFor(() => expect(git.prepareGit).toHaveBeenCalledWith("/code/app", { mode: "new_worktree", branch: "agent/brave-river-0001", base: "main" }));
- expect(api.startIdeSession).toHaveBeenCalledWith("/code/app/.worktrees/agent-brave-river-0001", [{ agent: "codex" }], { projectId: "p1", name: "agent/brave-river-0001" });
+ expect(api.startIdeSession).toHaveBeenCalledWith("/code/app/.worktrees/agent-brave-river-0001", [{ agent: "codex" }], { projectId: "p1", name: "agent/brave-river-0001", onMessage: expect.any(Function) });
});
it("keeps the launch dialog open while creation is in flight", async () => {
@@ -146,7 +152,7 @@ describe("Agentic IDE project flow", () => {
fireEvent.click(await screen.findByRole("button", { name: "Pane add" }));
expect(screen.getByRole("dialog", { name: "Add coding agent" })).toBeTruthy();
fireEvent.click(screen.getByRole("button", { name: "Codex" }));
- await waitFor(() => expect(api.addTerminal).toHaveBeenCalledWith({ workspace_id: "w1", agent: "codex", direction: "down" }));
+ await waitFor(() => expect(api.addTerminal).toHaveBeenCalledWith({ workspace_id: "w1", agent: "codex", direction: "down" }, { onMessage: expect.any(Function) }));
});
it("lets the user choose which pane to split and in which direction", async () => {
@@ -168,7 +174,7 @@ describe("Agentic IDE project flow", () => {
expect(anchor.getAttribute("data-value")).toBe("T2");
fireEvent.click(within(dialog).getByRole("radio", { name: "Split left" }));
fireEvent.click(within(dialog).getByRole("button", { name: "Codex" }));
- await waitFor(() => expect(api.addTerminal).toHaveBeenCalledWith({ workspace_id: "w1", agent: "codex", anchor: "T2", direction: "left" }));
+ await waitFor(() => expect(api.addTerminal).toHaveBeenCalledWith({ workspace_id: "w1", agent: "codex", anchor: "T2", direction: "left" }, { onMessage: expect.any(Function) }));
expect(api.reorderIdeTerminals).not.toHaveBeenCalled();
});
@@ -285,3 +291,78 @@ describe("Agentic IDE project flow", () => {
});
});
+
+describe("Agentic IDE on a connected computer", () => {
+ const vps = { id: "c1", name: "vps", kind: "server", health: { status: "online", checked_at: 0, latency_ms: 5, message: null, load_1m: null, mem_used_pct: null } };
+ const remoteSession = { id: "w1", project_id: "p1", folder: "/code/app", name: "App work", created_at: 0, focus_mode: false, project: { name: "App" },
+ terminals: [{ key: "t1", history_id: "id1", name: "T1", display_name: "Codex", computer_id: "c1" }] };
+ const withClaudeOnlyThere = [agent, { ...agent, name: "claude", display_name: "Claude Code", installed: false }];
+
+ beforeEach(() => {
+ computers.list.mockResolvedValue([vps]);
+ // A pane jump left behind by an earlier test would switch the workspace.
+ useIdeChatStore.setState({ paneRequest: null, stagedPane: null });
+ try { localStorage.clear(); } catch { /* storage blocked */ }
+ });
+
+ it("opens a new agent where its neighbours run and offers the server's CLIs", async () => {
+ api.fetchIdeState.mockResolvedValue({ ...emptyState, active: true, active_id: "w1", session: remoteSession });
+ api.fetchIdeProjects.mockResolvedValue({ projects: [project], active_workspace_id: "w1" });
+ api.fetchIdeAgents.mockResolvedValue({ terminal_available: true, max_terminals: 8, suggested_names: [], agents: withClaudeOnlyThere });
+ api.addTerminal.mockResolvedValue(remoteSession);
+ render(<AgenticIdeView />);
+ fireEvent.click(await screen.findByRole("button", { name: "Pane add" }));
+ const dialog = screen.getByRole("dialog", { name: "Add coding agent" });
+ const onVps = await within(dialog).findByRole("radio", { name: /vps/ });
+ expect(onVps.getAttribute("aria-checked")).toBe("true");
+ // Installed only on the server: offered there, not for this PC.
+ fireEvent.click(within(dialog).getByRole("button", { name: "Claude Code" }));
+ await waitFor(() => expect(api.addTerminal).toHaveBeenCalledWith(
+ expect.objectContaining({ workspace_id: "w1", agent: "claude", computer_id: "c1" }), { onMessage: expect.any(Function) }));
+ });
+
+ it("says 'this PC' explicitly for a local agent in a remote workspace", async () => {
+ api.fetchIdeState.mockResolvedValue({ ...emptyState, active: true, active_id: "w1", session: remoteSession });
+ api.fetchIdeProjects.mockResolvedValue({ projects: [project], active_workspace_id: "w1" });
+ api.fetchIdeAgents.mockResolvedValue({ terminal_available: true, max_terminals: 8, suggested_names: [], agents: withClaudeOnlyThere });
+ api.addTerminal.mockResolvedValue(remoteSession);
+ render(<AgenticIdeView />);
+ fireEvent.click(await screen.findByRole("button", { name: "Pane add" }));
+ const dialog = screen.getByRole("dialog", { name: "Add coding agent" });
+ await within(dialog).findByRole("radio", { name: /vps/ });
+ fireEvent.click(within(dialog).getByRole("radio", { name: /This computer/ }));
+ expect(within(dialog).queryByRole("button", { name: "Claude Code" })).toBeNull();
+ fireEvent.click(within(dialog).getByRole("button", { name: "Codex" }));
+ await waitFor(() => expect(api.addTerminal).toHaveBeenCalledWith(
+ expect.objectContaining({ agent: "codex", computer_id: null }), { onMessage: expect.any(Function) }));
+ });
+
+ it("creates a workspace on the server and remembers that choice for the project", async () => {
+ api.fetchIdeProjects.mockResolvedValue({ projects: [project], active_project_id: null, active_workspace_id: null, max_terminals: 8 });
+ api.startIdeSession.mockResolvedValue(emptyState);
+ render(<AgenticIdeView />);
+ await screen.findByText("Choose a workspace");
+ act(() => useIdeProjectsStore.getState().newWorkspace("p1"));
+ let dialog = await screen.findByRole("dialog", { name: "New workspace" });
+ fireEvent.click(await within(dialog).findByRole("radio", { name: /vps/ }));
+ expect(within(dialog).getByTestId("ide-run-on-note").textContent).toContain(".env");
+ fireEvent.click(within(dialog).getByRole("button", { name: "Create workspace" }));
+ await waitFor(() => expect(api.startIdeSession).toHaveBeenCalledWith("/code/app", [{ agent: "codex" }],
+ expect.objectContaining({ projectId: "p1", computerId: "c1" })));
+ await waitFor(() => expect(screen.queryByRole("dialog", { name: "New workspace" })).toBeNull());
+
+ act(() => useIdeProjectsStore.getState().newWorkspace("p1"));
+ dialog = await screen.findByRole("dialog", { name: "New workspace" });
+ expect((await within(dialog).findByRole("radio", { name: /vps/ })).getAttribute("aria-checked")).toBe("true");
+ });
+
+ it("falls back to this PC when the remembered computer is gone", async () => {
+ localStorage.setItem("jarvis.agenticIde.runOn.p1", "c-removed");
+ api.fetchIdeProjects.mockResolvedValue({ projects: [project], active_project_id: null, active_workspace_id: null, max_terminals: 8 });
+ render(<AgenticIdeView />);
+ await screen.findByText("Choose a workspace");
+ act(() => useIdeProjectsStore.getState().newWorkspace("p1"));
+ const dialog = await screen.findByRole("dialog", { name: "New workspace" });
+ await waitFor(() => expect(within(dialog).getByRole("radio", { name: /This computer/ }).getAttribute("aria-checked")).toBe("true"));
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
index 66770bb4cb..7adef3b81e 100644
--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
@@ -4,7 +4,7 @@ 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 { RunOnPicker } from "@/components/agentic/RunOnPicker";
+import { RunOnPicker, storeRunOn, storedRunOn } from "@/components/agentic/RunOnPicker";
import { WorkspaceOptionsDialog } from "@/components/agentic/WorkspaceOptionsDialog";
import { FONT_DEFAULT } from "@/components/agentic/paneFont";
import { IdeSidePanelFrame } from "@/components/agentic/sidePanel/IdeSidePanel";
@@ -41,6 +41,13 @@ const SPLIT_DIRECTIONS: { id: PaneSplitDirection; label: string; hint: string; I
const isSplitDirection = (value: unknown): value is PaneSplitDirection =>
SPLIT_DIRECTIONS.some((item) => item.id === value);
+/** The computer every pane of a workspace runs on, or null when it runs here (or mixed). */
+function workspaceRunsOn(terminals: readonly TerminalState[]): string | null {
+ const places = new Set(terminals.map((terminal) => terminal.computer_id || ""));
+ const [only] = [...places];
+ return places.size === 1 && only ? only : null;
+}
+
/** The direction last picked in the dialog; storage may be blocked, so never throw. */
function storedSplitDirection(): PaneSplitDirection {
try {
@@ -78,6 +85,8 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
const [workspaceGit, setWorkspaceGit] = useState<GitPlan>(KEEP_CHECKOUT);
// Where the new workspace's agents run: null = this computer (see RunOnPicker).
const [workspaceComputer, setWorkspaceComputer] = useState<string | null>(null);
+ // Where an added agent runs; preset to where its neighbour runs.
+ const [agentComputer, setAgentComputer] = useState<string | null>(null);
const [agentGit, setAgentGit] = useState<GitPlan>(KEEP_CHECKOUT);
const [gitOpen, setGitOpen] = useState(false);
const [selected, setSelected] = useState("");
@@ -110,7 +119,12 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
const normalizingLayout = useRef(false);
const session = state?.session ?? null;
const maxPanes = state?.max_terminals ?? MAX_WORKSPACE_PANES;
- const installed = agents.filter((agent) => agent.installed && agent.kind !== "shell" && agent.accepts_prompts !== false);
+ const codingAgents = agents.filter((agent) => agent.kind !== "shell" && agent.accepts_prompts !== false);
+ const installed = codingAgents.filter((agent) => agent.installed);
+ // On a connected computer the CLI has to be installed THERE, not here: the
+ // server is checked before anything is copied, so every coding CLI is offered.
+ const workspaceChoices = workspaceComputer ? codingAgents : installed;
+ const agentChoices = agentComputer ? codingAgents : installed;
const dialogOpen = projectDialog || workspaceProject !== null || renameOpen || agentPicker !== null;
useEffect(() => {
@@ -282,6 +296,7 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
if (project) {
setWorkspaceProject(project); setWorkspaceName(""); setWorkspaceAgents([installed[0]?.name ?? ""]);
setWorkspaceGit(action.worktree ? { mode: "new_worktree", branch: "", base: "" } : KEEP_CHECKOUT);
+ setWorkspaceComputer(storedRunOn(project.id));
}
return;
}
@@ -296,17 +311,21 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
setProjects(listing.projects);
publishProjects(listing.projects, listing.active_workspace_id);
const found = listing.projects.find((entry) => entry.id === project.id);
- if (found) { setWorkspaceProject(found); setWorkspaceAgents([installed[0]?.name ?? ""]); setWorkspaceGit(KEEP_CHECKOUT); }
+ if (found) { setWorkspaceProject(found); setWorkspaceAgents([installed[0]?.name ?? ""]); setWorkspaceGit(KEEP_CHECKOUT); setWorkspaceComputer(storedRunOn(found.id)); }
});
+ const notify = useCallback((message: string) => pushToast("success", message), [pushToast]);
+
const createWorkspace = () => void run(async () => {
if (!workspaceProject || workspaceAgents.length === 0 || workspaceAgents.some((agent) => !agent)) throw new Error("Choose an installed coding agent for every session.");
+ storeRunOn(workspaceProject.id, workspaceComputer);
// Git first: a new branch or worktree decides WHICH folder the agents start in.
const prepared = workspaceGit.mode === "current" ? null : await prepareGit(workspaceProject.path, workspaceGit);
const ownCheckout = workspaceGit.mode === "new_worktree" || workspaceGit.mode === "open_worktree";
const next = await startIdeSession(prepared?.folder ?? workspaceProject.path, workspaceAgents.map((agent) => ({ agent })), {
projectId: workspaceProject.id, name: workspaceName.trim() || (ownCheckout && prepared?.branch ? prepared.branch : undefined),
computerId: workspaceComputer ?? undefined,
+ onMessage: notify,
});
setState(next);
setWorkspaceProject(null);
@@ -316,24 +335,31 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
// An agent with a worktree of its own opens as its own workspace tab in that
// worktree, grouped under the same project, so its files never collide with
// the agents sharing the original checkout.
- const addAgentInWorktree = (agentName: string, plan: GitPlan) => void run(async () => {
+ const addAgentInWorktree = (agentName: string, plan: GitPlan, computerId: string | null) => void run(async () => {
if (!session) return;
const prepared = await prepareGit(session.folder, plan);
setState(await startIdeSession(prepared.folder, [{ agent: agentName }], {
projectId: session.project_id ?? undefined, name: prepared.branch || undefined,
+ computerId: computerId ?? undefined, onMessage: notify,
}));
if (prepared.message) pushToast("success", prepared.message);
});
+ // A worktree opened from the Git panel runs where the workspace it came from runs.
const openWorktreeWorkspace = (path: string, branch: string) => void run(async () => {
- const agent = installed[0]?.name;
+ const computerId = session ? workspaceRunsOn(session.terminals) : null;
+ const agent = (computerId ? codingAgents : installed)[0]?.name;
if (!agent) throw new Error("Connect a coding agent in CLIs to continue.");
- setState(await startIdeSession(path, [{ agent }], { projectId: session?.project_id ?? undefined, name: branch || undefined }));
+ setState(await startIdeSession(path, [{ agent }], {
+ projectId: session?.project_id ?? undefined, name: branch || undefined,
+ computerId: computerId ?? undefined, onMessage: notify,
+ }));
});
const newWorktreeWorkspace = () => {
const project = projects.find((entry) => entry.id === session?.project_id);
if (!project) { pushToast("error", "This workspace belongs to no connected project."); return; }
setWorkspaceProject(project); setWorkspaceName(""); setWorkspaceAgents([installed[0]?.name ?? ""]);
setWorkspaceGit({ mode: "new_worktree", branch: "", base: "" });
+ setWorkspaceComputer(session ? workspaceRunsOn(session.terminals) : storedRunOn(project.id));
};
const addAgent = (
@@ -341,15 +367,22 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
workspaceId: string,
anchorName?: string,
direction: PaneSplitDirection = "down",
+ computerId: string | null = null,
+ onDone?: () => void,
) => void run(async () => {
const wasBalanced = session?.id === workspaceId && isBalancedWorkspace(session.layout, session.terminals);
const hasExplicitAnchor = Boolean(anchorName);
+ // "This PC" is said out loud only where it differs from the default: in a
+ // workspace with remote panes, an omitted choice would follow them.
+ const anyRemote = Boolean(session?.terminals.some((terminal) => terminal.computer_id));
let next = await addTerminal({
workspace_id: workspaceId,
agent: agentName,
anchor: anchorName || undefined,
direction,
- });
+ ...(computerId ? { computer_id: computerId } : anyRemote ? { computer_id: null } : {}),
+ }, { onMessage: notify });
+ onDone?.();
// Grow an automatic grid evenly when adding without an explicit anchor;
// keep a custom arrangement until another pane would exceed the workspace bounds.
if (next.id === workspaceId && next.terminals.length > 1 && ((wasBalanced && !hasExplicitAnchor) || (next.layout && !fitsWorkspace(next.layout)))) {
@@ -393,6 +426,10 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
setSplitAnchor(session.terminals.some((terminal) => terminal.name === pane) ? pane : "");
setSplitDirection(isSplitDirection(direction) ? direction : storedSplitDirection());
setAgentGit(KEEP_CHECKOUT);
+ // A new agent runs where the pane it opens beside runs, else where the
+ // whole workspace runs; the dialog lets the user pick another place.
+ const anchorPane = session.terminals.find((terminal) => terminal.name === pane);
+ setAgentComputer(anchorPane ? anchorPane.computer_id || null : workspaceRunsOn(session.terminals));
setAgentPicker({ id: session.id, name: session.name ?? session.project.name });
}, [session, selected]);
// The chosen direction when it fits; otherwise the first that does; null
@@ -469,6 +506,7 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
</div>
{session && <div className="mb-4"><GitCheckoutPicker folder={session.folder} value={agentGit} onChange={setAgentGit} disabled={busy} context="agent" /></div>}
+ <div className="mb-4"><RunOnPicker value={agentComputer} onChange={setAgentComputer} disabled={busy} hideWhenNone /></div>
{session && session.terminals.length > 0 && agentGit.mode === "current" && (() => {
const anchorTerminal = session.terminals.find((terminal) => terminal.name === splitAnchor);
@@ -505,17 +543,23 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
<div className="grid grid-cols-1 gap-2 sm:grid-cols-2">
{workspaceFull && agentGit.mode === "current" && <p role="status" className="col-span-full rounded-lg border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground">
This workspace is full ({maxPanes} agents). Close a pane, or open another workspace for more agents.</p>}
- {installed.map((agent) => <button key={agent.name} type="button" disabled={busy || (workspaceFull && agentGit.mode === "current")}
+ {agentChoices.map((agent) => <button key={agent.name} type="button" disabled={busy || (workspaceFull && agentGit.mode === "current")}
onClick={() => {
- const owner = agentPicker.id; setAgentPicker(null);
- if (agentGit.mode !== "current") addAgentInWorktree(agent.name, agentGit);
- else addAgent(agent.name, owner, effectiveDirection ? splitAnchor : undefined, effectiveDirection ?? "down");
+ const owner = agentPicker.id;
+ // Copying a folder to a computer takes a while: the dialog stays
+ // open, saying so, until the pane exists there.
+ const close = () => setAgentPicker(null);
+ if (!agentComputer) close();
+ if (agentGit.mode !== "current") { addAgentInWorktree(agent.name, agentGit, agentComputer); if (agentComputer) close(); }
+ else addAgent(agent.name, owner, effectiveDirection ? splitAnchor : undefined, effectiveDirection ?? "down", agentComputer, agentComputer ? close : undefined);
}}
className="flex min-h-12 items-center gap-3 rounded-lg border border-border px-3 py-2 text-left text-sm font-medium hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
<AgentMark agent={agent.name} label={agent.display_name} logoUrl={agent.logo_url} variant="plain" />{agent.display_name}
</button>)}
</div>
- {installed.length === 0 && <p className="text-sm text-muted-foreground">Connect a coding agent in CLIs to continue.</p>}
+ {busy && agentComputer && <p role="status" className="mt-3 flex items-center gap-2 text-xs text-muted-foreground">
+ <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden="true" />Copying the folder and starting the agent there. Large folders take a minute.</p>}
+ {agentChoices.length === 0 && <p className="text-sm text-muted-foreground">Connect a coding agent in CLIs to continue.</p>}
</section>
</div>}
@@ -547,7 +591,7 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
<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} maxSessions={maxPanes} />
+ <WorkspaceAgentSetup agents={workspaceChoices} sessions={workspaceAgents} onChange={setWorkspaceAgents} disabled={busy} maxSessions={maxPanes} />
<GitCheckoutPicker folder={workspaceProject.path} value={workspaceGit} onChange={setWorkspaceGit} disabled={busy} context="workspace" />
<RunOnPicker value={workspaceComputer} onChange={setWorkspaceComputer} disabled={busy} />
</div>
@@ -555,8 +599,8 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
<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>
+ <button type="button" disabled={busy || workspaceAgents.length === 0 || workspaceAgents.some((name) => !workspaceChoices.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 ? (workspaceComputer ? "Copying the folder…" : "Starting…") : "Create workspace"}</button>
</div>
</footer>
</section>