import { Link, useParams } from "@/lib/router"; import { useQuery } from "@tanstack/react-query"; import { ExternalLink } from "lucide-react"; import { executionWorkspacesApi } from "../api/execution-workspaces"; import { queryKeys } from "../lib/queryKeys"; function isSafeExternalUrl(value: string | null | undefined) { if (!value) return false; try { const parsed = new URL(value); return parsed.protocol === "http:" || parsed.protocol === "https:"; } catch { return false; } } function DetailRow({ label, children }: { label: string; children: React.ReactNode }) { return (
{label}
{children}
); } export function ExecutionWorkspaceDetail() { const { workspaceId } = useParams<{ workspaceId: string }>(); const { data: workspace, isLoading, error } = useQuery({ queryKey: queryKeys.executionWorkspaces.detail(workspaceId!), queryFn: () => executionWorkspacesApi.get(workspaceId!), enabled: Boolean(workspaceId), }); if (isLoading) return

Loading...

; if (error) return

{error instanceof Error ? error.message : "Failed to load workspace"}

; if (!workspace) return null; return (
Execution workspace

{workspace.name}

{workspace.status} · {workspace.mode} · {workspace.providerType}
{workspace.projectId ? {workspace.projectId} : "None"} {workspace.sourceIssueId ? {workspace.sourceIssueId} : "None"} {workspace.branchName ?? "None"} {workspace.baseRef ?? "None"} {workspace.cwd ?? "None"} {workspace.providerRef ?? "None"} {workspace.repoUrl && isSafeExternalUrl(workspace.repoUrl) ? ( {workspace.repoUrl} ) : workspace.repoUrl ? ( {workspace.repoUrl} ) : "None"} {new Date(workspace.openedAt).toLocaleString()} {new Date(workspace.lastUsedAt).toLocaleString()} {workspace.cleanupEligibleAt ? `${new Date(workspace.cleanupEligibleAt).toLocaleString()}${workspace.cleanupReason ? ` · ${workspace.cleanupReason}` : ""}` : "Not scheduled"}
); }