mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-19 20:10:39 +09:00
Show workspace changes and stale notices in issue threads (#5356)
## Thinking Path > - Paperclip orchestrates AI agents for zero-human companies > - The issue thread is the operator's durable audit trail for what changed and why > - Workspace changes and stale disposition notices need to be visible in that same timeline without noisy or misleading rendering > - The local branch already contained backend activity details, timeline conversion, and UI rendering work for those events > - This pull request isolates the issue-thread activity work into a standalone branch against `origin/master` > - The benefit is a focused audit-trail PR that can merge independently of the sidebar/operator UI polish branch ## What Changed - Adds readable workspace-change activity details to issue update activity events. - Surfaces workspace-change events in issue chat/timeline rendering. - Makes the existing issue comment migration idempotent. - Folds and renders stale disposition notices inline so they match activity-log styling and spacing. - Adds focused route, timeline, and issue-thread system notice coverage. ## Verification - `pnpm install --frozen-lockfile` - `pnpm exec vitest run server/src/__tests__/issue-activity-events-routes.test.ts ui/src/lib/issue-timeline-events.test.ts ui/src/components/IssueChatThreadSystemNotice.test.tsx` — 3 files passed, 22 tests passed. - Confirmed the PR changes 9 files and does not include `pnpm-lock.yaml` or `.github/workflows/*`. - `pnpm exec vitest run server/src/__tests__/issue-closed-workspace-routes.test.ts` — 1 file passed, 4 tests passed. - `pnpm exec vitest run server/src/__tests__/issue-activity-events-routes.test.ts ui/src/lib/issue-timeline-events.test.ts ui/src/components/IssueChatThreadSystemNotice.test.tsx server/src/services/recovery/successful-run-handoff.test.ts packages/shared/src/validators/issue.test.ts` — 5 files passed, 54 tests passed. - `pnpm --filter @paperclipai/shared typecheck && pnpm --filter @paperclipai/server typecheck && pnpm --filter @paperclipai/ui typecheck`. - `pnpm --filter @paperclipai/ui typecheck` after adding the Storybook screenshot fixture. - Captured Storybook screenshots for the new UI rendering paths: - Collapsed stale notice + workspace-change row: `docs/pr-screenshots/pr-5356/issue-thread-notices-collapsed.png` - Expanded stale notice details: `docs/pr-screenshots/pr-5356/issue-thread-notices-expanded.png` ### Screenshots Collapsed stale notice with workspace-change row:  Expanded stale notice details:  ## Risks - Moderate risk: this touches issue activity serialization and issue-thread rendering, both of which are central operator surfaces. - Migration risk is low: the only migration change makes an existing migration idempotent. - No new migrations are introduced, so there is no cross-PR migration ordering requirement. > 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, shell/tool-use enabled, used to split the existing branch, verify the isolated PR branch, and create this PR. ## 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>
This commit is contained in:
parent
4103978578
commit
d0e9cc76f2
17 changed files with 852 additions and 36 deletions
|
|
@ -7,7 +7,7 @@ import { MemoryRouter } from "react-router-dom";
|
|||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { IssueChatThread } from "./IssueChatThread";
|
||||
import type { IssueChatComment } from "../lib/issue-chat-messages";
|
||||
import type { Agent } from "@paperclipai/shared";
|
||||
import type { Agent, SuccessfulRunHandoffState } from "@paperclipai/shared";
|
||||
|
||||
vi.mock("@assistant-ui/react", () => ({
|
||||
AssistantRuntimeProvider: ({ children }: { children: ReactNode }) => <div>{children}</div>,
|
||||
|
|
@ -70,7 +70,14 @@ afterEach(() => {
|
|||
container.remove();
|
||||
});
|
||||
|
||||
function renderThread(comments: IssueChatComment[], agentMap?: Map<string, Agent>) {
|
||||
function renderThread(
|
||||
comments: IssueChatComment[],
|
||||
options: {
|
||||
agentMap?: Map<string, Agent>;
|
||||
issueStatus?: string;
|
||||
successfulRunHandoff?: SuccessfulRunHandoffState | null;
|
||||
} = {},
|
||||
) {
|
||||
act(() => {
|
||||
root.render(
|
||||
<MemoryRouter>
|
||||
|
|
@ -82,7 +89,9 @@ function renderThread(comments: IssueChatComment[], agentMap?: Map<string, Agent
|
|||
onAdd={async () => {}}
|
||||
showComposer={false}
|
||||
enableLiveTranscriptPolling={false}
|
||||
agentMap={agentMap}
|
||||
agentMap={options.agentMap}
|
||||
issueStatus={options.issueStatus}
|
||||
successfulRunHandoff={options.successfulRunHandoff}
|
||||
/>
|
||||
</MemoryRouter>,
|
||||
);
|
||||
|
|
@ -265,7 +274,7 @@ describe("IssueChatThread system notice routing", () => {
|
|||
...baseTimestamps,
|
||||
};
|
||||
|
||||
renderThread([comment], agentMap);
|
||||
renderThread([comment], { agentMap });
|
||||
|
||||
const status = container.querySelector('[role="status"]');
|
||||
expect(status).not.toBeNull();
|
||||
|
|
@ -395,4 +404,80 @@ describe("IssueChatThread system notice routing", () => {
|
|||
expect(container.querySelector('[role="status"]')).toBeNull();
|
||||
expect(container.querySelector('[data-message-role="assistant"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
it("folds stale successful-run disposition warnings into the activity log disclosure style", () => {
|
||||
const comment: IssueChatComment = {
|
||||
id: "comment-stale-disposition-warning",
|
||||
companyId: "company-1",
|
||||
issueId: "issue-1",
|
||||
authorType: "system",
|
||||
authorAgentId: null,
|
||||
authorUserId: null,
|
||||
runId: "run-stale",
|
||||
runAgentId: "agent-codex",
|
||||
body: "Paperclip needs a disposition before this issue can continue.",
|
||||
presentation: {
|
||||
kind: "system_notice",
|
||||
tone: "warning",
|
||||
title: "Missing issue disposition",
|
||||
detailsDefaultOpen: false,
|
||||
},
|
||||
metadata: {
|
||||
version: 1,
|
||||
sourceRunId: "run-stale",
|
||||
sections: [
|
||||
{
|
||||
title: "Run evidence",
|
||||
rows: [
|
||||
{ type: "run_link", label: "Completed run", runId: "run-stale", title: "succeeded" },
|
||||
{ type: "key_value", label: "Normalized cause", value: "successful_run_missing_state" },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
...baseTimestamps,
|
||||
};
|
||||
|
||||
renderThread([comment], {
|
||||
issueStatus: "done",
|
||||
successfulRunHandoff: {
|
||||
state: "resolved",
|
||||
required: false,
|
||||
sourceRunId: "run-stale",
|
||||
correctiveRunId: "run-corrective",
|
||||
assigneeAgentId: "agent-codex",
|
||||
detectedProgressSummary: null,
|
||||
createdAt: new Date("2026-05-04T17:00:00.000Z"),
|
||||
},
|
||||
});
|
||||
|
||||
const row = container.querySelector('[data-testid="stale-disposition-warning"]');
|
||||
expect(row).not.toBeNull();
|
||||
expect(row?.querySelector('span[aria-hidden="true"]')?.className).toContain("size-6");
|
||||
const toggle = row?.querySelector("button[aria-expanded]") as HTMLButtonElement;
|
||||
expect(toggle.className).toContain("w-full");
|
||||
expect(toggle.className).toContain("py-0.5");
|
||||
expect(row?.querySelector('[role="status"]')).toBeNull();
|
||||
expect(row?.querySelector(".lucide-triangle-alert")).toBeNull();
|
||||
expect(row?.querySelector(".lucide-chevron-down")).not.toBeNull();
|
||||
expect(row?.querySelector('[data-testid="stale-disposition-warning-time"]')?.parentElement?.className).toContain("ml-auto");
|
||||
expect(row?.textContent).toContain("Stale disposition warning");
|
||||
expect(row?.textContent).not.toContain("This disposition warning is stale because the issue now has a newer disposition.");
|
||||
expect(row?.textContent).not.toContain("Paperclip needs a disposition before this issue can continue.");
|
||||
|
||||
expect(toggle.getAttribute("aria-expanded")).toBe("false");
|
||||
const detailsId = toggle.getAttribute("aria-controls");
|
||||
expect(detailsId).toBeTruthy();
|
||||
const details = detailsId ? container.ownerDocument.getElementById(detailsId) : null;
|
||||
expect(details).not.toBeNull();
|
||||
expect(details?.textContent).toContain("run-stale");
|
||||
expect(details).toHaveProperty("hidden", true);
|
||||
act(() => {
|
||||
toggle.click();
|
||||
});
|
||||
|
||||
expect(toggle.getAttribute("aria-expanded")).toBe("true");
|
||||
expect(details).toHaveProperty("hidden", false);
|
||||
expect(container.textContent).toContain("run-stale");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue