Files
openworker/surfaces/gui/src/components/RootRow.tsx
T
Rohit C PrasadandDevika 2b45018ffa OpenWorker: initial import
Imported from andrewyng/aisuite@1b4bbf303e
(contents of its platform/ directory, hoisted to the repo root).
Development history prior to this commit lives in that repository.

Co-authored-by: Devika <devikaverma11@gmail.com>
2026-07-21 11:09:41 -07:00

62 lines
2.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { RootInfo } from "../api";
import { Icon } from "./Icon";
import { baseName } from "../paths";
// One directory row, shared by the composer popover and the session start panel. The primary is the
// session's bound workspace — the repo/folder for Code/Ops (shown by name), or a throwaway scratch
// for Cowork (shown as "Temporary space"). It's always read-write and can't be removed.
export function RootRow({
root,
busy,
scratchPrimary,
branch,
onToggle,
onRemove,
}: {
root: RootInfo;
busy?: boolean;
scratchPrimary?: boolean;
// The workspace's git branch — shown on the primary row (drawer's Working directories, §23).
branch?: string | null;
onToggle: (r: RootInfo) => void;
onRemove: (path: string) => void;
}) {
const label = root.primary
? scratchPrimary
? "Temporary space"
: baseName(root.path)
: root.label;
return (
<div className={"root-row" + (root.exists ? "" : " missing")}>
<Icon name="folder" size={14} className="root-ico" />
<span className="root-text" title={root.path}>
<span className="root-label">
{label}
{root.primary && !scratchPrimary && <span className="root-tag"> main</span>}
{branch && (
<span className="root-tag root-branch">
{" "}
<Icon name="branch" size={11} /> {branch}
</span>
)}
</span>
<span className="root-path">{root.path}</span>
</span>
{!root.exists && <span className="root-tag warn">missing</span>}
<button
className={"root-access" + (root.writable ? " rw" : " ro")}
onClick={() => onToggle(root)}
disabled={busy || root.primary}
title={root.primary ? "The main workspace is always read-write" : "Toggle read-only / read-write"}
>
{root.writable ? "Read-write" : "Read-only"}
</button>
{!root.primary && (
<button className="root-x" onClick={() => onRemove(root.path)} disabled={busy} title="Remove">
×
</button>
)}
</div>
);
}