diff --git a/ui/src/components/CommentThread.tsx b/ui/src/components/CommentThread.tsx index 3ebcb0bf..b1c2271a 100644 --- a/ui/src/components/CommentThread.tsx +++ b/ui/src/components/CommentThread.tsx @@ -1,4 +1,4 @@ -import { useEffect, useMemo, useRef, useState, type ChangeEvent } from "react"; +import { memo, useEffect, useMemo, useRef, useState, type ChangeEvent } from "react"; import { Link } from "react-router-dom"; import type { IssueComment, Agent } from "@paperclipai/shared"; import { Button } from "@/components/ui/button"; @@ -95,6 +95,91 @@ type TimelineItem = | { kind: "comment"; id: string; createdAtMs: number; comment: CommentWithRunMeta } | { kind: "run"; id: string; createdAtMs: number; run: LinkedRunItem }; +const TimelineList = memo(function TimelineList({ + timeline, + agentMap, +}: { + timeline: TimelineItem[]; + agentMap?: Map; +}) { + if (timeline.length === 0) { + return

No comments or runs yet.

; + } + + return ( +
+ {timeline.map((item) => { + if (item.kind === "run") { + const run = item.run; + return ( +
+
+ + + + + {formatDateTime(run.startedAt ?? run.createdAt)} + +
+
+ Run + + {run.runId.slice(0, 8)} + + +
+
+ ); + } + + const comment = item.comment; + return ( +
+
+ {comment.authorAgentId ? ( + + + + ) : ( + + )} + + {formatDateTime(comment.createdAt)} + +
+ {comment.body} + {comment.runId && ( +
+ {comment.runAgentId ? ( + + run {comment.runId.slice(0, 8)} + + ) : ( + + run {comment.runId.slice(0, 8)} + + )} +
+ )} +
+ ); + })} +
+ ); +}); + export function CommentThread({ comments, linkedRuns = [], @@ -212,80 +297,7 @@ export function CommentThread({

Comments & Runs ({timeline.length})

- {timeline.length === 0 && ( -

No comments or runs yet.

- )} - -
- {timeline.map((item) => { - if (item.kind === "run") { - const run = item.run; - return ( -
-
- - - - - {formatDateTime(run.startedAt ?? run.createdAt)} - -
-
- Run - - {run.runId.slice(0, 8)} - - -
-
- ); - } - - const comment = item.comment; - return ( -
-
- {comment.authorAgentId ? ( - - - - ) : ( - - )} - - {formatDateTime(comment.createdAt)} - -
- {comment.body} - {comment.runId && ( -
- {comment.runAgentId ? ( - - run {comment.runId.slice(0, 8)} - - ) : ( - - run {comment.runId.slice(0, 8)} - - )} -
- )} -
- ); - })} -
+ {liveRunSlot}