@devries-cameron20 / t3code-1 / commits / cf906e1fcf
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

feat(web): resolved review conversations fold into avatars on their diff line (#34644)

maria committed Nov 12, 2026 at 01:11 UTC cf906e1fcfb8a0a91262382acaec44f4e7f9f800
3 files changed +182 -7
apps/web/src/components/pullRequest/PullRequestCodeTab.browser.test.tsx
+92
@@ -355,3 +355,95 @@ it("answers a commit's diff link only once that commit's diff is shown", async (
355 await screen.rerender(scoped(oid, url));
356 await vi.waitFor(() => expect(settled).toHaveBeenCalledWith(url));
357 });
358 +
359 +it("hides a resolved conversation behind avatars on its line until they are clicked", async () => {
360 + setup({ paged: false });
361 + __setClientSettingsForTests({ ...DEFAULT_CLIENT_SETTINGS, diffFilesCollapsed: false });
362 + using _preferences = {
363 + [Symbol.dispose]() {
364 + __setClientSettingsForTests(DEFAULT_CLIENT_SETTINGS);
365 + },
366 + };
367 + const container = document.createElement("div");
368 + container.className = "flex h-[700px] w-[900px]";
369 + const comment = {
370 + author: { login: "reviewer", name: null, avatarUrl: null },
371 + body: "Rename this.",
372 + createdAt: "2026-09-01T00:00:00Z",
373 + url: null,
374 + };
375 + const withThread = (isResolved: boolean, oldSideToo = false) => (
376 + <PullRequestCodeTab
377 + scrollerRef={() => {}}
378 + environmentId={EnvironmentId.make("environment")}
379 + reference={detail}
380 + detail={{
381 + ...detail,
382 + capabilities: {
383 + ...detail.capabilities,
384 + review: { ...detail.capabilities.review, reply: true },
385 + },
386 + viewerPermissions: { ...detail.viewerPermissions, comment: true },
387 + reviewThreads: [
388 + {
389 + id: "thread",
390 + path: "a.ts",
391 + line: 3,
392 + side: "right",
393 + isResolved,
394 + isOutdated: false,
395 + comments: [{ id: "comment", ...comment }],
396 + },
397 + ...(oldSideToo
398 + ? [
399 + {
400 + id: "old-side",
401 + path: "a.ts",
402 + line: 3,
403 + side: "left" as const,
404 + isResolved: true,
405 + isOutdated: false,
406 + comments: [{ id: "old-side-comment", ...comment }],
407 + },
408 + ]
409 + : []),
410 + ],
411 + }}
412 + selectedCommitOid={null}
413 + onSelectedCommitChange={() => {}}
414 + onRefresh={() => {}}
415 + />
416 + );
417 + await using screen = await render(withThread(true), { container });
418 + const marker = screen.getByRole("button", { name: "Resolved conversation", exact: true });
419 + const card = (state: string) => screen.getByRole("button", { name: `${state} · 1 comment` });
420 + const reply = () => screen.getByRole("textbox", { name: "Reply to this conversation" });
421 +
422 + await expect.element(marker).toHaveAttribute("aria-expanded", "false");
423 + await expect.element(card("Resolved")).not.toBeInTheDocument();
424 +
425 + await marker.click();
426 + await expect.element(marker).toHaveAttribute("aria-expanded", "true");
427 + await expect.element(card("Resolved")).toHaveAttribute("aria-expanded", "true");
428 + await screen.getByRole("button", { name: "Reply", exact: true }).click();
429 + await reply().fill("Unsent");
430 +
431 + // Hidden conversations stay mounted, so the unsent reply is still there.
432 + await marker.click();
433 + await expect.element(card("Resolved")).not.toBeInTheDocument();
434 + await marker.click();
435 + await expect.element(reply()).toHaveValue("Unsent");
436 + await marker.click();
437 +
438 + // Seen open and then resolved, it stays until the avatars are clicked.
439 + await screen.rerender(withThread(false));
440 + await expect.element(card("Open")).toBeVisible();
441 + await screen.rerender(withThread(true));
442 + await expect.element(card("Resolved")).toBeVisible();
443 +
444 + // Stacked view draws a context row once, so both sides' conversations share the avatars.
445 + await screen.rerender(withThread(true, true));
446 + await expect
447 + .element(screen.getByRole("button", { name: "2 resolved conversations" }))
448 + .toBeVisible();
449 +});
apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
+20 -4
@@ -62,6 +62,7 @@ import {
62 canEditPullRequestComment,
63 canResolvePullRequestThread,
64 } from "@t3tools/client-runtime/pull-request-editing";
65 +import { fileDiffRows } from "@t3tools/client-runtime/review-guide-tour";
66 import { isTestChangedFile } from "@t3tools/shared/changedFileKind";
67 import { orderDiffFiles } from "./pullRequestFileOrder.logic";
68 import {
@@ -114,6 +115,7 @@ import { Toggle, ToggleGroup } from "../ui/toggle-group";
115 import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
116 import {
117 getReviewPositionAnchor,
118 + InlineReviewThreads,
119 PendingReviewCommentCard,
120 ReviewThreadCard,
121 toViewerSide,
@@ -638,7 +640,19 @@ function PullRequestCodeTab({
640 const fileKey = buildFileDiffRenderKey(fileDiff);
641 const path = resolveFileDiffPath(fileDiff);
642 const groups = new Map<string, MutableAnnotationGroup>();
641 - const groupAt = (side: PullRequestDiffSide, line: number) => {
643 + // Stacked view draws a context row once, so its old side shares the new side's annotation.
644 + const contextNewLines = new Map<number, number>();
645 + const groupAt = (anchorSide: PullRequestDiffSide, anchorLine: number) => {
646 + if (anchorSide === "left" && diffLayout !== "split" && contextNewLines.size === 0) {
647 + for (const row of fileDiffRows(fileDiff)) {
648 + if (row.oldLine !== null && row.newLine !== null) {
649 + contextNewLines.set(row.oldLine, row.newLine);
650 + }
651 + }
652 + }
653 + const contextLine = anchorSide === "left" ? contextNewLines.get(anchorLine) : undefined;
654 + const side = contextLine === undefined ? anchorSide : "right";
655 + const line = contextLine ?? anchorLine;
656 const key = `${side}:${line}`;
657 const existing = groups.get(key);
658 if (existing) return existing;
@@ -995,7 +1009,7 @@ function PullRequestCodeTab({
1009 return true;
1010 };
1011
998 - const renderThreadCard = (thread: PullRequestReviewThread) => (
1012 + const renderThreadCard = (thread: PullRequestReviewThread, hidden?: boolean) => (
1013 <ReviewThreadCard
1014 // Host thread ids can collide across pull requests.
1015 key={`${reference.projectId}#${reference.number}:${thread.id}`}
@@ -1060,12 +1074,14 @@ function PullRequestCodeTab({
1074 )
1075 }
1076 onReacted={onRefresh}
1077 + {...(hidden === undefined ? {} : { hidden })}
1078 />
1079 );
1080
1081 const renderAnnotation = (...[annotation]: CodeViewAnnotationArgs<ReviewAnnotationGroup>) => (
1067 - <div className="py-1 font-sans text-foreground">
1068 - {annotation.metadata.threads.map(renderThreadCard)}
1082 + // Folded resolved conversations alone add no row, so the code reads straight through.
1083 + <div className="relative font-sans text-foreground has-[>:not([data-resolved-threads])]:py-1">
1084 + <InlineReviewThreads threads={annotation.metadata.threads} renderThread={renderThreadCard} />
1085 {annotation.metadata.pending.map((comment) => (
1086 <PendingReviewCommentCard
1087 key={comment.id}
apps/web/src/components/pullRequest/PullRequestReviewAnnotation.tsx
+70 -3
@@ -1,5 +1,6 @@
1 import type {
2 EnvironmentId,
3 + PullRequestActor,
4 PullRequestDiffSide,
5 PullRequestRef,
6 PullRequestReviewPosition,
@@ -15,7 +16,7 @@ import {
16 CircleCheckIcon,
17 CircleIcon,
18 } from "lucide-react";
18 -import { useRef, useState } from "react";
19 +import { type ReactNode, useRef, useState } from "react";
20 import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
21
22 import { RelativeTime } from "~/components/RelativeTime";
@@ -23,6 +24,7 @@ import { cn } from "~/lib/utils";
24 import { SpeechTextField, TextFieldSpeechControls } from "~/speech/useTextFieldSpeech";
25
26 import { Button } from "../ui/button";
27 +import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
28 import { PullRequestEditButton } from "./PullRequestEditButton";
29 import { isCommentSubmitShortcut } from "../diffs/commentSubmitShortcut";
30 import {
@@ -30,7 +32,7 @@ import {
32 mergePullRequestThreadComments,
33 visibleBody,
34 } from "./pullRequestDetail.logic";
33 -import { PullRequestActorLabel } from "./pullRequestPresentation";
35 +import { PullRequestActorAvatar, PullRequestActorLabel } from "./pullRequestPresentation";
36 import { PullRequestMarkdown } from "./PullRequestMarkdown";
37 import { PullRequestMarkdownEditor } from "./PullRequestMarkdownEditor";
38 import { PullRequestReactionBar } from "./PullRequestReactions";
@@ -114,6 +116,66 @@ export function PendingReviewCommentCard({
116 );
117 }
118
119 +/** The conversations on one diff line. Resolved ones hide behind their authors' avatars. */
120 +export function InlineReviewThreads({
121 + threads,
122 + renderThread,
123 +}: {
124 + threads: ReadonlyArray<PullRequestReviewThread>;
125 + renderThread: (thread: PullRequestReviewThread, hidden: boolean) => ReactNode;
126 +}) {
127 + const [shown, setShown] = useState<ReadonlySet<string>>(() => new Set());
128 + // A conversation seen open stays shown once resolved, so it does not vanish under the reader.
129 + const open = threads.filter((thread) => !thread.isResolved);
130 + if (open.some((thread) => !shown.has(thread.id))) {
131 + setShown(new Set([...shown, ...open.map((thread) => thread.id)]));
132 + }
133 + const resolved = threads.filter((thread) => thread.isResolved);
134 + const expanded = resolved.every((thread) => shown.has(thread.id));
135 + const authors = new Map<string, PullRequestActor | null>();
136 + for (const comment of resolved.flatMap((thread) => thread.comments)) {
137 + authors.set(comment.author?.login ?? "ghost", comment.author);
138 + }
139 + if (authors.size === 0) authors.set("ghost", null);
140 + const label =
141 + resolved.length === 1 ? "Resolved conversation" : `${resolved.length} resolved conversations`;
142 + return (
143 + <>
144 + {resolved.length > 0 ? (
145 + <Tooltip>
146 + <TooltipTrigger
147 + render={
148 + <button
149 + type="button"
150 + data-resolved-threads
151 + aria-label={label}
152 + aria-expanded={expanded}
153 + // Sits on the commented line, which is the row above this annotation.
154 + className="absolute right-3 bottom-full flex h-[var(--diffs-line-height,20px)] cursor-pointer items-center -space-x-1 rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset"
155 + contentEditable={false}
156 + onPointerDown={(event) => event.stopPropagation()}
157 + onClick={() =>
158 + setShown(new Set((expanded ? open : threads).map((thread) => thread.id)))
159 + }
160 + />
161 + }
162 + >
163 + {[...authors].slice(0, 3).map(([login, author]) => (
164 + <PullRequestActorAvatar
165 + key={login}
166 + actor={author}
167 + className="ring-1 ring-background"
168 + />
169 + ))}
170 + </TooltipTrigger>
171 + <TooltipPopup side="left">{label}</TooltipPopup>
172 + </Tooltip>
173 + ) : null}
174 + {threads.map((thread) => renderThread(thread, thread.isResolved && !shown.has(thread.id)))}
175 + </>
176 + );
177 +}
178 +
179 export function ReviewThreadCard({
180 thread,
181 workspaceRoot,
@@ -134,6 +196,7 @@ export function ReviewThreadCard({
196 onEditComment,
197 onToggleResolved,
198 onReacted,
199 + hidden,
200 }: {
201 thread: PullRequestReviewThread;
202 workspaceRoot: string;
@@ -158,8 +221,10 @@ export function ReviewThreadCard({
221 onEditComment: (commentId: string, body: string) => Promise<boolean>;
222 onToggleResolved: () => void;
223 onReacted: () => void;
224 + /** Set on a diff line. Hidden draws nothing but stays mounted, so an unsent reply survives. */
225 + hidden?: boolean;
226 }) {
162 - const [expanded, setExpanded] = useState(!thread.isResolved);
227 + const [expanded, setExpanded] = useState(hidden !== undefined || !thread.isResolved);
228 const [replying, setReplying] = useState(false);
229 const [reply, setReply] = useState("");
230 const [editingId, setEditingId] = useState<string | null>(null);
@@ -232,6 +297,8 @@ export function ReviewThreadCard({
297 }));
298 };
299
300 + if (hidden) return null;
301 +
302 return (
303 <div
304 className={cn(CARD_CLASS, !expanded && "py-1")}