@devries-cameron20 / t3code Mirror · read-only / commits / f3da8ff63b
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 23:30 UTC

feat(gitlab): resolve overview threads from Summary and Timeline (#30575)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Antony committed Nov 11, 2026 at 13:16 UTC f3da8ff63b734917b6a9875b24ef1197707de6ec
18 files changed +421 -149
apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx
+21 -12
@@ -11,7 +11,7 @@ import {
11 squashAtomCommandFailure,
12 } from "@t3tools/client-runtime/state/runtime";
13 import { AsyncResult } from "effect/reactivity";
14 -import type { PullRequestThreadComment } from "@t3tools/contracts";
14 +import { pullRequestConversationThreads, type PullRequestThreadComment } from "@t3tools/contracts";
15 import { useRef, useState } from "react";
16 import { ScrollView, View, type ScrollViewInstance } from "react-native";
17 import { KeyboardAvoidingView, useKeyboardState } from "react-native-keyboard-controller";
@@ -60,7 +60,12 @@ function Discussion({ params }: { params: PullRequestParams & { readonly discuss
60 reportFailure: false,
61 });
62 const loadMore = useAtomCommand(composerPullRequests.threadComments, { reportFailure: false });
63 - const thread = activity.data?.reviewThreads.find((thread) => thread.id === params.discussionId);
63 + const thread =
64 + activity.data &&
65 + pullRequestConversationThreads(activity.data).find(
66 + (thread) => thread.id === params.discussionId,
67 + );
68 + const filePath = thread?.path ?? null;
69 const [body, setBody] = useState("");
70 const completions = usePullRequestCompletions({
71 environmentId: params.environmentId,
@@ -200,20 +205,24 @@ function Discussion({ params }: { params: PullRequestParams & { readonly discuss
205 {activity.isPending && !thread ? <AppActivityIndicator /> : null}
206 {thread ? (
207 <View className="gap-2 pb-4">
203 - <Text selectable className="font-mono text-xs text-foreground-muted">
204 - {thread.path}
205 - {thread.line ? `:${thread.line}` : ""}
206 - </Text>
208 + {thread.path === null ? null : (
209 + <Text selectable className="font-mono text-xs text-foreground-muted">
210 + {thread.path}
211 + {thread.line ? `:${thread.line}` : ""}
212 + </Text>
213 + )}
214 <Text className="text-xs text-foreground-muted">
215 {thread.isResolved ? "Resolved" : "Unresolved"}
216 {thread.isOutdated ? " · Outdated" : ""}
217 </Text>
211 - <Button
212 - label="View file diff"
213 - onPress={() =>
214 - navigation.navigate("PullRequestFile", { ...params, path: thread.path })
215 - }
216 - />
218 + {filePath === null ? null : (
219 + <Button
220 + label="View file diff"
221 + onPress={() =>
222 + navigation.navigate("PullRequestFile", { ...params, path: filePath })
223 + }
224 + />
225 + )}
226 </View>
227 ) : !activity.isPending ? (
228 <Text>This discussion is no longer available.</Text>
apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
+3 -1
@@ -52,6 +52,7 @@ import type { NativeStackNavigationProp } from "@react-navigation/native-stack";
52 import { RegistryContext, useAtomRefresh, useAtomValue } from "@effect/atom-react";
53 import { pullRequestReviewKey } from "./pullRequestReviewDrafts";
54 import {
55 + pullRequestConversationThreads,
56 type PullRequestDetail,
57 type PullRequestListEntry,
58 type PullRequestSummary,
@@ -176,7 +177,8 @@ function usePullRequestActivityRows(params: PullRequestParams, filter: ActivityF
177 ? result.data?.comments.find((comment) => pullRequestAnchorMatchesUrl(anchor, comment.url))
178 : null;
179 const targetThread = anchor
179 - ? result.data?.reviewThreads.find((thread) =>
180 + ? result.data &&
181 + pullRequestConversationThreads(result.data).find((thread) =>
182 thread.comments.some((comment) => pullRequestAnchorMatchesUrl(anchor, comment.url)),
183 )
184 : null;
apps/mobile/src/features/pull-requests/PullRequestTimeline.tsx
+20 -9
@@ -6,7 +6,11 @@ import { PullRequestEntryRow } from "./PullRequestEntryRow";
6 import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
7 import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
8 import IconGitCommit from "@tabler/icons-react-native/IconGitCommit";
9 -import type { PullRequestActivity, PullRequestComment } from "@t3tools/contracts";
9 +import {
10 + pullRequestConversationThreads,
11 + type PullRequestActivity,
12 + type PullRequestComment,
13 +} from "@t3tools/contracts";
14 import { StackActions, type NavigationProp } from "@react-navigation/native";
15 import { useMemo, useState, type ComponentProps, type ReactNode } from "react";
16 import { Pressable, StyleSheet, View } from "react-native";
@@ -216,8 +220,9 @@ export function pullRequestTimelineRows(
220 actions: CommentActions,
221 ) {
222 const linkTarget = parsePullRequestAnchor(params.navigationUrl);
223 + const threads = pullRequestConversationThreads(activity);
224 const discussionIds = new Set(
220 - activity.reviewThreads.flatMap((thread) => thread.comments.map((comment) => comment.id)),
225 + threads.flatMap((thread) => thread.comments.map((comment) => comment.id)),
226 );
227 const events = [
228 ...activity.comments
@@ -239,7 +244,7 @@ export function pullRequestTimelineRows(
244 />
245 ),
246 })),
242 - ...activity.reviewThreads.map((thread) => ({
247 + ...threads.map((thread) => ({
248 key: `discussion:${thread.id}`,
249 date: thread.comments[0]?.createdAt ?? "",
250 content: (
@@ -260,18 +265,24 @@ export function pullRequestTimelineRows(
265 </View>
266 <Pressable
267 accessibilityRole="button"
263 - accessibilityLabel={`Open ${thread.isResolved ? "resolved" : "unresolved"} discussion in ${thread.path}`}
268 + accessibilityLabel={`Open ${thread.isResolved ? "resolved" : "unresolved"} discussion in ${thread.path ?? "the overview"}`}
269 onPress={() =>
270 navigation.navigate("PullRequestDiscussion", { ...params, discussionId: thread.id })
271 }
272 className="gap-2 rounded-2xl bg-grouped-card p-3 active:opacity-70"
273 >
274 <View className="flex-row items-center gap-2">
270 - <SymbolView name="doc.text" size={14} tintColorClassName="accent-icon-muted" />
271 - <Text className="flex-1 font-mono text-xs" numberOfLines={2}>
272 - {thread.path}
273 - {thread.line ? `:${thread.line}` : ""}
274 - </Text>
275 + {thread.path === null ? (
276 + <Text className="flex-1 text-xs">Overview</Text>
277 + ) : (
278 + <>
279 + <SymbolView name="doc.text" size={14} tintColorClassName="accent-icon-muted" />
280 + <Text className="flex-1 font-mono text-xs" numberOfLines={2}>
281 + {thread.path}
282 + {thread.line ? `:${thread.line}` : ""}
283 + </Text>
284 + </>
285 + )}
286 <SymbolView name="chevron.right" size={12} tintColorClassName="accent-icon-muted" />
287 </View>
288 <Text className="text-xs text-foreground-muted">
apps/mobile/src/features/pull-requests/pullRequestActivityFilter.ts
+22 -15
@@ -1,4 +1,9 @@
1 -import type { PullRequestActivity, PullRequestActor } from "@t3tools/contracts";
1 +import {
2 + pullRequestConversationThreads,
3 + type PullRequestActivity,
4 + type PullRequestActor,
5 + type PullRequestConversationThread,
6 +} from "@t3tools/contracts";
7
8 export interface ActivityFilter {
9 readonly kind: "all" | "comments" | "commits";
@@ -25,30 +30,31 @@ function isVerdict(reviewState: string | null) {
30 }
31
32 function eventCount(activity: PullRequestActivity) {
33 + const threads = pullRequestConversationThreads(activity);
34 const discussionIds = new Set(
29 - activity.reviewThreads.flatMap((thread) => thread.comments.map((comment) => comment.id)),
35 + threads.flatMap((thread) => thread.comments.map((comment) => comment.id)),
36 );
37 return (
38 activity.comments.filter((comment) => !discussionIds.has(comment.id)).length +
33 - activity.reviewThreads.length +
39 + threads.length +
40 activity.commits.length
41 );
42 }
43
44 export function filterPullRequestActivity(activity: PullRequestActivity, filter: ActivityFilter) {
39 - const reviewThreads =
40 - filter.kind === "commits"
41 - ? []
42 - : activity.reviewThreads.filter(
43 - (thread) =>
44 - (filter.resolved || !thread.isResolved) &&
45 - (filter.bots ||
46 - (thread.commentCount ?? 0) > thread.comments.length ||
47 - thread.nextCommentsCursor != null ||
48 - thread.comments.some((comment) => !isBot(comment.author))),
49 - );
45 + const shown = (thread: PullRequestConversationThread) =>
46 + filter.kind !== "commits" &&
47 + (filter.resolved || !thread.isResolved) &&
48 + (filter.bots ||
49 + (thread.commentCount ?? 0) > thread.comments.length ||
50 + thread.nextCommentsCursor != null ||
51 + thread.comments.some((comment) => !isBot(comment.author)));
52 + const reviewThreads = activity.reviewThreads.filter(shown);
53 + const overviewThreads = activity.overviewThreads?.filter(shown);
54 const allDiscussionIds = new Set(
51 - activity.reviewThreads.flatMap((thread) => thread.comments.map((comment) => comment.id)),
55 + pullRequestConversationThreads(activity).flatMap((thread) =>
56 + thread.comments.map((comment) => comment.id),
57 + ),
58 );
59 const comments =
60 filter.kind === "commits"
@@ -63,6 +69,7 @@ export function filterPullRequestActivity(activity: PullRequestActivity, filter:
69 ...activity,
70 comments,
71 reviewThreads,
72 + ...(overviewThreads === undefined ? {} : { overviewThreads }),
73 commits: filter.kind === "comments" ? [] : activity.commits,
74 commentsTruncated: filter.kind !== "commits" && activity.commentsTruncated,
75 reviewThreadsTruncated: filter.kind !== "commits" && activity.reviewThreadsTruncated,
apps/server/src/pullRequest/PullRequestService.ts
+3
@@ -1956,6 +1956,9 @@ export const make = Effect.gen(function* () {
1956 ? {}
1957 : { reviewThreadsTruncated: activity.reviewThreadsTruncated }),
1958 reviewThreads: activity.reviewThreads,
1959 + ...(activity.overviewThreads === undefined
1960 + ? {}
1961 + : { overviewThreads: activity.overviewThreads }),
1962 commits: activity.commits,
1963 ...(activity.reactions === undefined ? {} : { reactions: activity.reactions }),
1964 })),
apps/web/src/components/pullRequest/PullRequestResolveThreadButton.tsx new
+66
@@ -0,0 +1,66 @@
1 +import type {
2 + EnvironmentId,
3 + PullRequestDetailView,
4 + PullRequestRef,
5 + PullRequestConversationThread,
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, so threads without a diff line (such as
18 + * GitLab overview threads) can be resolved too. Callers put it on the thread's first comment only.
19 + */
20 +export function PullRequestResolveThreadButton({
21 + environmentId,
22 + reference,
23 + detail,
24 + thread,
25 + onRefresh,
26 +}: {
27 + environmentId: EnvironmentId;
28 + reference: PullRequestRef;
29 + detail: PullRequestDetailView;
30 + thread: Pick<PullRequestConversationThread, "id" | "isResolved" | "canResolve">;
31 + onRefresh: () => void;
32 +}) {
33 + const [pending, setPending] = useState(false);
34 + const setThreadResolution = useAtomCommand(pullRequestEnvironment.setThreadResolution, {
35 + reportFailure: false,
36 + });
37 + if (!detail.capabilities.review.resolve || !canResolvePullRequestThread(detail, thread)) {
38 + return null;
39 + }
40 +
41 + const toggle = async () => {
42 + setPending(true);
43 + const result = await setThreadResolution({
44 + environmentId,
45 + input: { ...reference, threadId: thread.id, resolved: !thread.isResolved },
46 + });
47 + setPending(false);
48 + if (result._tag === "Failure") {
49 + toastManager.add({ type: "error", title: "The conversation could not be updated" });
50 + return;
51 + }
52 + onRefresh();
53 + };
54 +
55 + return (
56 + <Button
57 + size="xs"
58 + variant="ghost"
59 + className="shrink-0"
60 + disabled={pending}
61 + onClick={() => void toggle()}
62 + >
63 + {thread.isResolved ? "Unresolve" : "Resolve"}
64 + </Button>
65 + );
66 +}
apps/web/src/components/pullRequest/PullRequestSummaryTab.browser.test.tsx
+46
@@ -185,3 +185,49 @@ it("leaves description checkboxes read-only without the right to edit it", async
185 true,
186 );
187 });
188 +
189 +it("fixes an overview thread as its opening remark, since it has no line to attach", async () => {
190 + setup();
191 + const author = { login: "reviewer", name: null, avatarUrl: null };
192 + const note = { author, createdAt: "2026-09-01T00:00:00Z", url: null };
193 + const remark = {
194 + ...note,
195 + id: "10",
196 + kind: "review-comment" as const,
197 + body: "Mention the flag in the README",
198 + path: null,
199 + reviewState: null,
200 + };
201 + const onFixFinding = vi.fn();
202 + const value: PullRequestDetailView = {
203 + ...detail,
204 + comments: [remark],
205 + overviewThreads: [
206 + {
207 + id: "overview",
208 + path: null,
209 + line: null,
210 + side: "right",
211 + isResolved: false,
212 + isOutdated: false,
213 + comments: [{ ...note, id: "10", body: remark.body }],
214 + },
215 + ],
216 + };
217 + await using screen = await renderUi(
218 + <PullRequestSummaryTab
219 + scrollerRef={() => {}}
220 + environmentId={EnvironmentId.make("environment")}
221 + threadRef={null}
222 + reference={value}
223 + detail={value}
224 + activityPending={false}
225 + activityError={null}
226 + onRefresh={() => {}}
227 + onFixFinding={onFixFinding}
228 + />,
229 + );
230 +
231 + await userEvent.click(screen.getByRole("button", { name: "Fix in a thread" }));
232 + expect(onFixFinding).toHaveBeenCalledWith({ kind: "comment", comment: remark });
233 +});
apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx
+37 -14
@@ -6,13 +6,14 @@ import {
6 sourceControlClients,
7 } from "@t3tools/client-runtime/source-control-clients";
8 import { useAtomCommand } from "~/state/use-atom-command";
9 -import type {
10 - EnvironmentId,
11 - PullRequestComment,
12 - PullRequestDetailView,
13 - PullRequestRef,
14 - PullRequestReviewThread,
15 - ScopedThreadRef,
9 +import {
10 + type EnvironmentId,
11 + type PullRequestComment,
12 + type PullRequestDetailView,
13 + type PullRequestRef,
14 + type PullRequestConversationThread,
15 + type ScopedThreadRef,
16 + pullRequestConversationThreads,
17 } from "@t3tools/contracts";
18 import {
19 ArrowDownUpIcon,
@@ -93,6 +94,7 @@ import {
94 pullRequestCompletionScope,
95 } from "./PullRequestMarkdownTextarea";
96 import { PullRequestReactionBar } from "./PullRequestReactions";
97 +import { PullRequestResolveThreadButton } from "./PullRequestResolveThreadButton";
98 import { PullRequestConversationGhost } from "./PullRequestGhosts";
99 import { sectionCollapseAnchorScrollTop } from "./pullRequestSummaryScroll.logic";
100
@@ -147,7 +149,7 @@ function CommentLocation({
149 thread,
150 }: {
151 comment: PullRequestComment;
150 - thread: PullRequestReviewThread | undefined;
152 + thread: PullRequestConversationThread | undefined;
153 }) {
154 const path = thread?.path ?? comment.path;
155 if (!path) return null;
@@ -228,9 +230,10 @@ function CommentBody({
230 */
231 function chatSubject(
232 comment: PullRequestComment,
231 - thread: PullRequestReviewThread | undefined,
233 + thread: PullRequestConversationThread | undefined,
234 ): PullRequestChatSubject | null {
233 - if (thread !== undefined) {
235 + // An overview thread has no line to attach, so it goes as its opening remark, as fixing it does.
236 + if (thread !== undefined && thread.path !== null) {
237 return thread.comments.some((entry) => visibleBody(entry.body) !== null)
238 ? { kind: "thread", thread }
239 : null;
@@ -256,6 +259,7 @@ function CollapsedComment({
259 label,
260 body,
261 reactionBar,
262 + resolveButton,
263 detail,
264 thread,
265 replyCount = 0,
@@ -268,8 +272,9 @@ function CollapsedComment({
272 label: string;
273 body: string | null;
274 reactionBar: ReactNode;
275 + resolveButton: ReactNode;
276 detail: PullRequestDetailView;
272 - thread: PullRequestReviewThread | undefined;
277 + thread: PullRequestConversationThread | undefined;
278 replyCount?: number;
279 replies?: ReactNode;
280 moreReplies?: ReactNode;
@@ -298,6 +303,8 @@ function CollapsedComment({
303 className={cn("size-3.5 transition-transform", open && "rotate-180")}
304 />
305 </CollapsibleTrigger>
306 + {/* Collapsed, the status label already says "Resolved". */}
307 + {open ? resolveButton : null}
308 {onAddToChat ? <AddToChatButton onClick={onAddToChat} /> : null}
309 {reactionBar}
310 </div>
@@ -481,7 +488,10 @@ export function PullRequestSummaryTab({
488 DEFAULT_COMMENT_FILTER,
489 CommentFilterSchema,
490 );
484 - const items = pullRequestConversationItems(detail.comments, detail.reviewThreads);
491 + const items = pullRequestConversationItems(
492 + detail.comments,
493 + pullRequestConversationThreads(detail),
494 + );
495 const filteredItems = filterPullRequestConversationItems(items, commentFilter);
496 const commentCount = items.reduce(
497 (count, item) => count + pullRequestConversationItemComments(item).length,
@@ -696,9 +706,20 @@ export function PullRequestSummaryTab({
706 />
707 );
708
709 + const resolveButtonFor = (thread: PullRequestConversationThread | undefined) =>
710 + thread === undefined ? null : (
711 + <PullRequestResolveThreadButton
712 + environmentId={environmentId}
713 + reference={reference}
714 + detail={detail}
715 + thread={thread}
716 + onRefresh={onRefresh}
717 + />
718 + );
719 +
720 const renderCommentCard = (
721 comment: PullRequestComment,
701 - thread: PullRequestReviewThread | undefined,
722 + thread: PullRequestConversationThread | undefined,
723 { reply = false }: { reply?: boolean } = {},
724 ) => {
725 const body = visibleBody(comment.body);
@@ -708,7 +729,7 @@ export function PullRequestSummaryTab({
729 (comment.kind !== "review" && comment.kind !== "review-comment") ||
730 outcome === "approved"
731 ? null
711 - : thread === undefined
732 + : thread === undefined || thread.path === null
733 ? body === null
734 ? null
735 : { kind: "comment", comment }
@@ -747,6 +768,7 @@ export function PullRequestSummaryTab({
768 </span>
769 </Button>
770 ) : null}
771 + {resolveButtonFor(thread)}
772 {onAddToChat && chat !== null ? (
773 <AddToChatButton onClick={() => onAddToChat(chat)} />
774 ) : null}
@@ -791,6 +813,7 @@ export function PullRequestSummaryTab({
813 moreReplies={moreReplies}
814 onAddToChat={onAddToChat && chat !== null ? () => onAddToChat(chat) : undefined}
815 reactionBar={reactionBarFor(comment)}
816 + resolveButton={resolveButtonFor(thread)}
817 />
818 );
819 }
apps/web/src/components/pullRequest/PullRequestTimelineTab.tsx
+57 -33
@@ -56,6 +56,7 @@ import { PullRequestMarkdown } from "./PullRequestMarkdown";
56 import { PullRequestMoreReplies } from "./PullRequestMoreReplies";
57 import { PullRequestMarkdownEditor } from "./PullRequestMarkdownEditor";
58 import { PullRequestReactionBar } from "./PullRequestReactions";
59 +import { PullRequestResolveThreadButton } from "./PullRequestResolveThreadButton";
60 import {
61 PullRequestActorAvatar,
62 PullRequestDiffStat,
@@ -443,10 +444,12 @@ function ReviewThreadEvent({
444 cwd,
445 onOpen,
446 reactions,
447 + detail,
448 }: {
449 revealAnchor?: string | null;
450 event: PullRequestTimelineEvent;
451 thread: PullRequestTimelineThread;
452 + detail: PullRequestDetailView;
453 editable: ReadonlyMap<string, PullRequestComment>;
454 cwd: string;
455 onOpen: (url: string) => void;
@@ -471,40 +474,60 @@ function ReviewThreadEvent({
474 fallback={<MessageSquareIcon className="size-3.5" />}
475 muted={!expanded}
476 />
474 - <button
475 - type="button"
476 - 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"
477 - aria-expanded={expanded}
478 - onClick={() => setExpanded((current) => !current)}
479 - >
480 - <FileCode2Icon aria-hidden className="size-3 shrink-0" />
481 - <span className="min-w-0 truncate font-mono">
482 - {thread.line === null ? thread.path : `${thread.path}:${thread.line}`}
483 - </span>
484 - {thread.isResolved ? (
485 - <span className="inline-flex shrink-0 items-center gap-1 font-medium text-success-foreground">
486 - <CircleCheckIcon aria-hidden className="size-3" />
487 - Resolved
488 - </span>
477 + <div className="flex min-w-0 items-center gap-1">
478 + <button
479 + type="button"
480 + 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"
481 + aria-expanded={expanded}
482 + onClick={() => setExpanded((current) => !current)}
483 + >
484 + {thread.path === null ? (
485 + <span className="min-w-0 truncate">Overview</span>
486 + ) : (
487 + <>
488 + <FileCode2Icon aria-hidden className="size-3 shrink-0" />
489 + <span className="min-w-0 truncate font-mono">
490 + {thread.line === null ? thread.path : `${thread.path}:${thread.line}`}
491 + </span>
492 + </>
493 + )}
494 + {thread.isResolved ? (
495 + <span className="inline-flex shrink-0 items-center gap-1 font-medium text-success-foreground">
496 + <CircleCheckIcon aria-hidden className="size-3" />
497 + Resolved
498 + </span>
499 + ) : null}
500 + {dismissed ? <span className="shrink-0 font-medium">Review dismissed</span> : null}
501 + {thread.isOutdated ? <span className="shrink-0 font-medium">Outdated</span> : null}
502 + {expanded ? null : (
503 + <span className="shrink-0">
504 + · {event.actor?.login ?? "ghost"}
505 + {replyCount > 0 ? (
506 + <>
507 + {" "}
508 + · {replyCount.toLocaleString()} {replyCount === 1 ? "reply" : "replies"}
509 + </>
510 + ) : null}
511 + </span>
512 + )}
513 + <ChevronDownIcon
514 + aria-hidden
515 + className={cn(
516 + "ml-auto size-3.5 shrink-0 transition-transform",
517 + expanded && "rotate-180",
518 + )}
519 + />
520 + </button>
521 + {expanded ? (
522 + <PullRequestResolveThreadButton
523 + environmentId={reactions.environmentId}
524 + reference={reactions.reference}
525 + detail={detail}
526 + thread={thread}
527 + onRefresh={reactions.onRefresh}
528 + />
529 ) : null}
490 - {dismissed ? <span className="shrink-0 font-medium">Review dismissed</span> : null}
491 - {thread.isOutdated ? <span className="shrink-0 font-medium">Outdated</span> : null}
492 - {expanded ? null : (
493 - <span className="shrink-0">
494 - · {event.actor?.login ?? "ghost"}
495 - {replyCount > 0 ? (
496 - <>
497 - {" "}
498 - · {replyCount.toLocaleString()} {replyCount === 1 ? "reply" : "replies"}
499 - </>
500 - ) : null}
501 - </span>
502 - )}
503 - <ChevronDownIcon
504 - aria-hidden
505 - className={cn("ml-auto size-3.5 shrink-0 transition-transform", expanded && "rotate-180")}
506 - />
507 - </button>
530 + </div>
531 {expanded ? (
532 <>
533 <ConversationCard
@@ -828,6 +851,7 @@ export function PullRequestTimelineTab({
851 <ReviewThreadEvent
852 event={event}
853 thread={event.thread}
854 + detail={detail}
855 revealAnchor={anchor}
856 editable={editable}
857 cwd={detail.workspaceRoot}
apps/web/src/components/pullRequest/pullRequestDetail.logic.ts
+15 -6
@@ -32,6 +32,7 @@ import {
32 type PullRequestMergeMethod,
33 type PullRequestRef,
34 type RepositoryIdentity,
35 + type PullRequestConversationThread,
36 type PullRequestReviewThread,
37 type PullRequestState,
38 type PullRequestUpdateMethod,
@@ -487,7 +488,10 @@ export interface PullRequestReplyAvailability {
488
489 export interface PullRequestTimelineThread
490 extends
490 - Pick<PullRequestReviewThread, "path" | "line" | "isResolved" | "isOutdated">,
491 + Pick<
492 + PullRequestConversationThread,
493 + "id" | "path" | "line" | "isResolved" | "isOutdated" | "canResolve"
494 + >,
495 PullRequestReplyAvailability {
496 readonly replies: ReadonlyArray<PullRequestTimelineEvent>;
497 }
@@ -557,12 +561,12 @@ export type PullRequestConversationItem =
561 readonly createdAt: string;
562 readonly root: PullRequestComment;
563 readonly replies: ReadonlyArray<PullRequestComment>;
560 - readonly thread: PullRequestReviewThread;
564 + readonly thread: PullRequestConversationThread;
565 } & PullRequestReplyAvailability);
566
567 export function pullRequestConversationItems(
568 comments: ReadonlyArray<PullRequestComment>,
565 - reviewThreads: ReadonlyArray<PullRequestReviewThread>,
569 + reviewThreads: ReadonlyArray<PullRequestConversationThread>,
570 ): ReadonlyArray<PullRequestConversationItem> {
571 const byId = new Map(comments.map((comment) => [comment.id, comment]));
572 const claimed = new Set<string>();
@@ -623,7 +627,7 @@ export function pullRequestConversationItemComments(
627
628 export function isPullRequestCommentFinished(
629 comment: PullRequestComment,
626 - thread?: PullRequestReviewThread,
630 + thread?: PullRequestConversationThread,
631 ): boolean {
632 return (
633 thread?.isResolved === true || pullRequestReviewOutcome(comment.reviewState) === "dismissed"
@@ -780,7 +784,7 @@ export function buildPullRequestTimeline(
784 PullRequestDetailView,
785 "provider" | "createdAt" | "author" | "commits" | "comments" | "mergedAt" | "closedAt"
786 > &
783 - Partial<Pick<PullRequestDetailView, "reviewThreads">>,
787 + Partial<Pick<PullRequestDetailView, "reviewThreads" | "overviewThreads">>,
788 ): ReadonlyArray<PullRequestTimelineEvent> {
789 const term = sourceControlClients.get(detail.provider).changeRequest.singular;
790 return [
@@ -816,11 +820,16 @@ export function buildPullRequestTimeline(
820 reviewState: null,
821 reactions: [],
822 })),
819 - ...pullRequestConversationItems(detail.comments, detail.reviewThreads ?? []).map((item) => {
823 + ...pullRequestConversationItems(detail.comments, [
824 + ...(detail.reviewThreads ?? []),
825 + ...(detail.overviewThreads ?? []),
826 + ]).map((item) => {
827 if (item.kind === "comment") return commentTimelineEvent(item.comment);
828 return {
829 ...commentTimelineEvent(item.root),
830 thread: {
831 + id: item.thread.id,
832 + ...(item.thread.canResolve === undefined ? {} : { canResolve: item.thread.canResolve }),
833 path: item.thread.path,
834 line: item.thread.line,
835 isResolved: item.thread.isResolved,
apps/web/src/components/pullRequest/usePullRequestDetail.ts
+3
@@ -182,6 +182,9 @@ export function usePullRequestDetail(
182 ),
183 commentsTruncated: activity?.commentsTruncated ?? false,
184 reviewThreads: activity?.reviewThreads ?? [],
185 + ...(activity?.overviewThreads === undefined
186 + ? {}
187 + : { overviewThreads: activity.overviewThreads }),
188 commits: activity?.commits ?? [],
189 reactions: activity?.reactions ?? [],
190 };
packages/contracts/src/pullRequest.ts
+19
@@ -196,6 +196,16 @@ export const PullRequestReviewThread = Schema.Struct({
196 });
197 export type PullRequestReviewThread = typeof PullRequestReviewThread.Type;
198
199 +/** A thread on the change request as a whole, such as a GitLab overview thread. */
200 +export const PullRequestOverviewThread = Schema.Struct({
201 + ...PullRequestReviewThread.fields,
202 + path: Schema.Null,
203 + line: Schema.Null,
204 +});
205 +export type PullRequestOverviewThread = typeof PullRequestOverviewThread.Type;
206 +
207 +export type PullRequestConversationThread = PullRequestReviewThread | PullRequestOverviewThread;
208 +
209 export const PullRequestReviewerKind = Schema.Literals(["user", "team"]);
210 export type PullRequestReviewerKind = typeof PullRequestReviewerKind.Type;
211
@@ -667,11 +677,20 @@ export const PullRequestActivity = Schema.Struct({
677 commentsTruncated: Schema.Boolean,
678 reviewThreadsTruncated: Schema.optional(Schema.Boolean),
679 reviewThreads: Schema.Array(PullRequestReviewThread),
680 + // Apart from reviewThreads so clients that require a thread path still decode the activity.
681 + overviewThreads: Schema.optional(Schema.Array(PullRequestOverviewThread)),
682 commits: Schema.Array(PullRequestCommit),
683 reactions: Schema.optional(Schema.Array(PullRequestReaction)),
684 });
685 export type PullRequestActivity = typeof PullRequestActivity.Type;
686
687 +export const pullRequestConversationThreads = (
688 + activity: Pick<PullRequestActivity, "reviewThreads" | "overviewThreads">,
689 +): ReadonlyArray<PullRequestConversationThread> =>
690 + activity.overviewThreads === undefined || activity.overviewThreads.length === 0
691 + ? activity.reviewThreads
692 + : [...activity.reviewThreads, ...activity.overviewThreads];
693 +
694 export const PullRequestDetailView = Schema.Struct({
695 ...PullRequestDetail.fields,
696 ...PullRequestActivity.fields,
packages/source-control-core/src/server/PullRequestProvider.ts
+2
@@ -28,6 +28,7 @@ import type {
28 PullRequestReactionContent,
29 PullRequestReviewCommentDraft,
30 PullRequestReviewDecision,
31 + PullRequestOverviewThread,
32 PullRequestReviewThread,
33 PullRequestThreadCommentsResult,
34 PullRequestReviewVerdict,
@@ -221,6 +222,7 @@ export interface ProviderChangeRequestActivity {
222 readonly commentsTruncated: boolean;
223 readonly reviewThreadsTruncated?: boolean;
224 readonly reviewThreads: ReadonlyArray<PullRequestReviewThread>;
225 + readonly overviewThreads?: ReadonlyArray<PullRequestOverviewThread>;
226 readonly commits: ReadonlyArray<PullRequestCommit>;
227 readonly reactions?: ReadonlyArray<PullRequestReaction>;
228 }
packages/source-control-gitlab/src/server/GitLabPullRequestCli.test.ts
+6 -1
@@ -1417,7 +1417,7 @@ layer("GitLabPullRequestCli.layer", (it) => {
1417 );
1418
1419 it.effect(
1420 - "reads a positioned discussion as a thread and an open overview discussion as a finding",
1420 + "reads a positioned discussion at its line and an overview discussion as a thread and a finding",
1421 () =>
1422 Effect.gen(function* () {
1423 mockedExecute.mockReturnValueOnce(
@@ -1534,9 +1534,14 @@ layer("GitLabPullRequestCli.layer", (it) => {
1534 expect(overviewFindingIds).toEqual(["4"]);
1535 expect(threads.map(({ id, path, line, side }) => ({ id, path, line, side }))).toEqual([
1536 { id: "abc123", path: "src/a.ts", line: 12, side: "right" },
1537 + { id: "ghi789", path: null, line: null, side: "right" },
1538 + { id: "jkl012", path: null, line: null, side: "right" },
1539 { id: "file789", path: "src/b.ts", line: null, side: "right" },
1540 { id: "img012", path: "logo.png", line: null, side: "right" },
1541 ]);
1542 + expect(threads[1]).toMatchObject({ isResolved: false });
1543 + expect(threads[1]?.comments.map(({ id }) => id)).toEqual(["4", "5"]);
1544 + expect(threads[2]).toMatchObject({ isResolved: true });
1545 expect([...diffRefsByThreadId]).toEqual([
1546 ["abc123", { baseSha: "base", startSha: "start", headSha: "head" }],
1547 ]);
packages/source-control-gitlab/src/server/GitLabPullRequestCli.ts
+3 -3
@@ -29,7 +29,7 @@ import type {
29 PullRequestReactionContent,
30 PullRequestReviewCommentDraft,
31 PullRequestReviewPosition,
32 - PullRequestReviewThread,
32 + PullRequestConversationThread,
33 PullRequestReviewVerdict,
34 PullRequestReviewerCandidateList,
35 } from "@t3tools/contracts";
@@ -345,7 +345,7 @@ const isVcsProcessExitError = Schema.is(VcsProcessExitError);
345 const DIFF_FILE_MAX_OUTPUT_BYTES = 1024 * 1024;
346
347 export interface GitLabDiscussionThreads {
348 - readonly threads: ReadonlyArray<PullRequestReviewThread>;
348 + readonly threads: ReadonlyArray<PullRequestConversationThread>;
349 readonly diffRefsByThreadId: ReadonlyMap<string, GitLabDiffRefs>;
350 readonly overviewFindingIds: ReadonlyArray<string>;
351 readonly truncated: boolean;
@@ -1310,7 +1310,7 @@ export const make = Effect.gen(function* () {
1310 readonly repository: string;
1311 readonly number: number;
1312 readonly page: number;
1313 - readonly collected: ReadonlyArray<PullRequestReviewThread>;
1313 + readonly collected: ReadonlyArray<PullRequestConversationThread>;
1314 readonly collectedDiffRefs: ReadonlyMap<string, GitLabDiffRefs>;
1315 readonly collectedFindingIds: ReadonlyArray<string>;
1316 }): Effect.Effect<GitLabDiscussionThreads, GitLabPullRequestCliError> =>
packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts
+44 -27
@@ -605,35 +605,51 @@ describe("optional activity reads", () => {
605 }),
606 );
607
608 - it.effect("turns the first note of an open overview discussion into a review finding", () =>
609 - Effect.gen(function* () {
610 - const finding = { ...comment, id: "10", body: "Mention the flag in the README" };
611 - const reply = { ...comment, id: "11", body: "Will do" };
612 - const provider = yield* make.pipe(
613 - Effect.provide(
614 - Layer.mock(GitLabPullRequestCli.GitLabPullRequestCli)({
615 - ...reads,
616 - listNotes: () =>
617 - Effect.succeed({ comments: [comment, finding, reply], truncated: false }),
618 - listDiscussions: () =>
619 - Effect.succeed({
620 - threads: [],
621 - diffRefsByThreadId: new Map(),
622 - overviewFindingIds: ["10"],
623 - truncated: false,
624 - }),
625 - }),
626 - ),
627 - );
608 + it.effect(
609 + "turns an open overview discussion into a finding and a thread apart from file threads",
610 + () =>
611 + Effect.gen(function* () {
612 + const finding = { ...comment, id: "10", body: "Mention the flag in the README" };
613 + const reply = { ...comment, id: "11", body: "Will do" };
614 + const thread = {
615 + side: "right",
616 + isResolved: false,
617 + isOutdated: false,
618 + comments: [],
619 + } as const;
620 + const provider = yield* make.pipe(
621 + Effect.provide(
622 + Layer.mock(GitLabPullRequestCli.GitLabPullRequestCli)({
623 + ...reads,
624 + listNotes: () =>
625 + Effect.succeed({ comments: [comment, finding, reply], truncated: false }),
626 + listDiscussions: () =>
627 + Effect.succeed({
628 + threads: [
629 + { ...thread, id: "overview", path: null, line: null },
630 + { ...thread, id: "file", path: "src/a.ts", line: 3 },
631 + ],
632 + diffRefsByThreadId: new Map(),
633 + overviewFindingIds: ["10"],
634 + truncated: false,
635 + }),
636 + }),
637 + ),
638 + );
639
629 - const { comments } = yield* provider.getChangeRequestActivity(reference);
640 + const { comments, reviewThreads, overviewThreads } =
641 + yield* provider.getChangeRequestActivity(reference);
642
631 - expect(comments.map((item) => [item.id, item.kind])).toEqual([
632 - ["42", "issue-comment"],
633 - ["10", "review-comment"],
634 - ["11", "issue-comment"],
635 - ]);
636 - }),
643 + // Clients that require a thread path must never receive one without it.
644 + expect(reviewThreads.map(({ id }) => id)).toEqual(["file"]);
645 + expect(overviewThreads?.map(({ id }) => id)).toEqual(["overview"]);
646 +
647 + expect(comments.map((item) => [item.id, item.kind])).toEqual([
648 + ["42", "issue-comment"],
649 + ["10", "review-comment"],
650 + ["11", "issue-comment"],
651 + ]);
652 + }),
653 );
654
655 it.effect("dates edited comments in the conversation and in threads", () =>
@@ -785,6 +801,7 @@ describe("optional activity reads", () => {
801 commentCount: 1,
802 commentsTruncated: true,
803 reviewThreads: [],
804 + overviewThreads: [],
805 reactions: [],
806 commits: [commit],
807 });
packages/source-control-gitlab/src/server/GitLabPullRequestProvider.ts
+27 -14
@@ -8,6 +8,7 @@ import type {
8 PullRequestActor,
9 PullRequestCapabilities,
10 PullRequestReaction,
11 + PullRequestThreadComment,
12 PullRequestViewerPermissions,
13 } from "@t3tools/contracts";
14
@@ -423,6 +424,13 @@ export const make = Effect.gen(function* () {
424 author !== null && botLogins.has(author.login.toLowerCase())
425 ? { ...author, isBot: true }
426 : author;
427 + const withNoteDetails = (comment: PullRequestThreadComment) => ({
428 + ...comment,
429 + ...edited(comment.id),
430 + author: withBotFlag(comment.author),
431 + url: noteUrl(comment.id),
432 + reactions: awards.reactionsByNoteId.get(comment.id) ?? [],
433 + });
434 return {
435 reactions: awards.reactions,
436 comments: notes.comments.map((comment) => ({
@@ -435,20 +443,25 @@ export const make = Effect.gen(function* () {
443 })),
444 commentCount: notes.comments.length,
445 commentsTruncated: notes.truncated || discussions.truncated,
438 - reviewThreads: discussions.threads.map((thread) => ({
439 - ...thread,
440 - isOutdated: isOutdated(
441 - discussions.diffRefsByThreadId.get(thread.id),
442 - detail?.diffRefs,
443 - ),
444 - comments: thread.comments.map((comment) => ({
445 - ...comment,
446 - ...edited(comment.id),
447 - author: withBotFlag(comment.author),
448 - url: noteUrl(comment.id),
449 - reactions: awards.reactionsByNoteId.get(comment.id) ?? [],
450 - })),
451 - })),
446 + reviewThreads: discussions.threads.flatMap((thread) =>
447 + thread.path === null
448 + ? []
449 + : [
450 + {
451 + ...thread,
452 + isOutdated: isOutdated(
453 + discussions.diffRefsByThreadId.get(thread.id),
454 + detail?.diffRefs,
455 + ),
456 + comments: thread.comments.map(withNoteDetails),
457 + },
458 + ],
459 + ),
460 + overviewThreads: discussions.threads.flatMap((thread) =>
461 + thread.path === null
462 + ? [{ ...thread, comments: thread.comments.map(withNoteDetails) }]
463 + : [],
464 + ),
465 commits,
466 };
467 },
packages/source-control-gitlab/src/server/gitLabMergeRequestJson.ts
+27 -14
@@ -18,7 +18,7 @@ import type {
18 PullRequestReactionContent,
19 PullRequestReferenceCandidate,
20 PullRequestReviewDecision,
21 - PullRequestReviewThread,
21 + PullRequestConversationThread,
22 PullRequestReviewerCandidate,
23 PullRequestState,
24 } from "@t3tools/contracts";
@@ -789,7 +789,7 @@ export interface GitLabDiffRefs {
789 }
790
791 export interface GitLabDiscussions {
792 - readonly threads: ReadonlyArray<PullRequestReviewThread>;
792 + readonly threads: ReadonlyArray<PullRequestConversationThread>;
793 /** GitLab moves a thread onto each new diff that still has its line; this is the last one. */
794 readonly diffRefsByThreadId: ReadonlyMap<string, GitLabDiffRefs>;
795 /** First notes of unresolved discussions on the MR itself rather than a diff line. */
@@ -808,7 +808,7 @@ export function decodeDiscussionsJson(
808 if (!Result.isSuccess(decoded)) {
809 return Result.fail(decoded.failure);
810 }
811 - const threads: PullRequestReviewThread[] = [];
811 + const threads: PullRequestConversationThread[] = [];
812 const diffRefsByThreadId = new Map<string, GitLabDiffRefs>();
813 const overviewFindingIds: string[] = [];
814 for (const entry of decoded.success) {
@@ -816,11 +816,30 @@ export function decodeDiscussionsJson(
816 if (!Exit.isSuccess(discussion)) continue;
817 const notes = (discussion.value.notes ?? []).filter((note) => note.system !== true);
818 const root = notes[0];
819 - const position = root?.position;
820 - if (root !== undefined && !position && root.resolvable === true && root.resolved !== true) {
821 - overviewFindingIds.push(String(root.id));
819 + if (root === undefined) continue;
820 + const comments = notes.map((note) => ({
821 + id: String(note.id),
822 + author: toActor(note.author),
823 + body: note.body ?? "",
824 + createdAt: note.created_at,
825 + url: null,
826 + }));
827 + const position = root.position;
828 + if (!position) {
829 + // A thread started on the overview: resolvable, unlike a single comment.
830 + if (root.resolvable !== true) continue;
831 + if (root.resolved !== true) overviewFindingIds.push(String(root.id));
832 + threads.push({
833 + id: discussion.value.id,
834 + path: null,
835 + line: null,
836 + side: "right",
837 + isResolved: root.resolved === true,
838 + isOutdated: false,
839 + comments,
840 + });
841 + continue;
842 }
823 - if (root === undefined || !position) continue;
843 let side: "left" | "right";
844 let path: string | null;
845 let line: number | null | undefined;
@@ -850,13 +869,7 @@ export function decodeDiscussionsJson(
869 side,
870 isResolved: root.resolved === true,
871 isOutdated: false,
853 - comments: notes.map((note) => ({
854 - id: String(note.id),
855 - author: toActor(note.author),
856 - body: note.body ?? "",
857 - createdAt: note.created_at,
858 - url: null,
859 - })),
872 + comments,
873 });
874 }
875 return Result.succeed({