Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-7480: Link delivered steers to final replies (#8623)
Multica Eve3de6275eb31a
diff --git a/apps/docs/content/docs/mentioning-agents.mdx b/apps/docs/content/docs/mentioning-agents.mdxindex 9bd7dc6ff5..aad643c650 100644--- a/apps/docs/content/docs/mentioning-agents.mdx+++ b/apps/docs/content/docs/mentioning-agents.mdx@@ -53,6 +53,8 @@ If the runtime does not support steering, the route is ambiguous, the turn endsAn “already delivered” receipt is historical: its timestamp does not disappear if the turn later fails or is stopped. Editing a comment before it is claimed lets the active turn read the updated text; editing it after claiming has begun does not inject it a second time or start a duplicate follow-up. All steered comments remain in issue history so later natural runs can re-read the current text.+After that run publishes its final reply, the delivered receipt adds **View final reply**. Use it to scroll to and highlight the run's single answer in the original discussion. Receipts do not show this link while the run is still working, when the comment is waiting for follow-up work, or when the run ended without an answer.+When one comment @-mentions several different agents, each agent gets its own run; multiple mentions resolving to the same agent keep only one.## Comments that don't trigger agentsdiff --git a/packages/core/api/schemas.test.ts b/packages/core/api/schemas.test.tsindex 62163e9954..8d8eeb39f2 100644--- a/packages/core/api/schemas.test.ts+++ b/packages/core/api/schemas.test.ts@@ -29,6 +29,7 @@ import {ChatPendingTaskSchema,ChatSessionListSchema,ChatSessionSchema,+ CommentSchema,PrioritizeQueuedChatTaskResponseSchema,CreateFeedbackResponseSchema,DuplicateIssueErrorBodySchema,@@ -541,6 +542,54 @@ describe("IssueTriggerPreviewSchema", () => {});describe("TimelineEntriesSchema", () => {+ it("preserves optional and nullable delivery task ids across server versions", () => {+ const baseComment = {+ type: "comment",+ id: "comment-1",+ actor_type: "member",+ actor_id: "user-1",+ created_at: "2026-01-01T00:00:00Z",+ content: "Steered input",+ };+ const parsed = TimelineEntriesSchema.parse([+ {+ ...baseComment,+ agent_deliveries: [+ { agent_id: "a1", agent_name: "Walt", task_id: "task-1", status: "delivered" },+ { agent_id: "a2", agent_name: "Bob", task_id: null, status: "follow_up" },+ { agent_id: "a3", agent_name: "Kim", status: "pending" },+ ],+ },+ ]);++ expect(parsed[0]?.agent_deliveries?.map((delivery) => delivery.task_id)).toEqual([+ "task-1",+ null,+ undefined,+ ]);+ });++ it("keeps old comment responses valid when delivery task_id is absent", () => {+ const parsed = CommentSchema.parse({+ id: "comment-1",+ issue_id: "issue-1",+ author_type: "member",+ author_id: "user-1",+ content: "Legacy receipt",+ type: "comment",+ parent_id: null,+ reactions: [],+ attachments: [],+ created_at: "2026-01-01T00:00:00Z",+ updated_at: "2026-01-01T00:00:00Z",+ agent_deliveries: [+ { agent_id: "a1", agent_name: "Walt", status: "delivered" },+ ],+ });++ expect(parsed.agent_deliveries?.[0]?.task_id).toBeUndefined();+ });+it("preserves source_task_id for agent failure comments", () => {const parsed = TimelineEntriesSchema.parse([{diff --git a/packages/core/api/schemas.ts b/packages/core/api/schemas.tsindex 523e70ae08..3aa6bdc83b 100644--- a/packages/core/api/schemas.ts+++ b/packages/core/api/schemas.ts@@ -918,6 +918,7 @@ const TimelineEntrySchema = z.object({agent_deliveries: z.array(z.object({agent_id: z.string(),agent_name: z.string(),+ task_id: z.string().nullable().optional(),status: z.string(),delivered_at: z.string().nullable().optional(),}).loose()).optional().catch(undefined),@@ -1066,6 +1067,7 @@ export const CommentSchema = z.object({agent_deliveries: z.array(z.object({agent_id: z.string(),agent_name: z.string(),+ task_id: z.string().nullable().optional(),status: z.string(),delivered_at: z.string().nullable().optional(),}).loose()).optional().catch(undefined),diff --git a/packages/core/types/comment.ts b/packages/core/types/comment.tsindex f172274b9f..e9d63d37a8 100644--- a/packages/core/types/comment.ts+++ b/packages/core/types/comment.ts@@ -53,6 +53,11 @@ export interface Comment {export interface CommentAgentDelivery {agent_id: string;agent_name: string;+ /**+ * Run associated with this receipt. Older servers omit it and receipts+ * created directly as follow-up have no task, so accept both forms.+ */+ task_id?: string | null;status: "pending" | "delivered" | "follow_up" | string;delivered_at?: string | null;}diff --git a/packages/views/issues/components/comment-card.test.tsx b/packages/views/issues/components/comment-card.test.tsxindex 677f840d84..b365567147 100644--- a/packages/views/issues/components/comment-card.test.tsx+++ b/packages/views/issues/components/comment-card.test.tsx@@ -1,5 +1,5 @@import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";-import { render, screen, waitFor } from "@testing-library/react";+import { fireEvent, render, screen, waitFor } from "@testing-library/react";import type { ReactElement } from "react";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { renderWithI18n } from "../../test/i18n";@@ -70,6 +70,49 @@ describe("CommentDeliveryReceipts", () => {expect(screen.getByText("Waiting to deliver to Walt's current work")).toBeInTheDocument();expect(screen.getByText(/Delivered to Bob's current work/)).toBeInTheDocument();expect(screen.getByText("Kim will handle this in follow-up work")).toBeInTheDocument();+ expect(screen.queryByRole("button")).toBeNull();+ });++ it("locates only delivered recipients that already have a final reply", () => {+ const onLocateComment = vi.fn();+ const repliesByTask = new Map([+ ["task-1", { id: "reply-1", comment_type: "comment" } as any],+ ["task-2", { id: "reply-2", comment_type: "comment" } as any],+ ["task-deleted", { id: "reply-deleted", comment_type: "comment", deleted_at: "2026-01-01T00:00:00Z" } as any],+ ["task-failed", { id: "failure-comment", comment_type: "system" } as any],+ ]);+ renderWithI18n(+ <CommentDeliveryReceipts+ entry={{+ agent_deliveries: [+ { agent_id: "a1", agent_name: "Walt", task_id: "task-1", status: "delivered" },+ { agent_id: "a2", agent_name: "Bob", task_id: "task-2", status: "delivered" },+ { agent_id: "a3", agent_name: "Kim", task_id: "task-1", status: "pending" },+ { agent_id: "a4", agent_name: "Eve", task_id: "task-2", status: "follow_up" },+ { agent_id: "a5", agent_name: "Running", task_id: "task-running", status: "delivered" },+ { agent_id: "a6", agent_name: "Deleted", task_id: "task-deleted", status: "delivered" },+ { agent_id: "a7", agent_name: "Failed", task_id: "task-failed", status: "delivered" },+ { agent_id: "a8", agent_name: "Cancelled", task_id: "task-cancelled", status: "delivered" },+ { agent_id: "a9", agent_name: "Edited", task_id: "task-edited", status: "delivered" },+ ],+ } as any}+ repliesByTask={repliesByTask}+ onLocateComment={onLocateComment}+ />,+ );++ const links = screen.getAllByRole("button", { name: /View final reply/ });+ expect(links).toHaveLength(2);+ fireEvent.click(links[0]!);+ fireEvent.click(links[1]!);+ expect(onLocateComment.mock.calls).toEqual([["reply-1"], ["reply-2"]]);+ expect(screen.getByText("Waiting to deliver to Kim's current work")).toBeInTheDocument();+ expect(screen.getByText("Eve will handle this in follow-up work")).toBeInTheDocument();+ expect(screen.getByText(/Delivered to Running's current work/).closest("button")).toBeNull();+ expect(screen.getByText(/Delivered to Deleted's current work/).closest("button")).toBeNull();+ expect(screen.getByText(/Delivered to Failed's current work/).closest("button")).toBeNull();+ expect(screen.getByText(/Delivered to Cancelled's current work/).closest("button")).toBeNull();+ expect(screen.getByText(/Delivered to Edited's current work/).closest("button")).toBeNull();});});diff --git a/packages/views/issues/components/comment-card.tsx b/packages/views/issues/components/comment-card.tsxindex edcb3f8410..2533577f57 100644--- a/packages/views/issues/components/comment-card.tsx+++ b/packages/views/issues/components/comment-card.tsx@@ -1,6 +1,6 @@"use client";-import { Fragment, memo, useCallback, useEffect, useRef, useState, type ReactNode } from "react";+import { Fragment, memo, useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";import { CheckCircle2, ChevronRight, ListChevronsDownUp, Copy, Link2, Loader2, MessageSquarePlus, MoreHorizontal, Pencil, RotateCcw, Trash2 } from "lucide-react";import { toast } from "sonner";import { Card } from "@multica/ui/components/ui/card";@@ -48,7 +48,7 @@ import { CommentsFoldBar } from "./resolved-thread-bar";import { deriveThreadResolution } from "./thread-utils";import { RevisionConflictCompare } from "./revision-conflict-compare";import { InlineCommentRun, useInlineCommentRunState, type InlineCommentRunState } from "./inline-comment-run";-import { EMPTY_COMMENT_RUNS, showCommentRunInHeader, type CommentRun } from "./comment-runs";+import { EMPTY_COMMENT_RUNS, finalAgentReplyByTask, showCommentRunInHeader, type CommentRun } from "./comment-runs";import { useCommentAnnotations } from "./use-comment-annotations";import { useRunCommentMotion } from "./use-run-comment-motion";@@ -60,7 +60,17 @@ const highlightedCommentBackgroundClass =const stickyHeaderFadeClass ="after:pointer-events-none after:absolute after:inset-x-0 after:top-full after:h-1 after:bg-[inherit] after:[mask-image:linear-gradient(to_bottom,#000,transparent)] after:[-webkit-mask-image:linear-gradient(to_bottom,#000,transparent)]";-export function CommentDeliveryReceipts({ entry, className }: { entry: TimelineEntry; className?: string }) {+export function CommentDeliveryReceipts({+ entry,+ repliesByTask,+ onLocateComment,+ className,+}: {+ entry: TimelineEntry;+ repliesByTask?: ReadonlyMap<string, TimelineEntry>;+ onLocateComment?: (commentId: string) => void;+ className?: string;+}) {const { t } = useT("issues");const timeAgo = useTimeAgo();if (!entry.agent_deliveries?.length) return null;@@ -75,7 +85,22 @@ export function CommentDeliveryReceipts({ entry, className }: { entry: TimelineE: delivery.status === "pending"? t(($) => $.comment.delivery_pending, { name: delivery.agent_name }): t(($) => $.comment.delivery_follow_up, { name: delivery.agent_name });- return <div key={delivery.agent_id}>{text}</div>;+ const reply = delivery.status === "delivered" && delivery.task_id+ ? repliesByTask?.get(delivery.task_id)+ : undefined;+ if (!reply || reply.comment_type !== "comment" || reply.deleted_at || !onLocateComment) {+ return <div key={delivery.agent_id}>{text}</div>;+ }+ return (+ <button+ type="button"+ key={delivery.agent_id}+ onClick={() => onLocateComment(reply.id)}+ className="w-fit cursor-pointer text-left hover:text-foreground hover:underline"+ >+ {text} · {t(($) => $.comment.delivery_view_reply)}+ </button>+ );})}</div>);@@ -164,6 +189,8 @@ interface CommentCardProps {*/expandedResolvedIds?: ReadonlySet<string>;onResolvedExpandChange?: (rootId: string, expand: boolean) => void;+ /** Scroll and flash a delivered steer run's existing final reply. */+ onLocateComment?: (commentId: string) => void;/** ID of the comment to highlight (flash animation). */highlightedCommentId?: string | null;}@@ -642,6 +669,8 @@ function CommentRow({onCreateSubIssue,onResolveToggle,onCopyLink,+ deliveryRepliesByTask,+ onLocateComment,}: {runHeader?: ReactNode;runMetadata?: ReactNode;@@ -661,6 +690,8 @@ function CommentRow({onCreateSubIssue?: (commentId: string) => void;onResolveToggle?: (commentId: string, resolved: boolean) => void;onCopyLink?: (commentId: string) => void;+ deliveryRepliesByTask?: ReadonlyMap<string, TimelineEntry>;+ onLocateComment?: (commentId: string) => void;}) {const { t } = useT("issues");const locale = useLocale();@@ -901,7 +932,12 @@ function CommentRow({<ReadonlyContent content={entry.content ?? ""} attachments={entry.attachments} /></div><AttachmentList attachments={entry.attachments} content={entry.content} className="mt-1.5 pl-12 pr-4 max-md:pl-3 max-md:pr-3" />- <CommentDeliveryReceipts entry={entry} className="pl-12 pr-4 max-md:pl-3 max-md:pr-3" />+ <CommentDeliveryReceipts+ entry={entry}+ repliesByTask={deliveryRepliesByTask}+ onLocateComment={onLocateComment}+ className="pl-12 pr-4 max-md:pl-3 max-md:pr-3"+ />{retryableAgentFailureComment(entry) && (<TaskCommentRetryButtonissueId={issueId}@@ -993,6 +1029,7 @@ function CommentCardImpl({onCollapseResolved,expandedResolvedIds,onResolvedExpandChange,+ onLocateComment,highlightedCommentId,}: CommentCardProps) {const { t } = useT("issues");@@ -1027,6 +1064,10 @@ function CommentCardImpl({const [confirmDelete, setConfirmDelete] = useState(false);const allNestedReplies = replies;+ const deliveryRepliesByTask = useMemo(+ () => finalAgentReplyByTask([entry, ...allNestedReplies]),+ [entry, allNestedReplies],+ );// What the thread shows. Tombstones are excluded from display and counts but// stay in `allNestedReplies`, which run anchoring and "has replies" reason// over. Every tombstone has at least one live descendant (the server prunes@@ -1046,6 +1087,7 @@ function CommentCardImpl({return <Fragment key={run.task.id}><AgentRunComment run={run} entering={enteringRunIds?.has(run.task.id)} commentProps={reply ? {issueId, entry: reply, replies: [], currentUserId, canModerate, onReply, onEdit, onDelete,onToggleReaction, onCreateSubIssue, onResolveToggle, onCopyLink, highlightedCommentId, enteringRunIds,+ onLocateComment,} : undefined} />{reply && reply.id !== commentId && renderAnchoredRuns(reply.id)}</Fragment>;});@@ -1360,7 +1402,12 @@ function CommentCardImpl({<ReadonlyContent content={entry.content ?? ""} attachments={entry.attachments} /></div><AttachmentList attachments={entry.attachments} content={entry.content} className="mt-1.5 pl-8 max-md:pl-0" />- <CommentDeliveryReceipts entry={entry} className="pl-8 max-md:pl-0" />+ <CommentDeliveryReceipts+ entry={entry}+ repliesByTask={deliveryRepliesByTask}+ onLocateComment={onLocateComment}+ className="pl-8 max-md:pl-0"+ />{retryableAgentFailureComment(entry) && (<TaskCommentRetryButtonissueId={issueId}@@ -1425,6 +1472,8 @@ function CommentCardImpl({onCreateSubIssue={onCreateSubIssue}onResolveToggle={onResolveToggle}onCopyLink={onCopyLink}+ deliveryRepliesByTask={deliveryRepliesByTask}+ onLocateComment={onLocateComment}/></div>{renderAnchoredRuns(resolutionReply.id)}@@ -1474,6 +1523,8 @@ function CommentCardImpl({onCreateSubIssue={onCreateSubIssue}onResolveToggle={onResolveToggle}onCopyLink={onCopyLink}+ deliveryRepliesByTask={deliveryRepliesByTask}+ onLocateComment={onLocateComment}/></div>)}diff --git a/packages/views/issues/components/comment-runs.test.ts b/packages/views/issues/components/comment-runs.test.tsindex 1fb27b27a7..f14dcf0b65 100644--- a/packages/views/issues/components/comment-runs.test.ts+++ b/packages/views/issues/components/comment-runs.test.ts@@ -1,7 +1,7 @@// @vitest-environment nodeimport { describe, expect, it } from "vitest";import type { AgentTask, TimelineEntry } from "@multica/core/types";-import { commentRunOutput, buildCommentRunView, orderTimelineWithRuns, type CommentRun } from "./comment-runs";+import { commentRunOutput, buildCommentRunView, finalAgentReplyByTask, orderTimelineWithRuns, type CommentRun } from "./comment-runs";const groupCommentRuns = (...args: Parameters<typeof buildCommentRunView>) => buildCommentRunView(...args).runs;@@ -13,6 +13,31 @@ function comment(id: string, overrides: Partial<TimelineEntry> = {}): TimelineEnreturn { id, type: "comment", actor_type: "member", actor_id: "user", created_at: "2026-09-07T00:00:00Z", ...overrides };}+describe("finalAgentReplyByTask", () => {+ it("keeps the latest eligible answer when newer task-owned rows are system or deleted comments", () => {+ const answer = comment("answer", {+ actor_type: "agent",+ source_task_id: "run",+ comment_type: "comment",+ });+ const failure = comment("failure", {+ actor_type: "agent",+ source_task_id: "run",+ comment_type: "system",+ created_at: "2026-09-07T00:01:00Z",+ });+ const deleted = comment("deleted", {+ actor_type: "agent",+ source_task_id: "run",+ comment_type: "comment",+ deleted_at: "2026-09-07T00:03:00Z",+ created_at: "2026-09-07T00:02:00Z",+ });++ expect(finalAgentReplyByTask([answer, failure, deleted]).get("run")).toBe(answer);+ });+});+describe("groupCommentRuns", () => {it.each(["queued", "dispatched", "running", "completed"] as const)("waits for a missing trigger before placing a %s run and its reply", (status) => {const run = task("run", { status, trigger_comment_id: "trigger",diff --git a/packages/views/issues/components/comment-runs.ts b/packages/views/issues/components/comment-runs.tsindex 6052051825..a093db9d7f 100644--- a/packages/views/issues/components/comment-runs.ts+++ b/packages/views/issues/components/comment-runs.ts@@ -22,6 +22,45 @@ export function isActiveCommentRun(task: AgentTask): boolean {return ["queued", "dispatched", "waiting_local_directory", "running"].includes(task.status);}+/**+ * Index the published agent reply for each task. A run has one final comment,+ * but choosing the latest row keeps mixed-version and retry data deterministic+ * in the same way as the existing run projection.+ */+export function agentReplyByTask(+ timeline: readonly TimelineEntry[],+): ReadonlyMap<string, TimelineEntry> {+ const replies = new Map<string, TimelineEntry>();+ for (const entry of timeline) {+ if (entry.type !== "comment" || !entry.source_task_id || entry.actor_type !== "agent") continue;+ const prior = replies.get(entry.source_task_id);+ if (!prior || entry.created_at > prior.created_at || (entry.created_at === prior.created_at && entry.id > prior.id)) {+ replies.set(entry.source_task_id, entry);+ }+ }+ return replies;+}++/**+ * Index replies that can be a delivered steer receipt's final-answer target.+ * Filter before choosing the latest row so a later task-owned system failure+ * or deleted comment cannot hide an earlier published answer for that task.+ */+export function finalAgentReplyByTask(+ timeline: readonly TimelineEntry[],+): ReadonlyMap<string, TimelineEntry> {+ const replies = new Map<string, TimelineEntry>();+ for (const entry of timeline) {+ if (entry.type !== "comment" || !entry.source_task_id || entry.actor_type !== "agent"+ || entry.comment_type !== "comment" || entry.deleted_at) continue;+ const prior = replies.get(entry.source_task_id);+ if (!prior || entry.created_at > prior.created_at || (entry.created_at === prior.created_at && entry.id > prior.id)) {+ replies.set(entry.source_task_id, entry);+ }+ }+ return replies;+}+/** Published replies own their log entry even while the agent finishes its run. */export function showCommentRunInHeader(run: CommentRun): boolean {return run.hasReply && (isActiveCommentRun(run.task) || run.task.status === "completed");@@ -55,14 +94,7 @@ export function buildCommentRunView(}return entry?.id;};- const replies = new Map<string, TimelineEntry>();- for (const entry of comments.values()) {- if (!entry.source_task_id || entry.actor_type !== "agent") continue;- const prior = replies.get(entry.source_task_id);- if (!prior || entry.created_at > prior.created_at || (entry.created_at === prior.created_at && entry.id > prior.id)) {- replies.set(entry.source_task_id, entry);- }- }+ const replies = agentReplyByTask(timeline);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[] = [];diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsxindex 28297f2d62..6ecd0bf16d 100644--- a/packages/views/issues/components/issue-detail.test.tsx+++ b/packages/views/issues/components/issue-detail.test.tsx@@ -1279,6 +1279,149 @@ describe("IssueDetail (shared)", () => {expect(mockApiObj.listTaskMessages).toHaveBeenCalledWith(taskId);});+ it("scrolls to and highlights the final reply from a delivered steer receipt", async () => {+ const taskId = "4a2e8d1c-7f9b-4e2a-9c1d-123456789abc";+ const root: TimelineEntry = {+ ...mockTimeline[0]!,+ id: "steer-root",+ parent_id: null,+ created_at: "2026-01-16T00:00:00Z",+ };+ const steer: TimelineEntry = {+ ...mockTimeline[0]!,+ id: "steer-input",+ parent_id: root.id,+ content: "Also include the deployment risk",+ created_at: "2026-01-16T00:01:00Z",+ agent_deliveries: [+ { agent_id: "agent-1", agent_name: "Claude Agent", task_id: taskId, status: "delivered" },+ ],+ };+ const finalReply: TimelineEntry = {+ ...mockTimeline[1]!,+ id: "steer-final-reply",+ parent_id: root.id,+ source_task_id: taskId,+ content: "Original answer with the deployment risk included",+ created_at: "2026-01-16T00:02:00Z",+ };+ const laterFailure: TimelineEntry = {+ ...mockTimeline[1]!,+ id: "steer-later-failure",+ parent_id: root.id,+ source_task_id: taskId,+ content: "The already-published task later reported a failure",+ comment_type: "system",+ created_at: "2026-01-16T00:03:00Z",+ };+ mockApiObj.listTimeline.mockResolvedValue([root, steer, finalReply, laterFailure]);+ mockApiObj.listTasksByIssue.mockResolvedValue([{+ id: taskId,+ agent_id: "agent-1",+ runtime_id: "runtime-1",+ issue_id: "issue-1",+ status: "completed",+ priority: 0,+ created_at: root.created_at,+ started_at: root.created_at,+ dispatched_at: root.created_at,+ completed_at: finalReply.created_at,+ result: { comment: finalReply.content },+ error: null,+ trigger_comment_id: root.id,+ delivered_comment_ids: [root.id],+ } as AgentTask]);++ renderIssueDetail();+ const locate = await screen.findByRole("button", { name: /View final reply/ });+ fireEvent.click(locate);++ await waitFor(() => {+ expect(hasHighlightedCommentBackground(document.getElementById("comment-steer-final-reply"))).toBe(true);+ });+ expect(scrollToIndexSpy).toHaveBeenCalledWith({ index: 0, align: "start", offset: -16 });+ expect(scrollIntoViewSpy).not.toHaveBeenCalled();+ });++ it("expands a folded reply-resolution thread before locating the delivered steer answer", async () => {+ const taskId = "5a2e8d1c-7f9b-4e2a-9c1d-123456789abc";+ const root: TimelineEntry = {+ ...mockTimeline[0]!,+ id: "folded-steer-root",+ parent_id: null,+ created_at: "2026-01-16T00:00:00Z",+ agent_deliveries: [+ { agent_id: "agent-1", agent_name: "Claude Agent", task_id: taskId, status: "delivered" },+ ],+ };+ const finalReply: TimelineEntry = {+ ...mockTimeline[1]!,+ id: "folded-steer-final-reply",+ parent_id: root.id,+ source_task_id: taskId,+ content: "Final answer hidden behind the resolution fold",+ created_at: "2026-01-16T00:01:00Z",+ };+ const resolution: TimelineEntry = {+ ...mockTimeline[0]!,+ id: "folded-steer-resolution",+ parent_id: root.id,+ content: "Resolved after the answer",+ created_at: "2026-01-16T00:02:00Z",+ resolved_at: "2026-01-16T00:03:00Z",+ };+ mockApiObj.listTimeline.mockResolvedValue([root, finalReply, resolution]);++ renderIssueDetail();+ const locate = await screen.findByRole("button", { name: /View final reply/ });+ expect(document.getElementById(`comment-${finalReply.id}`)).toBeNull();++ fireEvent.click(locate);++ await waitFor(() => {+ expect(hasHighlightedCommentBackground(document.getElementById(`comment-${finalReply.id}`))).toBe(true);+ });+ expect(screen.getByRole("button", { name: "Collapse" })).toBeInTheDocument();+ expect(scrollToIndexSpy).toHaveBeenCalledWith({ index: 0, align: "start", offset: -16 });+ });++ it("locates a delivered steer answer in flat deep-link mode", async () => {+ const taskId = "6a2e8d1c-7f9b-4e2a-9c1d-123456789abc";+ const root: TimelineEntry = {+ ...mockTimeline[0]!,+ id: "flat-steer-root",+ parent_id: null,+ created_at: "2026-01-16T00:00:00Z",+ agent_deliveries: [+ { agent_id: "agent-1", agent_name: "Claude Agent", task_id: taskId, status: "delivered" },+ ],+ };+ const finalReply: TimelineEntry = {+ ...mockTimeline[1]!,+ id: "flat-steer-final-reply",+ parent_id: root.id,+ source_task_id: taskId,+ content: "Final answer in the flat timeline",+ created_at: "2026-01-16T00:01:00Z",+ };+ mockApiObj.listTimeline.mockResolvedValue([root, finalReply]);++ renderIssueDetailWithHighlight(root.id);+ const locate = await screen.findByRole("button", { name: /View final reply/ });+ await waitFor(() => {+ expect(hasHighlightedCommentBackground(document.getElementById(`comment-${root.id}`))).toBe(true);+ });++ scrollToIndexSpy.mockClear();+ fireEvent.click(locate);++ await waitFor(() => {+ expect(hasHighlightedCommentBackground(document.getElementById(`comment-${finalReply.id}`))).toBe(true);+ });+ expect(scrollToIndexSpy).not.toHaveBeenCalled();+ expect(scrollIntoViewSpy).not.toHaveBeenCalled();+ });+it("places one coalesced queued block after the batch's latest reply", async () => {const root = mockTimeline[0]!;const first = { ...mockTimeline[1]!, id: "queued-first", parent_id: root.id,diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsxindex 1802d033cc..7b3393c4a8 100644--- a/packages/views/issues/components/issue-detail.tsx+++ b/packages/views/issues/components/issue-detail.tsx@@ -1736,9 +1736,11 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = trreturn () => cancelAnimationFrame(rafId);}, [pendingPostedCommentId, items, replyToRoot, isFlatTimeline, scrollContainerEl]);const jumpFlashTimerRef = useRef<number | null>(null);+ const locateCommentRafRef = useRef<number | null>(null);useEffect(() => () => {if (jumpFlashTimerRef.current !== null) window.clearTimeout(jumpFlashTimerRef.current);+ if (locateCommentRafRef.current !== null) cancelAnimationFrame(locateCommentRafRef.current);},[],);@@ -1771,6 +1773,56 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr[isFlatTimeline, items, scrollContainerEl],);+ const locateTimelineComment = useCallback(+ (commentId: string) => {+ const rootId = replyToRoot.get(commentId) ?? commentId;+ const index = items.findIndex((item) => item.id === rootId);+ if (index < 0) return;++ // The receipt is visible, so its thread is mounted and expanded. The+ // answer can still be behind a reply-resolution fold; open that fold+ // before waiting for React to materialize the target row.+ if (!document.getElementById(`comment-${commentId}`) && rootId !== commentId) {+ toggleResolvedExpand(rootId, true);+ }+ if (!isFlatTimeline) {+ virtuosoRef.current?.scrollToIndex({ index, align: "start", offset: -16 });+ }++ setHighlightedId(commentId);+ if (jumpFlashTimerRef.current !== null) window.clearTimeout(jumpFlashTimerRef.current);+ jumpFlashTimerRef.current = window.setTimeout(() => setHighlightedId(null), 2500);+ if (locateCommentRafRef.current !== null) cancelAnimationFrame(locateCommentRafRef.current);++ let attempts = 0;+ let last = -1;+ const center = () => {+ const element = document.getElementById(`comment-${commentId}`);+ const container = scrollContainerEl;+ if (!element || !container) {+ if (++attempts < 30) locateCommentRafRef.current = requestAnimationFrame(center);+ return;+ }+ const containerRect = container.getBoundingClientRect();+ const elementRect = element.getBoundingClientRect();+ const target = Math.max(+ 0,+ container.scrollTop + (elementRect.top - containerRect.top)+ - (container.clientHeight - elementRect.height) / 2,+ );+ container.scrollTop = target;+ if (Math.abs(target - last) > 1 && ++attempts < 30) {+ last = target;+ locateCommentRafRef.current = requestAnimationFrame(center);+ } else {+ locateCommentRafRef.current = null;+ }+ };+ locateCommentRafRef.current = requestAnimationFrame(center);+ },+ [isFlatTimeline, items, replyToRoot, scrollContainerEl, toggleResolvedExpand],+ );+const {reactions: issueReactions,toggleReaction: handleToggleIssueReaction,@@ -2664,6 +2716,7 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tronCopyLink: actions.copyCommentLink,onCollapseResolved: reply.resolved_at ? () => toggleResolvedExpand(reply.id, false) : undefined,expandedResolvedIds: expandedResolved, onResolvedExpandChange: toggleResolvedExpand,+ onLocateComment: locateTimelineComment,highlightedCommentId: highlightedId,runs: commentRuns.get(reply.id) ?? EMPTY_COMMENT_RUNS, enteringRunIds,} : undefined} />}@@ -2703,6 +2756,7 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tronCollapseResolved={isResolved ? () => toggleResolvedExpand(item.id, false) : undefined}expandedResolvedIds={expandedResolved}onResolvedExpandChange={toggleResolvedExpand}+ onLocateComment={locateTimelineComment}highlightedCommentId={highlightedId}/></div>diff --git a/packages/views/issues/hooks/use-issue-timeline.test.tsx b/packages/views/issues/hooks/use-issue-timeline.test.tsxindex 73be2991e3..254f396fa5 100644--- a/packages/views/issues/hooks/use-issue-timeline.test.tsx+++ b/packages/views/issues/hooks/use-issue-timeline.test.tsx@@ -380,6 +380,60 @@ describe("useIssueTimeline", () => {]);});+ it("preserves delivery task ids from realtime receipt updates", () => {+ queryState.data = [+ {+ type: "comment",+ id: "c1",+ actor_type: "member",+ actor_id: "user-1",+ content: "steer this run",+ parent_id: null,+ created_at: "2026-05-06T01:00:00Z",+ updated_at: "2026-05-06T01:00:00Z",+ revision: 1,+ reactions: [],+ attachments: [],+ },+ ];+ renderHook(() => useIssueTimeline("issue-1", "user-1"));++ act(() => {+ wsHandlers.get("comment:updated")!({+ comment: {+ id: "c1",+ issue_id: "issue-1",+ author_type: "member",+ author_id: "user-1",+ content: "steer this run",+ parent_id: null,+ created_at: "2026-05-06T01:00:00Z",+ updated_at: "2026-05-06T02:00:00Z",+ revision: 2,+ type: "comment",+ reactions: [],+ attachments: [],+ agent_deliveries: [+ {+ agent_id: "agent-1",+ agent_name: "Walt",+ task_id: "task-1",+ status: "delivered",+ },+ ],+ },+ });+ });++ expect(cacheUpdates.last).toMatchObject([+ {+ agent_deliveries: [+ { agent_id: "agent-1", task_id: "task-1", status: "delivered" },+ ],+ },+ ]);+ });+it("refetches instead of applying an unversioned event over versioned cache state", () => {queryState.data = [{type: "comment",diff --git a/packages/views/issues/hooks/use-issue-timeline.ts b/packages/views/issues/hooks/use-issue-timeline.tsindex cee70faf44..c191422b4b 100644--- a/packages/views/issues/hooks/use-issue-timeline.ts+++ b/packages/views/issues/hooks/use-issue-timeline.ts@@ -65,6 +65,7 @@ function commentToTimelineEntry(c: Comment): TimelineEntry {resolved_by_type: c.resolved_by_type,resolved_by_id: c.resolved_by_id,source_task_id: c.source_task_id,+ agent_deliveries: c.agent_deliveries,deleted_at: c.deleted_at,};}diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.jsonindex 5cf63f2a30..161615fe9b 100644--- a/packages/views/locales/en/issues.json+++ b/packages/views/locales/en/issues.json@@ -563,6 +563,7 @@"trigger_current_safe_point": "Updates current work at the next safe point.","delivery_pending": "Waiting to deliver to {{name}}'s current work","delivery_delivered": "Delivered to {{name}}'s current work · {{time}}",+ "delivery_view_reply": "View final reply","delivery_follow_up": "{{name}} will handle this in follow-up work","trigger_will_start_count_one": "{{count}} agent will start when sent","trigger_will_start_count_other": "{{count}} agents will start when sent",diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.jsonindex dc8f6c0af8..18a3e9c46f 100644--- a/packages/views/locales/fr/issues.json+++ b/packages/views/locales/fr/issues.json@@ -563,6 +563,7 @@"trigger_current_safe_point": "Complète le travail en cours au prochain point sûr.","delivery_pending": "En attente de livraison au travail en cours de {{name}}","delivery_delivered": "Livré au travail en cours de {{name}} · {{time}}",+ "delivery_view_reply": "Voir la réponse finale","delivery_follow_up": "{{name}} le traitera dans un suivi","trigger_will_start_count_one": "{{count}} agent démarrera à l'envoi","trigger_will_start_count_other": "{{count}} agents démarreront à l'envoi",diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.jsonindex 86a370c9dd..2e7e7823eb 100644--- a/packages/views/locales/ja/issues.json+++ b/packages/views/locales/ja/issues.json@@ -551,6 +551,7 @@"trigger_current_safe_point": "次の安全な時点で現在の作業に追加します。","delivery_pending": "{{name}} の現在の作業への配信を待機中","delivery_delivered": "{{name}} の現在の作業に配信済み · {{time}}",+ "delivery_view_reply": "最終回答を表示","delivery_follow_up": "{{name}} がフォローアップで対応します","trigger_will_start_count_other": "送信後に {{count}} 体のエージェントが作業を開始します","trigger_starts_now": "すぐに開始します。",diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.jsonindex 5e7bb4d8a3..fac1e8ddf6 100644--- a/packages/views/locales/ko/issues.json+++ b/packages/views/locales/ko/issues.json@@ -551,6 +551,7 @@"trigger_current_safe_point": "다음 안전 지점에서 현재 작업에 추가됩니다.","delivery_pending": "{{name}}의 현재 작업에 전달 대기 중","delivery_delivered": "{{name}}의 현재 작업에 전달됨 · {{time}}",+ "delivery_view_reply": "최종 답변 보기","delivery_follow_up": "{{name}}이 후속 작업에서 처리합니다","trigger_will_start_count_other": "전송 후 에이전트 {{count}}개가 작업을 시작합니다","trigger_starts_now": "바로 시작합니다.",diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.jsonindex a717b2b6dc..eb5a66a42e 100644--- a/packages/views/locales/zh-Hans/issues.json+++ b/packages/views/locales/zh-Hans/issues.json@@ -551,6 +551,7 @@"trigger_current_safe_point": "将在下一个安全边界补充当前工作。","delivery_pending": "等待送达 {{name}} 的当前工作","delivery_delivered": "已送达 {{name}} 的当前工作 · {{time}}",+ "delivery_view_reply": "查看最终回复","delivery_follow_up": "{{name}} 将在后续工作中处理","trigger_will_start_count_other": "发送后 {{count}} 个智能体开始工作","trigger_starts_now": "立即开始。",diff --git a/server/internal/handler/comment.go b/server/internal/handler/comment.goindex 3d8a26b517..2aad3d3655 100644--- a/server/internal/handler/comment.go+++ b/server/internal/handler/comment.go@@ -87,8 +87,13 @@ type CommentResponse struct {}type CommentAgentDeliveryResponse struct {- AgentID string `json:"agent_id"`- AgentName string `json:"agent_name"`+ AgentID string `json:"agent_id"`+ AgentName string `json:"agent_name"`+ // TaskID links a delivered steer receipt to the final comment whose+ // source_task_id names the same run. It is nullable for receipts created+ // directly as follow-up and omitted by older servers, so mixed-version+ // clients must treat it as optional read-side metadata rather than state.+ TaskID *string `json:"task_id,omitempty"`Status string `json:"status"` // pending | delivered | follow_upDeliveredAt *string `json:"delivered_at,omitempty"`}@@ -2005,7 +2010,7 @@ func (h *Handler) groupCommentAgentDeliveries(ctx context.Context, commentIDs []status = "pending"}grouped[uuidToString(row.CommentID)] = append(grouped[uuidToString(row.CommentID)], CommentAgentDeliveryResponse{- AgentID: uuidToString(row.AgentID), AgentName: row.AgentName, Status: status,+ AgentID: uuidToString(row.AgentID), AgentName: row.AgentName, TaskID: uuidToPtr(row.TaskID), Status: status,DeliveredAt: timestampToPtr(row.DeliveredAt),})}diff --git a/server/internal/handler/comment_steer_test.go b/server/internal/handler/comment_steer_test.goindex ea56e02d30..4b6dbda9d2 100644--- a/server/internal/handler/comment_steer_test.go+++ b/server/internal/handler/comment_steer_test.go@@ -296,3 +296,51 @@ func TestCancelTaskSettlesUndeliveredSteersWithoutStartingRun(t *testing.T) {t.Fatalf("task count after Stop = %d, want no replacement run", taskCount)}}++func TestCommentSteerDeliveryReadModelIncludesNullableTaskID(t *testing.T) {+ if testHandler == nil {+ t.Skip("database not available")+ }+ f := newCommentSteerFixture(t, "read-model-task")+ deliveredID := f.reply(t, "injected constraint", "4 minutes")+ followUpID := f.reply(t, "future work", "2 minutes")+ registerCommentSteer(t, f, deliveredID)+ if _, err := testHandler.Queries.ClaimNextCommentSteer(context.Background(), util.MustParseUUID(f.taskID)); err != nil {+ t.Fatalf("claim steer: %v", err)+ }+ if _, err := testHandler.Queries.AckCommentSteerDelivered(context.Background(), db.AckCommentSteerDeliveredParams{+ TaskID: util.MustParseUUID(f.taskID), CommentID: util.MustParseUUID(deliveredID),+ }); err != nil {+ t.Fatalf("ack steer: %v", err)+ }+ if err := testHandler.Queries.RecordCommentFollowUpDelivery(context.Background(), db.RecordCommentFollowUpDeliveryParams{+ CommentID: util.MustParseUUID(followUpID), AgentID: util.MustParseUUID(f.agentID),+ FailureReason: pgtype.Text{String: "turn_ended", Valid: true},+ }); err != nil {+ t.Fatalf("record follow-up receipt: %v", err)+ }++ entries, status := fetchTimeline(t, f.issueID)+ if status != http.StatusOK {+ t.Fatalf("timeline status = %d, want 200", status)+ }+ byID := make(map[string]TimelineEntry, len(entries))+ for _, entry := range entries {+ byID[entry.ID] = entry+ }+ delivered := byID[deliveredID].AgentDeliveries+ if len(delivered) != 1 || delivered[0].Status != "delivered" || delivered[0].TaskID == nil || *delivered[0].TaskID != f.taskID {+ t.Fatalf("delivered receipt = %+v, want task_id %s", delivered, f.taskID)+ }+ followUp := byID[followUpID].AgentDeliveries+ if len(followUp) != 1 || followUp[0].Status != "follow_up" || followUp[0].TaskID != nil {+ t.Fatalf("follow-up receipt = %+v, want nullable task_id", followUp)+ }++ var recordedAsDelivered bool+ dbfx.QueryRow(t, `SELECT $2::uuid = ANY(delivered_comment_ids) FROM agent_task_queue WHERE id=$1`, f.taskID, deliveredID).+ Scan(&recordedAsDelivered)+ if recordedAsDelivered {+ t.Fatal("read-side task linkage wrote the steer comment into delivered_comment_ids")+ }+}diff --git a/server/pkg/db/generated/steer.sql.go b/server/pkg/db/generated/steer.sql.goindex 2c09f83a7d..31cd0b4837 100644--- a/server/pkg/db/generated/steer.sql.go+++ b/server/pkg/db/generated/steer.sql.go@@ -239,7 +239,7 @@ func (q *Queries) GetCommentSteerDeliveryForTask(ctx context.Context, arg GetCom}const listCommentAgentDeliveries = `-- name: ListCommentAgentDeliveries :many-SELECT d.comment_id, d.agent_id, a.name AS agent_name, d.status, d.delivered_at+SELECT d.comment_id, d.agent_id, a.name AS agent_name, d.task_id, d.status, d.delivered_atFROM comment_agent_delivery dJOIN agent a ON a.id = d.agent_idWHERE d.comment_id = ANY($1::uuid[])@@ -250,6 +250,7 @@ type ListCommentAgentDeliveriesRow struct {CommentID pgtype.UUID `json:"comment_id"`AgentID pgtype.UUID `json:"agent_id"`AgentName string `json:"agent_name"`+ TaskID pgtype.UUID `json:"task_id"`Status string `json:"status"`DeliveredAt pgtype.Timestamptz `json:"delivered_at"`}@@ -267,6 +268,7 @@ func (q *Queries) ListCommentAgentDeliveries(ctx context.Context, commentIds []p&i.CommentID,&i.AgentID,&i.AgentName,+ &i.TaskID,&i.Status,&i.DeliveredAt,); err != nil {diff --git a/server/pkg/db/queries/steer.sql b/server/pkg/db/queries/steer.sqlindex c432145032..b258c13377 100644--- a/server/pkg/db/queries/steer.sql+++ b/server/pkg/db/queries/steer.sql@@ -133,7 +133,7 @@ FROM comment_agent_deliveryWHERE task_id = @task_id AND status = 'delivered';-- name: ListCommentAgentDeliveries :many-SELECT d.comment_id, d.agent_id, a.name AS agent_name, d.status, d.delivered_at+SELECT d.comment_id, d.agent_id, a.name AS agent_name, d.task_id, d.status, d.delivered_atFROM comment_agent_delivery dJOIN agent a ON a.id = d.agent_idWHERE d.comment_id = ANY(@comment_ids::uuid[])