2e74d32871
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The board UI is the operator surface where users create, assign, monitor, and review work items. > - The product language is moving toward "tasks" for user-facing work items while the internal API and database still use "issues". > - PR #7543 bundled this copy migration with broader information-architecture work, which made the branch too large for Greptile review. > - This pull request peels the Issue-to-Task copy migration into a smaller, independently reviewable change. > - The benefit is clearer user-facing terminology, less agent confusion via the Paperclip skill note, and a smaller PR that Greptile can review. ## Linked Issues or Issue Description Refs #7645 Refs #7543 Refs PAP-10430 This PR was split out of #7543 so the Issue-to-Task copy migration can be reviewed separately and the remaining IA PR can fall under Greptile's file limit. ## What Changed - Preserves Scott Tong's original `PAP-57` copy-only commit, with author and co-author credit intact, to rename user-facing "Issues" copy to "Tasks" across the UI while keeping routes/API/internal symbols as `issue`. - Updates onboarding and release-smoke browser selectors from `Create & Open Issue` to `Create & Open Task`. - Adds a terminology note to `skills/paperclip/SKILL.md` clarifying that task and issue refer to the same Paperclip work item. - Resolves the only cherry-pick conflict by keeping current search artifacts support and changing visible search copy to "tasks". ## Verification - `pnpm --filter @paperclipai/ui build` passed. - `NODE_ENV=test pnpm exec vitest run ui/src/components/IssuesList.test.tsx ui/src/components/Sidebar.test.tsx ui/src/components/NewIssueDialog.test.tsx ui/src/pages/IssueDetail.test.tsx` passed: 4 files, 66 tests. - `git diff --check origin/master...HEAD` passed. - Diff is 80 files, below Greptile's 100-file limit. - Before/after UI copy examples: "Issues" -> "Tasks", "New Issue" -> "New Task", "Create & Open Issue" -> "Create & Open Task". ## Risks - Medium copy-risk: this intentionally changes user-facing terminology broadly while keeping internal issue identifiers and routes unchanged. - Some docs and APIs still say `issue`; the skill note clarifies this so agents do not treat task and issue as separate entities. - Browser-level visual validation is expected from CI because this local container is missing usable browser dependencies. > 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 Scott Tong authored the original `PAP-57` copy migration, assisted by Claude Opus 4.8 and Paperclip agents per the preserved commit metadata. Codex / GPT-5-class coding agent with shell, GitHub CLI, and repository access performed the PR split, conflict resolution, skill note, and verification. ## 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 searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [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] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: scotttong <scott.tong@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Paperclip <noreply@paperclip.ing>
260 lines
9.6 KiB
TypeScript
260 lines
9.6 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { createRoot } from "react-dom/client";
|
|
import { flushSync } from "react-dom";
|
|
import type { AnchorHTMLAttributes, ReactElement } from "react";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import type { Agent, IssueRecoveryAction } from "@paperclipai/shared";
|
|
import { IssueRecoveryActionCard, deriveRecoveryCardState } from "./IssueRecoveryActionCard";
|
|
|
|
vi.mock("@/lib/router", () => ({
|
|
Link: ({ children, to, ...props }: AnchorHTMLAttributes<HTMLAnchorElement> & { to: string }) => (
|
|
<a href={to} {...props}>{children}</a>
|
|
),
|
|
}));
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true;
|
|
|
|
function act<T>(callback: () => T): T {
|
|
let result: T | undefined;
|
|
flushSync(() => {
|
|
result = callback();
|
|
});
|
|
const maybePromise = result as unknown as PromiseLike<unknown>;
|
|
if (result && typeof maybePromise.then === "function") {
|
|
throw new TypeError("This test act shim only supports synchronous callbacks.");
|
|
}
|
|
return result as T;
|
|
}
|
|
|
|
let root: ReturnType<typeof createRoot> | null = null;
|
|
let container: HTMLDivElement | null = null;
|
|
|
|
afterEach(() => {
|
|
if (root) {
|
|
act(() => root?.unmount());
|
|
}
|
|
root = null;
|
|
container?.remove();
|
|
container = null;
|
|
});
|
|
|
|
function render(element: ReactElement) {
|
|
container = document.createElement("div");
|
|
document.body.appendChild(container);
|
|
root = createRoot(container);
|
|
act(() => root?.render(element));
|
|
return container;
|
|
}
|
|
|
|
function click(element: Element | null) {
|
|
if (!element) throw new Error("Expected element to exist");
|
|
act(() => {
|
|
element.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
});
|
|
}
|
|
|
|
const ownerAgent: Agent = {
|
|
id: "11111111-1111-1111-1111-111111111111",
|
|
companyId: "company-1",
|
|
name: "ClaudeCoder",
|
|
role: "engineer",
|
|
status: "idle",
|
|
adapterType: "claude_local",
|
|
adapterConfig: {},
|
|
runtimeConfig: {},
|
|
permissions: {},
|
|
urlKey: "claudecoder",
|
|
} as unknown as Agent;
|
|
|
|
const returnAgent: Agent = {
|
|
...ownerAgent,
|
|
id: "22222222-2222-2222-2222-222222222222",
|
|
name: "CodexCoder",
|
|
urlKey: "codexcoder",
|
|
} as Agent;
|
|
|
|
function buildAction(overrides: Partial<IssueRecoveryAction> = {}): IssueRecoveryAction {
|
|
return {
|
|
id: "00000000-0000-0000-0000-0000000000aa",
|
|
companyId: "company-1",
|
|
sourceIssueId: "00000000-0000-0000-0000-0000000000ff",
|
|
recoveryIssueId: null,
|
|
kind: "missing_disposition",
|
|
status: "active",
|
|
ownerType: "agent",
|
|
ownerAgentId: ownerAgent.id,
|
|
ownerUserId: null,
|
|
previousOwnerAgentId: returnAgent.id,
|
|
returnOwnerAgentId: returnAgent.id,
|
|
cause: "missing_disposition",
|
|
fingerprint: "fp",
|
|
evidence: {
|
|
summary: "Run finished but no disposition was chosen.",
|
|
sourceRunId: "7accd7a4-c9ca-4db2-9233-3228a037cc09",
|
|
},
|
|
nextAction: "Choose and record a valid issue disposition.",
|
|
wakePolicy: { type: "wake_owner" },
|
|
monitorPolicy: null,
|
|
attemptCount: 1,
|
|
maxAttempts: 3,
|
|
timeoutAt: null,
|
|
lastAttemptAt: "2026-05-09T19:30:00.000Z",
|
|
outcome: null,
|
|
resolutionNote: null,
|
|
resolvedAt: null,
|
|
createdAt: "2026-05-09T19:30:00.000Z",
|
|
updatedAt: "2026-05-09T19:30:00.000Z",
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
describe("deriveRecoveryCardState", () => {
|
|
it("maps active missing_disposition to needed", () => {
|
|
expect(deriveRecoveryCardState(buildAction())).toBe("needed");
|
|
});
|
|
|
|
it("maps active_run_watchdog to observe_only", () => {
|
|
expect(deriveRecoveryCardState(buildAction({ kind: "active_run_watchdog" }))).toBe("observe_only");
|
|
});
|
|
|
|
it("maps escalated status to escalated", () => {
|
|
expect(deriveRecoveryCardState(buildAction({ status: "escalated" }))).toBe("escalated");
|
|
});
|
|
|
|
it("maps resolved/cancelled to resolved", () => {
|
|
expect(deriveRecoveryCardState(buildAction({ status: "resolved" }))).toBe("resolved");
|
|
expect(deriveRecoveryCardState(buildAction({ status: "cancelled" }))).toBe("resolved");
|
|
});
|
|
});
|
|
|
|
describe("IssueRecoveryActionCard", () => {
|
|
it("renders required fields and an aria-label naming the state", () => {
|
|
const node = render(
|
|
<IssueRecoveryActionCard
|
|
action={buildAction()}
|
|
agentMap={new Map([
|
|
[ownerAgent.id, ownerAgent],
|
|
[returnAgent.id, returnAgent],
|
|
])}
|
|
onResolve={() => {}}
|
|
/>,
|
|
);
|
|
const section = node.querySelector("section[aria-label]");
|
|
expect(section?.getAttribute("aria-label")).toBe("Recovery action: needed");
|
|
expect(node.textContent).toContain("RECOVERY NEEDED");
|
|
expect(node.textContent).toContain("Missing Disposition");
|
|
expect(node.textContent).not.toContain("missing_disposition");
|
|
expect(node.textContent).toContain("This task's run finished, but no next step was chosen.");
|
|
expect(node.textContent).toContain("ClaudeCoder");
|
|
expect(node.textContent).toContain("CodexCoder");
|
|
expect(node.textContent).toContain("Choose and record a valid issue disposition.");
|
|
expect(node.textContent).toContain("Corrective wake queued");
|
|
});
|
|
|
|
it("falls back to em dash when wake policy is absent", () => {
|
|
const node = render(
|
|
<IssueRecoveryActionCard action={buildAction({ wakePolicy: null })} />,
|
|
);
|
|
expect(node.textContent).toContain("—");
|
|
});
|
|
|
|
it("renders observe_only tone for active_run_watchdog", () => {
|
|
const node = render(
|
|
<IssueRecoveryActionCard action={buildAction({ kind: "active_run_watchdog" })} />,
|
|
);
|
|
const section = node.querySelector("section[aria-label]");
|
|
expect(section?.getAttribute("aria-label")).toBe("Recovery action: observing active run");
|
|
expect(node.textContent).toContain("OBSERVING ACTIVE RUN");
|
|
});
|
|
|
|
it("renders a workspace-specific label and headline for workspace_validation", () => {
|
|
const node = render(
|
|
<IssueRecoveryActionCard
|
|
action={buildAction({
|
|
kind: "workspace_validation",
|
|
cause: "workspace_validation_failed",
|
|
nextAction:
|
|
"Repair the source issue workspace link, project workspace cwd, or git checkout before resuming adapter execution.",
|
|
wakePolicy: { type: "manual_repair_required" },
|
|
evidence: {
|
|
recoveryCause: "workspace_validation_failed",
|
|
latestRunErrorCode: "workspace_validation_failed",
|
|
},
|
|
})}
|
|
/>,
|
|
);
|
|
const section = node.querySelector("section[aria-label]");
|
|
expect(section?.getAttribute("data-recovery-kind")).toBe("workspace_validation");
|
|
expect(node.textContent).toContain("Workspace Validation");
|
|
expect(node.textContent).not.toContain("workspace_validation\n");
|
|
expect(node.textContent).toContain(
|
|
"Paperclip stopped this run because the task's git workspace could not be validated.",
|
|
);
|
|
expect(node.textContent).toContain("Repair the source issue workspace link");
|
|
expect(node.textContent).toContain("Manual repair required");
|
|
});
|
|
|
|
it("renders the resolved label and outcome when resolved", () => {
|
|
const node = render(
|
|
<IssueRecoveryActionCard action={buildAction({ status: "resolved", outcome: "restored", resolvedAt: "2026-05-09T19:35:00.000Z" })} />,
|
|
);
|
|
expect(node.textContent).toContain("RECOVERY RESOLVED");
|
|
expect(node.textContent).toContain("Resolved as restored");
|
|
});
|
|
|
|
it("calls resolve with todo and does not offer delegated recovery", () => {
|
|
const onResolve = vi.fn();
|
|
const node = render(
|
|
<IssueRecoveryActionCard action={buildAction()} onResolve={onResolve} />,
|
|
);
|
|
click(node.querySelector("[data-testid='recovery-action-resolve-trigger']"));
|
|
|
|
expect(document.body.textContent).toContain("Try again");
|
|
expect(document.body.textContent).toContain("Mark task done");
|
|
expect(document.body.textContent).not.toContain("Mark blocked");
|
|
expect(document.body.textContent).not.toContain("Delegate follow-up issue");
|
|
click([...document.body.querySelectorAll("button")].find((button) => button.textContent?.includes("Try again")) ?? null);
|
|
|
|
expect(onResolve).toHaveBeenCalledWith("todo");
|
|
});
|
|
|
|
it("does not offer blocked recovery resolution without a blocker selection flow", () => {
|
|
const node = render(
|
|
<IssueRecoveryActionCard action={buildAction()} onResolve={() => {}} canFalsePositive />,
|
|
);
|
|
click(node.querySelector("[data-testid='recovery-action-resolve-trigger']"));
|
|
|
|
expect(document.body.textContent).toContain("Try again");
|
|
expect(document.body.textContent).toContain("Mark task done");
|
|
expect(document.body.textContent).toContain("Send for review");
|
|
expect(document.body.textContent).toContain("False positive, done");
|
|
expect(document.body.textContent).toContain("False positive, review");
|
|
expect(document.body.textContent).not.toContain("Mark blocked");
|
|
});
|
|
|
|
it("hides false-positive options unless canFalsePositive is set", () => {
|
|
const first = render(
|
|
<IssueRecoveryActionCard action={buildAction()} onResolve={() => {}} />,
|
|
);
|
|
click(first.querySelector("[data-testid='recovery-action-resolve-trigger']"));
|
|
expect(document.body.textContent).not.toContain("False positive");
|
|
|
|
act(() => root?.unmount());
|
|
root = null;
|
|
container?.remove();
|
|
container = null;
|
|
|
|
const onResolve = vi.fn();
|
|
const second = render(
|
|
<IssueRecoveryActionCard action={buildAction()} onResolve={onResolve} canFalsePositive />,
|
|
);
|
|
click(second.querySelector("[data-testid='recovery-action-resolve-trigger']"));
|
|
expect(document.body.textContent).toContain("False positive, done");
|
|
expect(document.body.textContent).toContain("False positive, review");
|
|
click([...document.body.querySelectorAll("button")].find((button) => button.textContent?.includes("False positive, done")) ?? null);
|
|
expect(onResolve).toHaveBeenCalledWith("false_positive_done");
|
|
});
|
|
});
|