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 23, 04:15 UTC
fix(web): explain pull request diff load failures (#19945)
Jake Leventhal committed
Oct 18, 2026 at 15:20 UTC
09e54fd990eb3ef986f2c622cb05d215b2ebf188
4 files changed
+121
-1
apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
+7
-1
@@ -102,6 +102,7 @@ import {
102
type DiffFoldOverride,
103
} from "./pullRequestDiff.logic";
104
import { PullRequestDiffStat, PullRequestMetaLine } from "./pullRequestPresentation";
105
+import { PullRequestDiffUnavailableState } from "./PullRequestDiffUnavailableState";
106
import { usePullRequestFilesViewed } from "./usePullRequestFilesViewed";
107
import {
108
nextPendingReviewCommentId,
@@ -1307,7 +1308,12 @@ function PullRequestCodeTab({
1308
1309
if (diffQuery.error && loadedSlices.length === 0) {
1310
return withToolbar(
1310
- <p className="px-4 py-5 text-sm text-muted-foreground">{diffQuery.error}</p>,
1311
+ <PullRequestDiffUnavailableState
1312
+ error={diffQuery.error}
1313
+ provider={detail.provider}
1314
+ url={detail.url}
1315
+ onRetry={() => diffQuery.refresh()}
1316
+ />,
1317
);
1318
}
1319
apps/web/src/components/pullRequest/PullRequestDiffUnavailableState.tsx
new
+58
@@ -0,0 +1,58 @@
1
+import type { SourceControlProviderKind } from "@t3tools/contracts";
2
+import { ExternalLinkIcon, TriangleAlertIcon } from "lucide-react";
3
+
4
+import { getSourceControlPresentationForKind } from "~/sourceControlPresentation";
5
+
6
+import { Button } from "../ui/button";
7
+import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "../ui/empty";
8
+import { RefreshIcon } from "../ui/refresh-icon";
9
+import { describePullRequestDiffError } from "./pullRequestDiffError";
10
+
11
+export function PullRequestDiffUnavailableState({
12
+ error,
13
+ provider,
14
+ url,
15
+ onRetry,
16
+}: {
17
+ error: string;
18
+ provider: SourceControlProviderKind;
19
+ url: string;
20
+ onRetry: () => void;
21
+}) {
22
+ const { providerName } = getSourceControlPresentationForKind(provider);
23
+ const { title, description } = describePullRequestDiffError(error, providerName);
24
+
25
+ return (
26
+ <Empty size="compact" className="min-h-full" role="status">
27
+ <div className="flex size-11 items-center justify-center rounded-full bg-warning-surface text-warning">
28
+ <TriangleAlertIcon aria-hidden className="size-5" />
29
+ </div>
30
+ <EmptyHeader>
31
+ <EmptyTitle>{title}</EmptyTitle>
32
+ <EmptyDescription>{description}</EmptyDescription>
33
+ </EmptyHeader>
34
+ <div className="flex flex-wrap justify-center gap-2">
35
+ <Button size="sm" variant="default" onClick={onRetry}>
36
+ <RefreshIcon />
37
+ Try again
38
+ </Button>
39
+ <Button
40
+ size="sm"
41
+ variant="outline"
42
+ render={<a href={url} target="_blank" rel="noopener noreferrer" />}
43
+ >
44
+ <ExternalLinkIcon aria-hidden />
45
+ Open on {providerName}
46
+ </Button>
47
+ </div>
48
+ <details className="w-full max-w-lg text-xs text-muted-foreground">
49
+ <summary className="mx-auto w-fit cursor-pointer rounded-sm -outline-offset-2 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring">
50
+ Technical details
51
+ </summary>
52
+ <pre className="scrollbar-gutter-both mt-3 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-lg border border-border bg-muted/40 p-3 text-left font-mono text-xs">
53
+ {error}
54
+ </pre>
55
+ </details>
56
+ </Empty>
57
+ );
58
+}
apps/web/src/components/pullRequest/pullRequestDiffError.test.ts
new
+42
@@ -0,0 +1,42 @@
1
+import { describe, expect, it } from "vite-plus/test";
2
+
3
+import { describePullRequestDiffError } from "./pullRequestDiffError";
4
+
5
+describe("describePullRequestDiffError", () => {
6
+ it("explains the rate limit inside an HTTP transport error without exposing the endpoint", () => {
7
+ const error =
8
+ "Failed to fetch remote environment endpoint http://127.0.0.1:49477/api/pull-requests/diff (PullRequestOperationError: Pull request operation diff failed: github requests to github.com are paused until the rate limit resets.).";
9
+ const result = describePullRequestDiffError(error, "GitHub");
10
+
11
+ expect(result.title).toBe("GitHub rate limit reached");
12
+ expect(result.description).toContain("after the limit resets");
13
+ expect(result.description).not.toContain("127.0.0.1");
14
+ expect(result.description).not.toContain("PullRequestOperationError");
15
+ });
16
+
17
+ it("recognizes a provider's API quota error", () => {
18
+ expect(describePullRequestDiffError("GitHub API rate limit exceeded.", "GitHub").title).toBe(
19
+ "GitHub rate limit reached",
20
+ );
21
+ });
22
+
23
+ it("uses the actual host's name for a rate limit", () => {
24
+ const result = describePullRequestDiffError("Too many requests", "GitLab");
25
+
26
+ expect(result.title).toBe("GitLab rate limit reached");
27
+ expect(result.description).toContain("on GitLab");
28
+ expect(result.description).not.toContain("GitHub");
29
+ });
30
+
31
+ it("does not blame a rate limit for an unknown connection failure", () => {
32
+ const result = describePullRequestDiffError(
33
+ "Failed to fetch remote environment endpoint http://localhost:49477/api/pull-requests/diff (TypeError: Failed to fetch).",
34
+ "GitHub",
35
+ );
36
+
37
+ expect(result.title).toBe("Couldn't load the changes");
38
+ expect(result.description).toContain("Try again");
39
+ expect(result.description).not.toContain("localhost");
40
+ expect(result.description).not.toContain("limit");
41
+ });
42
+});
apps/web/src/components/pullRequest/pullRequestDiffError.ts
new
+14
@@ -0,0 +1,14 @@
1
+/** Diff failures currently include transport wrappers, so recognize the reason inside them. */
2
+export function describePullRequestDiffError(error: string, providerName: string) {
3
+ if (/\brate limit\b|\brate[-_]limited\b|\btoo many requests\b/i.test(error)) {
4
+ return {
5
+ title: `${providerName} rate limit reached`,
6
+ description: `${providerName} is temporarily limiting requests, so this diff couldn't be loaded. Try again after the limit resets, or view the changes on ${providerName}.`,
7
+ };
8
+ }
9
+
10
+ return {
11
+ title: "Couldn't load the changes",
12
+ description: `The environment couldn't load this pull request's diff. Try again, or view the changes on ${providerName}.`,
13
+ };
14
+}