forked from farhoodlabs/paperclip
e400315cbf
## Thinking Path > - Paperclip orchestrates AI agents for zero-human companies > - The issue graph and liveness recovery system decide whether assigned work is executable or parked > - Assigned issues created without an explicit status could silently land in backlog, making parents look blocked with no productive wake path > - The server, shared validators, recovery analysis, and UI all need to agree on that execution semantic > - This pull request makes assigned issue creation default to `todo`, flags assigned backlog blockers, and surfaces the state in the board > - The benefit is that parked assigned work becomes intentional and visible instead of creating silent liveness stalls ## What Changed - Adds contract tests for assigned issue creation defaults. - Defaults assigned issue creation to `todo` when status is omitted while preserving explicit `backlog` parking. - Exposes `resolveCreateIssueStatusDefault` through shared validators. - Teaches liveness/blocker attention paths to distinguish assigned backlog blockers. - Adds UI notices, row/header badges, and issue detail safeguards for assigned backlog blockers. - Adds Storybook fixtures and execution-semantics documentation for the assigned-backlog behavior. ## Verification - `pnpm run preflight:workspace-links && pnpm exec vitest run packages/shared/src/validators/issue.test.ts server/src/__tests__/issue-assigned-backlog-contract-routes.test.ts server/src/__tests__/issue-blocker-attention.test.ts server/src/__tests__/issue-liveness.test.ts server/src/__tests__/heartbeat-issue-liveness-escalation.test.ts ui/src/components/IssueAssignedBacklogNotice.test.tsx ui/src/components/IssueRow.test.tsx` — 50 passed, 23 skipped. - Skipped tests were embedded Postgres suites on this host with the repo skip message: `Postgres init script exited with code null. Please check the logs for extra info. The data directory might already exist.` - Pairwise merge check against the issue-controls PR branch completed without conflicts via `git merge --no-commit --no-ff` in a temporary worktree. - Screenshots for assigned-backlog UI states: [light](docs/pr-screenshots/pr-5428/assigned-backlog-light.png), [dark](docs/pr-screenshots/pr-5428/assigned-backlog-dark.png). - Follow-up checks: `pnpm --filter /ui typecheck`; `pnpm --filter /mcp-server build`; `pnpm --filter /mcp-server test`; `pnpm exec vitest run packages/shared/src/validators/issue.test.ts`; focused UI component tests. - Remote PR checks on head `6300b3c`: policy, verify, serialized server shards 1/4-4/4, Canary Dry Run, e2e, Greptile Review, and Snyk all passed. ## Risks - Medium: changes status defaulting for assigned issue creation when the caller omits status. Explicit `backlog` remains supported, and server/shared tests cover both paths. - Medium: liveness classification changes can affect blocker attention labels; focused service and UI tests cover the new assigned-backlog state. > 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 coding agent, GPT-5 model family (`gpt-5`), tool-enabled Paperclip heartbeat environment. Context window and internal reasoning mode are not exposed by the runtime. ## 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>
189 lines
9.4 KiB
TypeScript
189 lines
9.4 KiB
TypeScript
import type { IssueBlockerAttention, IssueRelationIssueSummary, SuccessfulRunHandoffState } from "@paperclipai/shared";
|
|
import { AlertTriangle, Flag } from "lucide-react";
|
|
import { Link } from "@/lib/router";
|
|
import { createIssueDetailPath } from "../lib/issueDetailBreadcrumb";
|
|
import { IssueLinkQuicklook } from "./IssueLinkQuicklook";
|
|
import { isAssignedBacklogBlocker } from "../lib/issue-blockers";
|
|
|
|
export function IssueBlockedNotice({
|
|
issueStatus,
|
|
blockers,
|
|
blockerAttention,
|
|
successfulRunHandoff,
|
|
agentName,
|
|
}: {
|
|
issueStatus?: string;
|
|
blockers: IssueRelationIssueSummary[];
|
|
blockerAttention?: IssueBlockerAttention | null;
|
|
successfulRunHandoff?: SuccessfulRunHandoffState | null;
|
|
agentName?: string | null;
|
|
}) {
|
|
if (issueStatus === "done" || issueStatus === "cancelled") return null;
|
|
const showSuccessfulRunHandoff = successfulRunHandoff?.required === true;
|
|
if (!showSuccessfulRunHandoff && blockers.length === 0 && issueStatus !== "blocked") return null;
|
|
|
|
const blockerLabel = blockers.length === 1 ? "the linked issue" : "the linked issues";
|
|
const terminalBlockers = blockers
|
|
.flatMap((blocker) => blocker.terminalBlockers ?? [])
|
|
.filter((blocker, index, all) => all.findIndex((candidate) => candidate.id === blocker.id) === index);
|
|
|
|
const isStalled = blockerAttention?.state === "stalled";
|
|
const parkedBlockers = (() => {
|
|
const seen = new Set<string>();
|
|
const collected: IssueRelationIssueSummary[] = [];
|
|
const sources: IssueRelationIssueSummary[] = [...blockers];
|
|
for (const blocker of blockers) {
|
|
for (const terminal of blocker.terminalBlockers ?? []) {
|
|
sources.push(terminal);
|
|
}
|
|
}
|
|
for (const blocker of sources) {
|
|
if (!isAssignedBacklogBlocker(blocker)) continue;
|
|
if (seen.has(blocker.id)) continue;
|
|
seen.add(blocker.id);
|
|
collected.push(blocker);
|
|
}
|
|
return collected;
|
|
})();
|
|
const showParkedRow = parkedBlockers.length > 0;
|
|
const stalledLeafIdentifier =
|
|
blockerAttention?.sampleStalledBlockerIdentifier ?? blockerAttention?.sampleBlockerIdentifier ?? null;
|
|
const stalledLeafBlockers = (() => {
|
|
const candidates: IssueRelationIssueSummary[] = [];
|
|
for (const blocker of [...blockers, ...terminalBlockers]) {
|
|
if (blocker.status !== "in_review") continue;
|
|
if (candidates.some((existing) => existing.id === blocker.id)) continue;
|
|
candidates.push(blocker);
|
|
}
|
|
if (stalledLeafIdentifier) {
|
|
const preferred = candidates.find(
|
|
(blocker) => (blocker.identifier ?? blocker.id) === stalledLeafIdentifier,
|
|
);
|
|
if (preferred) {
|
|
return [preferred, ...candidates.filter((blocker) => blocker.id !== preferred.id)];
|
|
}
|
|
}
|
|
return candidates;
|
|
})();
|
|
const showStalledRow = isStalled && stalledLeafBlockers.length > 0;
|
|
|
|
const renderBlockerChip = (blocker: IssueRelationIssueSummary) => {
|
|
const issuePathId = blocker.identifier ?? blocker.id;
|
|
return (
|
|
<IssueLinkQuicklook
|
|
key={blocker.id}
|
|
issuePathId={issuePathId}
|
|
to={createIssueDetailPath(issuePathId)}
|
|
className="inline-flex max-w-full items-center gap-1 rounded-md border border-amber-300/70 bg-background/80 px-2 py-1 font-mono text-xs text-amber-950 transition-colors hover:border-amber-500 hover:bg-amber-100 hover:underline dark:border-amber-500/40 dark:bg-background/40 dark:text-amber-100 dark:hover:bg-amber-500/15"
|
|
>
|
|
<span>{blocker.identifier ?? blocker.id.slice(0, 8)}</span>
|
|
<span className="max-w-[18rem] truncate font-sans text-[11px] text-amber-800 dark:text-amber-200">
|
|
{blocker.title}
|
|
</span>
|
|
</IssueLinkQuicklook>
|
|
);
|
|
};
|
|
|
|
return (
|
|
<div
|
|
data-blocker-attention-state={blockerAttention?.state}
|
|
data-successful-run-handoff={showSuccessfulRunHandoff ? "required" : undefined}
|
|
className="mb-3 rounded-md border border-amber-300/70 bg-amber-50/90 px-3 py-2.5 text-sm text-amber-950 shadow-sm dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-100"
|
|
>
|
|
<div className="flex items-start gap-2">
|
|
<AlertTriangle className="mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-300" />
|
|
<div className="min-w-0 space-y-1.5">
|
|
{showSuccessfulRunHandoff ? (
|
|
<>
|
|
<p className="font-medium leading-5">This issue still needs a next step.</p>
|
|
<p className="leading-5">
|
|
A run finished successfully, but this issue is still open in{" "}
|
|
<code className="rounded bg-amber-100 px-1 py-0.5 text-[12px] dark:bg-amber-400/15">
|
|
in_progress
|
|
</code>{" "}
|
|
with no clear owner for the next action.
|
|
</p>
|
|
<ul className="list-disc space-y-1 pl-5 text-xs leading-5 text-amber-900 dark:text-amber-100">
|
|
<li>Mark it done or cancelled.</li>
|
|
<li>Send it for review or ask for input.</li>
|
|
<li>Mark it blocked with a blocker owner.</li>
|
|
<li>Delegate follow-up work or queue a continuation.</li>
|
|
</ul>
|
|
<div className="flex flex-wrap gap-1.5 text-xs">
|
|
{successfulRunHandoff.sourceRunId && successfulRunHandoff.assigneeAgentId ? (
|
|
<Link
|
|
to={`/agents/${successfulRunHandoff.assigneeAgentId}/runs/${successfulRunHandoff.sourceRunId}`}
|
|
className="rounded-md border border-amber-300/70 bg-background/80 px-2 py-1 font-mono text-amber-950 hover:border-amber-500 hover:bg-amber-100 hover:underline dark:border-amber-500/40 dark:bg-background/40 dark:text-amber-100 dark:hover:bg-amber-500/15"
|
|
>
|
|
run {successfulRunHandoff.sourceRunId.slice(0, 8)}
|
|
</Link>
|
|
) : successfulRunHandoff.sourceRunId ? (
|
|
<span className="rounded-md border border-amber-300/70 bg-background/80 px-2 py-1 font-mono text-amber-950 dark:border-amber-500/40 dark:bg-background/40 dark:text-amber-100">
|
|
run {successfulRunHandoff.sourceRunId.slice(0, 8)}
|
|
</span>
|
|
) : null}
|
|
<span className="rounded-md border border-amber-300/70 bg-background/80 px-2 py-1 text-amber-900 dark:border-amber-500/40 dark:bg-background/40 dark:text-amber-100">
|
|
Corrective wake queued for {agentName ?? "the assignee"}
|
|
</span>
|
|
</div>
|
|
{successfulRunHandoff.detectedProgressSummary ? (
|
|
<p className="text-xs leading-5 text-amber-800 dark:text-amber-200">
|
|
Detected progress: {successfulRunHandoff.detectedProgressSummary}
|
|
</p>
|
|
) : null}
|
|
</>
|
|
) : null}
|
|
{showSuccessfulRunHandoff && (blockers.length > 0 || issueStatus === "blocked") ? (
|
|
<div className="border-t border-amber-300/60 pt-1.5 dark:border-amber-500/30" />
|
|
) : null}
|
|
{blockers.length > 0 || issueStatus === "blocked" ? (
|
|
<>
|
|
<p className="leading-5">
|
|
{blockers.length > 0
|
|
? isStalled
|
|
? stalledLeafBlockers.length > 1
|
|
? <>Work on this issue is blocked by {blockerLabel}, but the chain is stalled in review without a clear next step. Resolve the stalled reviews below or remove them as blockers.</>
|
|
: <>Work on this issue is blocked by {blockerLabel}, but the chain is stalled in review without a clear next step. Resolve the stalled review below or remove it as a blocker.</>
|
|
: <>Work on this issue is blocked by {blockerLabel} until {blockers.length === 1 ? "it is" : "they are"} complete. Comments still wake the assignee for questions or triage.</>
|
|
: <>Work on this issue is blocked until it is moved back to todo. Comments still wake the assignee for questions or triage.</>}
|
|
</p>
|
|
{blockers.length > 0 ? (
|
|
<div className="flex flex-wrap gap-1.5">
|
|
{blockers.map(renderBlockerChip)}
|
|
</div>
|
|
) : null}
|
|
{showStalledRow ? (
|
|
<div className="flex flex-wrap items-center gap-1.5 pt-0.5">
|
|
<span className="text-xs font-medium text-amber-800 dark:text-amber-200">
|
|
Stalled in review
|
|
</span>
|
|
{stalledLeafBlockers.map(renderBlockerChip)}
|
|
</div>
|
|
) : terminalBlockers.length > 0 ? (
|
|
<div className="flex flex-wrap items-center gap-1.5 pt-0.5">
|
|
<span className="text-xs font-medium text-amber-800 dark:text-amber-200">
|
|
Ultimately waiting on
|
|
</span>
|
|
{terminalBlockers.map(renderBlockerChip)}
|
|
</div>
|
|
) : null}
|
|
{showParkedRow ? (
|
|
<div
|
|
data-testid="issue-blocked-notice-parked-row"
|
|
className="flex flex-wrap items-center gap-1.5 pt-0.5"
|
|
>
|
|
<span className="inline-flex items-center gap-1 text-xs font-medium text-amber-800 dark:text-amber-200">
|
|
<Flag className="h-3 w-3" aria-hidden />
|
|
Blocked by parked work
|
|
</span>
|
|
{parkedBlockers.map(renderBlockerChip)}
|
|
</div>
|
|
) : null}
|
|
</>
|
|
) : null}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|