Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3786,18 +3786,23 @@ layer("GitHubPullRequestApi.layer", (it) => {
}),
);

it.effect("stops at the thread bound and says the conversation was cut short", () =>
it.effect("stops at a thousand threads and says the conversation was cut short", () =>
Effect.gen(function* () {
mockedExecute.mockReturnValue(
Effect.succeed(
// Serves whatever page size the document asks for, so the bound holds in threads.
mockedExecute.mockImplementation((call) => {
const query = call.kind === "graphql" ? call.query : "";
const first = Number(/reviewThreads\(first:(\d+)/.exec(query)?.[1]);
const start = Number(call.kind === "graphql" ? (call.variables?.["after"] ?? 0) : 0);
const ids = Array.from({ length: first }, (_, index) => `PRRT_${start + index + 1}`);
return Effect.succeed(
output(
reviewThreadsPage(
[{ ...thread("PRRT_1", "c1"), comments: threadComments(["c1"], "Y3Vyc29yOjI", 3) }],
"Y3Vyc29yOjE",
ids.map((id) => thread(id, `c_${id}`)),
String(start + first),
),
),
),
);
);
});
const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;

const conversation = yield* cli.listReviewThreadComments({
Expand All @@ -3807,7 +3812,8 @@ layer("GitHubPullRequestApi.layer", (it) => {
number: 7,
});

assert.strictEqual(mockedExecute.mock.calls.length, 10);
assert.strictEqual(conversation.reviewThreads.length, 1_000);
assert.strictEqual(conversation.reviewThreads.at(-1)?.id, "PRRT_1000");
assert.isTrue(conversation.truncated);
assert.isTrue(conversation.reviewThreadsTruncated);
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ export const NODE_ID_CACHE_CAPACITY = 128;

const REVIEW_THREAD_PAGES = 10;

// `ReviewThreads` reads 25 threads a page; forty pages keep the 1,000-thread ceiling.
const REVIEW_THREAD_LIST_PAGES = 40;

const CHECK_CONTEXT_PAGES = 10;

export interface GitHubPullRequestListBatch {
Expand Down Expand Up @@ -2231,7 +2234,7 @@ export const make = Effect.gen(function* () {
let cursor = first.nextCursor;
let page = 1;
// Later pages carry the threads alone; the PR-wide fields above come from the first.
while (cursor !== null && page < REVIEW_THREAD_PAGES) {
while (cursor !== null && page < REVIEW_THREAD_LIST_PAGES) {
const later: Pick<
GitHubReviewThreadPage,
"threads" | "nextCursor" | "avatarsByLogin" | "botLogins"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ query ReviewThreads($owner: String!, $name: String!, $number: Int!, $requestedRe
}
repository(owner: $owner, name: $name) {
pullRequest(number: $number) {
reviewThreads(first: 100) {
# GitHub prices a page by the rows it may return, not the rows that exist, so a page of
# twenty-five threads costs 6 points even on a pull request with none.
reviewThreads(first: 25) {
...ReviewThreadPage
}
viewerCanUpdate
Expand Down Expand Up @@ -204,7 +206,7 @@ query ReviewThreadPages($owner: String!, $name: String!, $number: Int!, $after:
}
repository(owner: $owner, name: $name) {
pullRequest(number: $number) {
reviewThreads(first: 100, after: $after) {
reviewThreads(first: 25, after: $after) {
...ReviewThreadPage
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading