Skip to content

Commit e261a20

Browse files
TonybynMp4claude
andcommitted
feat(gitlab): resolve overview threads from Summary and Timeline
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d51bc58 commit e261a20

12 files changed

Lines changed: 232 additions & 67 deletions

File tree

‎apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ function Discussion({ params }: { params: PullRequestParams & { readonly discuss
5656
});
5757
const loadMore = useAtomCommand(composerPullRequests.threadComments, { reportFailure: false });
5858
const thread = activity.data?.reviewThreads.find((thread) => thread.id === params.discussionId);
59+
const filePath = thread?.path ?? null;
5960
const [body, setBody] = useState("");
6061
const [extra, setExtra] = useState<readonly PullRequestThreadComment[]>([]);
6162
const [cursor, setCursor] = useState<string | null | undefined>();
@@ -181,20 +182,24 @@ function Discussion({ params }: { params: PullRequestParams & { readonly discuss
181182
{activity.isPending && !thread ? <AppActivityIndicator /> : null}
182183
{thread ? (
183184
<View className="gap-2 pb-4">
184-
<Text selectable className="font-mono text-xs text-foreground-muted">
185-
{thread.path}
186-
{thread.line ? `:${thread.line}` : ""}
187-
</Text>
185+
{thread.path === null ? null : (
186+
<Text selectable className="font-mono text-xs text-foreground-muted">
187+
{thread.path}
188+
{thread.line ? `:${thread.line}` : ""}
189+
</Text>
190+
)}
188191
<Text className="text-xs text-foreground-muted">
189192
{thread.isResolved ? "Resolved" : "Unresolved"}
190193
{thread.isOutdated ? " · Outdated" : ""}
191194
</Text>
192-
<Button
193-
label="View file diff"
194-
onPress={() =>
195-
navigation.navigate("PullRequestFile", { ...params, path: thread.path })
196-
}
197-
/>
195+
{filePath === null ? null : (
196+
<Button
197+
label="View file diff"
198+
onPress={() =>
199+
navigation.navigate("PullRequestFile", { ...params, path: filePath })
200+
}
201+
/>
202+
)}
198203
</View>
199204
) : !activity.isPending ? (
200205
<Text>This discussion is no longer available.</Text>

‎apps/mobile/src/features/pull-requests/PullRequestTimeline.tsx‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,24 @@ export function pullRequestTimelineRows(
234234
</View>
235235
<Pressable
236236
accessibilityRole="button"
237-
accessibilityLabel={`Open ${thread.isResolved ? "resolved" : "unresolved"} discussion in ${thread.path}`}
237+
accessibilityLabel={`Open ${thread.isResolved ? "resolved" : "unresolved"} discussion in ${thread.path ?? "the overview"}`}
238238
onPress={() =>
239239
navigation.navigate("PullRequestDiscussion", { ...params, discussionId: thread.id })
240240
}
241241
className="gap-2 rounded-2xl bg-grouped-card p-3 active:opacity-70"
242242
>
243243
<View className="flex-row items-center gap-2">
244-
<SymbolView name="doc.text" size={14} tintColorClassName="accent-icon-muted" />
245-
<Text className="flex-1 font-mono text-xs" numberOfLines={2}>
246-
{thread.path}
247-
{thread.line ? `:${thread.line}` : ""}
248-
</Text>
244+
{thread.path === null ? (
245+
<Text className="flex-1 text-xs">Overview</Text>
246+
) : (
247+
<>
248+
<SymbolView name="doc.text" size={14} tintColorClassName="accent-icon-muted" />
249+
<Text className="flex-1 font-mono text-xs" numberOfLines={2}>
250+
{thread.path}
251+
{thread.line ? `:${thread.line}` : ""}
252+
</Text>
253+
</>
254+
)}
249255
<SymbolView name="chevron.right" size={12} tintColorClassName="accent-icon-muted" />
250256
</View>
251257
<Text className="text-xs text-foreground-muted">

‎apps/mobile/src/features/pull-requests/pullRequestDiffComments.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function annotatePullRequestDiff(
7373
anchors.set(anchor.id, rows);
7474
};
7575
for (const thread of threads) {
76-
if (thread.isOutdated) continue;
76+
if (thread.isOutdated || thread.path === null) continue;
7777
const anchor =
7878
thread.line === null
7979
? firstByPath.get(thread.path)

‎apps/server/src/pullRequest/pullRequestReviewGuideInput.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function settledReviewSummary(activity: PullRequestActivity): string {
1919
if (opener === undefined) return [];
2020
const who = opener.author?.login ?? "ghost";
2121
const state = thread.isResolved ? "resolved" : "outdated";
22-
return [`- ${thread.path} (${state}, ${who}): ${oneLine(opener.body)}`];
22+
return [`- ${thread.path ?? "overview"} (${state}, ${who}): ${oneLine(opener.body)}`];
2323
})
2424
.join("\n");
2525
}

‎apps/web/src/components/pullRequest/PullRequestCodeTab.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ function reviewThreadsByPath(threads: ReadonlyArray<PullRequestReviewThread>) {
237237
if (byPath === undefined) {
238238
const grouped = new Map<string, PullRequestReviewThread[]>();
239239
for (const thread of threads) {
240+
if (thread.path === null) continue;
240241
const list = grouped.get(thread.path);
241242
if (list) list.push(thread);
242243
else grouped.set(thread.path, [thread]);
@@ -1448,6 +1449,8 @@ function PullRequestCodeTab({
14481449
const orphanThreads = detail.reviewThreads.filter((thread) => !placedThreadIds.has(thread.id));
14491450
const orphanFiles = new Map<string, PullRequestReviewThread[]>();
14501451
for (const thread of orphanThreads) {
1452+
// Threads on the change request as a whole belong to Summary and Timeline, not to a file.
1453+
if (thread.path === null) continue;
14511454
const existing = orphanFiles.get(thread.path);
14521455
if (existing) existing.push(thread);
14531456
else orphanFiles.set(thread.path, [thread]);
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import type {
2+
EnvironmentId,
3+
PullRequestDetailView,
4+
PullRequestRef,
5+
PullRequestReviewThread,
6+
} from "@t3tools/contracts";
7+
import { canResolvePullRequestThread } from "@t3tools/client-runtime/pull-request-editing";
8+
import { useState } from "react";
9+
10+
import { pullRequestEnvironment } from "~/state/pullRequests";
11+
import { useAtomCommand } from "~/state/use-atom-command";
12+
13+
import { Button } from "../ui/button";
14+
import { toastManager } from "../ui/toast";
15+
16+
/**
17+
* Resolves or unresolves a thread from the conversation rather than from its line in the Code tab,
18+
* which a thread on the change request as a whole does not have. Callers put it on the thread's
19+
* first comment only. Renders nothing where the host or this account cannot resolve the thread.
20+
*/
21+
export function PullRequestResolveThreadButton({
22+
environmentId,
23+
reference,
24+
detail,
25+
thread,
26+
onRefresh,
27+
}: {
28+
environmentId: EnvironmentId;
29+
reference: PullRequestRef;
30+
detail: PullRequestDetailView;
31+
thread: Pick<PullRequestReviewThread, "id" | "isResolved" | "canResolve">;
32+
onRefresh: () => void;
33+
}) {
34+
// Held until a refreshed detail arrives, so the button does not re-enable on the old label.
35+
const [sent, setSent] = useState<PullRequestDetailView | "pending" | null>(null);
36+
if (sent !== null && sent !== "pending" && sent !== detail) setSent(null);
37+
const setThreadResolution = useAtomCommand(pullRequestEnvironment.setThreadResolution, {
38+
reportFailure: false,
39+
});
40+
if (!detail.capabilities.review.resolve || !canResolvePullRequestThread(detail, thread)) {
41+
return null;
42+
}
43+
44+
const toggle = async () => {
45+
setSent("pending");
46+
const result = await setThreadResolution({
47+
environmentId,
48+
input: { ...reference, threadId: thread.id, resolved: !thread.isResolved },
49+
});
50+
if (result._tag === "Failure") {
51+
setSent(null);
52+
toastManager.add({ type: "error", title: "The conversation could not be updated" });
53+
return;
54+
}
55+
setSent(detail);
56+
onRefresh();
57+
};
58+
59+
return (
60+
<Button
61+
size="xs"
62+
variant="ghost"
63+
className="shrink-0"
64+
disabled={sent !== null}
65+
onClick={() => void toggle()}
66+
>
67+
{thread.isResolved ? "Unresolve" : "Resolve"}
68+
</Button>
69+
);
70+
}

‎apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ import { PullRequestCommentBody } from "./PullRequestCommentBody";
7979
import { PullRequestMoreReplies } from "./PullRequestMoreReplies";
8080
import { PullRequestMarkdownEditor } from "./PullRequestMarkdownEditor";
8181
import { PullRequestReactionBar } from "./PullRequestReactions";
82+
import { PullRequestResolveThreadButton } from "./PullRequestResolveThreadButton";
8283
import { PullRequestConversationGhost } from "./PullRequestGhosts";
8384
import { sectionCollapseAnchorScrollTop } from "./pullRequestSummaryScroll.logic";
8485

@@ -212,6 +213,7 @@ function CollapsedComment({
212213
label,
213214
body,
214215
reactionBar,
216+
resolveButton,
215217
detail,
216218
thread,
217219
replyCount = 0,
@@ -223,6 +225,7 @@ function CollapsedComment({
223225
label: string;
224226
body: string | null;
225227
reactionBar: ReactNode;
228+
resolveButton: ReactNode;
226229
detail: PullRequestDetailView;
227230
thread: PullRequestReviewThread | undefined;
228231
replyCount?: number;
@@ -252,6 +255,7 @@ function CollapsedComment({
252255
className={cn("size-3.5 transition-transform", open && "rotate-180")}
253256
/>
254257
</CollapsibleTrigger>
258+
{resolveButton}
255259
{reactionBar}
256260
</div>
257261
<CommentLocation comment={comment} thread={thread} />
@@ -550,6 +554,17 @@ export function PullRequestSummaryTab({
550554
/>
551555
);
552556

557+
const resolveButtonFor = (thread: PullRequestReviewThread | undefined) =>
558+
thread === undefined ? null : (
559+
<PullRequestResolveThreadButton
560+
environmentId={environmentId}
561+
reference={reference}
562+
detail={detail}
563+
thread={thread}
564+
onRefresh={onRefresh}
565+
/>
566+
);
567+
553568
const renderCommentCard = (
554569
comment: PullRequestComment,
555570
thread: PullRequestReviewThread | undefined,
@@ -599,6 +614,7 @@ export function PullRequestSummaryTab({
599614
</span>
600615
</Button>
601616
) : null}
617+
{resolveButtonFor(thread)}
602618
{reactionBarFor(comment)}
603619
</div>
604620
{reply ? null : (
@@ -638,6 +654,7 @@ export function PullRequestSummaryTab({
638654
replies={replies}
639655
moreReplies={moreReplies}
640656
reactionBar={reactionBarFor(comment)}
657+
resolveButton={resolveButtonFor(thread)}
641658
/>
642659
);
643660
}

‎apps/web/src/components/pullRequest/PullRequestTimelineTab.tsx‎

Lines changed: 55 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import { PullRequestMarkdown } from "./PullRequestMarkdown";
4747
import { PullRequestMoreReplies } from "./PullRequestMoreReplies";
4848
import { PullRequestMarkdownEditor } from "./PullRequestMarkdownEditor";
4949
import { PullRequestReactionBar } from "./PullRequestReactions";
50+
import { PullRequestResolveThreadButton } from "./PullRequestResolveThreadButton";
5051
import {
5152
PullRequestActorAvatar,
5253
PullRequestDiffStat,
@@ -375,9 +376,11 @@ function ReviewThreadEvent({
375376
cwd,
376377
onOpen,
377378
reactions,
379+
detail,
378380
}: {
379381
event: PullRequestTimelineEvent;
380382
thread: PullRequestTimelineThread;
383+
detail: PullRequestDetailView;
381384
editable: ReadonlyMap<string, PullRequestComment>;
382385
cwd: string;
383386
onOpen: (url: string) => void;
@@ -395,40 +398,58 @@ function ReviewThreadEvent({
395398
fallback={<MessageSquareIcon className="size-3.5" />}
396399
muted={!expanded}
397400
/>
398-
<button
399-
type="button"
400-
className="flex w-full min-w-0 items-center gap-2 px-2 py-2 text-left text-2xs text-muted-foreground hover:text-foreground"
401-
aria-expanded={expanded}
402-
onClick={() => setExpanded((current) => !current)}
403-
>
404-
<FileCode2Icon aria-hidden className="size-3 shrink-0" />
405-
<span className="min-w-0 truncate font-mono">
406-
{thread.line === null ? thread.path : `${thread.path}:${thread.line}`}
407-
</span>
408-
{thread.isResolved ? (
409-
<span className="inline-flex shrink-0 items-center gap-1 font-medium text-success-foreground">
410-
<CircleCheckIcon aria-hidden className="size-3" />
411-
Resolved
412-
</span>
413-
) : null}
414-
{dismissed ? <span className="shrink-0 font-medium">Review dismissed</span> : null}
415-
{thread.isOutdated ? <span className="shrink-0 font-medium">Outdated</span> : null}
416-
{expanded ? null : (
417-
<span className="shrink-0">
418-
· {event.actor?.login ?? "ghost"}
419-
{replyCount > 0 ? (
420-
<>
421-
{" "}
422-
· {replyCount.toLocaleString()} {replyCount === 1 ? "reply" : "replies"}
423-
</>
424-
) : null}
425-
</span>
426-
)}
427-
<ChevronDownIcon
428-
aria-hidden
429-
className={cn("ml-auto size-3.5 shrink-0 transition-transform", expanded && "rotate-180")}
401+
<div className="flex min-w-0 items-center gap-1">
402+
<button
403+
type="button"
404+
className="flex min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left text-2xs text-muted-foreground hover:text-foreground"
405+
aria-expanded={expanded}
406+
onClick={() => setExpanded((current) => !current)}
407+
>
408+
{thread.path === null ? (
409+
<span className="min-w-0 truncate">Overview</span>
410+
) : (
411+
<>
412+
<FileCode2Icon aria-hidden className="size-3 shrink-0" />
413+
<span className="min-w-0 truncate font-mono">
414+
{thread.line === null ? thread.path : `${thread.path}:${thread.line}`}
415+
</span>
416+
</>
417+
)}
418+
{thread.isResolved ? (
419+
<span className="inline-flex shrink-0 items-center gap-1 font-medium text-success-foreground">
420+
<CircleCheckIcon aria-hidden className="size-3" />
421+
Resolved
422+
</span>
423+
) : null}
424+
{dismissed ? <span className="shrink-0 font-medium">Review dismissed</span> : null}
425+
{thread.isOutdated ? <span className="shrink-0 font-medium">Outdated</span> : null}
426+
{expanded ? null : (
427+
<span className="shrink-0">
428+
· {event.actor?.login ?? "ghost"}
429+
{replyCount > 0 ? (
430+
<>
431+
{" "}
432+
· {replyCount.toLocaleString()} {replyCount === 1 ? "reply" : "replies"}
433+
</>
434+
) : null}
435+
</span>
436+
)}
437+
<ChevronDownIcon
438+
aria-hidden
439+
className={cn(
440+
"ml-auto size-3.5 shrink-0 transition-transform",
441+
expanded && "rotate-180",
442+
)}
443+
/>
444+
</button>
445+
<PullRequestResolveThreadButton
446+
environmentId={reactions.environmentId}
447+
reference={reactions.reference}
448+
detail={detail}
449+
thread={thread}
450+
onRefresh={reactions.onRefresh}
430451
/>
431-
</button>
452+
</div>
432453
{expanded ? (
433454
<>
434455
<ConversationCard
@@ -694,6 +715,7 @@ export function PullRequestTimelineTab({
694715
<ReviewThreadEvent
695716
event={event}
696717
thread={event.thread}
718+
detail={detail}
697719
editable={editable}
698720
cwd={detail.workspaceRoot}
699721
onOpen={openOnHost}

0 commit comments

Comments
 (0)