Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(issues): preserve assignment reply threads (#9171)
Frezc80930229c2bd
diff --git a/packages/views/issues/components/comment-runs.test.ts b/packages/views/issues/components/comment-runs.test.tsindex 119f10e2b2..931e0335bc 100644--- a/packages/views/issues/components/comment-runs.test.ts+++ b/packages/views/issues/components/comment-runs.test.ts@@ -139,7 +139,7 @@ describe("groupCommentRuns", () => {.toBe(latest.id);});- it("projects chained answers and assignment subtrees before finding run roots", () => {+ it("projects chained answers while preserving an assignment reply's thread", () => {const first = task("first", { trigger_comment_id: "root" });const second = task("second", { trigger_comment_id: "answer-a" });const assigned = task("assigned");@@ -150,14 +150,47 @@ describe("groupCommentRuns", () => {comment("assigned-answer", { parent_id: "root", actor_type: "agent", source_task_id: assigned.id }),comment("nested", { parent_id: "assigned-answer" })];const view = buildCommentRunView([followup, second, assigned, first], timeline);- expect(view.runs.get("root")?.map((run) => run.task.id)).toEqual(["first", "second"]);- expect(view.runs.get("assigned-answer")?.map((run) => run.task.id)).toEqual(["assigned", "followup"]);+ expect(view.runs.get("root")?.map((run) => run.task.id)).toEqual(["assigned", "first", "followup", "second"]);+ expect(view.runs.has("assigned-answer")).toBe(false);+ expect(view.standaloneRuns).toEqual([]);expect(view.timeline.find((entry) => entry.id === "answer-a")?.parent_id).toBe("root");expect(view.timeline.find((entry) => entry.id === "answer-b")?.parent_id).toBe("answer-a");- expect(view.timeline.find((entry) => entry.id === "assigned-answer")?.parent_id).toBeUndefined();+ expect(view.timeline.find((entry) => entry.id === "assigned-answer")?.parent_id).toBe("root");expect(timeline.find((entry) => entry.id === "assigned-answer")?.parent_id).toBe("root");});+ it("keeps an assignment's outputs in their explicit threads and its log with the latest reply", () => {+ const run = task("assigned", { kind: "direct", delivered_comment_ids: [] });+ const root = comment("root");+ const nested = comment("nested", { parent_id: root.id });+ const timeline = [root, nested, comment("other-thread"),+ comment("progress", { actor_type: "agent", source_task_id: run.id }),+ comment("other-reply", { parent_id: "other-thread", actor_type: "agent", source_task_id: run.id }),+ comment("answer", { parent_id: nested.id, actor_type: "agent", source_task_id: run.id,+ created_at: "2026-09-07T00:01:00Z" })];++ const view = buildCommentRunView([run], timeline);+ expect(view.timeline).toEqual(timeline);+ const placement = { task: run, commentId: "answer", anchorCommentId: nested.id, hasReply: true };+ expect(view.runs.get(root.id)).toEqual([placement]);+ expect(view.standaloneRuns).toEqual([]);+ expect(orderThreadWithRuns(root, [nested, timeline[5]!], view.runs.get(root.id)!))+ .toEqual([nested, { run: placement, reply: timeline[5]!, replyTo: undefined }]);+ });++ it("waits for a missing assignment reply parent without promoting the reply", () => {+ const run = task("assigned", { kind: "direct", delivered_comment_ids: [] });+ const answer = comment("answer", { parent_id: "pending-parent", actor_type: "agent", source_task_id: run.id });+ const pending = buildCommentRunView([run], [answer]);+ expect(pending.timeline).toEqual([answer]);+ expect(pending.runs.size).toBe(0);+ expect(pending.standaloneRuns).toEqual([]);++ const loaded = buildCommentRunView([run], [comment("pending-parent"), answer], pending.runs);+ expect(loaded.runs.get("pending-parent")?.[0]?.anchorCommentId).toBe("pending-parent");+ expect(loaded.standaloneRuns).toEqual([]);+ });+it("moves a run's earlier top-level comments into the thread with its reply", () => {// MUL-7548: only the latest comment used to move under the trigger, so it// rendered above the run's earlier top-level comments.diff --git a/packages/views/issues/components/comment-runs.ts b/packages/views/issues/components/comment-runs.tsindex 6fe63e3d88..36e5ddc508 100644--- a/packages/views/issues/components/comment-runs.ts+++ b/packages/views/issues/components/comment-runs.ts@@ -5,7 +5,7 @@ import { commentSupplementReceipts } from "@multica/core/issues/run-steering";export interface CommentRun {task: AgentTask;commentId?: string;- /** Last input this run covers; absent for issue-level runs such as assignment. */+ /** Last covered input, or a published assignment reply's explicit parent. */anchorCommentId?: string;/** The comment already contains this run's reply; only append its activity. */hasReply: boolean;@@ -96,6 +96,7 @@ export function buildCommentRunView(const byTask = new Map(inlineTasks.map((task) => [task.id, task]));const priorAnchors = new Map([...previous.values()].flatMap((runs) => runs.map((run) => [run.task.id, run.anchorCommentId] as const)));const placements: CommentRun[] = [];+ const parents = new Map<string, string | undefined>();for (const task of [...inlineTasks].sort((a, b) => a.created_at.localeCompare(b.created_at) || a.id.localeCompare(b.id))) {const reply = replies.get(task.id);if (isObsoleteCommentRun(task) && !reply) continue;@@ -149,21 +150,17 @@ export function buildCommentRunView(}source = source.parent_task_id ? byTask.get(source.parent_task_id) : undefined;}- placements.push({ task, commentId: reply?.id ?? anchorId, anchorCommentId: anchorId, hasReply: !!reply });- }- // Project every task-owned answer first, then use that same tree for run- // grouping, replies, resolution, and navigation. Assignment answers become- // roots even if the agent originally posted them inside an existing thread.- // The run's other top-level comments follow its reply: moving only the- // latest one would render it above the progress posted before it (MUL-7548).- // Comments the agent placed in a thread stay where it put them.- const parents = new Map<string, string | undefined>();- for (const run of placements) {- if (run.hasReply && run.commentId && run.commentId !== run.anchorCommentId) {- for (const output of topLevelOutputs.get(run.task.id) ?? []) parents.set(output.id, run.anchorCommentId);- parents.set(run.commentId, run.anchorCommentId);+ // Covered input anchors project the run's top-level output into its thread+ // (MUL-7548). An assignment without input keeps each output's own parent;+ // its published reply also owns the log's position in that thread.+ if (anchorId && reply && reply.id !== anchorId) {+ for (const output of topLevelOutputs.get(task.id) ?? []) parents.set(output.id, anchorId);+ parents.set(reply.id, anchorId);}+ placements.push({ task, commentId: reply?.id ?? anchorId,+ anchorCommentId: anchorId ?? reply?.parent_id ?? undefined, hasReply: !!reply });}+ // Use the same projected tree for run grouping, replies, resolution, and navigation.const cyclic = new Set<string>();for (const id of parents.keys()) {const seen = new Set([id]);diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsxindex 26f505b304..50af4564f6 100644--- a/packages/views/issues/components/issue-detail.test.tsx+++ b/packages/views/issues/components/issue-detail.test.tsx@@ -1525,8 +1525,15 @@ describe("IssueDetail (shared)", () => {});await waitFor(() => expect(screen.getAllByText(reply.content!)).toHaveLength(1));await waitFor(() => expect(container.querySelector(`[data-run-comment-id="${task.id}"]`)).toBeNull());- expect(container.querySelector(`[data-run-slot-id="${task.id}"]`)).toBe(assignmentSlot);const replyBlock = container.querySelector("#comment-assignment-reply")!;+ const parentBlock = container.querySelector("#comment-comment-1")!;+ if (parentId) {+ expect(parentBlock).toContainElement(replyBlock as HTMLElement);+ expect(parentBlock.querySelector(`[data-run-slot-id="${task.id}"]`)).not.toBeNull();+ } else {+ expect(parentBlock).not.toContainElement(replyBlock as HTMLElement);+ expect(container.querySelector(`[data-run-slot-id="${task.id}"]`)).toBe(assignmentSlot);+ }expect(replyBlock.querySelector(`[data-run-id="${task.id}"]`)).not.toBeNull();expect(container.querySelectorAll(`[data-run-id="${task.id}"]`)).toHaveLength(1);const headerLog = within(replyBlock as HTMLElement).getByRole("button", { name: "Open full log" });@@ -2316,6 +2323,39 @@ describe("IssueDetail (shared)", () => {});describe("highlightCommentId scroll-to-comment", () => {+ it("folds an assignment reply with its resolved parent and unfolds that thread for a notification", async () => {+ const run: AgentTask = { id: "ba2e8d1c-7f9b-4e2a-9c1d-123456789abc", agent_id: "agent-1", runtime_id: "runtime-1", issue_id: "issue-1",+ kind: "direct", status: "completed", priority: 0, created_at: "2026-01-16T00:00:00Z", started_at: null, dispatched_at: null,+ completed_at: "2026-01-16T00:01:00Z", result: null, error: null, delivered_comment_ids: [] };+ const root = { ...mockTimeline[0]!, resolved_at: "2026-01-17T00:00:00Z" };+ const target = { ...mockTimeline[1]!, id: "assigned-reply", parent_id: root.id, source_task_id: run.id,+ content: "Assignment reply in the resolved discussion" };+ mockApiObj.listTimeline.mockResolvedValue([root, target]);+ mockApiObj.listTasksByIssue.mockResolvedValue([run]);+ const client = createTestQueryClient();+ const { container, rerender } = render(<I18nProvider locale="en" resources={TEST_RESOURCES}>+ <QueryClientProvider client={client}>+ <IssueDetail issueId="issue-1" />+ </QueryClientProvider>+ </I18nProvider>);+ await screen.findByRole("button", { name: /2 resolved comments/ });+ expect(container.querySelector(`#comment-${target.id}`)).toBeNull();++ rerender(<I18nProvider locale="en" resources={TEST_RESOURCES}>+ <QueryClientProvider client={client}>+ <IssueDetail issueId="issue-1" highlightCommentId={target.id} />+ </QueryClientProvider>+ </I18nProvider>);+ await waitFor(() => expect(container.querySelector(`#comment-${target.id}`))+ .toHaveClass(highlightedCommentBackgroundClass));+ expect(container.querySelector(`#comment-${root.id}`))+ .toContainElement(container.querySelector(`#comment-${target.id}`) as HTMLElement);+ expect(screen.getAllByText(target.content)).toHaveLength(1);+ expect(container.querySelectorAll(`[data-run-id="${run.id}"]`)).toHaveLength(1);+ expect(within(container.querySelector(`#comment-${target.id}`) as HTMLElement)+ .getByRole("button", { name: "Open full log" })).toBeInTheDocument();+ });+it.each(["root", "reply"])("unfolds an assignment run with a resolved %s when a notification targets a hidden reply", async (resolved) => {const run: AgentTask = { id: "ba2e8d1c-7f9b-4e2a-9c1d-123456789abc", agent_id: "agent-1", runtime_id: "runtime-1", issue_id: "issue-1",status: "completed", priority: 0, created_at: "2026-01-16T00:00:00Z", started_at: null, dispatched_at: null,