mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-16 02:40: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
|
|
@ -455,6 +455,11 @@ function createTimelineEventMessage(args: {
|
|||
: (formatAssigneeUserLabel(event.assigneeChange.to.userId, currentUserId, userLabelMap) ?? "Unassigned");
|
||||
lines.push(`Assignee: ${from} -> ${to}`);
|
||||
}
|
||||
if (event.workspaceChange) {
|
||||
lines.push(
|
||||
`Workspace: ${event.workspaceChange.from.label ?? "none"} -> ${event.workspaceChange.to.label ?? "none"}`,
|
||||
);
|
||||
}
|
||||
|
||||
const message: ThreadSystemMessage = {
|
||||
id: `activity:${event.id}`,
|
||||
|
|
@ -471,6 +476,7 @@ function createTimelineEventMessage(args: {
|
|||
actorId: event.actorId,
|
||||
statusChange: event.statusChange ?? null,
|
||||
assigneeChange: event.assigneeChange ?? null,
|
||||
workspaceChange: event.workspaceChange ?? null,
|
||||
followUpRequested: event.followUpRequested === true,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -171,6 +171,67 @@ describe("extractIssueTimelineEvents", () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it("extracts workspace changes from issue update activity", () => {
|
||||
const events = extractIssueTimelineEvents([
|
||||
{
|
||||
id: "evt-workspace",
|
||||
companyId: "company-1",
|
||||
actorType: "user",
|
||||
actorId: "local-board",
|
||||
action: "issue.updated",
|
||||
entityType: "issue",
|
||||
entityId: "issue-1",
|
||||
agentId: null,
|
||||
runId: null,
|
||||
createdAt: new Date("2026-03-31T12:01:00.000Z"),
|
||||
details: {
|
||||
projectWorkspaceId: "workspace-2",
|
||||
workspaceChange: {
|
||||
from: {
|
||||
label: "Main workspace",
|
||||
projectWorkspaceId: "workspace-1",
|
||||
executionWorkspaceId: null,
|
||||
mode: "shared_workspace",
|
||||
},
|
||||
to: {
|
||||
label: "Feature branch",
|
||||
projectWorkspaceId: "workspace-2",
|
||||
executionWorkspaceId: null,
|
||||
mode: "shared_workspace",
|
||||
},
|
||||
},
|
||||
_previous: {
|
||||
projectWorkspaceId: "workspace-1",
|
||||
},
|
||||
},
|
||||
},
|
||||
] satisfies ActivityEvent[]);
|
||||
|
||||
expect(events).toEqual([
|
||||
{
|
||||
id: "evt-workspace",
|
||||
createdAt: new Date("2026-03-31T12:01:00.000Z"),
|
||||
actorType: "user",
|
||||
actorId: "local-board",
|
||||
runId: null,
|
||||
workspaceChange: {
|
||||
from: {
|
||||
label: "Main workspace",
|
||||
projectWorkspaceId: "workspace-1",
|
||||
executionWorkspaceId: null,
|
||||
mode: "shared_workspace",
|
||||
},
|
||||
to: {
|
||||
label: "Feature branch",
|
||||
projectWorkspaceId: "workspace-2",
|
||||
executionWorkspaceId: null,
|
||||
mode: "shared_workspace",
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("synthesizes non-status follow-up rows from comment activity", () => {
|
||||
const events = extractIssueTimelineEvents([
|
||||
{
|
||||
|
|
@ -205,7 +266,7 @@ describe("extractIssueTimelineEvents", () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it("ignores issue updates without visible status or assignee transitions", () => {
|
||||
it("ignores issue updates without visible status, assignee, or workspace transitions", () => {
|
||||
const events = extractIssueTimelineEvents([
|
||||
{
|
||||
id: "evt-title",
|
||||
|
|
|
|||
|
|
@ -19,10 +19,26 @@ export interface IssueTimelineEvent {
|
|||
from: IssueTimelineAssignee;
|
||||
to: IssueTimelineAssignee;
|
||||
};
|
||||
workspaceChange?: {
|
||||
from: IssueTimelineWorkspace;
|
||||
to: IssueTimelineWorkspace;
|
||||
};
|
||||
commentId?: string | null;
|
||||
followUpRequested?: boolean;
|
||||
}
|
||||
|
||||
export interface IssueTimelineWorkspace {
|
||||
label: string | null;
|
||||
projectWorkspaceId: string | null;
|
||||
executionWorkspaceId: string | null;
|
||||
mode: string | null;
|
||||
}
|
||||
|
||||
export function formatTimelineWorkspaceLabel(workspace: IssueTimelineWorkspace) {
|
||||
const fallbackId = workspace.executionWorkspaceId ?? workspace.projectWorkspaceId;
|
||||
return workspace.label ?? (fallbackId ? fallbackId.slice(0, 8) : "None");
|
||||
}
|
||||
|
||||
function asRecord(value: unknown): Record<string, unknown> | null {
|
||||
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
||||
return value as Record<string, unknown>;
|
||||
|
|
@ -44,6 +60,33 @@ function sameAssignee(left: IssueTimelineAssignee, right: IssueTimelineAssignee)
|
|||
return left.agentId === right.agentId && left.userId === right.userId;
|
||||
}
|
||||
|
||||
function sameWorkspace(left: IssueTimelineWorkspace, right: IssueTimelineWorkspace) {
|
||||
return left.projectWorkspaceId === right.projectWorkspaceId
|
||||
&& left.executionWorkspaceId === right.executionWorkspaceId
|
||||
&& left.mode === right.mode
|
||||
&& left.label === right.label;
|
||||
}
|
||||
|
||||
function workspaceFromRecord(value: unknown): IssueTimelineWorkspace | null {
|
||||
const record = asRecord(value);
|
||||
if (!record) return null;
|
||||
return {
|
||||
label: nullableString(record.label),
|
||||
projectWorkspaceId: nullableString(record.projectWorkspaceId),
|
||||
executionWorkspaceId: nullableString(record.executionWorkspaceId),
|
||||
mode: nullableString(record.mode),
|
||||
};
|
||||
}
|
||||
|
||||
function workspaceChangeFromDetails(details: Record<string, unknown>) {
|
||||
const change = asRecord(details.workspaceChange);
|
||||
if (!change) return null;
|
||||
const from = workspaceFromRecord(change.from);
|
||||
const to = workspaceFromRecord(change.to);
|
||||
if (!from || !to || sameWorkspace(from, to)) return null;
|
||||
return { from, to };
|
||||
}
|
||||
|
||||
function sortTimelineEvents<T extends { createdAt: Date | string; id: string }>(events: T[]) {
|
||||
return [...events].sort((a, b) => {
|
||||
const createdAtDiff = toTimestamp(a.createdAt) - toTimestamp(b.createdAt);
|
||||
|
|
@ -120,7 +163,17 @@ export function extractIssueTimelineEvents(activity: ActivityEvent[] | null | un
|
|||
}
|
||||
}
|
||||
|
||||
if (timelineEvent.statusChange || timelineEvent.assigneeChange || timelineEvent.followUpRequested) {
|
||||
const workspaceChange = workspaceChangeFromDetails(details);
|
||||
if (workspaceChange) {
|
||||
timelineEvent.workspaceChange = workspaceChange;
|
||||
}
|
||||
|
||||
if (
|
||||
timelineEvent.statusChange
|
||||
|| timelineEvent.assigneeChange
|
||||
|| timelineEvent.workspaceChange
|
||||
|| timelineEvent.followUpRequested
|
||||
) {
|
||||
events.push(timelineEvent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue