@devries-cameron20 / t3code-1 / commits / 92d4a2e996
Fork 0

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

fix(web): scope pull request errors to their environment (#6490)

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

Adamulek123 committed Aug 13, 2026 at 22:40 UTC 92d4a2e996b19239d95e32a3feb05208e0a52306
5 files changed +70 -17
apps/web/src/components/pullRequest/PullRequestListFilters.test.tsx
+19 -3
@@ -3,7 +3,7 @@ import { CircleIcon } from "lucide-react";
3 import { Children, isValidElement, type ReactElement, type ReactNode } from "react";
4 import { describe, expect, it, vi } from "vite-plus/test";
5
6 -import { PullRequestFiltersMenu } from "./PullRequestListFilters";
6 +import { PullRequestFiltersMenu, pullRequestProjectKey } from "./PullRequestListFilters";
7
8 function findValueChange(
9 node: ReactNode,
@@ -129,7 +129,7 @@ describe("pull request filters menu", () => {
129 const radioGroup = findValueChange(view);
130 expect(radioGroup).toBeDefined();
131
132 - radioGroup?.props.onValueChange(`${environmentId} ${projectId}`);
132 + radioGroup?.props.onValueChange(pullRequestProjectKey({ id: projectId, environmentId }));
133 expect(onProject).not.toHaveBeenCalled();
134
135 radioGroup?.props.onValueChange("all");
@@ -159,7 +159,23 @@ describe("pull request filters menu", () => {
159 const radioGroup = findValueChange(view);
160 expect(radioGroup).toBeDefined();
161
162 - radioGroup?.props.onValueChange(`env-2 ${projectId}`);
162 + radioGroup?.props.onValueChange(
163 + pullRequestProjectKey({ id: projectId, environmentId: "env-2" as EnvironmentId }),
164 + );
165 expect(onProject).toHaveBeenCalledWith(projectId, "env-2");
166 });
167 +
168 + it("does not collide when environment and project ids contain spaces", () => {
169 + expect(
170 + pullRequestProjectKey({
171 + environmentId: "a b" as EnvironmentId,
172 + id: "c" as ProjectId,
173 + }),
174 + ).not.toBe(
175 + pullRequestProjectKey({
176 + environmentId: "a" as EnvironmentId,
177 + id: "b c" as ProjectId,
178 + }),
179 + );
180 + });
181 });
apps/web/src/components/pullRequest/PullRequestListFilters.tsx
+11 -9
@@ -122,10 +122,10 @@ const UNFILTERED_VALUE = "all";
122 * A project's own radio value, carrying the server along with the id: the id alone is only
123 * unique within its own server, so two rows sharing one would otherwise both read as checked.
124 */
125 -const projectMenuValue = (project: {
125 +export const pullRequestProjectKey = (project: {
126 readonly id: ProjectId;
127 readonly environmentId: EnvironmentId;
128 -}) => `${project.environmentId} ${project.id}`;
128 +}) => JSON.stringify([project.environmentId, project.id]);
129
130 const DRAFT_OPTIONS = [
131 { value: UNFILTERED_VALUE, label: "All", Icon: LayersIcon },
@@ -247,7 +247,7 @@ export function PullRequestFiltersMenu({
247 * the reader is already choosing between projects, rather than as a count above the list
248 * that says something is missing without saying which.
249 */
250 - unavailable: ReadonlyMap<ProjectId, string>;
250 + unavailable: ReadonlyMap<string, string>;
251 /** The environment comes with the project id, since picking a row picks a specific server's copy of it. */
252 onProject: (projectId: ProjectId | undefined, environmentId: EnvironmentId | undefined) => void;
253 }) {
@@ -350,7 +350,7 @@ export function PullRequestFiltersMenu({
350 value={
351 projectId === undefined || projectEnvironmentId === undefined
352 ? ALL_PROJECTS_VALUE
353 - : projectMenuValue({ id: projectId, environmentId: projectEnvironmentId })
353 + : pullRequestProjectKey({ id: projectId, environmentId: projectEnvironmentId })
354 }
355 onValueChange={(next) => {
356 if (next === ALL_PROJECTS_VALUE) {
@@ -359,7 +359,7 @@ export function PullRequestFiltersMenu({
359 }
360 // The value carries both halves, since the id alone cannot tell two servers' rows
361 // apart once they share one.
362 - const project = projects.find((candidate) => projectMenuValue(candidate) === next);
362 + const project = projects.find((candidate) => pullRequestProjectKey(candidate) === next);
363 if (
364 project !== undefined &&
365 (project.id !== projectId || project.environmentId !== projectEnvironmentId)
@@ -379,14 +379,16 @@ export function PullRequestFiltersMenu({
379 as a broken menu rather than as a workspace with three unreadable repositories. */}
380 {projects
381 .toSorted(
382 - (left, right) => Number(unavailable.has(left.id)) - Number(unavailable.has(right.id)),
382 + (left, right) =>
383 + Number(unavailable.has(pullRequestProjectKey(left))) -
384 + Number(unavailable.has(pullRequestProjectKey(right))),
385 )
386 .map((project) => {
385 - const reason = unavailable.get(project.id);
387 + const reason = unavailable.get(pullRequestProjectKey(project));
388 return (
389 <MenuRadioItem
388 - key={projectMenuValue(project)}
389 - value={projectMenuValue(project)}
390 + key={pullRequestProjectKey(project)}
391 + value={pullRequestProjectKey(project)}
392 disabled={reason !== undefined}
393 title={reason}
394 >
apps/web/src/components/pullRequest/pullRequestList.logic.test.ts
+15 -1
@@ -1,4 +1,4 @@
1 -import type { EnvironmentId, PullRequestListEntry } from "@t3tools/contracts";
1 +import type { EnvironmentId, ProjectId, PullRequestListEntry } from "@t3tools/contracts";
2 import { describe, expect, it } from "vite-plus/test";
3
4 import {
@@ -710,6 +710,20 @@ describe("merging the environments' own listings", () => {
710 );
711 });
712
713 + it("keeps project errors scoped to the environment that reported them", () => {
714 + const error = {
715 + projectId: "project-1" as ProjectId,
716 + projectTitle: "Web",
717 + message: "Not signed in",
718 + } as const;
719 + const merged = mergePullRequestLists([
720 + [ENV_1, answer({ errors: [error] })],
721 + [ENV_2, answer()],
722 + ]);
723 +
724 + expect(merged?.errors).toEqual([{ ...error, environmentId: ENV_1 }]);
725 + });
726 +
727 it("folds a host reached from two environments into one switcher row", () => {
728 const merged = mergePullRequestLists([
729 [ENV_1, answer()],
apps/web/src/components/pullRequest/pullRequestList.logic.ts
+14 -3
@@ -3,6 +3,7 @@ import * as Schema from "effect/Schema";
3 import {
4 EnvironmentId,
5 PullRequestListEntry,
6 + PullRequestListProjectError,
7 PullRequestListResult,
8 resolvePullRequestAuthorFilter,
9 } from "@t3tools/contracts";
@@ -27,6 +28,10 @@ export interface EnvironmentPullRequestStat extends PullRequestDiffStat {
28 readonly environmentId: EnvironmentId;
29 }
30
31 +export interface EnvironmentPullRequestError extends PullRequestListProjectError {
32 + readonly environmentId: EnvironmentId;
33 +}
34 +
35 export type PullRequestGroupKey = "reviewRequested" | "authored" | "others";
36
37 export interface PullRequestGroup<Entry extends PullRequestListEntry = PullRequestListEntry> {
@@ -452,7 +457,7 @@ export interface MergedPullRequestList {
457 readonly viewers: PullRequestViewers;
458 readonly providers: PullRequestListResult["providers"];
459 readonly entries: ReadonlyArray<EnvironmentPullRequestEntry>;
455 - readonly errors: PullRequestListResult["errors"];
460 + readonly errors: ReadonlyArray<EnvironmentPullRequestError>;
461 readonly truncated: boolean;
462 readonly nextCursors: Readonly<Record<string, PullRequestListCursors>>;
463 /**
@@ -476,7 +481,7 @@ export function mergePullRequestLists(
481 const truncatedEnvironments: string[] = [];
482 const providers = new Map<string, PullRequestListResult["providers"][number]>();
483 const entries: EnvironmentPullRequestEntry[] = [];
479 - const errors: Array<PullRequestListResult["errors"][number]> = [];
484 + const errors: EnvironmentPullRequestError[] = [];
485 const nextCursors: Record<string, PullRequestListCursors> = {};
486 let truncated = false;
487 for (const [environmentId, answer] of answers) {
@@ -498,7 +503,7 @@ export function mergePullRequestLists(
503 );
504 }
505 entries.push(...answer.entries.map((entry) => ({ ...entry, environmentId })));
501 - errors.push(...answer.errors);
506 + errors.push(...answer.errors.map((error) => ({ ...error, environmentId })));
507 truncated ||= answer.truncated;
508 if (answer.truncated) truncatedEnvironments.push(environmentId);
509 if (Object.keys(answer.nextCursors).length > 0) {
@@ -559,12 +564,18 @@ const EnvironmentPullRequestEntrySchema = Schema.Struct({
564 environmentId: EnvironmentId,
565 });
566
567 +const EnvironmentPullRequestErrorSchema = Schema.Struct({
568 + ...PullRequestListProjectError.fields,
569 + environmentId: EnvironmentId,
570 +});
571 +
572 const decodeSnapshot = Schema.decodeUnknownOption(
573 Schema.Struct({
574 scope: Schema.String,
575 data: Schema.Struct({
576 ...PullRequestListResult.fields,
577 entries: Schema.Array(EnvironmentPullRequestEntrySchema),
578 + errors: Schema.Array(EnvironmentPullRequestErrorSchema),
579 // Per environment here, unlike the wire shape, which is per repository within one.
580 nextCursors: Schema.Record(Schema.String, PullRequestListResult.fields.nextCursors),
581 truncatedEnvironments: Schema.Array(Schema.String),
apps/web/src/routes/_chat.pull-requests.tsx
+11 -1
@@ -60,6 +60,7 @@ import {
60 PullRequestFiltersMenu,
61 PullRequestSearchInput,
62 pullRequestHostLabel,
63 + pullRequestProjectKey,
64 type PullRequestExpectedHost,
65 type PullRequestFilterOption,
66 } from "../components/pullRequest/PullRequestListFilters";
@@ -1250,7 +1251,16 @@ function PullRequestsRouteView() {
1251
1252 /** Reported per project rather than as a count, so the reader can see which one it was. */
1253 const unavailableProjects = useMemo(
1253 - () => new Map(listErrors.map((error) => [error.projectId, error.message] as const)),
1254 + () =>
1255 + new Map(
1256 + listErrors.map(
1257 + (error) =>
1258 + [
1259 + pullRequestProjectKey({ id: error.projectId, environmentId: error.environmentId }),
1260 + error.message,
1261 + ] as const,
1262 + ),
1263 + ),
1264 [listErrors],
1265 );
1266