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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(office): drop files and open a new workspace from the spawn point
rubenluetke10-beep9cff551de3af
diff --git a/jarvis/ui/web/frontend/src/components/society/office/MissionControlPanel.tsx b/jarvis/ui/web/frontend/src/components/society/office/MissionControlPanel.tsxindex 2506fb2221..8b068ad220 100644--- a/jarvis/ui/web/frontend/src/components/society/office/MissionControlPanel.tsx+++ b/jarvis/ui/web/frontend/src/components/society/office/MissionControlPanel.tsx@@ -6,20 +6,27 @@* (workspace, CLI, how many) and, when a task is given, waits for each pane to* come up and hands it the task through `/terminals/{name}/prompt` — the path* voice and the grid use, so every prompt is recorded and receipted the same- * way. "Message several agents" sends one message to every picked session.- * The office adds no backend contract of its own.+ * way. Files dropped on the launcher are held until each pane is live and+ * then go through the pane's own `/terminals/{name}/attach`. "New workspace"+ * opens a folder as another workspace through the IDE's `POST /session`,+ * with the new agents as its panes. "Message several agents" sends one+ * message to every picked session. The office adds no backend contract of+ * its own.*/-import { useCallback, useEffect, useMemo, useState, type KeyboardEvent } from "react";-import { Minus, Plus } from "lucide-react";+import { useCallback, useEffect, useMemo, useRef, useState, type KeyboardEvent } from "react";+import { Minus, Paperclip, Plus, X } from "lucide-react";import { useT } from "@/i18n";import {- fetchIdeAgents, fetchIdeState, fetchWorkspacePanes, interruptTerminal, openTerminal, promptTerminal,- type AgentStatus, type WorkspaceCard,+ attachToTerminal, fetchIdeAgents, fetchIdeProjects, fetchIdeState, fetchWorkspacePanes, interruptTerminal,+ openIdeWorkspace, openTerminal, promptTerminal,+ type AgentStatus, type DropAttachment, type IdeProject, type WorkspaceCard,} from "@/lib/agenticIdeApi";-import { useEventStore } from "@/store/events";+import { openProject } from "@/lib/chatLibraryApi";import { useWorkspacePanesStore } from "@/store/workspacePanes";import { AgentMark } from "@/components/agentic/AgentMark";import { paneOccupants, type PaneOccupant } from "./codingFloor";+import { NewWorkspaceFields, type NewWorkspaceTarget } from "./NewWorkspaceFields";+import { briefWithFiles, heldPayload, useSpawnFiles, type HeldFile } from "./spawnFiles";import "./missionControl.css";/** At most this many agents per launch; the IDE caps the workspace on its own too. */@@ -29,6 +36,9 @@ const START_TIMEOUT_MS = 30_000;const START_POLL_MS = 600;const START_JITTER_MS = 300;+/** The workspace picker's value for "open a new workspace". */+export const NEW_WORKSPACE = "__new__";+type LaunchLine = { tone: "busy" | "ok" | "warn" | "error"; text: string };/** Coding CLIs a new agent can run: installed, and not a plain shell. Pure. */@@ -36,6 +46,11 @@ export function launchableAgents(agents: readonly AgentStatus[]): AgentStatus[]return agents.filter((a) => a.installed && (a.kind ?? "cli") !== "shell");}+/** Projects a new workspace can open in: real, reachable folders the user connected. Pure. */+export function workspaceProjects(projects: readonly IdeProject[]): IdeProject[] {+ return projects.filter((p) => !p.scratch && !p.archived && p.exists);+}+/** Every session on the floor, or none: the one bulk pick the list offers. Pure. */export function pickAll(occupants: readonly PaneOccupant[], picked: ReadonlySet<string>): Set<string> {const everyone = occupants.every((o) => picked.has(o.agent.agentId));@@ -64,19 +79,32 @@ function errorText(err: unknown): string {return err instanceof Error ? err.message : String(err);}-/** Start coding agents: CLI, workspace, how many and an optional first task. Also the coding floor's spawn point. */+/** What a launch read once and every pane shares: the attached files, as references and analysis. */+type Handover = { references: string[]; analysis: DropAttachment[] };++/** Start coding agents: CLI, workspace (or a new one), how many, an optional first task and files. Also the coding floor's spawn point. */export function StartAgent() {const t = useT();const [workspaces, setWorkspaces] = useState<WorkspaceCard[] | null>(null);+ const [projects, setProjects] = useState<IdeProject[]>([]);const [agents, setAgents] = useState<AgentStatus[] | null>(null);const [loadError, setLoadError] = useState<string | null>(null);const [workspaceId, setWorkspaceId] = useState("");+ const [newTarget, setNewTarget] = useState<NewWorkspaceTarget | null>(null);+ const [newName, setNewName] = useState("");const [agentName, setAgentName] = useState("");const [count, setCount] = useState(1);const [task, setTask] = useState("");const [sharpen, setSharpen] = useState(false);const [running, setRunning] = useState(false);const [lines, setLines] = useState<LaunchLine[]>([]);+ const files = useSpawnFiles();+ const fileInput = useRef<HTMLInputElement>(null);++ const loadProjects = useCallback(() => fetchIdeProjects()+ .then((listing) => setProjects(workspaceProjects(listing.projects)))+ // Only the new-workspace picker lists these; without them it still offers "choose a folder".+ .catch((err) => console.warn("Mission Control: projects did not load", err)), []);useEffect(() => {let alive = true;@@ -84,68 +112,126 @@ export function StartAgent() {.then(([state, list]) => {if (!alive) return;setWorkspaces(state.workspaces);- setWorkspaceId((current) => current || state.active_id || state.workspaces[0]?.id || "");+ setWorkspaceId((current) => current || state.active_id || state.workspaces[0]?.id || NEW_WORKSPACE);const usable = launchableAgents(list.agents);setAgents(usable);setAgentName((current) => current || usable[0]?.name || "");}).catch((err) => { if (alive) setLoadError(errorText(err)); });+ void loadProjects();return () => { alive = false; };- }, []);+ }, [loadProjects]);const setLine = (index: number, line: LaunchLine) =>setLines((prev) => { const next = [...prev]; next[index] = line; return next; });+ /** Wait for one new pane, then hand it the files and the task. */+ const settle = async (+ i: number, name: string, wsId: string, brief: string, held: readonly HeldFile[], shared: { handover?: Handover },+ ) => {+ if (!brief && held.length === 0) {+ setLine(i, { tone: "ok", text: t("society.office.mission_done_open").replace("{0}", name) });+ return;+ }+ setLine(i, { tone: "busy", text: t("society.office.mission_waiting").replace("{0}", name) });+ if (!(await waitLive(wsId, name))) {+ setLine(i, { tone: "warn", text: t("society.office.mission_not_started").replace("{0}", name) });+ return;+ }+ let text = brief;+ let attachments: DropAttachment[] = [];+ if (held.length > 0) {+ setLine(i, { tone: "busy", text: t("society.office.mission_files_handing").replace("{0}", name) });+ let handover: Handover;+ try {+ if (!brief) {+ // Files alone: typed into the pane's input, as a drop on the pane itself would be.+ await attachToTerminal(name, heldPayload(held));+ setLine(i, { tone: "ok", text: t("society.office.mission_files_typed").replace("{0}", name) });+ return;+ }+ // Read once per launch: every pane shares the workspace and the CLI, so+ // the references are the same, and describing a picture again for each+ // pane would bill the user again for the same answer.+ handover = shared.handover ??= await attachToTerminal(name, { ...heldPayload(held), analyze: true, deliver: false })+ .then((result) => ({ references: result.references, analysis: result.analysis ?? [] }));+ } catch (err) {+ setLine(i, { tone: "error", text: t("society.office.mission_files_failed").replace("{0}", name).replace("{1}", errorText(err)) });+ return;+ }+ attachments = handover.analysis;+ text = briefWithFiles(brief, handover.references, attachments);+ }+ setLine(i, { tone: "busy", text: t("society.office.mission_briefing").replace("{0}", name) });+ try {+ const result = await promptTerminal(name, text, { compose: sharpen, workspaceId: wsId, attachments });+ setLine(i, result.submitted === true+ ? { tone: "ok", text: t("society.office.mission_done_briefed").replace("{0}", name) }+ : { tone: "warn", text: result.detail || t("society.office.cmd_unconfirmed") });+ } catch (err) {+ setLine(i, { tone: "error", text: errorText(err) });+ }+ };++ const creating = workspaceId === NEW_WORKSPACE;+ const ready = Boolean(agentName) && (creating ? newTarget !== null : Boolean(workspaceId));+const launch = async () => {- if (running || !workspaceId || !agentName) return;+ if (running || !ready) return;setRunning(true);setLines([]);const brief = task.trim();- for (let i = 0; i < count; i += 1) {- setLine(i, { tone: "busy", text: t("society.office.mission_opening") });- let name = "";+ const held = files.held;+ const shared: { handover?: Handover } = {};+ let opened = 0;+ if (creating && newTarget) {+ setLine(0, { tone: "busy", text: t("society.office.mission_ws_creating") });try {- name = (await openTerminal({ workspace_id: workspaceId, agent: agentName })).name;+ const project = newTarget.projectId ? { id: newTarget.projectId, path: newTarget.path } : await openProject(newTarget.path);+ const { session, state } = await openIdeWorkspace(+ project.path, Array.from({ length: count }, () => ({ agent: agentName })),+ { projectId: project.id, name: newName.trim() || undefined },+ );+ // The next launch lands beside these agents, not in yet another new workspace.+ setWorkspaces(state.workspaces);+ setWorkspaceId(session.id);+ setNewTarget(null);+ setNewName("");+ void loadProjects();+ void useWorkspacePanesStore.getState().load();+ opened = session.terminals.length;+ for (const [i, term] of session.terminals.entries()) await settle(i, term.name, session.id, brief, held, shared);} catch (err) {- setLine(i, { tone: "error", text: t("society.office.mission_failed").replace("{0}", errorText(err)) });- break;+ setLine(0, { tone: "error", text: t("society.office.mission_failed").replace("{0}", errorText(err)) });}- void useWorkspacePanesStore.getState().load();- if (!brief) { setLine(i, { tone: "ok", text: t("society.office.mission_done_open").replace("{0}", name) }); continue; }- setLine(i, { tone: "busy", text: t("society.office.mission_waiting").replace("{0}", name) });- if (!(await waitLive(workspaceId, name))) {- setLine(i, { tone: "warn", text: t("society.office.mission_not_started").replace("{0}", name) });- continue;- }- setLine(i, { tone: "busy", text: t("society.office.mission_briefing").replace("{0}", name) });- try {- const result = await promptTerminal(name, brief, { compose: sharpen, workspaceId });- setLine(i, result.submitted === true- ? { tone: "ok", text: t("society.office.mission_done_briefed").replace("{0}", name) }- : { tone: "warn", text: result.detail || t("society.office.cmd_unconfirmed") });- } catch (err) {- setLine(i, { tone: "error", text: errorText(err) });+ } else {+ for (let i = 0; i < count; i += 1) {+ setLine(i, { tone: "busy", text: t("society.office.mission_opening") });+ let name = "";+ try {+ name = (await openTerminal({ workspace_id: workspaceId, agent: agentName })).name;+ } catch (err) {+ setLine(i, { tone: "error", text: t("society.office.mission_failed").replace("{0}", errorText(err)) });+ break;+ }+ opened += 1;+ void useWorkspacePanesStore.getState().load();+ await settle(i, name, workspaceId, brief, held, shared);}}- if (brief) setTask("");+ // Kept for another try when not a single agent opened.+ if (opened > 0) {+ if (brief) setTask("");+ files.release(held);+ }void useWorkspacePanesStore.getState().load();setRunning(false);};if (loadError) return <p className="office-mc-note" role="alert">{loadError}</p>;if (!workspaces || !agents) return <p className="office-mc-note" role="status">{t("society.office.mission_loading")}</p>;- if (workspaces.length === 0) {- return (- <div className="office-mc-empty">- <p>{t("society.office.mission_no_workspace")}</p>- <button type="button" className="office-mc-primary" onClick={() => useEventStore.getState().setActiveSection("agentic-ide")}>- {t("society.office.open_ide")}- </button>- </div>- );- }return (- <div className="office-mc-block">+ <div className="office-mc-block office-mc-dropzone" data-dragging={files.dragging || undefined} {...files.handlers}>{agents.length === 0 ? <p className="office-mc-note">{t("society.office.mission_no_agents")}</p> : (<div className="office-mc-agents" role="radiogroup" aria-label={t("society.office.mission_agent")}>{agents.map((a) => (@@ -158,25 +244,48 @@ export function StartAgent() {</div>)}- {workspaces.length > 1 && (+ {workspaces.length === 0 ? <p className="office-mc-note">{t("society.office.mission_no_workspace")}</p> : (<label className="office-mc-row"><span>{t("society.office.mission_workspace")}</span><select value={workspaceId} onChange={(e) => setWorkspaceId(e.target.value)} disabled={running}>{workspaces.map((w) => <option key={w.id} value={w.id}>{w.name}{w.branch ? ` · ${w.branch}` : ""}</option>)}+ <option value={NEW_WORKSPACE}>{t("society.office.mission_ws_new")}</option></select></label>)}+ {creating && (+ <NewWorkspaceFields projects={projects} target={newTarget} onTarget={setNewTarget}+ name={newName} onName={setNewName} disabled={running} />+ )}<textarea className="office-mc-task" rows={3} value={task} maxLength={8000} disabled={running}placeholder={t("society.office.mission_task_placeholder")} aria-label={t("society.office.mission_task")}- onChange={(e) => setTask(e.target.value)}+ onChange={(e) => setTask(e.target.value)} onPaste={files.onPaste}onKeyDown={(e) => { if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) { e.preventDefault(); void launch(); } }} />- {task.trim() && (- <label className="office-cmd-check">- <input type="checkbox" checked={sharpen} disabled={running} onChange={(e) => setSharpen(e.target.checked)} />- <span>{t("society.office.cmd_sharpen")}</span>- </label>+ {files.held.length > 0 && (+ <ul className="office-mc-files" aria-label={t("society.office.mission_files_attach")}>+ {files.held.map((h) => (+ <li key={h.key} title={h.path ?? h.name}>+ <span>{h.name}</span>+ <button type="button" disabled={running} onClick={() => files.remove(h.key)}+ aria-label={t("society.office.mission_files_remove").replace("{0}", h.name)}><X aria-hidden /></button>+ </li>+ ))}+ </ul>)}+ <div className="office-mc-tools">+ <button type="button" className="office-mc-link office-mc-attach" disabled={running} onClick={() => fileInput.current?.click()}>+ <Paperclip aria-hidden />{t("society.office.mission_files_attach")}+ </button>+ <input ref={fileInput} type="file" multiple hidden tabIndex={-1}+ onChange={(e) => { files.addFiles(Array.from(e.target.files ?? [])); e.target.value = ""; }} />+ {task.trim() && (+ <label className="office-cmd-check">+ <input type="checkbox" checked={sharpen} disabled={running} onChange={(e) => setSharpen(e.target.checked)} />+ <span>{t("society.office.cmd_sharpen")}</span>+ </label>+ )}+ </div><div className="office-mc-go"><div className="office-mc-stepper" role="group" aria-label={t("society.office.mission_count")}>@@ -186,7 +295,7 @@ export function StartAgent() {<button type="button" disabled={running || count >= MAX_LAUNCH} onClick={() => setCount((n) => n + 1)}aria-label={t("society.office.mission_more")}><Plus aria-hidden /></button></div>- <button type="button" className="office-mc-primary" disabled={running || !workspaceId || !agentName} onClick={() => void launch()}>+ <button type="button" className="office-mc-primary" disabled={running || !ready} onClick={() => void launch()}>{count === 1 ? t("society.office.mission_start_one") : t("society.office.mission_start_many").replace("{0}", String(count))}</button></div>@@ -196,6 +305,7 @@ export function StartAgent() {{lines.map((line, i) => <li key={i} data-tone={line.tone}><i aria-hidden />{line.text}</li>)}</ul>)}+ {files.dragging && <div className="office-mc-drophint" aria-hidden>{t("society.office.mission_files_drop")}</div>}</div>);}diff --git a/jarvis/ui/web/frontend/src/components/society/office/NewWorkspaceFields.tsx b/jarvis/ui/web/frontend/src/components/society/office/NewWorkspaceFields.tsxnew file mode 100644index 0000000000..47e82a203b--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/office/NewWorkspaceFields.tsx@@ -0,0 +1,93 @@+/**+ * A new workspace, chosen at the spawn point: which folder, and what the tab+ * is called. Only the CHOICE is made here. The workspace itself is opened by+ * the launch, with the new agents already in it, so a spawn point closed+ * halfway leaves no empty workspace and no half-registered project behind.+ */+import { lazy, Suspense, useState } from "react";+import * as Dialog from "@radix-ui/react-dialog";+import { X } from "lucide-react";+import { useT } from "@/i18n";+import type { IdeProject } from "@/lib/agenticIdeApi";++const FolderPicker = lazy(() => import("@/components/agentic/FolderPicker").then((module) => ({ default: module.FolderPicker })));++/** Where the new workspace opens: a connected project, or a folder that is not one yet. */+export interface NewWorkspaceTarget {+ path: string;+ label: string;+ projectId?: string;+}++const PICK = "__pick__";++const samePath = (a: string, b: string) =>+ a.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase() === b.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();++/** A picked folder as a target: the connected project it already is, if any. Pure. */+export function folderTarget(path: string, projects: readonly IdeProject[]): NewWorkspaceTarget {+ const project = projects.find((p) => samePath(p.path, path));+ if (project) return { path: project.path, label: project.name, projectId: project.id };+ return { path, label: path.replace(/[\\/]+$/, "").split(/[\\/]/).pop() || path };+}++export function NewWorkspaceFields({ projects, target, onTarget, name, onName, disabled }: {+ projects: readonly IdeProject[];+ target: NewWorkspaceTarget | null;+ onTarget: (target: NewWorkspaceTarget) => void;+ name: string;+ onName: (name: string) => void;+ disabled: boolean;+}) {+ const t = useT();+ const [picking, setPicking] = useState(false);+ const [candidate, setCandidate] = useState<string | null>(null);+ const value = target ? target.projectId ?? `folder:${target.path}` : "";++ return (+ <>+ <label className="office-mc-row">+ <span>{t("society.office.mission_ws_folder")}</span>+ <select value={value} disabled={disabled} title={target?.path}+ onChange={(e) => {+ // Picking "choose a folder" leaves the select on what it showed+ // before, so closing the window without a choice changes nothing.+ if (e.target.value === PICK) { setCandidate(target?.path ?? null); setPicking(true); return; }+ const project = projects.find((p) => p.id === e.target.value);+ if (project) onTarget({ path: project.path, label: project.name, projectId: project.id });+ }}>+ {!target && <option value="" disabled>{t("society.office.mission_ws_pick")}</option>}+ {projects.map((p) => <option key={p.id} value={p.id} title={p.path}>{p.name}</option>)}+ {target && !target.projectId && <option value={value} title={target.path}>{target.label}</option>}+ <option value={PICK}>{t("society.office.mission_ws_choose")}</option>+ </select>+ </label>+ <label className="office-mc-row">+ <span>{t("society.office.mission_ws_name")}</span>+ <input className="office-mc-input" value={name} maxLength={80} disabled={disabled}+ placeholder={target?.label ?? ""} onChange={(e) => onName(e.target.value)} />+ </label>++ <Dialog.Root open={picking} onOpenChange={setPicking}>+ <Dialog.Portal>+ <Dialog.Overlay className="fixed inset-0 z-[90] bg-[rgb(var(--scrim-rgb)/0.4)]" />+ <Dialog.Content className="fixed left-1/2 top-1/2 z-[91] flex max-h-[85vh] w-[min(680px,calc(100vw-24px))] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border border-border bg-popover p-4 text-foreground shadow-float">+ <Dialog.Title className="pr-8 text-sm font-semibold">{t("society.office.mission_ws_choose_title")}</Dialog.Title>+ <Dialog.Description className="mt-1 text-xs text-muted-foreground">{t("society.office.mission_ws_choose_hint")}</Dialog.Description>+ <Dialog.Close aria-label={t("society.office.mission_ws_close")} className="absolute right-3 top-3 rounded p-1 hover:bg-secondary"><X className="h-4 w-4" /></Dialog.Close>+ <div className="my-3 min-h-0 overflow-auto">+ <Suspense fallback={<p className="text-xs text-muted-foreground">{t("society.office.mission_loading")}</p>}>+ {picking && <FolderPicker selected={candidate} onSelect={setCandidate} />}+ </Suspense>+ </div>+ <button type="button" disabled={!candidate}+ onClick={() => { if (candidate) onTarget(folderTarget(candidate, projects)); setPicking(false); }}+ className="self-end rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-40">+ {t("society.office.mission_ws_use")}+ </button>+ </Dialog.Content>+ </Dialog.Portal>+ </Dialog.Root>+ </>+ );+}diff --git a/jarvis/ui/web/frontend/src/components/society/office/missionControl.css b/jarvis/ui/web/frontend/src/components/society/office/missionControl.cssindex e3324521f4..438f4fcb28 100644--- a/jarvis/ui/web/frontend/src/components/society/office/missionControl.css+++ b/jarvis/ui/web/frontend/src/components/society/office/missionControl.css@@ -38,7 +38,8 @@.office-mc-agents button:disabled { opacity:.5; cursor:not-allowed; }.office-mc-row { display:flex; align-items:center; justify-content:space-between; gap:10px; font-size:12px; color:hsl(var(--muted-foreground)); }-.office-mc-row select { flex:0 1 60%; min-width:0; padding:6px 8px; border:1px solid hsl(var(--border)); border-radius:8px; background:hsl(var(--background)); color:hsl(var(--foreground)); font:inherit; font-size:12px; }+.office-mc-row select, .office-mc-row input { flex:0 1 60%; min-width:0; padding:6px 8px; border:1px solid hsl(var(--border)); border-radius:8px; background:hsl(var(--background)); color:hsl(var(--foreground)); font:inherit; font-size:12px; }+.office-mc-row input::placeholder { color:hsl(var(--muted-foreground)); }.office-mc-task { width:100%; min-height:44px; resize:vertical; padding:9px 10px; border:1px solid hsl(var(--border)); border-radius:10px; background:hsl(var(--background)); color:hsl(var(--foreground)); font:inherit; font-size:13px; line-height:1.4; }.office-mc-task::placeholder { color:hsl(var(--muted-foreground)); }@@ -57,7 +58,22 @@.office-mc-primary:disabled, .office-mc-secondary:disabled { opacity:.4; cursor:not-allowed; }.office-mc-link { align-self:flex-start; padding:0; border:0; background:none; color:hsl(var(--muted-foreground)); font:inherit; font-size:12px; text-decoration:underline; text-underline-offset:2px; cursor:pointer; }.office-mc-link:hover { color:hsl(var(--foreground)); }-.office-mc button:focus-visible, .office-mc select:focus-visible, .office-mc textarea:focus-visible, .office-mc summary:focus-visible { outline:2px solid hsl(var(--ring)); outline-offset:2px; }+.office-mc button:focus-visible, .office-mc select:focus-visible, .office-mc input:focus-visible, .office-mc textarea:focus-visible, .office-mc summary:focus-visible { outline:2px solid hsl(var(--ring)); outline-offset:2px; }++/* Files: the whole launcher takes a drop; what is held sits under the task as quiet chips. */+.office-mc-dropzone { position:relative; }+.office-mc-drophint { position:absolute; inset:-6px; display:flex; align-items:center; justify-content:center; padding:16px; border:1.5px dashed hsl(var(--ring)); border-radius:12px; background:hsl(var(--background) / .9); color:hsl(var(--foreground)); font-size:13px; font-weight:600; text-align:center; pointer-events:none; }+.office-mc-tools { display:flex; align-items:center; justify-content:space-between; gap:10px; }+.office-mc-attach { display:inline-flex; align-items:center; gap:5px; text-decoration:none; }+.office-mc-attach svg { width:13px; height:13px; }+.office-mc-attach:disabled { opacity:.45; cursor:not-allowed; }+.office-mc-files { list-style:none; margin:0; padding:0; display:flex; flex-wrap:wrap; gap:6px; }+.office-mc-files li { display:inline-flex; align-items:center; gap:2px; max-width:100%; min-width:0; padding:2px 3px 2px 9px; border:1px solid hsl(var(--border)); border-radius:999px; background:hsl(var(--secondary) / .6); color:hsl(var(--foreground)); font-size:11px; }+.office-mc-files span { max-width:220px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }+.office-mc-files button { display:inline-flex; align-items:center; justify-content:center; flex:none; width:18px; height:18px; padding:0; border:0; border-radius:50%; background:none; color:hsl(var(--muted-foreground)); cursor:pointer; }+.office-mc-files button:hover:not(:disabled) { background:hsl(var(--secondary)); color:hsl(var(--foreground)); }+.office-mc-files button:disabled { opacity:.45; cursor:not-allowed; }+.office-mc-files button svg { width:12px; height:12px; }/* Launch progress: one quiet line per agent with a status dot. */.office-mc-log { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:5px; font-size:12px; color:hsl(var(--foreground)); }diff --git a/jarvis/ui/web/frontend/src/components/society/office/missionControl.test.ts b/jarvis/ui/web/frontend/src/components/society/office/missionControl.test.tsindex 1e08b6591b..e981ca2ddd 100644--- a/jarvis/ui/web/frontend/src/components/society/office/missionControl.test.ts+++ b/jarvis/ui/web/frontend/src/components/society/office/missionControl.test.ts@@ -1,8 +1,16 @@import { describe, expect, it } from "vitest";-import type { AgentStatus } from "@/lib/agenticIdeApi";+import type { AgentStatus, DropAttachment, IdeProject } from "@/lib/agenticIdeApi";import type { PaneOccupant } from "./codingFloor";-import { launchableAgents, pickAll } from "./MissionControlPanel";+import { launchableAgents, pickAll, workspaceProjects } from "./MissionControlPanel";+import { folderTarget } from "./NewWorkspaceFields";import { liveGrid } from "./PaneLiveScreen";+import { briefWithFiles, heldPayload, holdDrop } from "./spawnFiles";++const project = (id: string, path: string, extra: Partial<IdeProject> = {}): IdeProject =>+ ({ id, path, name: id, scratch: false, archived: false, exists: true, workspaces: [], ...extra } as IdeProject);++const described = (reference: string): DropAttachment =>+ ({ name: reference, reference, kind: "image", detail: "a chart", described_by: "vision", note: "" });const cli = (name: string, extra: Partial<AgentStatus> = {}): AgentStatus => ({name, display_name: name, installed: true, version: null, install_command: null, ...extra,@@ -37,4 +45,35 @@ describe("mission control", () => {expect([...pickAll(floor, new Set(["b"]))]).toEqual(["a", "b", "c"]);expect([...pickAll(floor, new Set(["a", "b", "c"]))]).toEqual([]);});++ it("offers a new workspace only in real, reachable, connected folders", () => {+ const list = [project("shop", "/w/shop"), project("chats", "/w/c", { scratch: true }),+ project("old", "/w/old", { archived: true }), project("usb", "/mnt/usb", { exists: false })];+ expect(workspaceProjects(list).map((p) => p.id)).toEqual(["shop"]);+ });++ it("recognises a picked folder that is already a connected project", () => {+ const list = [project("shop", "C:\\work\\shop")];+ expect(folderTarget("c:/work/shop/", list)).toEqual({ path: "C:\\work\\shop", label: "shop", projectId: "shop" });+ expect(folderTarget("/home/me/new-app", list)).toEqual({ path: "/home/me/new-app", label: "new-app" });+ });+});++describe("spawn point files", () => {+ const shot = new File(["png"], "shot.png", { type: "image/png", lastModified: 1 });++ it("holds each dropped file once, paths and bytes alike", () => {+ const once = holdDrop([], { paths: ["C:\\docs\\spec.pdf"], files: [shot] });+ const twice = holdDrop(once, { paths: ["c:/docs/spec.pdf"], files: [shot] });+ expect(twice.map((h) => h.name)).toEqual(["spec.pdf", "shot.png"]);+ expect(heldPayload(twice)).toEqual({ paths: ["C:\\docs\\spec.pdf"], files: [shot] });+ });++ it("writes in only the files the analysis did not describe, never ending on one", () => {+ expect(briefWithFiles("Fix it", ["@a.png"], [described("@a.png")])).toBe("Fix it");+ const brief = briefWithFiles("Fix it", ["@a.png", "@big.mov"], [described("@a.png")]);+ expect(brief).toContain("@big.mov");+ expect(brief).not.toContain("@a.png");+ expect(brief.trimEnd().endsWith("@big.mov")).toBe(false);+ });});diff --git a/jarvis/ui/web/frontend/src/components/society/office/spawnFiles.ts b/jarvis/ui/web/frontend/src/components/society/office/spawnFiles.tsnew file mode 100644index 0000000000..0345f8b6b6--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/office/spawnFiles.ts@@ -0,0 +1,129 @@+/**+ * Files dropped on the spawn point, held until the agents they are for exist.+ *+ * A drop on a pane goes straight to that pane's terminal. Here the terminal+ * does not exist yet, so a drop is only READ now and handed to each new pane+ * once it is live. The reading is the pane's own — the same drag tracking+ * (`usePaneFileDrag`), payload extraction (`paneDrop`) and desktop-shell path+ * resolution (`waitForNativeDrop`) — so the two surfaces cannot disagree about+ * what a drop is.+ */+import { useCallback, useState, type ClipboardEvent } from "react";+import {+ extractPaneDrop,+ extractPasteFiles,+ isEmptyPayload,+ nameClipboardFile,+ type PaneDropPayload,+} from "@/components/agentic/paneDrop";+import { usePaneFileDrag } from "@/components/agentic/paneFileDrag";+import type { DropAttachment } from "@/lib/agenticIdeApi";+import { waitForNativeDrop } from "@/lib/nativeDrop";++/** One held file: a real path the drag carried, or bytes it gave no path for. */+export interface HeldFile {+ key: string;+ name: string;+ path?: string;+ file?: File;+}++function baseName(path: string): string {+ return path.replace(/[\\/]+$/, "").split(/[\\/]/).pop() || path;+}++/** `held` plus whatever in `payload` is not held yet. Pure. */+export function holdDrop(held: readonly HeldFile[], payload: PaneDropPayload): HeldFile[] {+ const next = [...held];+ const seen = new Set(held.map((h) => h.key));+ const add = (item: HeldFile) => {+ if (seen.has(item.key)) return;+ seen.add(item.key);+ next.push(item);+ };+ for (const path of payload.paths) {+ add({ key: `path:${path.replace(/\\/g, "/").toLowerCase()}`, name: baseName(path), path });+ }+ for (const file of payload.files) {+ add({ key: `file:${file.name}:${file.size}:${file.lastModified}`, name: file.name, file });+ }+ return next;+}++/** The held files in the shape the attach endpoint takes. Pure. */+export function heldPayload(held: readonly HeldFile[]): PaneDropPayload {+ return {+ paths: held.flatMap((h) => (h.path ? [h.path] : [])),+ files: held.flatMap((h) => (h.file ? [h.file] : [])),+ };+}++/**+ * The brief, plus every attached file the analysis did not cover. Pure.+ *+ * A described file travels as an attachment and reaches the agent that way; a+ * file too large to read would otherwise vanish from the brief, so its+ * reference is written in. Never at the very end: a trailing `@path` holds the+ * CLI's completion popup open, and the Enter that follows picks a suggestion+ * instead of submitting.+ */+export function briefWithFiles(+ brief: string,+ references: readonly string[],+ analysis: readonly DropAttachment[],+): string {+ const described = new Set(analysis.map((a) => a.reference));+ const loose = references.filter((r) => !described.has(r));+ if (loose.length === 0) return brief;+ return `${brief}\n\nFiles for this task: ${loose.join(" ")} - open them as needed.`;+}++export function useSpawnFiles() {+ const [held, setHeld] = useState<HeldFile[]>([]);+ const hold = useCallback((payload: PaneDropPayload) => {+ if (!isEmptyPayload(payload)) setHeld((prev) => holdDrop(prev, payload));+ }, []);++ const { dragging, handlers } = usePaneFileDrag(+ useCallback(+ (dt: DataTransfer) => {+ // Both reads happen BEFORE any await: a DataTransfer empties the moment+ // this handler returns, and the desktop shell only answers a listener+ // that was already in place when the drop happened.+ const payload = extractPaneDrop(dt);+ void waitForNativeDrop().then((detail) => {+ if (!detail?.paths.length) return hold(payload);+ // Inside the desktop shell the real path beats a byte copy of the+ // same file; drop the copies the shell just accounted for.+ const named = new Set(detail.names.map((n) => n.toLowerCase()));+ hold({+ paths: Array.from(new Set([...payload.paths, ...detail.paths])),+ files: payload.files.filter((f) => !named.has(f.name.toLowerCase())),+ });+ });+ },+ [hold],+ ),+ );++ /** On the text box: claims a pasted IMAGE, never pasted text. */+ const onPaste = useCallback(+ (event: ClipboardEvent) => {+ const files = extractPasteFiles(event.clipboardData).map((f) => nameClipboardFile(f, "spawn"));+ if (files.length === 0) return;+ event.preventDefault();+ hold({ paths: [], files });+ },+ [hold],+ );++ const addFiles = useCallback((files: File[]) => hold({ paths: [], files }), [hold]);+ const remove = useCallback((key: string) => setHeld((prev) => prev.filter((h) => h.key !== key)), []);+ /** Forget exactly these — a file dropped while a launch ran stays for the next one. */+ const release = useCallback((used: readonly HeldFile[]) => {+ const keys = new Set(used.map((h) => h.key));+ setHeld((prev) => prev.filter((h) => !keys.has(h.key)));+ }, []);++ return { held, dragging, handlers, onPaste, addFiles, remove, release };+}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json b/jarvis/ui/web/frontend/src/i18n/locales/society/de.jsonindex 29f29ce703..1878d6108d 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/de.json@@ -950,12 +950,12 @@"cmd_close": "Diese Session schließen","cmd_close_confirm": "Nochmal klicken, um die Session zu schließen","mission_workspace": "Workspace",- "mission_no_workspace": "Kein Workspace ist offen. Öffne zuerst ein Projekt in der IDE.",+ "mission_no_workspace": "Noch ist kein Workspace offen. Wähle einen Ordner, dann öffnet er sich mit den neuen Agents darin.","mission_agent": "Coding-Agent","mission_no_agents": "Noch kein Coding-Agent installiert.","mission_count": "Wie viele","mission_task": "Erster Auftrag (optional)",- "mission_task_placeholder": "Woran soll er arbeiten? Leer lassen, um ihn nur zu öffnen.",+ "mission_task_placeholder": "Woran soll er arbeiten? Dateien kannst du hier ablegen. Leer lassen, um ihn nur zu öffnen.","mission_screen_agents": "Coding-Agents auf dieser Etage","room_command": "Mission Control","mission_screen_none": "Noch keine Coding-Agents",@@ -975,6 +975,22 @@"mission_not_started": "{0} ist offen, aber noch nicht gestartet. Öffne seinen Workspace in der IDE und brief ihn dann.","mission_failed": "Agent konnte nicht geöffnet werden: {0}","mission_loading": "Wird geladen…",+ "mission_ws_new": "Neuer Workspace…",+ "mission_ws_folder": "Ordner",+ "mission_ws_pick": "Projekt wählen",+ "mission_ws_choose": "Ordner auswählen…",+ "mission_ws_choose_title": "Ordner für den neuen Workspace",+ "mission_ws_choose_hint": "Der neue Workspace öffnet sich in diesem Ordner, mit den neuen Agents darin.",+ "mission_ws_use": "Diesen Ordner nehmen",+ "mission_ws_close": "Schließen",+ "mission_ws_name": "Name (optional)",+ "mission_ws_creating": "Neuer Workspace wird geöffnet…",+ "mission_files_attach": "Dateien anhängen",+ "mission_files_drop": "Dateien ablegen, um sie den neuen Agents mitzugeben",+ "mission_files_remove": "{0} entfernen",+ "mission_files_handing": "{0} bekommt die Dateien…",+ "mission_files_failed": "{0} hat die Dateien nicht bekommen: {1}",+ "mission_files_typed": "{0} ist offen, die Dateien stehen in seiner Eingabe.","fleet_empty": "Noch kein Coding-Agent auf der Etage.","fleet_placeholder": "Nachricht an die ausgewählten Agents","fleet_send": "An {0} senden",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json b/jarvis/ui/web/frontend/src/i18n/locales/society/en.jsonindex cc94374c2d..ea4367d805 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/en.json@@ -950,12 +950,12 @@"cmd_close": "Close this session","cmd_close_confirm": "Click again to close the session","mission_workspace": "Workspace",- "mission_no_workspace": "No workspace is open. Open a project in the IDE first.",+ "mission_no_workspace": "No workspace is open yet. Pick a folder and it opens with the new agents in it.","mission_agent": "Coding agent","mission_no_agents": "No coding agent is installed yet.","mission_count": "How many","mission_task": "First task (optional)",- "mission_task_placeholder": "What should it work on? Leave empty to just open it.",+ "mission_task_placeholder": "What should it work on? Drop files here too. Leave empty to just open it.","mission_screen_agents": "coding agents on this floor","room_command": "Mission Control","mission_screen_none": "No coding agents yet",@@ -975,6 +975,22 @@"mission_not_started": "{0} is open but has not started yet. Open its workspace in the IDE, then brief it.","mission_failed": "Could not open an agent: {0}","mission_loading": "Loading…",+ "mission_ws_new": "New workspace…",+ "mission_ws_folder": "Folder",+ "mission_ws_pick": "Pick a project",+ "mission_ws_choose": "Choose a folder…",+ "mission_ws_choose_title": "Folder for the new workspace",+ "mission_ws_choose_hint": "The new workspace opens in this folder, with the new agents in it.",+ "mission_ws_use": "Use this folder",+ "mission_ws_close": "Close",+ "mission_ws_name": "Name (optional)",+ "mission_ws_creating": "Opening the new workspace…",+ "mission_files_attach": "Attach files",+ "mission_files_drop": "Drop files to hand them to the new agents",+ "mission_files_remove": "Remove {0}",+ "mission_files_handing": "Handing the files to {0}…",+ "mission_files_failed": "{0} did not get the files: {1}",+ "mission_files_typed": "{0} is open, with the files in its input.","fleet_empty": "No coding agent is on the floor yet.","fleet_placeholder": "Message for the picked agents","fleet_send": "Send to {0}",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json b/jarvis/ui/web/frontend/src/i18n/locales/society/es.jsonindex 733444cfcc..da27eccfff 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/es.json@@ -950,12 +950,12 @@"cmd_close": "Cerrar esta sesión","cmd_close_confirm": "Haz clic otra vez para cerrar la sesión","mission_workspace": "Espacio de trabajo",- "mission_no_workspace": "No hay ningún espacio de trabajo abierto. Abre primero un proyecto en el IDE.",+ "mission_no_workspace": "Aún no hay ningún espacio de trabajo abierto. Elige una carpeta y se abrirá con los nuevos agentes dentro.","mission_agent": "Agente de código","mission_no_agents": "Aún no hay ningún agente de código instalado.","mission_count": "Cuántos","mission_task": "Primera tarea (opcional)",- "mission_task_placeholder": "¿En qué debe trabajar? Déjalo vacío para solo abrirlo.",+ "mission_task_placeholder": "¿En qué debe trabajar? También puedes soltar archivos aquí. Déjalo vacío para solo abrirlo.","mission_screen_agents": "agentes de código en esta planta","room_command": "Mission Control","mission_screen_none": "Aún no hay agentes de código",@@ -975,6 +975,22 @@"mission_not_started": "{0} está abierto pero aún no ha arrancado. Abre su espacio de trabajo en el IDE y luego infórmale.","mission_failed": "No se pudo abrir un agente: {0}","mission_loading": "Cargando…",+ "mission_ws_new": "Nuevo espacio de trabajo…",+ "mission_ws_folder": "Carpeta",+ "mission_ws_pick": "Elige un proyecto",+ "mission_ws_choose": "Elegir una carpeta…",+ "mission_ws_choose_title": "Carpeta del nuevo espacio de trabajo",+ "mission_ws_choose_hint": "El nuevo espacio de trabajo se abre en esta carpeta, con los nuevos agentes dentro.",+ "mission_ws_use": "Usar esta carpeta",+ "mission_ws_close": "Cerrar",+ "mission_ws_name": "Nombre (opcional)",+ "mission_ws_creating": "Abriendo el nuevo espacio de trabajo…",+ "mission_files_attach": "Adjuntar archivos",+ "mission_files_drop": "Suelta archivos para dárselos a los nuevos agentes",+ "mission_files_remove": "Quitar {0}",+ "mission_files_handing": "Pasando los archivos a {0}…",+ "mission_files_failed": "{0} no recibió los archivos: {1}",+ "mission_files_typed": "{0} está abierto, con los archivos en su entrada.","fleet_empty": "Todavía no hay agentes de código en la planta.","fleet_placeholder": "Mensaje para los agentes elegidos","fleet_send": "Enviar a {0}",diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.tsindex 0c24996a4c..f51c3a6673 100644--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts@@ -1183,14 +1183,30 @@ export async function resolveDroppedFolder(payload: {export async function startIdeSession(folder: string,terminals: TerminalPlan[],- 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;- } = {},+ options: OpenWorkspaceOptions = {},): Promise<IdeState> {+ return (await openIdeWorkspace(folder, terminals, options)).state;+}++export interface OpenWorkspaceOptions {+ 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;+}++/**+ * `startIdeSession` for a caller that goes on to use the new panes: the new+ * workspace ITSELF, beside the state. `state.session` is only whichever+ * workspace is at the front when the answer is built, and another window can+ * bring a different one forward in between.+ */+export async function openIdeWorkspace(+ folder: string,+ terminals: TerminalPlan[],+ options: OpenWorkspaceOptions = {},+): Promise<{ session: SessionState; state: IdeState }> {const res = await fetch("/api/agentic-ide/session", {method: "POST",headers: { "Content-Type": "application/json" },@@ -1208,9 +1224,10 @@ export async function startIdeSession(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 (- body.state ?? { ...EMPTY_IDE_STATE, active: true, session: body.session }- );+ return {+ session: body.session,+ state: body.state ?? { ...EMPTY_IDE_STATE, active: true, session: body.session },+ };}/** Shape a pre-workspace-bar backend does not send. */