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.

style(ide): one row per single-workspace project in the sidebar

rubenluetke10-beepf3f555e07841
diff --git a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.test.tsx
index 534f2fab97..d9019932ea 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.test.tsx
@@ -114,9 +114,29 @@ it("counts agent sessions across a project's workspaces", () => {
] };
useIdeProjectsStore.setState({ projects: [withTwo] });
render(<IdeProjectTree />);
+ // Open, the rows carry their own counts; folded, the header sums them.
+ expect(screen.queryByLabelText("9 agent sessions")).toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: "Collapse App" }));
expect(screen.getByLabelText("9 agent sessions").textContent).toBe("9");
});
+it("renders a project whose only workspace shares its name as one row", async () => {
+ const solo = { ...project(), workspaces: [{ ...project().workspaces[0], name: "app", status: "closed", live_terminals: 0, terminals: 4 }] } as IdeProject;
+ useIdeProjectsStore.setState({ projects: [solo], activeWorkspaceId: null });
+ render(<IdeProjectTree />);
+ expect(screen.queryByRole("button", { name: /Collapse App|Expand App/ })).toBeNull();
+ expect(screen.getAllByText(/^app$/i)).toHaveLength(1);
+ expect(screen.getByLabelText("4 agent sessions")).toBeDefined();
+ fireEvent.click(screen.getByRole("button", { name: "Open App" }));
+ expect(useIdeProjectsStore.getState().action).toMatchObject({ kind: "activate-workspace", workspaceId: "p1-w1" });
+ fireEvent.click(screen.getByRole("button", { name: "Project actions for App" }));
+ const menu = screen.getByRole("menu", { name: "Workspace actions for app" });
+ expect(menu.textContent).toContain("Rename project");
+ expect(menu.textContent).toContain("Reopen workspace");
+ expect(menu.textContent).not.toContain("Rename workspace");
+ expect(menu.textContent).not.toContain("Remove workspace");
+});
+
it("marks a queued workspace before the active workspace changes", () => {
render(<IdeProjectTree />);
act(() => useIdeProjectsStore.getState().setPendingWorkspaceId("p1-w1"));
diff --git a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsx b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsx
index ee0982121b..9b08245bc7 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/IdeProjectTree.tsx
@@ -49,6 +49,23 @@ function removalErrorMessage(error: unknown): string {
return error instanceof Error ? error.message : String(error);
}
+/**
+ * The project's only workspace when it carries the project's own name. Such a
+ * project renders as ONE row: a folder header over a child with the same name
+ * and the same count says everything twice.
+ */
+function soloWorkspace(project: IdeProject): ProjectWorkspace | null {
+ if (project.workspaces.length !== 1) return null;
+ const [workspace] = project.workspaces;
+ return workspace.name.trim().toLowerCase() === project.name.trim().toLowerCase() ? workspace : null;
+}
+
+/** Running agents glow, an open but idle workspace is a solid dot, a saved (closed) one a hollow ring. */
+function statusDotClass(workspace: ProjectWorkspace): string {
+ if (workspace.status !== "open") return "border border-muted-foreground/45";
+ return workspace.live_terminals > 0 ? "bg-emerald-500 ring-[3px] ring-emerald-500/15" : "bg-muted-foreground/40";
+}
+
function readExpansion(): Record<string, boolean> {
try {
const value: unknown = JSON.parse(localStorage.getItem(EXPANSION_KEY) ?? "{}");
@@ -156,6 +173,10 @@ export function IdeProjectTree() {
await openProject(project.path);
await patchProject(project.id, changes);
}
+ // A one-row project renames as one: its workspace follows, so the row
+ // does not split into a header and a differently named child.
+ const solo = soloWorkspace(project);
+ if (changes.name && solo?.status === "open") await renameWorkspace(solo.id, changes.name);
setRenamingId(null);
requestRefresh();
} catch (error) { pushToast("error", (error as Error).message); }
@@ -402,11 +423,16 @@ export function IdeProjectTree() {
const isProjectDragged = draggedProjectId === project.id;
const isProjectDropBefore = projectDropTarget?.id === project.id && projectDropTarget.before;
const isProjectDropAfter = projectDropTarget?.id === project.id && !projectDropTarget.before;
- const projectMenuOpen = contextMenu?.kind === "project" && contextMenu.projectId === project.id;
+ const solo = soloWorkspace(project);
+ const soloSelected = solo !== null && solo.id === activeWorkspaceId;
+ const soloPending = solo !== null && solo.id === pendingWorkspaceId;
+ const soloBlocked = solo !== null && solo.status === "closed" && !solo.restorable;
+ const projectMenuOpen = contextMenu?.projectId === project.id
+ && (solo ? contextMenu.kind === "workspace" && contextMenu.workspaceId === solo.id : contextMenu.kind === "project");
return <div key={project.id} className="mb-px" data-testid={`ide-project-${project.id}`}>
<div draggable={projectDraggable}
data-testid={`ide-project-header-${project.id}`}
- onContextMenu={(event) => openProjectMenu(event, project.id)}
+ onContextMenu={(event) => solo ? openWorkspaceMenu(event, project.id, solo.id) : openProjectMenu(event, project.id)}
onDragStart={(event) => {
if (!projectDraggable) { event.preventDefault(); return; }
event.dataTransfer.setData(PROJECT_DRAG_MIME, project.id);
@@ -439,7 +465,7 @@ export function IdeProjectTree() {
clearProjectDragState();
void moveProject(sourceId, project.id, before);
}}
- className={`group relative flex min-h-8 items-center rounded-md transition-colors hover:bg-muted ${active ? "text-foreground" : ""} ${isProjectDragged ? "opacity-40" : ""} ${isProjectDropBefore ? "before:absolute before:-top-0.5 before:left-2 before:right-2 before:h-0.5 before:rounded-full before:bg-primary" : ""} ${isProjectDropAfter ? "after:absolute after:-bottom-0.5 after:left-2 after:right-2 after:h-0.5 after:rounded-full after:bg-primary" : ""} ${projectDraggable ? "cursor-grab active:cursor-grabbing" : ""}`}>
+ className={`group relative flex min-h-8 items-center rounded-md transition-colors hover:bg-muted ${active ? "text-foreground" : ""} ${soloSelected || soloPending ? "bg-muted" : ""} ${isProjectDragged ? "opacity-40" : ""} ${isProjectDropBefore ? "before:absolute before:-top-0.5 before:left-2 before:right-2 before:h-0.5 before:rounded-full before:bg-primary" : ""} ${isProjectDropAfter ? "after:absolute after:-bottom-0.5 after:left-2 after:right-2 after:h-0.5 after:rounded-full after:bg-primary" : ""} ${projectDraggable ? "cursor-grab active:cursor-grabbing" : ""}`}>
{renamingId === project.id ? <form className="flex min-w-0 flex-1 items-center gap-1 px-2" onSubmit={(event) => { event.preventDefault(); const name = draftName.trim(); if (name && name !== project.name) void mutate(project, { name }); else setRenamingId(null); }}>
<input autoFocus aria-label={`Rename ${project.name}`} value={draftName} maxLength={80} disabled={working}
onChange={(event) => setDraftName(event.target.value)} onKeyDown={(event) => { if (event.key === "Escape") { event.stopPropagation(); setRenamingId(null); } }}
@@ -447,8 +473,12 @@ export function IdeProjectTree() {
<button type="submit" aria-label={`Save ${project.name}`} disabled={working || !draftName.trim()} className="rounded p-1 text-muted-foreground hover:text-foreground disabled:opacity-40"><Check className="h-4 w-4" /></button>
<button type="button" aria-label={`Cancel renaming ${project.name}`} onClick={() => setRenamingId(null)} className="rounded p-1 text-muted-foreground hover:text-foreground"><X className="h-4 w-4" /></button>
</form> : <>
- <button type="button" aria-label={`${open ? "Collapse" : "Expand"} ${project.name}`} aria-expanded={open}
- onClick={() => setProjectOpen(project.id, !open)}
+ <button type="button" aria-label={solo ? `Open ${project.name}` : `${open ? "Collapse" : "Expand"} ${project.name}`}
+ aria-expanded={solo ? undefined : open}
+ aria-current={soloSelected ? "page" : undefined} aria-busy={soloPending || undefined}
+ data-testid={solo ? `ide-workspace-${solo.id}` : undefined}
+ disabled={soloBlocked}
+ onClick={() => solo ? activateWorkspace(solo.id) : setProjectOpen(project.id, !open)}
onKeyDown={(event) => {
if (!event.altKey) return;
if (event.key !== "ArrowUp" && event.key !== "ArrowDown") return;
@@ -459,17 +489,26 @@ export function IdeProjectTree() {
if (!neighbour) return;
void moveProject(project.id, neighbour.id, event.key === "ArrowUp");
}}
- title={`${project.name} — drag to reorder, or press Alt plus arrow keys to move`}
- className="flex min-h-8 min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 text-left text-sm font-medium text-foreground [@media(hover:none)]:pr-14 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
- {open ? <ChevronDown aria-hidden className="h-3 w-3 shrink-0 text-muted-foreground/70" /> : <ChevronRight aria-hidden className="h-3 w-3 shrink-0 text-muted-foreground/70" />}
+ title={soloBlocked ? "This workspace cannot be restored on this machine" : `${project.name} — drag to reorder, or press Alt plus arrow keys to move`}
+ className={`flex min-h-8 min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 text-left text-sm font-medium [@media(hover:none)]:pr-14 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-45 ${solo && solo.status !== "open" && !soloSelected && !soloPending ? "text-muted-foreground" : "text-foreground"}`}>
+ {/* A one-row project has nothing to fold: its status dot takes the chevron's slot. */}
+ {solo
+ ? <span aria-hidden className="flex h-3 w-3 shrink-0 items-center justify-center">
+ {soloPending ? <Loader2 className="h-3 w-3 animate-spin" /> : <span className={`h-1.5 w-1.5 rounded-full ${statusDotClass(solo)}`} />}
+ </span>
+ : open ? <ChevronDown aria-hidden className="h-3 w-3 shrink-0 text-muted-foreground/70" /> : <ChevronRight aria-hidden className="h-3 w-3 shrink-0 text-muted-foreground/70" />}
<Folder aria-hidden className="ml-0.5 h-4 w-4 shrink-0 text-muted-foreground" strokeWidth={1.75} />
<span className="ml-0.5 min-w-0 flex-1 truncate">{project.name}</span>
- {count > 0 && <span className="text-xs tabular-nums text-muted-foreground/80 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0 [@media(hover:none)]:opacity-0" aria-label={`${count} agent ${count === 1 ? "session" : "sessions"}`}>{count}</span>}
+ {soloPending && <span className="sr-only">Switching workspace</span>}
+ {/* An open project's rows carry their own counts; the total only speaks for a folded one. */}
+ {count > 0 && (solo || !open) && <span className="text-xs tabular-nums text-muted-foreground/80 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0 [@media(hover:none)]:opacity-0" aria-label={`${count} agent ${count === 1 ? "session" : "sessions"}`}>{count}</span>}
</button>
<div className={`absolute inset-y-0 right-0 flex items-center rounded-r-md bg-gradient-to-l from-muted from-60% to-transparent pl-5 pr-1 transition-opacity ${projectMenuOpen ? "opacity-100" : "pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100"}`} data-project-menu={project.id}>
<button type="button" aria-label={`Project actions for ${project.name}`} title="Project actions" aria-haspopup="menu" aria-expanded={projectMenuOpen}
data-tree-menu-anchor
- onClick={(event) => toggleAnchoredMenu(event, { kind: "project", projectId: project.id })}
+ onClick={(event) => toggleAnchoredMenu(event, solo
+ ? { kind: "workspace", projectId: project.id, workspaceId: solo.id }
+ : { kind: "project", projectId: project.id })}
className={`rounded p-1 hover:bg-background/70 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${projectMenuOpen ? "bg-background/70 text-foreground" : "text-muted-foreground"}`}>
{working ? <Loader2 className="h-3.5 w-3.5 animate-spin" /> : <MoreHorizontal className="h-3.5 w-3.5" />}
</button>
@@ -480,7 +519,7 @@ export function IdeProjectTree() {
</div>
</>}
</div>
- {open && <div className="mb-1 ml-3.5 flex flex-col gap-px border-l border-border/60 pl-1.5">
+ {open && !solo && <div className="mb-1 ml-3.5 flex flex-col gap-px border-l border-border/60 pl-1.5">
{project.workspaces.map((workspace: ProjectWorkspace) => {
const pending = workspace.id === pendingWorkspaceId;
const selected = workspace.id === activeWorkspaceId;
@@ -583,7 +622,7 @@ export function IdeProjectTree() {
}}
className={`flex min-h-8 min-w-0 flex-1 items-center gap-2 rounded-md px-2 text-left text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-45 ${selected || pending ? "text-foreground" : "text-muted-foreground"} ${draggable ? "cursor-grab active:cursor-grabbing" : ""}`}>
{pending ? <Loader2 aria-hidden className="h-3 w-3 shrink-0 animate-spin" />
- : <span aria-hidden className={`h-1.5 w-1.5 shrink-0 rounded-full ${workspace.status === "open" && workspace.live_terminals > 0 ? "bg-emerald-500 ring-[3px] ring-emerald-500/15" : "bg-muted-foreground/35"}`} />}
+ : <span aria-hidden className={`h-1.5 w-1.5 shrink-0 rounded-full ${statusDotClass(workspace)}`} />}
<span className="min-w-0 flex-1 truncate">{workspace.name}</span>
<span className="text-xs tabular-nums text-muted-foreground/80 transition-opacity group-hover/space:opacity-0 group-focus-within/space:opacity-0 [@media(hover:none)]:opacity-0">{workspace.terminals}</span>
{pending && <span className="sr-only">Switching workspace</span>}
@@ -686,6 +725,23 @@ export function IdeProjectTree() {
];
};
+ /**
+ * A one-row project's menu: the workspace's agent actions plus the
+ * project's own, each once — one rename, one launcher set, one removal.
+ */
+ const soloMenuSections = (project: IdeProject, workspace: ProjectWorkspace): TreeMenuItem[][] => {
+ const [agentActions, , place = [], git = []] = workspaceMenuSections(project, workspace);
+ const [projectCreate, projectMeta, projectDelete] = projectMenuSections(project);
+ return [
+ agentActions,
+ [...projectCreate, { id: "copy", label: "Copy folder path", icon: Copy, testId: "ide-workspace-menu-copy", onSelect: run(() => void copyPath(workspace.folder || project.path)) }],
+ place,
+ git,
+ projectMeta,
+ projectDelete,
+ ];
+ };
+
const menuProject = contextMenu ? visible.find((project) => project.id === contextMenu.projectId) ?? null : null;
const menuWorkspace =
contextMenu?.kind === "workspace" && menuProject
@@ -724,7 +780,9 @@ export function IdeProjectTree() {
kind={contextMenu.kind}
busy={mutatingId !== null || reordering || confirmBusy}
sections={contextMenu.kind === "workspace" && menuWorkspace
- ? workspaceMenuSections(menuProject, menuWorkspace)
+ ? (soloWorkspace(menuProject)?.id === menuWorkspace.id
+ ? soloMenuSections(menuProject, menuWorkspace)
+ : workspaceMenuSections(menuProject, menuWorkspace))
: projectMenuSections(menuProject)}
/>
)}