From a8ea1e07fd5278463f3f5bdaeed7b2d620b00065 Mon Sep 17 00:00:00 2001 From: Dotta Date: Fri, 1 May 2026 10:09:04 -0500 Subject: [PATCH] Surface live run comment context Co-Authored-By: Paperclip --- .../src/__tests__/agent-live-run-routes.test.ts | 4 ++++ server/src/routes/agents.ts | 4 ++++ server/src/services/heartbeat.ts | 2 ++ ui/src/api/heartbeats.ts | 4 ++++ ui/src/lib/optimistic-issue-comments.test.ts | 17 +++++++++++++++++ ui/src/lib/optimistic-issue-comments.ts | 9 +++++++++ ui/src/pages/IssueDetail.tsx | 2 ++ 7 files changed, 42 insertions(+) diff --git a/server/src/__tests__/agent-live-run-routes.test.ts b/server/src/__tests__/agent-live-run-routes.test.ts index 2ac8658da59..cecc71691dd 100644 --- a/server/src/__tests__/agent-live-run-routes.test.ts +++ b/server/src/__tests__/agent-live-run-routes.test.ts @@ -187,6 +187,8 @@ describe("agent live run routes", () => { status: "running", invocationSource: "on_demand", triggerDetail: "manual", + contextCommentId: "comment-1", + contextWakeCommentId: "comment-1", startedAt: new Date("2026-04-10T09:30:00.000Z"), finishedAt: null, createdAt: new Date("2026-04-10T09:29:59.000Z"), @@ -224,6 +226,8 @@ describe("agent live run routes", () => { status: "running", invocationSource: "on_demand", triggerDetail: "manual", + contextCommentId: "comment-1", + contextWakeCommentId: "comment-1", startedAt: "2026-04-10T09:30:00.000Z", finishedAt: null, createdAt: "2026-04-10T09:29:59.000Z", diff --git a/server/src/routes/agents.ts b/server/src/routes/agents.ts index 6b663a85f5a..7a93ca5b322 100644 --- a/server/src/routes/agents.ts +++ b/server/src/routes/agents.ts @@ -2853,6 +2853,8 @@ export function agentRoutes( status: heartbeatRuns.status, invocationSource: heartbeatRuns.invocationSource, triggerDetail: heartbeatRuns.triggerDetail, + contextCommentId: sql`${heartbeatRuns.contextSnapshot} ->> 'commentId'`.as("contextCommentId"), + contextWakeCommentId: sql`${heartbeatRuns.contextSnapshot} ->> 'wakeCommentId'`.as("contextWakeCommentId"), startedAt: heartbeatRuns.startedAt, finishedAt: heartbeatRuns.finishedAt, createdAt: heartbeatRuns.createdAt, @@ -3089,6 +3091,8 @@ export function agentRoutes( status: heartbeatRuns.status, invocationSource: heartbeatRuns.invocationSource, triggerDetail: heartbeatRuns.triggerDetail, + contextCommentId: sql`${heartbeatRuns.contextSnapshot} ->> 'commentId'`.as("contextCommentId"), + contextWakeCommentId: sql`${heartbeatRuns.contextSnapshot} ->> 'wakeCommentId'`.as("contextWakeCommentId"), startedAt: heartbeatRuns.startedAt, finishedAt: heartbeatRuns.finishedAt, createdAt: heartbeatRuns.createdAt, diff --git a/server/src/services/heartbeat.ts b/server/src/services/heartbeat.ts index f7c0a220bd2..2756ba626ed 100644 --- a/server/src/services/heartbeat.ts +++ b/server/src/services/heartbeat.ts @@ -744,6 +744,8 @@ const heartbeatRunIssueSummaryColumns = { status: heartbeatRuns.status, invocationSource: heartbeatRuns.invocationSource, triggerDetail: heartbeatRuns.triggerDetail, + contextCommentId: sql`${heartbeatRuns.contextSnapshot} ->> 'commentId'`.as("contextCommentId"), + contextWakeCommentId: sql`${heartbeatRuns.contextSnapshot} ->> 'wakeCommentId'`.as("contextWakeCommentId"), startedAt: heartbeatRuns.startedAt, finishedAt: heartbeatRuns.finishedAt, createdAt: heartbeatRuns.createdAt, diff --git a/ui/src/api/heartbeats.ts b/ui/src/api/heartbeats.ts index b4bf89c81d7..fbaad815d7e 100644 --- a/ui/src/api/heartbeats.ts +++ b/ui/src/api/heartbeats.ts @@ -19,6 +19,8 @@ export interface ActiveRunForIssue { status: string; invocationSource: string; triggerDetail: string | null; + contextCommentId?: string | null; + contextWakeCommentId?: string | null; startedAt: string | Date | null; finishedAt: string | Date | null; createdAt: string | Date; @@ -41,6 +43,8 @@ export interface LiveRunForIssue { status: string; invocationSource: string; triggerDetail: string | null; + contextCommentId?: string | null; + contextWakeCommentId?: string | null; startedAt: string | null; finishedAt: string | null; createdAt: string; diff --git a/ui/src/lib/optimistic-issue-comments.test.ts b/ui/src/lib/optimistic-issue-comments.test.ts index f92c34199f1..0f6ddf0b7d4 100644 --- a/ui/src/lib/optimistic-issue-comments.test.ts +++ b/ui/src/lib/optimistic-issue-comments.test.ts @@ -726,14 +726,31 @@ describe("optimistic issue comments", () => { expect( isQueuedIssueComment({ comment: { + id: "comment-2", createdAt: new Date("2026-03-28T16:20:05.000Z"), }, activeRunStartedAt: new Date("2026-03-28T16:20:00.000Z"), + activeRunWakeCommentId: "comment-1", runId: null, }), ).toBe(true); }); + it("does not mark the comment that triggered the active run as queued", () => { + expect( + isQueuedIssueComment({ + comment: { + id: "comment-1", + createdAt: new Date("2026-03-28T16:20:05.000Z"), + }, + activeRunStartedAt: new Date("2026-03-28T16:20:00.000Z"), + activeRunCommentId: "comment-1", + activeRunWakeCommentId: "comment-1", + runId: null, + }), + ).toBe(false); + }); + it("does not mark comments with an associated run as queued", () => { expect( isQueuedIssueComment({ diff --git a/ui/src/lib/optimistic-issue-comments.ts b/ui/src/lib/optimistic-issue-comments.ts index c1ec5549af6..eb5fe90879e 100644 --- a/ui/src/lib/optimistic-issue-comments.ts +++ b/ui/src/lib/optimistic-issue-comments.ts @@ -70,15 +70,24 @@ export function createOptimisticIssueComment(params: { export function isQueuedIssueComment(params: { comment: Pick & Partial> & { + id?: string; authorAgentId?: string | null; }; activeRunStartedAt?: Date | string | null; activeRunAgentId?: string | null; + activeRunCommentId?: string | null; + activeRunWakeCommentId?: string | null; runId?: string | null; interruptedRunId?: string | null; }) { if (params.runId) return false; if (params.interruptedRunId) return false; + if ( + params.comment.id && + (params.comment.id === params.activeRunWakeCommentId || params.comment.id === params.activeRunCommentId) + ) { + return false; + } if (params.comment.authorAgentId && params.activeRunAgentId && params.comment.authorAgentId === params.activeRunAgentId) { return false; } diff --git a/ui/src/pages/IssueDetail.tsx b/ui/src/pages/IssueDetail.tsx index 78a2055f4df..9f71cf65997 100644 --- a/ui/src/pages/IssueDetail.tsx +++ b/ui/src/pages/IssueDetail.tsx @@ -778,6 +778,8 @@ const IssueDetailChatTab = memo(function IssueDetailChatTab({ comment: nextComment, activeRunStartedAt, activeRunAgentId: runningIssueRun?.agentId ?? null, + activeRunCommentId: runningIssueRun?.contextCommentId ?? null, + activeRunWakeCommentId: runningIssueRun?.contextWakeCommentId ?? null, runId: meta?.runId ?? nextComment.runId ?? null, interruptedRunId: meta?.interruptedRunId ?? nextComment.interruptedRunId ?? null, })