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
/**
* The row of open workspaces above the Agentic IDE, and the button that adds
* another one.
*
* A workspace is a folder with its own running coding agents. Several can be
* open at once, and switching between them costs nothing: the agents in the one
* you leave keep working, and the one you come back to reconnects to the
* processes that were running the whole time.
*
* Two things the tabs have to say out loud, because the alternative is a user
* guessing:
*
* * **how many terminal panes are open in there.** The number follows panes as
* they are added or closed; it is not a historical spawn total or a process
* health readout.
* * **which one is on screen.** With the panes of only one workspace visible at
* a time, an unmarked bar would make the grid look like it belongs to
* whichever tab the eye landed on.
*
* Closing is deliberately a two-step: the X reveals a confirm, because it is the
* one control in this bar that stops work — every other one is reversible.
*
* The tabs are also file targets. Dropping a screenshot on a workspace tab is
* the natural way to say "this belongs to THAT project" while looking at
* another one — it addresses the workspace by name instead of making the user
* switch first, drop second, and remember which pane had focus.
*/
import { useCallback, useEffect, useRef, useState } from "react";
import { Check, FolderGit2, Pencil, Plus, X } from "lucide-react";
import { fill, useT } from "@/i18n";
import { cn } from "@/lib/utils";
import type { WorkspaceCard } from "@/lib/agenticIdeApi";
import { dragCarriesFiles, extractPaneDrop, type PaneDropPayload } from "./paneDrop";
import { useDragSessionEnd } from "./dragSessionEnd";
/** Names remain useful through six tabs; after that, numbered icons scan better. */
const COMPACT_FROM_WORKSPACES = 7;
const FULL_TAB_TARGET_PX = 112;
const FULL_ADD_BUTTON_PX = 116;
const COMPACT_TAB_TARGET_PX = 36;
const COMPACT_ADD_BUTTON_PX = 28;
const ADD_TAB_FOCUS_ID = "__add_workspace__";
type WorkspaceDensity = "full" | "compact" | "ordinal";
/** Pick the smallest readable presentation for the space the toolbar left us. */
function densityFor(width: number | null, workspaceCount: number): WorkspaceDensity {
const measured = width !== null;
if (
measured &&
width < workspaceCount * COMPACT_TAB_TARGET_PX + COMPACT_ADD_BUTTON_PX
) {
return "ordinal";
}
if (
workspaceCount >= COMPACT_FROM_WORKSPACES ||
(measured && width < workspaceCount * FULL_TAB_TARGET_PX + FULL_ADD_BUTTON_PX)
) {
return "compact";
}
return "full";
}
interface WorkspaceBarProps {
workspaces: WorkspaceCard[];
/** Id of the workspace on screen, or null while the wizard is showing. */
activeId: string | null;
/** True while the wizard is open for an ADDITIONAL workspace. */
addingNew: boolean;
/** A legacy/backend safety cap, or null when workspace count is unrestricted. */
maxWorkspaces: number | null;
onSelect: (id: string) => void;
onAdd: () => void;
onRename: (id: string, name: string) => Promise<boolean>;
onClose: (id: string) => void;
/**
* Persist a drag-and-drop tab order. Absent, tabs are not draggable.
*
* Receives every open workspace id exactly once, in left-to-right order.
*/
onReorder?: (workspaceIds: string[]) => void | Promise<void>;
/**
* A file was dropped on a workspace TAB. Left out, the tabs refuse drags and
* the cursor says so rather than accepting a file nothing would do anything
* with.
*/
onDropFiles?: (workspaceId: string, payload: PaneDropPayload) => void;
/** Disable every control while a switch or a close is in flight. */
busy?: boolean;
/**
* The workspace's own controls, pinned to the right of this same row.
*
* They used to sit in a second bar directly underneath, which cost a whole
* line of the window to hold half a dozen buttons — in a view whose entire
* job is showing terminal output. The tabs rarely fill their half of the row,
* so the controls ride along in the space that was already there.
*/
actions?: React.ReactNode;
/**
* Rendered INSIDE another bar rather than as its own — drops the frame (its
* border and outer padding) so the host row draws exactly one line.
*/
embedded?: boolean;
}
export function WorkspaceBar({
workspaces,
activeId,
addingNew,
maxWorkspaces,
onSelect,
onAdd,
onRename,
onClose,
onReorder,
onDropFiles,
busy = false,
actions,
embedded = false,
}: WorkspaceBarProps) {
const WORKSPACE_TAB_MIME = "application/x-jarvis-workspace-tab";
const t = useT();
const barRef = useRef<HTMLDivElement>(null);
// Which tab has its close button armed. One at a time, and cleared on every
// other interaction, so an armed X can never be clicked by accident later.
const [confirming, setConfirming] = useState<string | null>(null);
const [editing, setEditing] = useState<string | null>(null);
const [draft, setDraft] = useState("");
// Which tab a file drag is currently over. One at a time — a drag has one
// position — so this is an id rather than a set.
const [dropTarget, setDropTarget] = useState<string | null>(null);
const [draggedTab, setDraggedTab] = useState<string | null>(null);
const [tabDropTarget, setTabDropTarget] = useState<{ id: string; before: boolean } | null>(null);
const [barWidth, setBarWidth] = useState<number | null>(null);
const [rovingFocusId, setRovingFocusId] = useState(
addingNew ? ADD_TAB_FOCUS_ID : (activeId ?? workspaces[0]?.id ?? ADD_TAB_FOCUS_ID),
);
const workspaceIdKey = workspaces.map((workspace) => workspace.id).join("\u0000");
const full = maxWorkspaces !== null && workspaces.length >= maxWorkspaces;
// A drag that ends anywhere else owes this bar no `dragleave` — and no
// `drop` or `dragend` either, once it ends outside the window. A tab left
// highlighted over a workspace nobody dropped on is a lie about what will
// happen next, so the end of the drag is detected rather than awaited (see
// ./dragSessionEnd, BUG-167).
const clearDropTarget = useCallback(() => setDropTarget(null), []);
useDragSessionEnd(dropTarget !== null, clearDropTarget);
const clearTabDrag = useCallback(() => { setDraggedTab(null); setTabDropTarget(null); }, []);
useDragSessionEnd(draggedTab !== null, clearTabDrag);
const moveTab = (sourceId: string, targetId: string, before: boolean) => {
if (!onReorder || sourceId === targetId) return;
const order = workspaces.map((workspace) => workspace.id);
const without = order.filter((id) => id !== sourceId);
const targetIndex = without.indexOf(targetId);
if (targetIndex < 0) return;
const insertAt = before ? targetIndex : targetIndex + 1;
const next = [...without.slice(0, insertAt), sourceId, ...without.slice(insertAt)];
if (next.join("\u0000") === order.join("\u0000")) return;
void onReorder(next);
};
/** Tab-reorder handlers. Empty when the owner does not persist an order. */
const tabDragHandlersFor = (workspace: WorkspaceCard) => {
if (!onReorder) return {};
const draggable = !busy && editing !== workspace.id;
return {
draggable,
onDragStart: (event: React.DragEvent) => {
if (!draggable) { event.preventDefault(); return; }
event.dataTransfer.setData(WORKSPACE_TAB_MIME, workspace.id);
event.dataTransfer.setData("text/plain", workspace.id);
event.dataTransfer.effectAllowed = "move";
setDraggedTab(workspace.id);
},
onDragEnd: clearTabDrag,
onDragOver: (event: React.DragEvent) => {
if (!draggedTab || draggedTab === workspace.id) return;
if (!event.dataTransfer.types.includes(WORKSPACE_TAB_MIME) && !event.dataTransfer.types.includes("text/plain")) return;
if (dragCarriesFiles(event.dataTransfer)) return;
event.preventDefault();
event.dataTransfer.dropEffect = "move";
const rect = event.currentTarget.getBoundingClientRect();
const before = (event.clientX - rect.left) < rect.width / 2;
setTabDropTarget((current) => current?.id === workspace.id && current.before === before ? current : { id: workspace.id, before });
},
onDragLeave: (event: React.DragEvent) => {
const next = event.relatedTarget as Node | null;
if (next && event.currentTarget.contains(next)) return;
setTabDropTarget((current) => current?.id === workspace.id ? null : current);
},
onDrop: (event: React.DragEvent) => {
if (!draggedTab || dragCarriesFiles(event.dataTransfer)) return;
event.preventDefault();
const sourceId = event.dataTransfer.getData(WORKSPACE_TAB_MIME) || draggedTab;
const rect = event.currentTarget.getBoundingClientRect();
const before = (event.clientX - rect.left) < rect.width / 2;
clearTabDrag();
moveTab(sourceId, workspace.id, before);
},
};
};
/** Drag-drop handlers for one tab. Empty when the owner takes no drops. */
const dropHandlersFor = (workspace: WorkspaceCard) => {
if (!onDropFiles) return {};
return {
onDragEnter: (event: React.DragEvent) => {
// Claimed even for payloads this tab will not take: the default action
// for a dropped link is to NAVIGATE, which would replace the whole IDE
// — every running agent in it with it.
event.preventDefault();
if (!dragCarriesFiles(event.dataTransfer)) return;
setDropTarget(workspace.id);
},
onDragOver: (event: React.DragEvent) => {
event.preventDefault();
event.dataTransfer.dropEffect = dragCarriesFiles(event.dataTransfer)
? "copy"
: "none";
},
onDragLeave: (event: React.DragEvent) => {
// A drag crossing the tab's own children fires leave for each of them;
// only a leave that actually exits the tab counts.
const next = event.relatedTarget as Node | null;
if (next && event.currentTarget.contains(next)) return;
setDropTarget((current) => (current === workspace.id ? null : current));
},
onDrop: (event: React.DragEvent) => {
event.preventDefault();
setDropTarget(null);
if (!dragCarriesFiles(event.dataTransfer)) return;
// Read SYNCHRONOUSLY — a DataTransfer empties the moment this returns.
onDropFiles(workspace.id, extractPaneDrop(event.dataTransfer));
},
};
};
const beginRename = (workspace: WorkspaceCard) => {
setConfirming(null);
setEditing(workspace.id);
setDraft(workspace.name);
};
const commitRename = async (workspace: WorkspaceCard) => {
const name = draft.trim();
if (!name) return;
if (name === workspace.name || (await onRename(workspace.id, name))) {
setEditing(null);
}
};
/*
* With nothing open there are no TABS — only the row that may carry actions.
*
* The distinction matters twice over. It is what the user sees: a tab strip
* offering "New workspace" above a wizard that IS the new workspace is a
* second button for the thing already on screen. And it is what the tests
* see: the tabs appear only once the workspace list has actually arrived, so
* nothing can be clicked or measured in the instant before the first fetch
* resolves — a bar that rendered its controls immediately handed those tests
* a "New workspace" button that was neither disabled nor still attached by
* the time the state landed.
*/
const hasTabs = workspaces.length > 0;
// The surrounding toolbar owns a variable number of icon controls. Count
// alone cannot know how much width they leave, so the tab density follows the
// space the bar actually receives and updates as the desktop window changes.
useEffect(() => {
const bar = barRef.current;
if (!hasTabs || !bar) return;
const update = (width: number) => {
// A hidden element and jsdom both report zero. That is not usable layout
// information; keep the count-based tier until the observer sees width.
if (width > 0 && Number.isFinite(width)) setBarWidth(width);
};
update(bar.getBoundingClientRect().width);
if (typeof ResizeObserver === "undefined") return;
const observer = new ResizeObserver((entries) => {
update(entries[0]?.contentRect.width ?? bar.getBoundingClientRect().width);
});
observer.observe(bar);
return () => observer.disconnect();
}, [hasTabs]);
// An external workspace switch becomes the roving tab stop too. Keeping the
// value in React state avoids imperative DOM mutations leaving two tab stops
// behind after a parent rerender.
useEffect(() => {
setRovingFocusId(
addingNew ? ADD_TAB_FOCUS_ID : (activeId ?? workspaces[0]?.id ?? ADD_TAB_FOCUS_ID),
);
}, [activeId, addingNew]);
// A refreshed array with the same IDs is not a navigation event. Only repair
// roving focus when its actual target disappeared (or Add became disabled).
useEffect(() => {
setRovingFocusId((current) => {
const stillAvailable =
current === ADD_TAB_FOCUS_ID
? !full
: workspaces.some((workspace) => workspace.id === current);
if (stillAvailable) return current;
return activeId ?? workspaces[0]?.id ?? (!full ? ADD_TAB_FOCUS_ID : current);
});
}, [workspaceIdKey, full]);
const density = densityFor(barWidth, workspaces.length);
const compact = density !== "full";
const ordinalOnly = density === "ordinal";
/** Standard roving focus across every available tab and the Add control. */
const moveTabFocus = (event: React.KeyboardEvent<HTMLDivElement>) => {
if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
const tabs = Array.from(
event.currentTarget.querySelectorAll<HTMLElement>('[role="tab"]:not(:disabled)'),
);
const current = (event.target as HTMLElement).closest<HTMLElement>('[role="tab"]');
const currentIndex = current ? tabs.indexOf(current) : -1;
if (currentIndex < 0 || tabs.length === 0) return;
event.preventDefault();
let nextIndex = currentIndex;
if (event.key === "Home") nextIndex = 0;
if (event.key === "End") nextIndex = tabs.length - 1;
if (event.key === "ArrowRight") nextIndex = (currentIndex + 1) % tabs.length;
if (event.key === "ArrowLeft") nextIndex = (currentIndex - 1 + tabs.length) % tabs.length;
const next = tabs[nextIndex];
if (!next) return;
setRovingFocusId(next.dataset.workspaceFocusId ?? ADD_TAB_FOCUS_ID);
next.focus();
};
// Nothing open, nothing to add to and no controls to carry: the wizard IS the
// screen, and an empty bar above it would be furniture.
if (!hasTabs && !actions) return null;
return (
<div
className={cn(
"flex items-center gap-2",
embedded ? "min-w-[12rem] flex-1" : "border-b border-border px-2 py-1",
)}
>
{!hasTabs && <div className="min-w-0 flex-1" />}
{hasTabs && (
<div
ref={barRef}
data-testid="workspace-bar"
data-density={density}
className={cn(
"flex min-w-0 flex-1 items-center overflow-hidden",
ordinalOnly ? "gap-px" : "gap-1",
)}
role="tablist"
aria-label={t("workspace_bar.open_workspaces")}
onKeyDown={moveTabFocus}
>
{workspaces.map((workspace, index) => {
const selected = !addingNew && workspace.id === activeId;
const armed = confirming === workspace.id;
const renaming = editing === workspace.id;
const dropping = dropTarget === workspace.id;
const tabDragging = draggedTab === workspace.id;
const tabDropBefore = tabDropTarget?.id === workspace.id && tabDropTarget.before;
const tabDropAfter = tabDropTarget?.id === workspace.id && !tabDropTarget.before;
const summary = t(
workspace.terminals === 1
? "workspace_bar.workspace_summary_one"
: "workspace_bar.workspace_summary_many",
)
.replace("{workspace}", workspace.name)
.replace("{index}", String(index + 1))
.replace("{count}", String(workspace.terminals));
const overlayAlignment =
index === 0
? "left-0"
: index === workspaces.length - 1
? "right-0"
: "left-1/2 -translate-x-1/2";
const ordinalRenamePosition =
index === 0
? "left-0"
: index === workspaces.length - 1
? "right-5"
: "left-1/2 -translate-x-full";
const ordinalClosePosition =
index === 0
? "left-5"
: index === workspaces.length - 1
? "right-0"
: "left-1/2";
return (
<div
key={workspace.id}
data-testid={`workspace-tab-drop-${workspace.id}`}
{...dropHandlersFor(workspace)}
{...tabDragHandlersFor(workspace)}
title={
onDropFiles
? fill(t("workspace_bar.drop_title"), { folder: workspace.folder })
: onReorder
? fill(t("workspace_bar.reorder_title"), { folder: workspace.folder })
: workspace.folder
}
/*
* The selected tab is a RAISED tab, marked once.
* It used to be marked three times over — a yellow border, a yellow
* fill, a yellow folder glyph and yellow label text — which is four
* ways of saying the same thing and left the accent unable to say
* anything else in this row. One filled surface carries "you are
* here"; the glyph keeps the colour because it is the smallest of
* the four and reads at a glance across a wide bar.
*/
className={cn(
"group/tab relative flex items-center gap-1.5 rounded-control border py-1 transition-colors",
compact
? ordinalOnly
? "min-w-0 flex-1 basis-0 justify-center px-0"
: renaming
? "min-w-0 flex-[10_1_0%] px-1"
: armed
? "min-w-0 flex-[8_1_0%] px-1"
: "min-w-0 flex-1 basis-0 justify-center px-1 hover:flex-[3_1_0%] focus-within:flex-[3_1_0%]"
: "min-w-[2.5rem] max-w-[18rem] shrink px-2",
dropping
? "border-dashed border-primary bg-primary/10"
: selected
? "border-border bg-secondary"
: "border-transparent hover:bg-secondary",
tabDragging && "opacity-40",
tabDropBefore && "before:absolute before:-left-0.5 before:bottom-1 before:top-1 before:w-0.5 before:rounded-full before:bg-primary",
tabDropAfter && "after:absolute after:-right-0.5 after:bottom-1 after:top-1 after:w-0.5 after:rounded-full after:bg-primary",
onReorder && !busy && "cursor-grab active:cursor-grabbing",
)}
>
{renaming ? (
<form
className={cn(
"flex items-center gap-1",
ordinalOnly &&
"absolute top-0 z-30 rounded-control border border-border bg-secondary p-0.5",
ordinalOnly && overlayAlignment,
)}
onSubmit={(event) => {
event.preventDefault();
void commitRename(workspace);
}}
>
<input
autoFocus
value={draft}
maxLength={80}
disabled={busy}
aria-label={fill(t("workspace_bar.rename"), { workspace: workspace.name })}
data-testid={`workspace-rename-input-${workspace.id}`}
onFocus={(event) => event.currentTarget.select()}
onChange={(event) => setDraft(event.target.value)}
onKeyDown={(event) => {
if (event.key === "Escape") setEditing(null);
}}
className={cn(
"rounded border border-primary/40 bg-background px-2 py-0.5 text-sm outline-none focus:border-primary disabled:opacity-60",
ordinalOnly ? "w-24" : "w-40",
)}
/>
<button
type="submit"
disabled={busy || !draft.trim()}
aria-label={fill(t("workspace_bar.rename_save"), { workspace: workspace.name })}
data-testid={`workspace-rename-save-${workspace.id}`}
className="flex h-6 w-6 items-center justify-center rounded text-primary hover:bg-primary/15 disabled:opacity-40"
>
<Check className="h-3.5 w-3.5" />
</button>
<button
type="button"
disabled={busy}
aria-label={t("workspace_bar.rename_cancel")}
onClick={() => setEditing(null)}
className="flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-muted"
>
<X className="h-3.5 w-3.5" />
</button>
</form>
) : (
<>
<button
type="button"
role="tab"
aria-selected={selected}
aria-label={summary}
tabIndex={rovingFocusId === workspace.id ? 0 : -1}
data-workspace-focus-id={workspace.id}
disabled={busy}
data-testid={`workspace-tab-${workspace.id}`}
title={compact ? `${summary} — ${workspace.folder}` : workspace.folder}
onClick={() => {
setConfirming(null);
if (!selected) onSelect(workspace.id);
}}
onFocus={() => setRovingFocusId(workspace.id)}
onKeyDown={(event) => {
if (!onReorder || !event.altKey) return;
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
event.preventDefault();
const neighbour = event.key === "ArrowLeft" ? workspaces[index - 1] : workspaces[index + 1];
if (!neighbour) return;
moveTab(workspace.id, neighbour.id, event.key === "ArrowLeft");
}}
className={cn(
"flex min-w-0 items-center text-left disabled:cursor-not-allowed disabled:opacity-60",
compact ? "flex-1 justify-center gap-1" : "gap-2",
)}
>
{!ordinalOnly && (
<FolderGit2
className={cn(
"h-3.5 w-3.5 shrink-0",
selected ? "text-primary" : "text-muted-foreground",
)}
/>
)}
<span
className={cn(
"max-w-[14rem] truncate text-sm",
compact && "sr-only",
selected
? "font-medium text-foreground"
: "text-muted-foreground",
)}
>
{workspace.name}
</span>
{compact ? (
<span
data-testid={`workspace-ordinal-${workspace.id}`}
className={cn(
"font-mono text-micro tabular-nums",
selected ? "font-semibold text-foreground" : "text-muted-foreground",
)}
>
{index + 1}
</span>
) : (
<PaneCount workspace={workspace} selected={selected} />
)}
</button>
<button
type="button"
aria-label={fill(t("workspace_bar.rename"), { workspace: workspace.name })}
title={fill(t("workspace_bar.rename"), { workspace: workspace.name })}
disabled={busy}
data-testid={`workspace-rename-${workspace.id}`}
onClick={() => beginRename(workspace)}
className={cn(
"flex h-5 w-5 items-center justify-center rounded text-muted-foreground opacity-0 transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 group-hover/tab:opacity-100 disabled:opacity-40",
compact && "absolute z-20 bg-secondary",
compact && (ordinalOnly ? ordinalRenamePosition : "left-0"),
)}
>
<Pencil className="h-3 w-3" />
</button>
</>
)}
{!renaming && armed ? (
<span
className={cn(
"flex items-center gap-1",
ordinalOnly &&
"absolute top-0 z-30 rounded-control border border-border bg-secondary p-0.5",
ordinalOnly && overlayAlignment,
)}
>
<button
type="button"
disabled={busy}
aria-label={fill(t("workspace_bar.close_confirm_aria"), { workspace: workspace.name })}
data-testid={`workspace-close-confirm-${workspace.id}`}
onClick={() => {
setConfirming(null);
onClose(workspace.id);
}}
className="rounded bg-destructive/20 px-2 py-0.5 text-micro font-medium text-destructive transition-colors hover:bg-destructive/30 disabled:opacity-50"
>
{fill(t("workspace_bar.close_stop"), { count: workspace.live_terminals || workspace.terminals })}
</button>
<button
type="button"
aria-label={t("workspace_bar.keep_aria")}
onClick={() => setConfirming(null)}
className="rounded px-1.5 py-0.5 text-micro text-muted-foreground hover:text-foreground"
>
{t("workspace_bar.keep")}
</button>
</span>
) : !renaming ? (
<button
type="button"
aria-label={fill(t("workspace_bar.close"), { workspace: workspace.name })}
title={fill(t("workspace_bar.close_title"), { workspace: workspace.name })}
disabled={busy}
data-testid={`workspace-close-${workspace.id}`}
onClick={() => setConfirming(workspace.id)}
className={cn(
"flex h-5 w-5 items-center justify-center rounded text-muted-foreground transition-opacity hover:bg-destructive/20 hover:text-destructive",
compact
? cn(
"absolute z-20 bg-secondary opacity-0 focus-visible:opacity-100 group-hover/tab:opacity-100",
ordinalOnly ? ordinalClosePosition : "right-0",
)
: selected
? "opacity-100"
: "opacity-0 focus-visible:opacity-100 group-hover/tab:opacity-100",
)}
>
<X className="h-3 w-3" />
</button>
) : null}
</div>
);
})}
<button
type="button"
role="tab"
aria-selected={addingNew}
tabIndex={rovingFocusId === ADD_TAB_FOCUS_ID ? 0 : -1}
data-workspace-focus-id={ADD_TAB_FOCUS_ID}
disabled={busy || full}
data-testid="workspace-add"
title={
full && maxWorkspaces !== null
? fill(t("workspace_bar.full"), { count: maxWorkspaces })
: t("workspace_bar.add_title")
}
onClick={() => {
setConfirming(null);
onAdd();
}}
onFocus={() => setRovingFocusId(ADD_TAB_FOCUS_ID)}
className={cn(
"flex shrink-0 items-center rounded-lg border border-transparent text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-40",
ordinalOnly
? "h-7 w-6 justify-center p-0"
: compact
? "h-7 w-7 justify-center p-0"
: "gap-1.5 px-2 py-1",
addingNew
? "border-primary/50 bg-primary/10 text-primary"
: "text-muted-foreground hover:bg-secondary hover:text-foreground",
)}
>
<Plus className="h-3.5 w-3.5" />
<span className={cn(compact && "sr-only")}>
{t("workspace_bar.new_workspace")}
</span>
</button>
</div>
)}
{actions && (
<div
data-testid="workspace-bar-actions"
className="flex shrink-0 items-center gap-1"
>
{actions}
</div>
)}
</div>
);
}
/** The number of terminal panes currently open in this workspace. */
function PaneCount({
workspace,
selected,
}: {
workspace: WorkspaceCard;
selected: boolean;
}) {
const t = useT();
return (
<span
data-testid={`workspace-panes-${workspace.id}`}
title={fill(
t(
workspace.terminals === 1
? "workspace_bar.terminals_open_one"
: "workspace_bar.terminals_open_other",
),
{ count: workspace.terminals },
)}
className={cn(
// No fill of its own: the tab it sits in is already a filled surface
// when selected, and a badge inside it was a second box inside a box.
"shrink-0 font-mono text-micro tabular-nums",
selected ? "text-primary" : "text-muted-foreground",
)}
>
{workspace.terminals}
</span>
);
}