forked from farhoodlabs/paperclip
012a738729
## Thinking Path > - Paperclip orchestrates AI-agent companies through company-scoped issues, comments, and execution context. > - The issue detail page is the board surface where operators and agents inspect a task in its parent/child workflow. > - Ordered sub-issues need a low-friction way to move through work without returning to the parent list after every issue. > - Existing issue detail navigation only covered sibling transitions and did not continue into a parent issue's first ordered child. > - This pull request adds ordered previous/next navigation for issue detail views and extends it to continue from a parent or last sibling into the first direct child. > - The benefit is a smoother review/execution path through hierarchical work while preserving hidden issue filtering and dependency-aware ordering. ## What Changed - Added `IssueSiblingNavigation` and route-state handling so issue detail footers can link to previous/next ordered issues. - Extended sub-issue ordering helpers to build navigation from siblings plus direct children, including root-parent and last-sibling-to-first-child cases. - Added page, component, and library tests for ordered sibling navigation, child fallback navigation, hidden issues, and link rendering. - Fixed the quicklook blur/click race Greptile found by deferring close until after portaled link clicks can complete, with a regression test. - Polished the navigation landmark label so it remains accurate when the next target is a direct child rather than a sibling. ## Verification - `pnpm exec vitest run src/components/IssueLinkQuicklook.test.tsx src/lib/issue-detail-subissues.test.ts src/components/IssueSiblingNavigation.test.tsx src/pages/IssueDetail.test.tsx --config vitest.config.ts` from `ui/` - 31 tests passed. - `pnpm --filter @paperclipai/ui typecheck` - passed. - `git diff --check` - passed. - GitHub PR checks on latest head `34046be2` - passed: Greptile Review, verify, e2e, Canary Dry Run, policy, Snyk, and serialized server shards. - Screenshots: not captured in this heartbeat; this PR is a draft and the changed states are covered by focused component/page tests. ## Risks - Low risk; this is a UI navigation addition with no database or API contract changes. - The main behavioral risk is navigation ordering drift if `workflowSort` expectations change later. - The IssueDetail navigation now waits for child issue loading, which avoids stale child fallback links but can delay footer navigation briefly while data loads. > 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 with repository tool use and shell execution. ## 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 - [ ] 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>
193 lines
5.9 KiB
TypeScript
193 lines
5.9 KiB
TypeScript
import * as React from "react";
|
|
import { useMemo, useState } from "react";
|
|
import * as RouterDom from "react-router-dom";
|
|
import type { Issue } from "@paperclipai/shared";
|
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
import { timeAgo } from "@/lib/timeAgo";
|
|
import { createIssueDetailPath, withIssueDetailHeaderSeed } from "@/lib/issueDetailBreadcrumb";
|
|
import {
|
|
getIssueDetailQueryOptions,
|
|
ISSUE_DETAIL_STALE_TIME_MS,
|
|
prefetchIssueDetail,
|
|
} from "@/lib/issueDetailCache";
|
|
import { queryKeys } from "@/lib/queryKeys";
|
|
import { cn } from "@/lib/utils";
|
|
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
|
import { StatusIcon } from "@/components/StatusIcon";
|
|
|
|
function summarizeIssueDescription(description: string | null | undefined) {
|
|
if (!description) return null;
|
|
const summary = description
|
|
.replace(/!\[[^\]]*]\([^)]+\)/g, " ")
|
|
.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1")
|
|
.replace(/[#>*_`~-]+/g, " ")
|
|
.replace(/\s+/g, " ")
|
|
.trim();
|
|
|
|
if (!summary) return null;
|
|
return summary.length > 180 ? `${summary.slice(0, 177).trimEnd()}...` : summary;
|
|
}
|
|
|
|
export function IssueQuicklookCard({
|
|
issue,
|
|
linkTo,
|
|
linkState,
|
|
compact = false,
|
|
}: {
|
|
issue: Issue;
|
|
linkTo: RouterDom.To;
|
|
linkState?: unknown;
|
|
compact?: boolean;
|
|
}) {
|
|
const description = useMemo(() => summarizeIssueDescription(issue.description), [issue.description]);
|
|
|
|
return (
|
|
<div className={cn("space-y-2", compact && "space-y-1.5")}>
|
|
<div className="flex items-start gap-2">
|
|
<StatusIcon status={issue.status} blockerAttention={issue.blockerAttention} className="mt-0.5 shrink-0" />
|
|
<RouterDom.Link
|
|
to={linkTo}
|
|
state={linkState ?? withIssueDetailHeaderSeed(null, issue)}
|
|
className="text-sm font-medium leading-snug hover:underline line-clamp-2"
|
|
>
|
|
{issue.title}
|
|
</RouterDom.Link>
|
|
</div>
|
|
<div className="flex flex-wrap items-center gap-2 text-xs text-muted-foreground">
|
|
<span className="font-mono">{issue.identifier ?? issue.id.slice(0, 8)}</span>
|
|
<span>·</span>
|
|
<span>{issue.status.replace(/_/g, " ")}</span>
|
|
<span>·</span>
|
|
<span>{timeAgo(new Date(issue.updatedAt))}</span>
|
|
</div>
|
|
{description ? (
|
|
<p className="text-xs leading-5 text-muted-foreground [display:-webkit-box] [-webkit-box-orient:vertical] [-webkit-line-clamp:4] overflow-hidden">
|
|
{description}
|
|
</p>
|
|
) : null}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export const IssueLinkQuicklook = React.forwardRef<
|
|
HTMLAnchorElement,
|
|
React.ComponentProps<typeof RouterDom.Link> & {
|
|
issuePathId: string;
|
|
disableIssueQuicklook?: boolean;
|
|
issuePrefetch?: Issue | null;
|
|
issueQuicklookSide?: React.ComponentProps<typeof PopoverContent>["side"];
|
|
issueQuicklookAlign?: React.ComponentProps<typeof PopoverContent>["align"];
|
|
}
|
|
>(function IssueLinkQuicklookImpl(
|
|
{
|
|
issuePathId,
|
|
to,
|
|
children,
|
|
className,
|
|
state,
|
|
disableIssueQuicklook = false,
|
|
issuePrefetch = null,
|
|
issueQuicklookSide = "top",
|
|
issueQuicklookAlign = "start",
|
|
onClick,
|
|
onClickCapture,
|
|
onMouseEnter,
|
|
onFocus,
|
|
onBlur,
|
|
onTouchStart,
|
|
...props
|
|
},
|
|
ref,
|
|
) {
|
|
const queryClient = useQueryClient();
|
|
const [open, setOpen] = useState(false);
|
|
const prefetchedState = issuePrefetch ? withIssueDetailHeaderSeed(state, issuePrefetch) : state;
|
|
const { data, isLoading } = useQuery({
|
|
...getIssueDetailQueryOptions(queryClient, issuePathId, { placeholderIssue: issuePrefetch ?? undefined }),
|
|
enabled: open,
|
|
staleTime: ISSUE_DETAIL_STALE_TIME_MS,
|
|
});
|
|
|
|
const detailPath = createIssueDetailPath(issuePathId);
|
|
const handlePrefetch = React.useCallback(() => {
|
|
void prefetchIssueDetail(queryClient, issuePathId, { issue: issuePrefetch });
|
|
}, [issuePathId, issuePrefetch, queryClient]);
|
|
const link = (
|
|
<RouterDom.Link
|
|
ref={ref}
|
|
to={to}
|
|
state={prefetchedState}
|
|
className={className}
|
|
onMouseEnter={(event) => {
|
|
handlePrefetch();
|
|
onMouseEnter?.(event);
|
|
}}
|
|
onFocus={(event) => {
|
|
handlePrefetch();
|
|
setOpen(true);
|
|
onFocus?.(event);
|
|
}}
|
|
onBlur={(event) => {
|
|
// Let clicks inside the portaled quicklook content finish before closing.
|
|
setTimeout(() => setOpen(false), 0);
|
|
onBlur?.(event);
|
|
}}
|
|
onTouchStart={(event) => {
|
|
handlePrefetch();
|
|
onTouchStart?.(event);
|
|
}}
|
|
onClickCapture={(event) => {
|
|
handlePrefetch();
|
|
onClickCapture?.(event);
|
|
}}
|
|
onClick={(event) => {
|
|
setOpen(false);
|
|
onClick?.(event);
|
|
}}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</RouterDom.Link>
|
|
);
|
|
|
|
if (disableIssueQuicklook) {
|
|
return link;
|
|
}
|
|
|
|
return (
|
|
<Popover open={open} onOpenChange={setOpen}>
|
|
<PopoverTrigger
|
|
asChild
|
|
onMouseEnter={() => {
|
|
handlePrefetch();
|
|
setOpen(true);
|
|
}}
|
|
onMouseLeave={() => setOpen(false)}
|
|
>
|
|
{link}
|
|
</PopoverTrigger>
|
|
<PopoverContent
|
|
className="w-72 p-3"
|
|
side={issueQuicklookSide}
|
|
align={issueQuicklookAlign}
|
|
onMouseEnter={() => setOpen(true)}
|
|
onMouseLeave={() => setOpen(false)}
|
|
onOpenAutoFocus={(event) => event.preventDefault()}
|
|
>
|
|
{data ? (
|
|
<IssueQuicklookCard issue={data} linkTo={detailPath} linkState={prefetchedState} compact />
|
|
) : (
|
|
<div className="space-y-2">
|
|
<div className="h-4 w-24 rounded bg-accent/50" />
|
|
<div className="h-4 w-full rounded bg-accent/40" />
|
|
<div className="h-4 w-3/4 rounded bg-accent/30" />
|
|
{!isLoading ? (
|
|
<p className="text-xs text-muted-foreground">Unable to load issue preview.</p>
|
|
) : null}
|
|
</div>
|
|
)}
|
|
</PopoverContent>
|
|
</Popover>
|
|
);
|
|
});
|