mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 01:50:39 +09:00
## 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>
123 lines
3.9 KiB
TypeScript
123 lines
3.9 KiB
TypeScript
import type { Issue, IssueStatus } from "@paperclipai/shared";
|
|
import { workflowSort } from "./workflow-sort";
|
|
|
|
export type SubIssueProgressTargetKind = "next" | "blocked";
|
|
|
|
export type SubIssueProgressTarget = {
|
|
issue: Issue;
|
|
kind: SubIssueProgressTargetKind;
|
|
};
|
|
|
|
export type SubIssueProgressSummary = {
|
|
totalCount: number;
|
|
doneCount: number;
|
|
inProgressCount: number;
|
|
blockedCount: number;
|
|
countsByStatus: Partial<Record<IssueStatus, number>>;
|
|
target: SubIssueProgressTarget | null;
|
|
};
|
|
|
|
export type IssueSiblingNavigation = {
|
|
previous: Issue | null;
|
|
next: Issue | null;
|
|
currentIndex: number;
|
|
totalCount: number;
|
|
};
|
|
|
|
export function shouldRenderRichSubIssuesSection(childIssuesLoading: boolean, childIssueCount: number): boolean {
|
|
return childIssuesLoading || childIssueCount > 0;
|
|
}
|
|
|
|
const MIN_CHILD_ISSUES_FOR_PROGRESS_SUMMARY = 2;
|
|
|
|
export function shouldRenderSubIssueProgressSummary(enabled: boolean | undefined, childIssueCount: number): boolean {
|
|
return enabled === true && childIssueCount >= MIN_CHILD_ISSUES_FOR_PROGRESS_SUMMARY;
|
|
}
|
|
|
|
export function buildSubIssueProgressSummary(issues: Issue[]): SubIssueProgressSummary {
|
|
const countsByStatus: Partial<Record<IssueStatus, number>> = {};
|
|
const progressIssues = issues.filter((issue) => issue.status !== "cancelled");
|
|
for (const issue of progressIssues) {
|
|
countsByStatus[issue.status] = (countsByStatus[issue.status] ?? 0) + 1;
|
|
}
|
|
|
|
const orderedIssues = workflowSort(progressIssues);
|
|
const nextIssue = orderedIssues.find((issue) => isActionableStatus(issue.status)) ?? null;
|
|
const remainingIssues = orderedIssues.filter((issue) => !isTerminalStatus(issue.status));
|
|
const blockedIssue =
|
|
nextIssue === null && remainingIssues.length > 0 && remainingIssues.every((issue) => issue.status === "blocked")
|
|
? remainingIssues[0]
|
|
: null;
|
|
|
|
return {
|
|
totalCount: progressIssues.length,
|
|
doneCount: countsByStatus.done ?? 0,
|
|
inProgressCount: countsByStatus.in_progress ?? 0,
|
|
blockedCount: countsByStatus.blocked ?? 0,
|
|
countsByStatus,
|
|
target: nextIssue
|
|
? { issue: nextIssue, kind: "next" }
|
|
: blockedIssue
|
|
? { issue: blockedIssue, kind: "blocked" }
|
|
: null,
|
|
};
|
|
}
|
|
|
|
export function buildIssueSiblingNavigation(
|
|
currentIssue: Issue,
|
|
siblingIssues: Issue[],
|
|
childIssues: Issue[] = [],
|
|
): IssueSiblingNavigation | null {
|
|
if (currentIssue.hiddenAt) return null;
|
|
|
|
const byId = new Map<string, Issue>();
|
|
if (currentIssue.parentId) {
|
|
for (const issue of siblingIssues) {
|
|
if (issue.parentId !== currentIssue.parentId || issue.hiddenAt) continue;
|
|
byId.set(
|
|
issue.id,
|
|
issue.id === currentIssue.id
|
|
? { ...issue, ...currentIssue, blockedBy: currentIssue.blockedBy ?? issue.blockedBy }
|
|
: issue,
|
|
);
|
|
}
|
|
if (!byId.has(currentIssue.id)) byId.set(currentIssue.id, currentIssue);
|
|
}
|
|
|
|
const ordered = workflowSort(Array.from(byId.values()));
|
|
const currentIndex = ordered.findIndex((issue) => issue.id === currentIssue.id);
|
|
const directChildren = workflowSort(
|
|
childIssues.filter((issue) => issue.parentId === currentIssue.id && !issue.hiddenAt),
|
|
);
|
|
const firstChild = directChildren[0] ?? null;
|
|
|
|
if (currentIndex < 0) {
|
|
return firstChild
|
|
? {
|
|
previous: null,
|
|
next: firstChild,
|
|
currentIndex: 0,
|
|
totalCount: directChildren.length + 1,
|
|
}
|
|
: null;
|
|
}
|
|
|
|
const previous = currentIndex > 0 ? ordered[currentIndex - 1] : null;
|
|
const next = currentIndex < ordered.length - 1 ? ordered[currentIndex + 1] : firstChild;
|
|
if (!previous && !next) return null;
|
|
|
|
return {
|
|
previous,
|
|
next,
|
|
currentIndex,
|
|
totalCount: ordered.length,
|
|
};
|
|
}
|
|
|
|
function isActionableStatus(status: IssueStatus): boolean {
|
|
return status !== "done" && status !== "cancelled" && status !== "blocked";
|
|
}
|
|
|
|
function isTerminalStatus(status: IssueStatus): boolean {
|
|
return status === "done" || status === "cancelled";
|
|
}
|