Skip to content

Commit 2433ea1

Browse files
committed
fix: preserve source behavior against current upstream contracts
1 parent b079345 commit 2433ea1

5 files changed

Lines changed: 48 additions & 39 deletions

File tree

‎apps/mobile/src/features/threads/useThreadHeaderOptions.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @vitest-environment jsdom
12
import type { VcsStatusResult } from "@t3tools/contracts";
23
import { act, useEffect } from "react";
34
import { createRoot, type Root } from "react-dom/client";

‎apps/server/src/git/GitManager.test.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6002,9 +6002,15 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
60026002

60036003
const preview = yield* driver.getReviewDiffPreview({ cwd: worktreePath });
60046004
const changes = preview.sources.find((source) => source.kind === "branch-range")!;
6005-
expect
6006-
.soft(changes.files)
6007-
.toEqual([{ path: "feature.txt", previousPath: null, additions: 1, deletions: 0 }]);
6005+
expect.soft(changes.files).toEqual([
6006+
{
6007+
path: "feature.txt",
6008+
previousPath: null,
6009+
additions: 1,
6010+
deletions: 0,
6011+
status: "added",
6012+
},
6013+
]);
60086014
yield* runGit(worktreePath, ["push", "-u", "origin", "feature/remote-base"]);
60096015

60106016
const generatedInputs: TextGeneration.PrContentGenerationInput[] = [];

‎apps/server/src/vcs/GitVcsDriverCore.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5593,7 +5593,7 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
55935593
const preview = yield* driver.getReviewDiffPreview({ cwd: worktreePath });
55945594
const changes = preview.sources.find((source) => source.kind === "branch-range")!;
55955595
assert.deepStrictEqual(changes.files, [
5596-
{ path: "feature.txt", previousPath: null, additions: 1, deletions: 0 },
5596+
{ path: "feature.txt", previousPath: null, additions: 1, deletions: 0, status: "added" },
55975597
]);
55985598
assert.include(changes.diff, "+feature work");
55995599
assert.notInclude(changes.diff, "upstream-only work");
@@ -5876,7 +5876,7 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
58765876
const preview = yield* driver.getReviewDiffPreview({ cwd });
58775877
const changes = preview.sources.find((source) => source.kind === "branch-range")!;
58785878
assert.deepStrictEqual(changes.files, [
5879-
{ path: "feature.txt", previousPath: null, additions: 1, deletions: 0 },
5879+
{ path: "feature.txt", previousPath: null, additions: 1, deletions: 0, status: "added" },
58805880
]);
58815881
assert.equal(changes.baseRef, "upstream/dev");
58825882
}),

‎apps/web/src/components/pullRequest/pullRequestDetail.logic.test.ts‎

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -835,35 +835,30 @@ describe("review thread conversations", () => {
835835
comments: [lastReply, { ...finding, body: "Stale finding" }, reply],
836836
};
837837

838-
it("keeps a timeline finding and its replies in one row at the finding time", () => {
838+
it("keeps a timeline finding and replies together at the latest activity time", () => {
839839
const events = buildPullRequestTimeline({
840840
...TIMELINE_SOURCE,
841841
comments,
842842
reviewThreads: [thread],
843843
});
844-
expect(events.map((event) => event.id)).toEqual(["c1", "finding", "1baf7bdcafe", "created"]);
845-
expect(events[1]).toMatchObject({
846-
id: finding.id,
847-
at: finding.createdAt,
848-
body: finding.body,
849-
url: finding.url,
850-
thread: {
851-
path: thread.path,
852-
line: 7,
853-
isOutdated: true,
854-
replies: [
855-
{ id: reply.id, body: reply.body, url: reply.url, reactions: reply.reactions },
856-
{ id: lastReply.id, body: lastReply.body, url: lastReply.url },
857-
],
858-
},
844+
expect(events.map((event) => event.id)).toEqual([
845+
"thread:thread",
846+
"c1",
847+
"1baf7bdcafe",
848+
"created",
849+
]);
850+
expect(events[0]).toMatchObject({
851+
at: lastReply.createdAt,
852+
reviewThread: { ...thread, comments: [finding, reply, lastReply] },
859853
});
854+
expect(events[0]?.reviewThread?.comments).toEqual([finding, reply, lastReply]);
860855
expect(groupPullRequestTimelineConversations(events).map((row) => row.kind)).toEqual([
861-
"comments",
862856
"event",
857+
"comments",
863858
"event",
864859
"event",
865860
]);
866-
expect(events[0]).toEqual(buildPullRequestTimeline(TIMELINE_SOURCE)[0]);
861+
expect(events[1]).toEqual(buildPullRequestTimeline(TIMELINE_SOURCE)[0]);
867862
});
868863

869864
it("orders and pages whole Summary conversations while retaining editable comment copies", () => {
@@ -921,24 +916,25 @@ describe("review thread conversations", () => {
921916
);
922917
});
923918

924-
it("distinguishes unloaded replies from complete threads, even when the host only supplies a cursor", () => {
925-
const timeline = (reviewThread: PullRequestReviewThread) =>
926-
buildPullRequestTimeline({
919+
it("retains reply pagination metadata for the shared review thread card", () => {
920+
for (const reviewThread of [
921+
{ ...thread, commentCount: 5 },
922+
{ ...thread, nextCommentsCursor: "next" },
923+
thread,
924+
]) {
925+
const timeline = buildPullRequestTimeline({
927926
...TIMELINE_SOURCE,
928927
comments,
929928
reviewThreads: [reviewThread],
930-
}).find((event) => event.id === finding.id)?.thread;
931-
expect(timeline({ ...thread, commentCount: 5 })).toMatchObject({
932-
moreReplies: 2,
933-
hasMoreReplies: true,
934-
url: finding.url,
935-
});
936-
expect(timeline({ ...thread, nextCommentsCursor: "next" })).toMatchObject({
937-
moreReplies: 0,
938-
hasMoreReplies: true,
939-
url: finding.url,
940-
});
941-
expect(timeline(thread)).toMatchObject({ moreReplies: 0, hasMoreReplies: false });
929+
});
930+
expect(timeline.find((event) => event.id === "thread:thread")?.reviewThread).toMatchObject({
931+
...reviewThread,
932+
comments: [finding, reply, lastReply],
933+
});
934+
expect(
935+
timeline.filter((event) => [finding.id, reply.id, lastReply.id].includes(event.id)),
936+
).toEqual([]);
937+
}
942938
});
943939
});
944940

‎apps/web/src/components/pullRequest/pullRequestDetail.logic.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,13 @@ export function buildPullRequestTimeline(
682682
"createdAt" | "author" | "commits" | "comments" | "mergedAt" | "closedAt"
683683
> & { readonly reviewThreads?: ReadonlyArray<PullRequestReviewThread> },
684684
): ReadonlyArray<PullRequestTimelineEvent> {
685-
const threads = detail.reviewThreads ?? [];
685+
const currentComments = new Map(detail.comments.map((comment) => [comment.id, comment]));
686+
const threads = (detail.reviewThreads ?? []).map((thread) => ({
687+
...thread,
688+
comments: thread.comments
689+
.map((comment) => currentComments.get(comment.id) ?? comment)
690+
.toSorted((left, right) => instant(left.createdAt) - instant(right.createdAt)),
691+
}));
686692
const threadedCommentIds = new Set(
687693
threads.flatMap((thread) => thread.comments.map((comment) => comment.id)),
688694
);

0 commit comments

Comments
 (0)