@devries-cameron20 / t3code Mirror · read-only / commits / 34cf030e5e
Fork 0

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, 16:00 UTC

fix(web): pull requests error names the environment that failed (#27882)

Julius Marminge committed Nov 13, 2026 at 20:52 UTC 34cf030e5e4cdfc175e1d875a6f21b66c4272d69
3 files changed +72 -10
apps/web/src/components/pullRequest/PullRequestsPage.tsx
+7 -4
@@ -1176,6 +1176,9 @@ export function PullRequestsPage() {
1176 {panelToggleControls}
1177 </div>
1178 );
1179 + const listError = listQuery.error
1180 + ? `${environmentLabels.get(listQuery.error.environmentId) || "Environment"}: ${listQuery.error.message}`
1181 + : null;
1182 const carriedToNothing =
1183 shownCount === 0 &&
1184 typedQuery.length === 0 &&
@@ -1191,9 +1194,9 @@ export function PullRequestsPage() {
1194 />
1195 ) : firstLoad ? (
1196 <PullRequestListGhost rows={7} caption="Loading pull requests…" />
1194 - ) : listQuery.error && shownCount === 0 ? (
1197 + ) : listError && shownCount === 0 ? (
1198 <PullRequestsUnavailableState
1196 - error={listQuery.error}
1199 + error={listError}
1200 refreshing={listQuery.isPending}
1201 onRetry={() => listQuery.refresh()}
1202 />
@@ -1236,9 +1239,9 @@ export function PullRequestsPage() {
1239 />
1240 )}
1241
1239 - {listQuery.error && shownCount > 0 ? (
1242 + {listError && shownCount > 0 ? (
1243 <div className="flex items-center justify-between gap-3 rounded-lg border border-warning/30 bg-warning-surface px-3 py-2 text-xs">
1241 - <span>{listQuery.error} Showing the last pull requests loaded.</span>
1244 + <span>{listError} Showing the last pull requests loaded.</span>
1245 <Button size="xs" variant="outline" onClick={() => listQuery.refresh()}>
1246 Retry
1247 </Button>
apps/web/src/state/pullRequests.test.ts
+53 -2
@@ -9,9 +9,34 @@ import {
9 type PullRequestListResult,
10 type PullRequestSummary,
11 } from "@t3tools/contracts";
12 -import { describe, expect, it, vi } from "vite-plus/test";
12 import * as Cause from "effect/Cause";
14 -import { AsyncResult } from "effect/reactivity";
13 +import { AsyncResult, Atom } from "effect/reactivity";
14 +import { describe, expect, it, vi } from "vite-plus/test";
15 +
16 +const listAnswers = vi.hoisted(() => new Map<string, unknown>());
17 +
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 +});
26 +vi.mock("@t3tools/client-runtime/state/pull-requests", async (importOriginal) => {
27 + const actual =
28 + await importOriginal<typeof import("@t3tools/client-runtime/state/pull-requests")>();
29 + return {
30 + ...actual,
31 + createPullRequestEnvironmentAtoms: (
32 + ...args: Parameters<typeof actual.createPullRequestEnvironmentAtoms>
33 + ) => ({
34 + ...actual.createPullRequestEnvironmentAtoms(...args),
35 + list: ({ environmentId }: { readonly environmentId: string }) =>
36 + listAnswers.get(environmentId),
37 + }),
38 + };
39 +});
40
41 import {
42 newestPullRequestObservation,
@@ -24,6 +49,7 @@ import {
49 restoredPullRequestList,
50 threadPullRequestLinkToSummary,
51 observeFailedPullRequestList,
52 + usePullRequestList,
53 } from "./pullRequests";
54
55 it("observes both typed list failures without changing their status or replaying cached timestamps", () => {
@@ -490,6 +516,31 @@ describe("pull request list answers across a reload", () => {
516 }
517 });
518
519 + it("names the environment whose list failed while the others' rows still show", () => {
520 + listAnswers.set(local, Atom.make(AsyncResult.success(answer([listEntry(1)]))));
521 + listAnswers.set(
522 + remote,
523 + Atom.make(
524 + AsyncResult.failure(
525 + Cause.fail(
526 + new Error("Relay could not reach the environment endpoint (endpoint_request_failed)."),
527 + ),
528 + ),
529 + ),
530 + );
531 +
532 + const view = usePullRequestList([
533 + { environmentId: local, input },
534 + { environmentId: remote, input },
535 + ]);
536 +
537 + expect(view.data?.entries.map((row) => [row.environmentId, row.number])).toEqual([[local, 1]]);
538 + expect(view.error).toEqual({
539 + environmentId: remote,
540 + message: "Relay could not reach the environment endpoint (endpoint_request_failed).",
541 + });
542 + });
543 +
544 it("removes the composite snapshots it replaced", () => {
545 const storage = makeStorage();
546 storage.held.set("t3.pullRequests.list:env-local,env-remote", "{}");
apps/web/src/state/pullRequests.ts
+12 -4
@@ -525,10 +525,15 @@ export interface EnvironmentQueryTarget<Input> {
525 readonly input: Input;
526 }
527
528 +interface EnvironmentQueryError {
529 + readonly environmentId: EnvironmentId;
530 + readonly message: string;
531 +}
532 +
533 interface MergedEnvironmentQueryView<A> {
534 readonly observations: ReadonlyArray<readonly [EnvironmentId, A, number]>;
535 readonly values: ReadonlyArray<readonly [EnvironmentId, A]>;
531 - readonly error: string | null;
536 + readonly error: EnvironmentQueryError | null;
537 readonly isPending: boolean;
538 }
539
@@ -568,14 +573,17 @@ function createMergedEnvironmentQuery<Input, A>(
573 const values: Array<readonly [EnvironmentId, A]> = [];
574 const observations: Array<readonly [EnvironmentId, A, number]> = [];
575 const pendingEnvironments = new Set<EnvironmentId>();
571 - let error: string | null = null;
576 + let error: EnvironmentQueryError | null = null;
577 let isPending = false;
578 for (const target of targets) {
579 const result = get(atomFor(target));
580 isPending ||= result.waiting;
581 if (result.waiting) pendingEnvironments.add(target.environmentId);
582 if (result._tag === "Failure" && error === null) {
578 - error = formatEnvironmentQueryError(result.cause);
583 + error = {
584 + environmentId: target.environmentId,
585 + message: formatEnvironmentQueryError(result.cause),
586 + };
587 }
588 const value = AsyncResult.getOrElse(result, () => null);
589 if (value !== null) values.push([target.environmentId, value]);
@@ -656,7 +664,7 @@ export function usePullRequestTurnRefresh(environmentId: EnvironmentId): number
664
665 export interface MergedPullRequestListView {
666 readonly data: MergedPullRequestList | null;
659 - readonly error: string | null;
667 + readonly error: EnvironmentQueryError | null;
668 readonly isPending: boolean;
669 readonly observations: ReadonlyArray<readonly [EnvironmentId, PullRequestListResult, number]>;
670 readonly refresh: (targets?: ReadonlyArray<EnvironmentQueryTarget<PullRequestListInput>>) => void;