forked from farhoodlabs/paperclip
df425fde96
## Thinking Path > - Paperclip orchestrates AI agents for zero-human companies. > - Operators use issue detail pages and child issue lists to understand multi-step execution plans. > - Ordered sub-issues currently read like a flat table, so dependency chains and current next steps are harder to scan. > - The branch work adds a workflow-oriented presentation for child issues without changing the single-assignee task model. > - This pull request makes ordered sub-issues read more like a progress checklist while preserving normal issue list controls. > - The benefit is that operators can see completed steps, active work, blocked follow-ups, and dependency order at a glance. ## What Changed - Added workflow sorting utilities and tests for dependency-aware child issue ordering. - Added sub-issue progress summary, checklist numbering, current-step affordances, blocker context, and done-state de-emphasis in the issue list UI. - Wired issue detail sub-issue panels to use the workflow sort/progress checklist presentation. - Updated issue service behavior/tests for child issue ordering inputs used by the UI. - Added a Storybook visual review fixture and screenshot helper for the sub-issue workflow checklist surface. ## Verification - `pnpm run preflight:workspace-links && pnpm exec vitest run server/src/__tests__/issues-service.test.ts ui/src/components/IssueRow.test.tsx ui/src/components/IssuesList.test.tsx ui/src/pages/IssueDetail.test.tsx ui/src/lib/issue-detail-subissues.test.ts ui/src/lib/workflow-sort.test.ts` - Result: 6 test files passed, 55 tests passed, 34 embedded Postgres issue-service tests skipped because `@embedded-postgres/darwin-x64` is unavailable on this host. - Visual review: generated Storybook screenshots from the existing local Storybook server on port 6006 with `node scripts/screenshot-subissues.mjs /tmp/pap-2189-subissues-screens http://localhost:6006`. - Screenshot artifacts: - Desktop dark:  - Desktop light:  - Mobile dark:  - Mobile light:  - Local Storybook note: starting a second Storybook process selected port 6008 because 6006 was occupied, then Vite failed with an esbuild host/binary version mismatch (`0.25.12` host vs `0.27.3` binary). The already-running Storybook server on 6006 served the fixture successfully for screenshots. ## Risks - Medium UI risk: the issue list now has additional sub-issue-specific visual states, so dense lists should be checked for spacing and scanability. - Low ordering risk: workflow sorting is covered by focused unit tests, but unusual dependency topologies may still need reviewer attention. - No migration risk: this PR does not add database migrations or touch `pnpm-lock.yaml`. > 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 coding agent, tool-enabled shell/git/GitHub workflow. Context window is runtime-provided and not exposed in this environment. ## 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>
391 lines
13 KiB
TypeScript
391 lines
13 KiB
TypeScript
import type { ReactNode } from "react";
|
|
import type { Issue } from "@paperclipai/shared";
|
|
import { Columns3 } from "lucide-react";
|
|
import { pickTextColorForPillBg } from "@/lib/color-contrast";
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuCheckboxItem,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuLabel,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu";
|
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
|
import { formatAssigneeUserLabel } from "../lib/assignees";
|
|
import type { InboxIssueColumn } from "../lib/inbox";
|
|
import { cn } from "../lib/utils";
|
|
import { timeAgo } from "../lib/timeAgo";
|
|
import { Identity } from "./Identity";
|
|
import { StatusIcon } from "./StatusIcon";
|
|
|
|
export const issueTrailingColumns: InboxIssueColumn[] = ["assignee", "project", "workspace", "parent", "labels", "updated"];
|
|
|
|
const issueColumnLabels: Record<InboxIssueColumn, string> = {
|
|
status: "Status",
|
|
id: "ID",
|
|
assignee: "Assignee",
|
|
project: "Project",
|
|
workspace: "Workspace",
|
|
parent: "Parent issue",
|
|
labels: "Tags",
|
|
updated: "Last updated",
|
|
};
|
|
|
|
const issueColumnDescriptions: Record<InboxIssueColumn, string> = {
|
|
status: "Issue state chip on the left edge.",
|
|
id: "Ticket identifier like PAP-1009.",
|
|
assignee: "Assigned agent or board user.",
|
|
project: "Linked project pill with its color.",
|
|
workspace: "Execution or project workspace used for the issue.",
|
|
parent: "Parent issue identifier and title.",
|
|
labels: "Issue labels and tags.",
|
|
updated: "Latest visible activity time.",
|
|
};
|
|
|
|
export function issueActivityText(issue: Issue): string {
|
|
return `Updated ${timeAgo(issue.lastActivityAt ?? issue.lastExternalCommentAt ?? issue.updatedAt)}`;
|
|
}
|
|
|
|
function issueTrailingGridTemplate(columns: InboxIssueColumn[]): string {
|
|
return columns
|
|
.map((column) => {
|
|
if (column === "assignee") return "minmax(6rem, 8rem)";
|
|
if (column === "project") return "minmax(4.5rem, 7rem)";
|
|
if (column === "workspace") return "minmax(6rem, 9rem)";
|
|
if (column === "parent") return "minmax(3.5rem, 5.5rem)";
|
|
if (column === "labels") return "minmax(3rem, 6rem)";
|
|
return "minmax(3.5rem, 4.5rem)";
|
|
})
|
|
.join(" ");
|
|
}
|
|
|
|
export function IssueColumnPicker({
|
|
availableColumns,
|
|
visibleColumnSet,
|
|
onToggleColumn,
|
|
onResetColumns,
|
|
title,
|
|
iconOnly = false,
|
|
}: {
|
|
availableColumns: InboxIssueColumn[];
|
|
visibleColumnSet: ReadonlySet<InboxIssueColumn>;
|
|
onToggleColumn: (column: InboxIssueColumn, enabled: boolean) => void;
|
|
onResetColumns: () => void;
|
|
title: string;
|
|
iconOnly?: boolean;
|
|
}) {
|
|
return (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
type="button"
|
|
variant={iconOnly ? "outline" : "ghost"}
|
|
size={iconOnly ? "icon" : "sm"}
|
|
className={iconOnly ? "h-8 w-8 shrink-0" : "hidden h-8 shrink-0 px-2 text-xs sm:inline-flex"}
|
|
title="Columns"
|
|
>
|
|
<Columns3 className={iconOnly ? "h-3.5 w-3.5" : "mr-1 h-3.5 w-3.5"} />
|
|
{!iconOnly && "Columns"}
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-[300px] rounded-xl border-border/70 p-1.5 shadow-xl shadow-black/10">
|
|
<DropdownMenuLabel className="px-2 pb-1 pt-1.5">
|
|
<div className="space-y-1">
|
|
<div className="text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground">
|
|
Desktop issue rows
|
|
</div>
|
|
<div className="text-sm font-medium text-foreground">
|
|
{title}
|
|
</div>
|
|
</div>
|
|
</DropdownMenuLabel>
|
|
<DropdownMenuSeparator />
|
|
{availableColumns.map((column) => (
|
|
<DropdownMenuCheckboxItem
|
|
key={column}
|
|
checked={visibleColumnSet.has(column)}
|
|
onSelect={(event) => event.preventDefault()}
|
|
onCheckedChange={(checked) => onToggleColumn(column, checked === true)}
|
|
className="items-start rounded-lg px-3 py-2.5 pl-8"
|
|
>
|
|
<span className="flex flex-col gap-0.5">
|
|
<span className="text-sm font-medium text-foreground">
|
|
{issueColumnLabels[column]}
|
|
</span>
|
|
<span className="text-xs leading-relaxed text-muted-foreground">
|
|
{issueColumnDescriptions[column]}
|
|
</span>
|
|
</span>
|
|
</DropdownMenuCheckboxItem>
|
|
))}
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem
|
|
onSelect={onResetColumns}
|
|
className="rounded-lg px-3 py-2 text-sm"
|
|
>
|
|
Reset defaults
|
|
<span className="ml-auto text-xs text-muted-foreground">status, id, updated</span>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
);
|
|
}
|
|
|
|
export function InboxIssueMetaLeading({
|
|
issue,
|
|
isLive,
|
|
showStatus = true,
|
|
showIdentifier = true,
|
|
statusSlot,
|
|
checklistStepNumber = null,
|
|
}: {
|
|
issue: Issue;
|
|
isLive: boolean;
|
|
showStatus?: boolean;
|
|
showIdentifier?: boolean;
|
|
statusSlot?: ReactNode;
|
|
checklistStepNumber?: number | string | null;
|
|
}) {
|
|
return (
|
|
<>
|
|
{showStatus ? (
|
|
<span className="hidden shrink-0 sm:inline-flex">
|
|
{statusSlot ?? <StatusIcon status={issue.status} blockerAttention={issue.blockerAttention} />}
|
|
</span>
|
|
) : null}
|
|
{checklistStepNumber !== null ? (
|
|
<span className="shrink-0 font-mono text-xs text-muted-foreground" aria-hidden="true">
|
|
{checklistStepNumber}.
|
|
</span>
|
|
) : null}
|
|
{showIdentifier ? (
|
|
<span className="shrink-0 font-mono text-xs text-muted-foreground">
|
|
{issue.identifier ?? issue.id.slice(0, 8)}
|
|
</span>
|
|
) : null}
|
|
{isLive && (
|
|
<span
|
|
className={cn(
|
|
"inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 sm:gap-1.5 sm:px-2",
|
|
"bg-blue-500/10",
|
|
)}
|
|
>
|
|
<span className="relative flex h-2 w-2">
|
|
<span className="absolute inline-flex h-full w-full animate-pulse rounded-full bg-blue-400 opacity-75" />
|
|
<span
|
|
className={cn(
|
|
"relative inline-flex h-2 w-2 rounded-full",
|
|
"bg-blue-500",
|
|
)}
|
|
/>
|
|
</span>
|
|
<span
|
|
className={cn(
|
|
"hidden text-[11px] font-medium sm:inline",
|
|
"text-blue-600 dark:text-blue-400",
|
|
)}
|
|
>
|
|
Live
|
|
</span>
|
|
</span>
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
|
|
export function InboxIssueTrailingColumns({
|
|
issue,
|
|
columns,
|
|
projectName,
|
|
projectColor,
|
|
workspaceId,
|
|
workspaceName,
|
|
assigneeName,
|
|
assigneeUserName,
|
|
assigneeUserAvatarUrl,
|
|
currentUserId,
|
|
parentIdentifier,
|
|
parentTitle,
|
|
assigneeContent,
|
|
onFilterWorkspace,
|
|
}: {
|
|
issue: Issue;
|
|
columns: InboxIssueColumn[];
|
|
projectName: string | null;
|
|
projectColor: string | null;
|
|
workspaceId?: string | null;
|
|
workspaceName: string | null;
|
|
assigneeName: string | null;
|
|
assigneeUserName?: string | null;
|
|
assigneeUserAvatarUrl?: string | null;
|
|
currentUserId: string | null;
|
|
parentIdentifier: string | null;
|
|
parentTitle: string | null;
|
|
assigneeContent?: ReactNode;
|
|
onFilterWorkspace?: (workspaceId: string) => void;
|
|
}) {
|
|
const activityText = timeAgo(issue.lastActivityAt ?? issue.lastExternalCommentAt ?? issue.updatedAt);
|
|
const userLabel = assigneeUserName ?? formatAssigneeUserLabel(issue.assigneeUserId, currentUserId) ?? "User";
|
|
|
|
return (
|
|
<span
|
|
className="grid items-center gap-2"
|
|
style={{ gridTemplateColumns: issueTrailingGridTemplate(columns) }}
|
|
>
|
|
{columns.map((column) => {
|
|
if (column === "assignee") {
|
|
if (assigneeContent) {
|
|
return <span key={column} className="min-w-0">{assigneeContent}</span>;
|
|
}
|
|
|
|
if (issue.assigneeAgentId) {
|
|
return (
|
|
<span key={column} className="min-w-0 text-xs text-foreground">
|
|
<Identity
|
|
name={assigneeName ?? issue.assigneeAgentId.slice(0, 8)}
|
|
size="sm"
|
|
className="min-w-0"
|
|
/>
|
|
</span>
|
|
);
|
|
}
|
|
|
|
if (issue.assigneeUserId) {
|
|
return (
|
|
<span key={column} className="min-w-0 text-xs text-foreground">
|
|
<Identity
|
|
name={userLabel}
|
|
avatarUrl={assigneeUserAvatarUrl}
|
|
size="sm"
|
|
className="min-w-0"
|
|
/>
|
|
</span>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<span key={column} className="min-w-0 truncate text-xs text-muted-foreground">
|
|
Unassigned
|
|
</span>
|
|
);
|
|
}
|
|
|
|
if (column === "project") {
|
|
if (projectName) {
|
|
const accentColor = projectColor ?? "#64748b";
|
|
return (
|
|
<span
|
|
key={column}
|
|
className="inline-flex min-w-0 items-center gap-2 text-xs font-medium"
|
|
style={{ color: pickTextColorForPillBg(accentColor, 0.12) }}
|
|
>
|
|
<span
|
|
className="h-1.5 w-1.5 shrink-0 rounded-full"
|
|
style={{ backgroundColor: accentColor }}
|
|
/>
|
|
<span className="truncate">{projectName}</span>
|
|
</span>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<span key={column} className="min-w-0 truncate text-xs text-muted-foreground">
|
|
No project
|
|
</span>
|
|
);
|
|
}
|
|
|
|
if (column === "labels") {
|
|
if ((issue.labels ?? []).length > 0) {
|
|
return (
|
|
<span key={column} className="flex min-w-0 items-center gap-1 overflow-hidden">
|
|
{(issue.labels ?? []).slice(0, 2).map((label) => (
|
|
<span
|
|
key={label.id}
|
|
className="inline-flex min-w-0 max-w-full shrink-0 items-center rounded-full border px-1.5 py-0 text-[10px] font-medium"
|
|
style={{
|
|
borderColor: label.color,
|
|
color: pickTextColorForPillBg(label.color, 0.12),
|
|
backgroundColor: `${label.color}1f`,
|
|
}}
|
|
>
|
|
<span className="truncate">{label.name}</span>
|
|
</span>
|
|
))}
|
|
{(issue.labels ?? []).length > 2 ? (
|
|
<span className="shrink-0 text-[10px] font-medium text-muted-foreground">
|
|
+{(issue.labels ?? []).length - 2}
|
|
</span>
|
|
) : null}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
return <span key={column} className="min-w-0" aria-hidden="true" />;
|
|
}
|
|
|
|
if (column === "workspace") {
|
|
if (!workspaceName) {
|
|
return <span key={column} className="min-w-0" aria-hidden="true" />;
|
|
}
|
|
|
|
return (
|
|
<span key={column} className="min-w-0 truncate text-xs text-muted-foreground">
|
|
{workspaceId && onFilterWorkspace ? (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<button
|
|
type="button"
|
|
className="truncate rounded-sm text-left text-xs text-muted-foreground transition-colors hover:text-foreground hover:underline"
|
|
onClick={(event) => {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
onFilterWorkspace(workspaceId);
|
|
}}
|
|
>
|
|
{workspaceName}
|
|
</button>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="top" sideOffset={6}>
|
|
Filter by workspace
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
) : (
|
|
workspaceName
|
|
)}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
if (column === "parent") {
|
|
if (!issue.parentId) {
|
|
return <span key={column} className="min-w-0" aria-hidden="true" />;
|
|
}
|
|
|
|
return (
|
|
<span key={column} className="min-w-0 truncate text-xs text-muted-foreground" title={parentTitle ?? undefined}>
|
|
{parentIdentifier ? (
|
|
<span className="font-mono">{parentIdentifier}</span>
|
|
) : (
|
|
<span className="italic">Sub-issue</span>
|
|
)}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
if (column === "updated") {
|
|
return (
|
|
<span key={column} className="min-w-0 truncate text-right text-[11px] font-medium text-muted-foreground">
|
|
{activityText}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
return null;
|
|
})}
|
|
</span>
|
|
);
|
|
}
|