@devries-cameron20 / t3code-1 / commits / 9cd5733f58
Fork 0

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

fix(web): an unreachable environment no longer hides pull requests from repositories it shares (#34088)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>

John committed Nov 14, 2026 at 17:53 UTC 9cd5733f5899b97f81c534775c8fa854000ac351
3 files changed +48 -5
apps/web/src/components/pullRequest/pullRequestProjectAssignment.logic.test.ts
+26
@@ -188,6 +188,32 @@ describe("one server per repository", () => {
188 expect(plain(assignment)).toEqual({ "env-2": ["a2"] });
189 });
190
191 + it("lets a reachable server list a repository an unreachable one also holds", () => {
192 + const assignment = assignProjectsToEnvironments(
193 + [
194 + project("a1", "env-1", "github.com/acme/app"),
195 + project("b1", "env-1", "github.com/acme/tools"),
196 + project("a2", "env-2", "github.com/acme/app"),
197 + ],
198 + envs("env-1", "env-2"),
199 + "env-1" as EnvironmentId,
200 + undefined,
201 + new Set(envs("env-1")),
202 + );
203 + expect(plain(assignment)).toEqual({ "env-1": ["b1"], "env-2": ["a2"] });
204 + const unreadableHost = assignProjectsToEnvironments(
205 + [
206 + project("a1", "env-1", "github.com/acme/app"),
207 + project("a2", "env-2", "github.com/acme/app"),
208 + ],
209 + envs("env-1", "env-2"),
210 + "env-1" as EnvironmentId,
211 + new Map([["env-2" as EnvironmentId, hostAvailability(new Map([["github.com", false]]))]]),
212 + new Set(envs("env-1")),
213 + );
214 + expect(plain(unreadableHost)).toEqual({ "env-2": ["a2"] });
215 + });
216 +
217 it("falls back from an unreadable host without moving other repositories", () => {
218 const assignment = assignProjectsToEnvironments(
219 [
apps/web/src/components/pullRequest/pullRequestProjectAssignment.logic.ts
+9 -4
@@ -124,6 +124,7 @@ export function assignProjectsToEnvironments(
124 environmentIds: ReadonlyArray<EnvironmentId>,
125 preferredEnvironmentId?: EnvironmentId | null,
126 hostAvailability?: PullRequestHostAvailability,
127 + unreachableEnvironmentIds: ReadonlySet<EnvironmentId> = new Set(),
128 ): Map<EnvironmentId, ProjectId[]> {
129 const rank = new Map(environmentIds.map((id, index) => [id, index] as const));
130 const owner = new Map<string, AssignableProject>();
@@ -137,6 +138,8 @@ export function assignProjectsToEnvironments(
138 );
139 return availability?.hosts.get(host)?.configured === false;
140 };
141 + const cost = (project: AssignableProject) =>
142 + (unreachableEnvironmentIds.has(project.environmentId) ? 2 : 0) + (unreadable(project) ? 1 : 0);
143 for (const project of projects) {
144 const key = repositoryKey(project);
145 if (!key) continue;
@@ -147,10 +150,10 @@ export function assignProjectsToEnvironments(
150 owner.set(key, project);
151 continue;
152 }
150 - const currentUnreadable = unreadable(current);
151 - const candidateUnreadable = unreadable(project);
152 - if (currentUnreadable !== candidateUnreadable) {
153 - if (currentUnreadable) owner.set(key, project);
153 + const currentCost = cost(current);
154 + const candidateCost = cost(project);
155 + if (currentCost !== candidateCost) {
156 + if (candidateCost < currentCost) owner.set(key, project);
157 continue;
158 }
159 if (current.environmentId === preferredEnvironmentId) continue;
@@ -177,6 +180,7 @@ export function pullRequestProjectQueries(
180 projects: ReadonlyArray<AssignableProject>,
181 environmentIds: ReadonlyArray<EnvironmentId>,
182 hostAvailability?: PullRequestHostAvailability,
183 + unreachableEnvironmentIds?: ReadonlySet<EnvironmentId>,
184 ): ReadonlyArray<{
185 readonly environmentId: EnvironmentId;
186 readonly projectIds?: ReadonlyArray<ProjectId>;
@@ -186,6 +190,7 @@ export function pullRequestProjectQueries(
190 environmentIds,
191 environmentIds[0],
192 hostAvailability,
193 + unreachableEnvironmentIds,
194 );
195 const totals = new Map<EnvironmentId, number>();
196 for (const project of projects)
apps/web/src/components/pullRequest/usePullRequestListView.ts
+13 -1
@@ -1,3 +1,4 @@
1 +import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
2 import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
3 import { parsePullRequestQuery } from "@t3tools/client-runtime/pull-request-query";
4 import {
@@ -55,6 +56,12 @@ export interface PullRequestsSearch extends PullRequestListPreferences {
56 }
57
58 const SEARCH_DEBOUNCE_MS = 250;
59 +const UNREACHABLE_PHASES: ReadonlySet<EnvironmentConnectionPhase> = new Set([
60 + "offline",
61 + "reconnecting",
62 + "error",
63 + "unsupported",
64 +]);
65
66 /** Which servers and projects the page reads, from the URL and what this client knows. */
67 export function usePullRequestScope(
@@ -121,6 +128,11 @@ export function usePullRequestScope(
128 scopedProjectId,
129 projectsKnown,
130 );
131 + const unreachable = new Set(
132 + environments.flatMap((environment) =>
133 + UNREACHABLE_PHASES.has(environment.connection.phase) ? [environment.environmentId] : [],
134 + ),
135 + );
136 const queriesFor = (
137 availability?: PullRequestHostAvailability,
138 ): ReadonlyArray<{
@@ -129,7 +141,7 @@ export function usePullRequestScope(
141 }> => {
142 const plain = queryEnvironmentIds.map((environmentId) => ({ environmentId }));
143 if (!projectsKnown || scopedProjectId !== undefined) return plain;
132 - return pullRequestProjectQueries(projects, queryEnvironmentIds, availability);
144 + return pullRequestProjectQueries(projects, queryEnvironmentIds, availability, unreachable);
145 };
146 const environmentQueries = queriesFor(hostAvailability);
147 // What the page reads once a refresh forgets host reads; refresh must refetch these too.