GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): an unreachable environment no longer hides pull requests fr… · pingdotgg/t3code@f77656e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components/pullRequest
    • pullRequestProjectAssignment.logic.test.ts
    • pullRequestProjectAssignment.logic.ts
    • usePullRequestListView.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/pullRequest/pullRequestProjectAssignment.logic.test.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/pullRequest/pullRequestProjectAssignment.logic.test.ts
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ describe("one server per repository", () => {
5050
expect(plain(assignment)).toEqual({ "env-2": ["a2"] });
5151
});
5252

53+
it("lets a reachable server list a repository an unreachable one also holds", () => {
54+
const assignment = assignProjectsToEnvironments(
55+
[
56+
project("a1", "env-1", "github.com/acme/app"),
57+
project("b1", "env-1", "github.com/acme/tools"),
58+
project("a2", "env-2", "github.com/acme/app"),
59+
],
60+
envs("env-1", "env-2"),
61+
"env-1" as EnvironmentId,
62+
new Set(envs("env-1")),
63+
);
64+
expect(plain(assignment)).toEqual({ "env-1": ["b1"], "env-2": ["a2"] });
65+
});
66+
5367
it("keeps every copy of a project that has no identity to compare", () => {
5468
const assignment = assignProjectsToEnvironments(
5569
[project("p1", "env-1"), project("p2", "env-2")],
Collapse file

‎apps/web/src/components/pullRequest/pullRequestProjectAssignment.logic.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/pullRequest/pullRequestProjectAssignment.logic.ts
+9-10Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,23 @@ export function assignProjectsToEnvironments(
1414
projects: ReadonlyArray<AssignableProject>,
1515
environmentIds: ReadonlyArray<EnvironmentId>,
1616
preferredEnvironmentId?: EnvironmentId | null,
17+
unreachableEnvironmentIds: ReadonlySet<EnvironmentId> = new Set(),
1718
): Map<EnvironmentId, ProjectId[]> {
18-
const rank = new Map(environmentIds.map((id, index) => [id, index] as const));
19+
const priority = (id: EnvironmentId) =>
20+
(unreachableEnvironmentIds.has(id) ? 2 : 0) + (id === preferredEnvironmentId ? 0 : 1);
21+
const rank = new Map(
22+
environmentIds
23+
.toSorted((left, right) => priority(left) - priority(right))
24+
.map((id, index) => [id, index] as const),
25+
);
1926
const owner = new Map<string, EnvironmentId>();
2027
for (const project of projects) {
2128
const key = repositoryKey(project);
2229
if (!key) continue;
2330
const environmentRank = rank.get(project.environmentId);
2431
if (environmentRank === undefined) continue;
2532
const current = owner.get(key);
26-
if (current === undefined) {
27-
owner.set(key, project.environmentId);
28-
continue;
29-
}
30-
if (current === preferredEnvironmentId) continue;
31-
if (
32-
project.environmentId === preferredEnvironmentId ||
33-
environmentRank < (rank.get(current) ?? Number.MAX_SAFE_INTEGER)
34-
) {
33+
if (current === undefined || environmentRank < (rank.get(current) ?? Number.MAX_SAFE_INTEGER)) {
3534
owner.set(key, project.environmentId);
3635
}
3736
}
Collapse file

‎apps/web/src/components/pullRequest/usePullRequestListView.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/pullRequest/usePullRequestListView.ts
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export interface PullRequestsSearch extends PullRequestListPreferences {
5151
}
5252

5353
const SEARCH_DEBOUNCE_MS = 250;
54+
const UNREACHABLE_PHASES = new Set(["offline", "reconnecting", "error", "unsupported"]);
5455

5556
/** Which servers and projects the page reads, from the URL and what this client knows. */
5657
export function usePullRequestScope(search: PullRequestsSearch) {
@@ -120,10 +121,16 @@ export function usePullRequestScope(search: PullRequestsSearch) {
120121
}> => {
121122
const plain = queryEnvironmentIds.map((environmentId) => ({ environmentId }));
122123
if (!projectsKnown || scopedProjectId !== undefined) return plain;
124+
const unreachable = new Set(
125+
environments.flatMap((environment) =>
126+
UNREACHABLE_PHASES.has(environment.connection.phase) ? [environment.environmentId] : [],
127+
),
128+
);
123129
const assignment = assignProjectsToEnvironments(
124130
projects,
125131
queryEnvironmentIds,
126132
queryEnvironmentIds[0],
133+
unreachable,
127134
);
128135
const totals = new Map<EnvironmentId, number>();
129136
for (const project of projects) {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.