@devries-cameron20 / t3code-1 / commits / 77f87ea4c1
Fork 0

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

fix(github): page closing pull requests past the first twenty on issues (#38487)

Wout Stiens committed Nov 18, 2026 at 09:21 UTC 77f87ea4c191de3533567ee90ed67998b5ca4a5d
5 files changed +367 -27
packages/source-control-github/src/server/GitHubIssueTracker.test.ts
+26 -2
@@ -80,6 +80,7 @@ const DETAIL_RESPONSE = JSON.stringify({
80 viewerCanReopen: true,
81 reactionGroups: [],
82 closedByPullRequestsReferences: {
83 + pageInfo: { hasNextPage: true, endCursor: "links-next" },
84 nodes: [
85 {
86 number: 50,
@@ -186,9 +187,18 @@ function tracker(onRequest: (variables: unknown) => void, templateRepository?: u
187 pageInfo: { hasNextPage: false, endCursor: null },
188 nodes: [{ name: "needs repro", color: "ffffff" }],
189 },
189 - assignees: {
190 + closedByPullRequestsReferences: {
191 pageInfo: { hasNextPage: false, endCursor: null },
191 - nodes: [],
192 + nodes: [
193 + {
194 + number: 61,
195 + title: "fix(web): restore focus after paste",
196 + url: "https://github.com/acme/web/pull/61",
197 + state: "OPEN",
198 + isDraft: true,
199 + repository: { nameWithOwner: "acme/web" },
200 + },
201 + ],
202 },
203 },
204 },
@@ -549,6 +559,10 @@ Redact secrets before uploading.`);
559 number: 42,
560 labelsCursor: "labels-next",
561 assigneesCursor: null,
562 + closingPullRequestsCursor: "links-next",
563 + withLabels: true,
564 + withAssignees: false,
565 + withClosingPullRequests: true,
566 },
567 ]);
568 expect(issue).toMatchObject({
@@ -600,6 +614,16 @@ Redact secrets before uploading.`);
614 isDraft: false,
615 closesIssue: true,
616 },
617 + // A closing reference past the first page, with no timeline sighting, still shows.
618 + {
619 + repository: "acme/web",
620 + number: 61,
621 + title: "fix(web): restore focus after paste",
622 + url: "https://github.com/acme/web/pull/61",
623 + state: "open",
624 + isDraft: true,
625 + closesIssue: true,
626 + },
627 ]);
628 // An event kind this page has no vocabulary for is dropped rather than guessed at.
629 expect(issue.events.map((event) => [event.kind, event.detail])).toEqual([
packages/source-control-github/src/server/GitHubIssueTracker.ts
+71 -17
@@ -4,7 +4,9 @@ import { GraphQLClient, GraphQLClientError, GraphQLGroup } from "effect/graphql"
4 import {
5 IssueTrackerKind,
6 type IssueCapabilities,
7 + type IssueActor,
8 type IssueInvolvement,
9 + type IssueLabel,
10 type IssueListSort,
11 } from "@t3tools/contracts";
12 import {
@@ -227,51 +229,75 @@ export const make = Effect.gen(function* () {
229 const result = yield* client
230 .IssueDetail({ owner, name, number })
231 .pipe(graphql(input.host, "getIssue"));
230 - const detail = toIssueDetail(result);
231 - const raw = result.repository?.issue;
232 - if (detail === null || raw == null) return yield* notFound("getIssue");
233 - // Editing replaces these sets. Finish their pages before handing them to a client.
232 + const repository = result.repository;
233 + const raw = repository?.issue;
234 + if (repository == null || raw == null) return yield* notFound("getIssue");
235 + // Editing replaces labels and assignees, and a closing reference can sit past the first
236 + // page. Finish their pages before handing the issue to a client.
237 let labels = raw.labels;
238 let assignees = raw.assignees;
239 + let closing = raw.closedByPullRequestsReferences;
240 const seen = new Set<string>();
237 - const allLabels = [...detail.labels];
238 - const allAssignees = [...detail.assignees];
239 - while (labels?.pageInfo.hasNextPage === true || assignees.pageInfo.hasNextPage) {
241 + const moreLabels: IssueLabel[] = [];
242 + const moreAssignees: IssueActor[] = [];
243 + const allClosing = [...(closing?.nodes ?? [])];
244 + while (
245 + labels?.pageInfo.hasNextPage === true ||
246 + assignees.pageInfo.hasNextPage ||
247 + closing?.pageInfo.hasNextPage === true
248 + ) {
249 const labelsCursor = labels?.pageInfo.hasNextPage ? labels.pageInfo.endCursor : null;
250 const assigneesCursor = assignees.pageInfo.hasNextPage
251 ? assignees.pageInfo.endCursor
252 : null;
244 - const key = `${labelsCursor ?? ""} ${assigneesCursor ?? ""}`;
253 + const closingPullRequestsCursor = closing?.pageInfo.hasNextPage
254 + ? closing.pageInfo.endCursor
255 + : null;
256 + const key = `${labelsCursor ?? ""} ${assigneesCursor ?? ""} ${closingPullRequestsCursor ?? ""}`;
257 if (
258 (labels?.pageInfo.hasNextPage && labelsCursor === null) ||
259 (assignees.pageInfo.hasNextPage && assigneesCursor === null) ||
260 + (closing?.pageInfo.hasNextPage && closingPullRequestsCursor === null) ||
261 seen.has(key)
262 ) {
263 return yield* invalid(
264 "getIssue",
252 - "GitHub did not return complete issue labels or assignees.",
265 + "GitHub did not return complete issue labels, assignees or linked pull requests.",
266 );
267 }
268 seen.add(key);
269 const page = yield* client
257 - .IssueCollections({ owner, name, number, labelsCursor, assigneesCursor })
270 + .IssueCollections({
271 + owner,
272 + name,
273 + number,
274 + labelsCursor,
275 + assigneesCursor,
276 + closingPullRequestsCursor,
277 + withLabels: labelsCursor !== null,
278 + withAssignees: assigneesCursor !== null,
279 + withClosingPullRequests: closingPullRequestsCursor !== null,
280 + })
281 .pipe(graphql(input.host, "getIssue"));
282 const next = page.repository?.issue;
283 if (next == null) return yield* notFound("getIssue");
261 - if (labels?.pageInfo.hasNextPage) {
262 - labels = next.labels;
263 - if (next.labels === null) {
284 + if (labelsCursor !== null) {
285 + if (next.labels == null) {
286 return yield* invalid("getIssue", "GitHub did not return complete issue labels.");
287 }
266 - allLabels.push(
288 + labels = next.labels;
289 + moreLabels.push(
290 ...(next.labels.nodes ?? []).flatMap((node) =>
291 node === null ? [] : [{ name: node.name, color: node.color }],
292 ),
293 );
294 }
272 - if (assignees.pageInfo.hasNextPage) {
295 + if (assigneesCursor !== null) {
296 + if (next.assignees === undefined) {
297 + return yield* invalid("getIssue", "GitHub did not return complete issue assignees.");
298 + }
299 assignees = next.assignees;
274 - allAssignees.push(
300 + moreAssignees.push(
301 ...(next.assignees.nodes ?? []).flatMap((node) =>
302 node === null
303 ? []
@@ -279,8 +305,36 @@ export const make = Effect.gen(function* () {
305 ),
306 );
307 }
308 + if (closingPullRequestsCursor !== null) {
309 + if (next.closedByPullRequestsReferences == null) {
310 + return yield* invalid(
311 + "getIssue",
312 + "GitHub did not return complete linked pull requests.",
313 + );
314 + }
315 + closing = next.closedByPullRequestsReferences;
316 + allClosing.push(...(closing.nodes ?? []));
317 + }
318 }
283 - return { ...detail, labels: allLabels, assignees: allAssignees };
319 + const detail = toIssueDetail({
320 + ...result,
321 + repository: {
322 + ...repository,
323 + issue: {
324 + ...raw,
325 + closedByPullRequestsReferences:
326 + raw.closedByPullRequestsReferences === null
327 + ? null
328 + : { ...raw.closedByPullRequestsReferences, nodes: allClosing },
329 + },
330 + },
331 + });
332 + if (detail === null) return yield* notFound("getIssue");
333 + return {
334 + ...detail,
335 + labels: [...detail.labels, ...moreLabels],
336 + assignees: [...detail.assignees, ...moreAssignees],
337 + };
338 }),
339
340 getComments: (input) =>
packages/source-control-github/src/server/issues.graphql
+30 -2
@@ -99,6 +99,10 @@ query IssueDetail($owner: String!, $name: String!, $number: Int!) {
99 }
100 }
101 closedByPullRequestsReferences(first: 20, includeClosedPrs: true) {
102 + pageInfo {
103 + hasNextPage
104 + endCursor
105 + }
106 nodes {
107 number
108 title
@@ -363,10 +367,14 @@ query IssueCollections(
367 $number: Int!
368 $labelsCursor: String
369 $assigneesCursor: String
370 + $closingPullRequestsCursor: String
371 + $withLabels: Boolean!
372 + $withAssignees: Boolean!
373 + $withClosingPullRequests: Boolean!
374 ) {
375 repository(owner: $owner, name: $name) {
376 issue(number: $number) {
369 - labels(first: 100, after: $labelsCursor) {
377 + labels(first: 100, after: $labelsCursor) @include(if: $withLabels) {
378 pageInfo {
379 hasNextPage
380 endCursor
@@ -376,7 +384,7 @@ query IssueCollections(
384 color
385 }
386 }
379 - assignees(first: 100, after: $assigneesCursor) {
387 + assignees(first: 100, after: $assigneesCursor) @include(if: $withAssignees) {
388 pageInfo {
389 hasNextPage
390 endCursor
@@ -387,6 +395,26 @@ query IssueCollections(
395 avatarUrl
396 }
397 }
398 + closedByPullRequestsReferences(
399 + first: 100
400 + after: $closingPullRequestsCursor
401 + includeClosedPrs: true
402 + ) @include(if: $withClosingPullRequests) {
403 + pageInfo {
404 + hasNextPage
405 + endCursor
406 + }
407 + nodes {
408 + number
409 + title
410 + url
411 + state
412 + isDraft
413 + repository {
414 + nameWithOwner
415 + }
416 + }
417 + }
418 }
419 }
420 }
packages/source-control-github/src/server/issues.graphql.ts
+18 -6
@@ -332,6 +332,8 @@ export interface NodesPullRequest extends Schema.Struct.Type<typeof NodesPullReq
332
333 /** The connection type for PullRequest. */
334 export const PullRequestConnection = Schema.Struct({
335 + /** Information to aid in pagination. */
336 + pageInfo: SearchPageInfoPageInfo,
337 /** A list of nodes. */
338 nodes: Schema.NullOr(Schema.Array(Schema.NullOr(NodesPullRequest)))
339 })
@@ -582,7 +584,7 @@ export const IssueDetail = GraphQL.query("IssueDetail", {
584 ],
585 selections: [
586 { name: "viewer", body: ["{login}"] },
585 - { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){viewerPermission issue(number:$", "number", "){...IssueRow assignees(first:100){pageInfo{hasNextPage endCursor}nodes{login name avatarUrl}}labels(first:100){pageInfo{hasNextPage endCursor}nodes{name color}}body viewerCanUpdate viewerCanClose viewerCanReopen...Reactions comments(last:100){totalCount pageInfo{hasPreviousPage startCursor}nodes{id author{__typename login avatarUrl}body createdAt url...Reactions}}closedByPullRequestsReferences(first:20 includeClosedPrs:true){nodes{number title url state isDraft repository{nameWithOwner}}}timelineItems(last:100 itemTypes:[CLOSED_EVENT REOPENED_EVENT LABELED_EVENT UNLABELED_EVENT ASSIGNED_EVENT UNASSIGNED_EVENT RENAMED_TITLE_EVENT CROSS_REFERENCED_EVENT]){nodes{__typename...on ClosedEvent{id createdAt actor{__typename login avatarUrl}}...on ReopenedEvent{id createdAt actor{__typename login avatarUrl}}...on LabeledEvent{id createdAt actor{__typename login avatarUrl}label{name}}...on UnlabeledEvent{id createdAt actor{__typename login avatarUrl}label{name}}...on AssignedEvent{id createdAt actor{__typename login avatarUrl}assignee{__typename...on User{login name}...on Bot{login}}}...on UnassignedEvent{id createdAt actor{__typename login avatarUrl}assignee{__typename...on User{login name}...on Bot{login}}}...on RenamedTitleEvent{id createdAt actor{__typename login avatarUrl}currentTitle}...on CrossReferencedEvent{id createdAt actor{__typename login avatarUrl}source{__typename...on PullRequest{number title url state isDraft repository{nameWithOwner}}...on Issue{number repository{nameWithOwner}}}}}}}}"] }
587 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){viewerPermission issue(number:$", "number", "){...IssueRow assignees(first:100){pageInfo{hasNextPage endCursor}nodes{login name avatarUrl}}labels(first:100){pageInfo{hasNextPage endCursor}nodes{name color}}body viewerCanUpdate viewerCanClose viewerCanReopen...Reactions comments(last:100){totalCount pageInfo{hasPreviousPage startCursor}nodes{id author{__typename login avatarUrl}body createdAt url...Reactions}}closedByPullRequestsReferences(first:20 includeClosedPrs:true){pageInfo{hasNextPage endCursor}nodes{number title url state isDraft repository{nameWithOwner}}}timelineItems(last:100 itemTypes:[CLOSED_EVENT REOPENED_EVENT LABELED_EVENT UNLABELED_EVENT ASSIGNED_EVENT UNASSIGNED_EVENT RENAMED_TITLE_EVENT CROSS_REFERENCED_EVENT]){nodes{__typename...on ClosedEvent{id createdAt actor{__typename login avatarUrl}}...on ReopenedEvent{id createdAt actor{__typename login avatarUrl}}...on LabeledEvent{id createdAt actor{__typename login avatarUrl}label{name}}...on UnlabeledEvent{id createdAt actor{__typename login avatarUrl}label{name}}...on AssignedEvent{id createdAt actor{__typename login avatarUrl}assignee{__typename...on User{login name}...on Bot{login}}}...on UnassignedEvent{id createdAt actor{__typename login avatarUrl}assignee{__typename...on User{login name}...on Bot{login}}}...on RenamedTitleEvent{id createdAt actor{__typename login avatarUrl}currentTitle}...on CrossReferencedEvent{id createdAt actor{__typename login avatarUrl}source{__typename...on PullRequest{number title url state isDraft repository{nameWithOwner}}...on Issue{number repository{nameWithOwner}}}}}}}}"] }
588 ],
589 fragments: [
590 { name: "IssueRow", body: ["on Issue{number title url state stateReason createdAt updatedAt closedAt author{__typename login avatarUrl...on User{name}}}"] },
@@ -980,9 +982,11 @@ export declare namespace IssueViewer {
982 /** An Issue is a place to discuss ideas, enhancements, tasks, and bugs for a project. */
983 export const IssueCollectionsRepositoryIssueIssue = Schema.Struct({
984 /** A list of labels associated with the object. */
983 - labels: Schema.NullOr(IssueLabelsLabelConnection),
985 + labels: Schema.optionalKey(Schema.NullOr(IssueLabelsLabelConnection)),
986 /** A list of Users assigned to this object. */
985 - assignees: IssueAssigneesUserConnection
987 + assignees: Schema.optionalKey(IssueAssigneesUserConnection),
988 + /** List of open pull requests referenced from this issue */
989 + closedByPullRequestsReferences: Schema.optionalKey(Schema.NullOr(PullRequestConnection))
990 })
991 export interface IssueCollectionsRepositoryIssueIssue extends Schema.Struct.Type<typeof IssueCollectionsRepositoryIssueIssue.fields> {}
992
@@ -1001,10 +1005,14 @@ export const IssueCollections = GraphQL.query("IssueCollections", {
1005 { name: "name", body: "String!" },
1006 { name: "number", body: "Int!" },
1007 { name: "labelsCursor", body: "String" },
1004 - { name: "assigneesCursor", body: "String" }
1008 + { name: "assigneesCursor", body: "String" },
1009 + { name: "closingPullRequestsCursor", body: "String" },
1010 + { name: "withLabels", body: "Boolean!" },
1011 + { name: "withAssignees", body: "Boolean!" },
1012 + { name: "withClosingPullRequests", body: "Boolean!" }
1013 ],
1014 selections: [
1007 - { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){issue(number:$", "number", "){labels(first:100 after:$", "labelsCursor", "){pageInfo{hasNextPage endCursor}nodes{name color}}assignees(first:100 after:$", "assigneesCursor", "){pageInfo{hasNextPage endCursor}nodes{login name avatarUrl}}}}"] }
1015 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){issue(number:$", "number", "){labels(first:100 after:$", "labelsCursor", ")@include(if:$", "withLabels", "){pageInfo{hasNextPage endCursor}nodes{name color}}assignees(first:100 after:$", "assigneesCursor", ")@include(if:$", "withAssignees", "){pageInfo{hasNextPage endCursor}nodes{login name avatarUrl}}closedByPullRequestsReferences(first:100 after:$", "closingPullRequestsCursor", " includeClosedPrs:true)@include(if:$", "withClosingPullRequests", "){pageInfo{hasNextPage endCursor}nodes{number title url state isDraft repository{nameWithOwner}}}}}"] }
1016 ],
1017 fragments: []
1018 },
@@ -1013,7 +1021,11 @@ export const IssueCollections = GraphQL.query("IssueCollections", {
1021 name: Schema.String,
1022 number: Shared.Int,
1023 labelsCursor: Schema.optional(Schema.NullOr(Schema.String)),
1016 - assigneesCursor: Schema.optional(Schema.NullOr(Schema.String))
1024 + assigneesCursor: Schema.optional(Schema.NullOr(Schema.String)),
1025 + closingPullRequestsCursor: Schema.optional(Schema.NullOr(Schema.String)),
1026 + withLabels: Schema.Boolean,
1027 + withAssignees: Schema.Boolean,
1028 + withClosingPullRequests: Schema.Boolean
1029 },
1030 result: Schema.Struct({
1031 /** Lookup a given repository by the owner and repository name. */
scripts/scenarios/github-closing-pr-after-first-page.e2e.ts new
+222
@@ -0,0 +1,222 @@
1 +import * as NodeServices from "@effect/platform-node/NodeServices";
2 +import * as HostProcess from "@t3tools/shared/HostProcess";
3 +import * as NetService from "@t3tools/shared/Net";
4 +import { expect } from "e2e";
5 +import * as Deferred from "effect/Deferred";
6 +import * as Effect from "effect/Effect";
7 +import * as Fiber from "effect/Fiber";
8 +import * as Path from "effect/Path";
9 +import * as Schema from "effect/Schema";
10 +import { FetchHttpClient, HttpClient, HttpClientResponse } from "effect/http";
11 +
12 +import { APP_DIR, T3_HOME } from "../e2e.config.ts";
13 +import { run, ScenarioError } from "./shell.ts";
14 +import { prepareHome, start } from "./start-app.ts";
15 +import { makeState, runPromise, test, WEB } from "./t3.ts";
16 +
17 +const HOST = "github.scenario.invalid";
18 +const SCOPE = "scenario/demo";
19 +const HOME = `${T3_HOME}-github-issue-links`;
20 +
21 +// Install only on the isolated server. The real GitHub adapter still builds and decodes requests.
22 +const upstream = String.raw`
23 +const host = "${HOST}";
24 +const scope = "${SCOPE}";
25 +const viewer = { login: "scenario-user" };
26 +const createdAt = "2026-10-01T00:00:00Z";
27 +const updatedAt = "2026-10-05T00:00:00Z";
28 +const row = {
29 + __typename: "Issue", number: 42, title: "Release preparation",
30 + url: "https://" + host + "/" + scope + "/issues/42",
31 + state: "OPEN", stateReason: null, author: null, createdAt, updatedAt, closedAt: null,
32 +};
33 +const empty = { nodes: [], totalCount: 0, pageInfo: { hasNextPage: false, endCursor: null } };
34 +const links = Array.from({ length: 21 }, (_, i) => ({
35 + number: 100 + i,
36 + title: i === 20 ? "Backfill release metadata" : "Fix release check " + (i + 1),
37 + url: "https://" + host + "/" + scope + "/pull/" + (100 + i),
38 + state: "OPEN",
39 + isDraft: false,
40 + repository: { nameWithOwner: scope },
41 +}));
42 +const timeline = [
43 + ...links.map((link) => ({
44 + __typename: "CrossReferencedEvent", id: "ref-" + link.number, createdAt, actor: null,
45 + source: { ...link, __typename: "PullRequest" },
46 + })),
47 + ...Array.from({ length: 100 }, (_, i) => ({
48 + __typename: "RenamedTitleEvent", id: "rename-" + i,
49 + createdAt: new Date(Date.parse(updatedAt) - (99 - i) * 60_000).toISOString(),
50 + actor: null, currentTitle: i === 99 ? row.title : "Release draft " + i,
51 + })),
52 +];
53 +function arg(query, field, argument, vars) {
54 + const args = query.match(new RegExp("\\b" + field + "\\s*\\(([^)]*)\\)"))?.[1] ?? "";
55 + const value = args.match(new RegExp("\\b" + argument + '\\s*:\\s*(\\$[\\w]+|[0-9]+|"[^"]*")'))?.[1];
56 + if (value === undefined) return undefined;
57 + if (value.startsWith("$")) return vars[value.slice(1)];
58 + return JSON.parse(value);
59 +}
60 +
61 +function page(nodes, query, field, vars) {
62 + const filter = arg(query, field, "query", vars)?.toLowerCase();
63 + const matches = filter ? nodes.filter((node) => node.name?.toLowerCase().includes(filter)) : nodes;
64 + const start = Number(arg(query, field, "after", vars) ?? 0);
65 + const end = start + (arg(query, field, "first", vars) ?? 100);
66 + const last = arg(query, field, "last", vars);
67 + return {
68 + nodes: last === undefined ? matches.slice(start, end) : matches.slice(-last),
69 + totalCount: matches.length,
70 + pageInfo: { hasNextPage: end < matches.length, endCursor: String(end) },
71 + };
72 +}
73 +
74 +const fetchActual = globalThis.fetch;
75 +globalThis.fetch = async (input, init) => {
76 + const request = new Request(input, init);
77 + const url = new URL(request.url);
78 + if (url.hostname !== host) return fetchActual(input, init);
79 + if (url.pathname === "/api/v3/user") return Response.json({ ...viewer, name: null });
80 + if (url.pathname !== "/api/graphql") return new Response(null, { status: 404 });
81 + const { query, variables = {} } = await request.json();
82 + if (/\bsearch\s*\(/.test(query)) {
83 + return Response.json({ data: { search: { ...empty, nodes: [
84 + { ...row, assignees: empty, labels: empty, comments: { totalCount: 0 } },
85 + ] } } });
86 + }
87 + const repository = {
88 + viewerPermission: "WRITE",
89 + labels: empty, assignableUsers: empty,
90 + issue: {
91 + ...row, labels: empty, assignees: empty, body: "Check the release notes.",
92 + viewerCanUpdate: true, viewerCanClose: true, viewerCanReopen: false, reactionGroups: [],
93 + locked: false, activeLockReason: null, viewerCanComment: true,
94 + comments: { nodes: [], totalCount: 0, pageInfo: { hasPreviousPage: false, startCursor: null } },
95 + closedByPullRequestsReferences: page(links, query, "closedByPullRequestsReferences", variables),
96 + timelineItems: page(timeline, query, "timelineItems", variables),
97 + },
98 + };
99 + return Response.json({ data: { viewer, repository } });
100 +};
101 +`;
102 +
103 +function startFixtureServer(webOrigin: string) {
104 + const ready = Promise.withResolvers<{ origin: string; token: string }>();
105 + const server = Effect.runFork(
106 + Effect.gen(function* () {
107 + yield* prepareHome(HOME);
108 + const port = yield* (yield* NetService.NetService).reserveLoopbackPort();
109 + const origin = `http://127.0.0.1:${port}`;
110 + const token = yield* Deferred.make<string>();
111 + const path = yield* Path.Path;
112 + const searchPath = (yield* HostProcess.Environment).PATH ?? "";
113 + const node = yield* HostProcess.ExecutablePath;
114 + const child = yield* start({
115 + cwd: APP_DIR,
116 + command: node,
117 + args: [
118 + `--import=data:text/javascript;base64,${Buffer.from(upstream).toString("base64")}`,
119 + "apps/server/src/bin.ts",
120 + "serve",
121 + "--host",
122 + "127.0.0.1",
123 + "--port",
124 + String(port),
125 + "--base-dir",
126 + HOME,
127 + "--dev-url",
128 + webOrigin,
129 + ],
130 + env: {
131 + PATH: `${path.join(HOME, "bin")}:${searchPath}`,
132 + HOME,
133 + GH_HOST: HOST,
134 + GH_ENTERPRISE_TOKEN: "scenario-only-token",
135 + T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD: "0",
136 + },
137 + onLine: (line) => {
138 + const value = /^Token:\s*(\S+)/.exec(line)?.[1];
139 + return value === undefined
140 + ? Effect.void
141 + : Deferred.succeed(token, value).pipe(Effect.asVoid);
142 + },
143 + });
144 + const exited = child.exitCode.pipe(
145 + Effect.flatMap(
146 + (code) => new ScenarioError({ message: `Fixture server exited (${code}).` }),
147 + ),
148 + );
149 + ready.resolve({ origin, token: yield* Effect.raceFirst(Deferred.await(token), exited) });
150 + return yield* exited;
151 + }).pipe(Effect.scoped, Effect.provide([NodeServices.layer, NetService.layer])),
152 + );
153 + void Effect.runPromise(Fiber.join(server)).catch(ready.reject);
154 + return { ready: ready.promise, stop: () => Effect.runPromise(Fiber.interrupt(server)) };
155 +}
156 +
157 +test(
158 + "A closing pull request remains visible after its timeline reference ages out",
159 + WEB,
160 + async ({ t3, app, browser, screen }) => {
161 + const workspace = await t3.project("Release");
162 + const server = startFixtureServer(app.baseUrl ?? "");
163 + try {
164 + const { origin, token } = await server.ready;
165 + const repository = await runPromise(
166 + Effect.map(Path.Path, (path) => path.join(HOME, "release")),
167 + );
168 + await runPromise(run("git", ["clone", "--quiet", workspace, repository]));
169 + await runPromise(
170 + run("git", ["remote", "set-url", "origin", `https://${HOST}/${SCOPE}.git`], {
171 + cwd: repository,
172 + }),
173 + );
174 + const added = await runPromise(makeState(HOME).cli(["project", "add", repository]));
175 + const projectId = /Added project (\S+) /.exec(added.stdout)?.[1];
176 + if (!projectId) throw new Error("The fixture project was not added.");
177 + const { environmentId } = await runPromise(
178 + HttpClient.get(`${origin}/.well-known/t3/environment`).pipe(
179 + Effect.flatMap(HttpClientResponse.filterStatusOk),
180 + Effect.flatMap(
181 + HttpClientResponse.schemaBodyJson(Schema.Struct({ environmentId: Schema.String })),
182 + ),
183 + Effect.provide(FetchHttpClient.layer),
184 + ),
185 + );
186 + const link = new URLSearchParams({
187 + key: "42",
188 + tracker: "github",
189 + scope: SCOPE,
190 + selectedHost: HOST,
191 + selectedEnvironmentId: environmentId,
192 + selectedProjectId: projectId,
193 + });
194 +
195 + await t3.open("/settings/connections");
196 + await screen.getByRole("button", "Add environment").tap();
197 + const dialog = screen.getByRole("dialog");
198 + await dialog.getByPlaceholder("backend.example.com").fill(origin);
199 + await dialog.getByPlaceholder("PAIRCODE").fill(token);
200 + await dialog.getByRole("button", "Add environment").tap();
201 + await screen.getByRole("button", "More actions for Scenario").waitFor();
202 + await app.open(`/issues?${link}`);
203 +
204 + await screen.getByRole("button", /Fix release check 20/).waitFor();
205 + try {
206 + await expect(screen.getByRole("button", /Backfill release metadata/)).toBeVisible();
207 + } finally {
208 + await browser.evaluate(() => {
209 + const rows = document.querySelectorAll("button");
210 + const row =
211 + [...rows].find((button) => button.textContent?.includes("Backfill release metadata")) ??
212 + [...rows].find((button) => button.textContent?.includes("Fix release check 20"));
213 + row?.scrollIntoView({ block: "center" });
214 + return null;
215 + });
216 + await app.screenshot("last-linked-pull-request");
217 + }
218 + } finally {
219 + await server.stop();
220 + }
221 + },
222 +);