Files
paperclip/ui/src/components/ProjectWorkspaceSummaryCard.tsx
Dotta fee514efcb [codex] Improve workspace navigation and runtime UI (#4089)
## Thinking Path

> - Paperclip agents do real work in project and execution workspaces.
> - Operators need workspace state to be visible, navigable, and
copyable without digging through raw run logs.
> - The branch included related workspace cards, navigation, runtime
controls, stale-service handling, and issue-property visibility.
> - These changes share the workspace UI and runtime-control surfaces
and can stand alone from unrelated access/profile work.
> - This pull request groups the workspace experience changes into one
standalone branch.
> - The benefit is a clearer workspace overview, better metadata copy
flows, and more accurate runtime service controls.

## What Changed

- Polished project workspace summary cards and made workspace metadata
copyable.
- Added a workspace navigation overview and extracted reusable project
workspace content.
- Squared and polished the execution workspace configuration page.
- Fixed stale workspace command matching and hid stopped stale services
in runtime controls.
- Showed live workspace service context in issue properties.

## Verification

- `pnpm install --frozen-lockfile`
- `pnpm exec vitest run
ui/src/components/ProjectWorkspaceSummaryCard.test.tsx
ui/src/lib/project-workspaces-tab.test.ts
ui/src/components/Sidebar.test.tsx
ui/src/components/WorkspaceRuntimeControls.test.tsx
ui/src/components/IssueProperties.test.tsx`
- `pnpm exec vitest run packages/shared/src/workspace-commands.test.ts
--config /dev/null` because the root Vitest project config does not
currently include `packages/shared` tests.
- Split integration check: merged after runtime/governance,
dev-infra/backups, and access/profiles with no merge conflicts.
- Confirmed this branch does not include `pnpm-lock.yaml`.

## Risks

- Medium risk: touches workspace navigation, runtime controls, and issue
property rendering.
- Visual layout changes may need browser QA, especially around smaller
screens and dense workspace metadata.
- No database migrations are included.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- OpenAI Codex, GPT-5.4 tool-enabled coding model, agentic
code-editing/runtime with local shell and GitHub CLI access; exact
context window and reasoning mode are not exposed by the Paperclip
harness.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-20 06:14:32 -05:00

264 lines
11 KiB
TypeScript

import { Link } from "@/lib/router";
import type { ExecutionWorkspace, Issue } from "@paperclipai/shared";
import { Button } from "@/components/ui/button";
import { CopyText } from "./CopyText";
import { IssuesQuicklook } from "./IssuesQuicklook";
import type { ProjectWorkspaceSummary } from "../lib/project-workspaces-tab";
import { cn, projectWorkspaceUrl } from "../lib/utils";
import { timeAgo } from "../lib/timeAgo";
import { Copy, ExternalLink, FolderOpen, GitBranch, Loader2, Play, Square } from "lucide-react";
function workspaceKindLabel(kind: ProjectWorkspaceSummary["kind"]) {
return kind === "execution_workspace" ? "Execution workspace" : "Project workspace";
}
function truncatePath(path: string) {
const parts = path.split("/").filter(Boolean);
if (parts.length <= 3) return path;
return `…/${parts.slice(-3).join("/")}`;
}
interface ProjectWorkspaceSummaryCardProps {
projectRef: string;
summary: ProjectWorkspaceSummary;
runtimeActionKey: string | null;
runtimeActionPending: boolean;
onRuntimeAction: (input: {
key: string;
kind: "project_workspace" | "execution_workspace";
workspaceId: string;
action: "start" | "stop" | "restart";
}) => void;
onCloseWorkspace: (input: {
id: string;
name: string;
status: ExecutionWorkspace["status"];
}) => void;
}
export function ProjectWorkspaceSummaryCard({
projectRef,
summary,
runtimeActionKey,
runtimeActionPending,
onRuntimeAction,
onCloseWorkspace,
}: ProjectWorkspaceSummaryCardProps) {
const visibleIssues = summary.issues.slice(0, 4);
const hiddenIssueCount = Math.max(summary.issues.length - visibleIssues.length, 0);
const workspaceHref =
summary.kind === "project_workspace"
? projectWorkspaceUrl({ id: projectRef, urlKey: projectRef }, summary.workspaceId)
: `/execution-workspaces/${summary.workspaceId}`;
const hasRunningServices = summary.runningServiceCount > 0;
const actionKey = `${summary.key}:${hasRunningServices ? "stop" : "start"}`;
return (
<div className="rounded-lg border border-border bg-background p-4 shadow-sm sm:p-5">
<div className="flex flex-col gap-4">
<div className="flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between">
<div className="min-w-0 space-y-2">
<div className="flex flex-wrap items-center gap-2">
<span className="inline-flex items-center rounded-full border border-border bg-muted/25 px-2.5 py-1 text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground">
{workspaceKindLabel(summary.kind)}
</span>
<span className="inline-flex items-center rounded-full border border-border/70 bg-background px-2.5 py-1 text-xs text-muted-foreground">
Updated {timeAgo(summary.lastUpdatedAt)}
</span>
{summary.serviceCount > 0 ? (
<span
className={cn(
"inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs",
hasRunningServices
? "border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"
: "border-border/70 bg-background text-muted-foreground",
)}
>
<span
className={cn(
"h-1.5 w-1.5 rounded-full",
hasRunningServices ? "bg-emerald-500" : "bg-muted-foreground/40",
)}
/>
{summary.runningServiceCount}/{summary.serviceCount} services
</span>
) : null}
{summary.executionWorkspaceStatus ? (
<span className="inline-flex items-center rounded-full border border-border/70 bg-background px-2.5 py-1 text-xs text-muted-foreground">
{summary.executionWorkspaceStatus.replace(/_/g, " ")}
</span>
) : null}
</div>
<Link
to={workspaceHref}
className="block break-words text-base font-semibold leading-6 text-foreground hover:underline"
>
{summary.workspaceName}
</Link>
</div>
<div
className="flex flex-col gap-2 min-[420px]:flex-row lg:w-auto lg:justify-end"
data-testid="workspace-summary-actions"
>
{summary.hasRuntimeConfig ? (
<Button
variant="outline"
size="sm"
className="h-9 justify-center px-3 text-xs"
disabled={runtimeActionPending}
onClick={() =>
onRuntimeAction({
key: summary.key,
kind: summary.kind,
workspaceId: summary.workspaceId,
action: hasRunningServices ? "stop" : "start",
})
}
>
{runtimeActionKey === actionKey ? (
<Loader2 className="mr-2 h-3.5 w-3.5 animate-spin" />
) : hasRunningServices ? (
<Square className="mr-2 h-3.5 w-3.5" />
) : (
<Play className="mr-2 h-3.5 w-3.5" />
)}
{hasRunningServices ? "Stop services" : "Start services"}
</Button>
) : null}
{summary.kind === "execution_workspace" && summary.executionWorkspaceId && summary.executionWorkspaceStatus ? (
<Button
variant="ghost"
size="sm"
className="h-9 px-3 text-xs text-muted-foreground"
onClick={() => onCloseWorkspace({
id: summary.executionWorkspaceId!,
name: summary.workspaceName,
status: summary.executionWorkspaceStatus!,
})}
>
{summary.executionWorkspaceStatus === "cleanup_failed" ? "Retry close" : "Close workspace"}
</Button>
) : null}
</div>
</div>
<div className="rounded-lg border border-border/70 bg-background px-3 py-3">
<div className="space-y-2 text-sm">
{summary.branchName ? (
<div className="flex items-start gap-2">
<GitBranch className="mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground" />
<div className="min-w-0 flex-1">
<div className="text-[11px] uppercase tracking-[0.14em] text-muted-foreground">Branch</div>
<div className="flex items-start gap-2">
<CopyText
text={summary.branchName}
containerClassName="min-w-0"
className="min-w-0 break-all text-left font-mono text-xs text-foreground"
copiedLabel="Branch copied"
>
{summary.branchName}
</CopyText>
<CopyText
text={summary.branchName}
ariaLabel="Copy branch"
className="mt-0.5 shrink-0 text-muted-foreground hover:text-foreground"
copiedLabel="Branch copied"
>
<Copy className="h-3.5 w-3.5" />
</CopyText>
</div>
</div>
</div>
) : null}
{summary.cwd ? (
<div className="flex items-start gap-2">
<FolderOpen className="mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground" />
<div className="min-w-0 flex-1">
<div className="text-[11px] uppercase tracking-[0.14em] text-muted-foreground">Path</div>
<div className="flex items-start gap-2">
<CopyText
text={summary.cwd}
title={summary.cwd}
containerClassName="min-w-0"
className="min-w-0 break-all text-left font-mono text-xs text-foreground"
copiedLabel="Path copied"
>
{truncatePath(summary.cwd)}
</CopyText>
<CopyText
text={summary.cwd}
ariaLabel="Copy path"
className="mt-0.5 shrink-0 text-muted-foreground hover:text-foreground"
copiedLabel="Path copied"
>
<Copy className="h-3.5 w-3.5" />
</CopyText>
</div>
</div>
</div>
) : null}
{summary.primaryServiceUrl ? (
<div className="flex items-start gap-2">
<ExternalLink className="mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground" />
<div className="min-w-0">
<div className="text-[11px] uppercase tracking-[0.14em] text-muted-foreground">Service</div>
<a
href={summary.primaryServiceUrl}
target="_blank"
rel="noreferrer"
className={cn(
"break-all font-mono text-xs hover:underline",
summary.primaryServiceUrlRunning
? "text-emerald-700 hover:text-emerald-800 dark:text-emerald-300 dark:hover:text-emerald-200"
: "text-foreground",
)}
>
{summary.primaryServiceUrl}
</a>
</div>
</div>
) : null}
</div>
</div>
{summary.issues.length > 0 ? (
<div className="space-y-2">
<div className="text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground">
Linked issues
</div>
<div className="flex flex-wrap gap-2">
{visibleIssues.map((issue) => (
<IssuePill key={issue.id} issue={issue} />
))}
{hiddenIssueCount > 0 ? (
<Link
to={workspaceHref}
className="inline-flex items-center rounded-full border border-border bg-background px-2.5 py-1 text-xs text-muted-foreground hover:text-foreground hover:underline"
>
+{hiddenIssueCount} more
</Link>
) : null}
</div>
</div>
) : null}
</div>
</div>
);
}
function IssuePill({ issue }: { issue: Issue }) {
return (
<IssuesQuicklook issue={issue}>
<Link
to={`/issues/${issue.identifier ?? issue.id}`}
className="inline-flex items-center rounded-full border border-border bg-background px-2.5 py-1 font-mono text-xs text-foreground transition-colors hover:border-foreground/30 hover:text-foreground hover:underline"
>
{issue.identifier ?? issue.id.slice(0, 8)}
</Link>
</IssuesQuicklook>
);
}