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, 04:45 UTC
fix(web): Retry on the Pull Requests list only refetches the environments that failed (#39536)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
tiliakoos committed
Nov 20, 2026 at 07:25 UTC
59651c1761f6c63e9b6056839067066968e6a406
3 files changed
+54
-11
apps/web/src/components/pullRequest/PullRequestsPage.tsx
+2
-2
@@ -1269,7 +1269,7 @@ export function PullRequestsPage() {
1269
<PullRequestsUnavailableState
1270
error={listError}
1271
refreshing={listQuery.isPending}
1272
- onRetry={() => listQuery.refresh()}
1272
+ onRetry={listQuery.retry}
1273
/>
1274
) : carriedToNothing ? (
1275
<PullRequestListGhost rows={7} />
@@ -1313,7 +1313,7 @@ export function PullRequestsPage() {
1313
{listError && shownCount > 0 ? (
1314
<div className="flex items-center justify-between gap-3 rounded-lg border border-warning/30 bg-warning-surface px-3 py-2 text-xs">
1315
<span>{gt("{error} Showing the last pull requests loaded.", { error: listError })}</span>
1316
- <Button size="xs" variant="outline" onClick={() => listQuery.refresh()}>
1316
+ <Button size="xs" variant="outline" onClick={listQuery.retry}>
1317
<T>Retry</T>
1318
</Button>
1319
</div>
apps/web/src/state/pullRequests.test.ts
+39
-8
@@ -10,19 +10,20 @@ import {
10
type PullRequestSummary,
11
} from "@t3tools/contracts";
12
import * as Cause from "effect/Cause";
13
+import * as Effect from "effect/Effect";
14
import { AsyncResult, Atom } from "effect/reactivity";
15
import { describe, expect, it, vi } from "vite-plus/test";
16
17
const listAnswers = vi.hoisted(() => new Map<string, unknown>());
18
+const registry = await vi.hoisted(async () =>
19
+ (await import("effect/reactivity")).AtomRegistry.make(),
20
+);
21
18
-vi.mock("@effect/atom-react", async (importOriginal) => {
19
- const { AtomRegistry } = await import("effect/reactivity");
20
- const registry = AtomRegistry.make();
21
- return {
22
- ...(await importOriginal<typeof import("@effect/atom-react")>()),
23
- useAtomValue: (atom: Atom.Atom<unknown>) => registry.get(atom),
24
- };
25
-});
22
+vi.mock("@effect/atom-react", async (importOriginal) => ({
23
+ ...(await importOriginal<typeof import("@effect/atom-react")>()),
24
+ useAtomValue: (atom: Atom.Atom<unknown>) => registry.get(atom),
25
+}));
26
+vi.mock("../rpc/atomRegistry", () => ({ appAtomRegistry: registry }));
27
vi.mock("@t3tools/client-runtime/state/pull-requests", async (importOriginal) => {
28
const actual =
29
await importOriginal<typeof import("@t3tools/client-runtime/state/pull-requests")>();
@@ -551,6 +552,36 @@ describe("pull request list answers across a reload", () => {
552
});
553
});
554
555
+ it("retries only the environment whose list failed, leaving one still loading to finish", () => {
556
+ const requests: string[] = [];
557
+ const read = (environmentId: string, answer: Effect.Effect<never, string>) =>
558
+ Atom.make(
559
+ Effect.suspend(() => {
560
+ requests.push(environmentId);
561
+ return answer;
562
+ }),
563
+ );
564
+ const slow = EnvironmentId.make("env-slow");
565
+ const failing = EnvironmentId.make("env-failing");
566
+ const reads = [read(slow, Effect.never), read(failing, Effect.fail("Unreachable"))];
567
+ listAnswers.set(slow, reads[0]);
568
+ listAnswers.set(failing, reads[1]);
569
+ const unmounts = reads.map((atom) => registry.mount(atom));
570
+ try {
571
+ const view = usePullRequestList([
572
+ { environmentId: slow, input },
573
+ { environmentId: failing, input },
574
+ ]);
575
+ expect(view).toMatchObject({ isPending: true, error: { environmentId: failing } });
576
+
577
+ view.retry();
578
+
579
+ expect(requests).toEqual([slow, failing, failing]);
580
+ } finally {
581
+ for (const unmount of unmounts) unmount();
582
+ }
583
+ });
584
+
585
it("removes the composite snapshots it replaced", () => {
586
const storage = makeStorage();
587
storage.held.set("t3.pullRequests.list:env-local,env-remote", "{}");
apps/web/src/state/pullRequests.ts
+13
-1
@@ -701,7 +701,16 @@ function createMergedEnvironmentQuery<Input, A>(
701
appAtomRegistry.refresh(atom);
702
}
703
};
704
- return { ...view, refresh };
704
+ // Retry reloads only failed environments, so a read still in flight elsewhere is not restarted.
705
+ const retry = () => {
706
+ for (const atom of new Set(
707
+ (JSON.parse(key) as ReadonlyArray<EnvironmentQueryTarget<Input>>).map(atomFor),
708
+ )) {
709
+ const result = appAtomRegistry.get(atom);
710
+ if (result._tag === "Failure" && !result.waiting) appAtomRegistry.refresh(atom);
711
+ }
712
+ };
713
+ return { ...view, refresh, retry };
714
};
715
}
716
@@ -753,6 +762,7 @@ export interface MergedPullRequestListView {
762
readonly isPending: boolean;
763
readonly observations: ReadonlyArray<readonly [EnvironmentId, PullRequestListResult, number]>;
764
readonly refresh: (targets?: ReadonlyArray<EnvironmentQueryTarget<PullRequestListInput>>) => void;
765
+ readonly retry: () => void;
766
}
767
768
// Merge inside each hook: the React Compiler memoizes it on `query.values` only there, and
@@ -768,6 +778,7 @@ export function usePullRequestList(
778
isPending: query.isPending,
779
observations: query.observations,
780
refresh: query.refresh,
781
+ retry: query.retry,
782
};
783
}
784
@@ -782,6 +793,7 @@ export function usePullRequestHostList(
793
isPending: query.isPending,
794
observations: query.observations,
795
refresh: query.refresh,
796
+ retry: query.retry,
797
};
798
}
799