@devries-cameron20 / t3code-1 / commits / 2d80ca0852
Fork 0

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

fix(github): pull request activity reports a rate-limited review-thread read instead of hiding its threads (#32620)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Victor committed Nov 15, 2026 at 00:22 UTC 2d80ca0852d6926ffddd674c7eef6f2de2fea4aa
2 files changed +70 -14
packages/source-control-github/src/server/GitHubPullRequestProvider.test.ts
+54 -2
@@ -3,7 +3,7 @@ import * as Effect from "effect/Effect";
3 import * as Layer from "effect/Layer";
4 import * as Redacted from "effect/Redacted";
5 import * as TestClock from "effect/testing/TestClock";
6 -import type { PullRequestReaction } from "@t3tools/contracts";
6 +import { SourceControlProviderKind, type PullRequestReaction } from "@t3tools/contracts";
7
8 import * as GitHubRequestPolicy from "./GitHubRequestPolicy.ts";
9 import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
@@ -786,7 +786,7 @@ describe("getChangeRequest commits", () => {
786 );
787 });
788
789 -describe("getChangeRequestActivity dismissed reviews", () => {
789 +describe("getChangeRequestActivity", () => {
790 const dismissedReview = (body: string) => ({
791 id: "PRR_1",
792 kind: "review" as const,
@@ -840,6 +840,58 @@ describe("getChangeRequestActivity dismissed reviews", () => {
840 Effect.provide(layerFor("<!-- Macroscope (Approvability) review body marker -->")),
841 ),
842 );
843 +
844 + const failingThreadRead = (error: GitHubPullRequestApi.GitHubPullRequestApiError) =>
845 + Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
846 + getPullRequestActivity: () => Effect.succeed({ author: null, comments: [], commits: [] }),
847 + listReviewThreadComments: () => Effect.fail(error),
848 + });
849 + const retryAt = 1_900_000_000_000;
850 +
851 + it.effect.each([
852 + {
853 + name: "rate limit",
854 + error: new GitHubRequestPolicy.GitHubApiRateLimitError({
855 + host: "github.com",
856 + operation: "listReviewThreadComments",
857 + retryAt,
858 + }),
859 + },
860 + {
861 + name: "rate-limit pause",
862 + error: new SourceControlRateLimit.SourceControlRateLimitPausedError({
863 + provider: SourceControlProviderKind.make("github"),
864 + host: "github.com",
865 + retryAt,
866 + }),
867 + },
868 + ])("fails rate-limited when the review-thread read hits a $name", ({ error }) =>
869 + readActivity.pipe(
870 + Effect.flip,
871 + Effect.map((failure) => expect(failure).toMatchObject({ reason: "rate-limited", retryAt })),
872 + Effect.provide(failingThreadRead(error)),
873 + ),
874 + );
875 +
876 + it.effect(
877 + "keeps activity with truncated threads when the review-thread read fails otherwise",
878 + () =>
879 + readActivity.pipe(
880 + Effect.map((activity) => {
881 + expect(activity.reviewThreads).toEqual([]);
882 + expect(activity.reviewThreadsTruncated).toBe(true);
883 + }),
884 + Effect.provide(
885 + failingThreadRead(
886 + new GitHubRequestPolicy.GitHubApiResponseError({
887 + host: "github.com",
888 + operation: "listReviewThreadComments",
889 + status: 500,
890 + }),
891 + ),
892 + ),
893 + ),
894 + );
895 });
896
897 describe("loginAvatarUrl", () => {
packages/source-control-github/src/server/GitHubPullRequestProvider.ts
+16 -12
@@ -540,12 +540,14 @@ export const make = Effect.gen(function* () {
540 Effect.mapError(fail("getChangeRequest")),
541 ),
542
543 - getChangeRequestActivity: (input) =>
544 - Effect.all(
545 - [
546 - cli.getPullRequestActivity(input),
547 - cli.listReviewThreadComments(input).pipe(
548 - Effect.orElseSucceed(() => ({
543 + getChangeRequestActivity: (input) => {
544 + const threadRead = cli.listReviewThreadComments(input).pipe(
545 + Effect.catchIf(
546 + (error) =>
547 + error._tag !== "GitHubApiRateLimitError" &&
548 + error._tag !== "SourceControlRateLimitPausedError",
549 + () =>
550 + Effect.succeed({
551 comments: [],
552 dismissalsByReviewId: new Map<string, string>(),
553 reactions: [],
@@ -560,11 +562,12 @@ export const make = Effect.gen(function* () {
562 botLogins: new Set<string>(),
563 commits: [],
564 viewer: { canUpdate: true, didAuthor: false },
563 - })),
564 - ),
565 - ],
566 - { concurrency: 2 },
567 - ).pipe(
565 + }),
566 + ),
567 + );
568 + return Effect.all([cli.getPullRequestActivity(input), threadRead], {
569 + concurrency: 2,
570 + }).pipe(
571 Effect.mapError(fail("getChangeRequestActivity")),
572 Effect.map(([pullRequest, reviewThreads]): ProviderChangeRequestActivity => {
573 const commitStats = new Map(
@@ -635,7 +638,8 @@ export const make = Effect.gen(function* () {
638 })),
639 };
640 }),
638 - ),
641 + );
642 + },
643
644 getReviewThreadComments: (input) =>
645 cli.getReviewThreadComments(input).pipe(Effect.mapError(fail("getReviewThreadComments"))),