The best way to control Claude Code, Codex and more from any computer or phone
fix(web): retrying a failed Issues list no longer restarts another environment's read (#38654)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Wout Stiens committed
Nov 19, 2026 at 03:34 UTC
63899c16b959fe0c13ae5ab2b73a6c08268c145c
5 files changed
+212
-12
apps/web/src/components/issue/IssuesPage.tsx
+2
-2
@@ -482,7 +482,7 @@ export function IssuesPage() {
482
) : noneAnswered && list.error ? (
483
<PullRequestsUnavailableState
484
error={list.error}
485
- onRetry={list.refresh}
485
+ onRetry={list.retry}
486
refreshing={list.isPending}
487
/>
488
) : groups.length === 0 ? (
@@ -508,7 +508,7 @@ export function IssuesPage() {
508
<Var>{list.error}</Var> Showing the issues that loaded.
509
</T>
510
</span>
511
- <Button size="xs" variant="outline" onClick={list.refresh}>
511
+ <Button size="xs" variant="outline" onClick={list.retry}>
512
<T>Retry</T>
513
</Button>
514
</div>
apps/web/src/state/issues.ts
+6
-2
@@ -46,9 +46,13 @@ const mergedIssueLists = createMergedIssueListAtoms(
46
/** The same listing read across every connected environment, as the pull-request page does. */
47
export function useIssueList(
48
targets: ReadonlyArray<IssueListTarget>,
49
-): MergedIssueList & { readonly refresh: () => void } {
49
+): MergedIssueList & { readonly refresh: () => void; readonly retry: () => void } {
50
const view = useAtomValue(mergedIssueLists.atom(targets));
51
- return { ...view, refresh: () => mergedIssueLists.refresh(appAtomRegistry, targets) };
51
+ return {
52
+ ...view,
53
+ refresh: () => mergedIssueLists.refresh(appAtomRegistry, targets),
54
+ retry: () => mergedIssueLists.retry(appAtomRegistry, targets),
55
+ };
56
}
57
58
/** After a write made beside the list, such as a state change in the detail panel. */
packages/client-runtime/src/state/issues.test.ts
+33
@@ -218,6 +218,39 @@ describe("createMergedIssueListAtoms", () => {
218
}
219
});
220
221
+ it("retries only failed environments, leaving one still loading to finish", () => {
222
+ const registry = AtomRegistry.make();
223
+ const targets = ["slow", "flaky"].map((environmentId) => ({
224
+ environmentId: EnvironmentId.make(environmentId),
225
+ input: { state: "open" as const },
226
+ }));
227
+ const requests: string[] = [];
228
+ const lists = Atom.family((environmentId: string) =>
229
+ Atom.make(
230
+ Effect.suspend(() => {
231
+ requests.push(environmentId);
232
+ return environmentId === "flaky" ? Effect.fail("Tracker unavailable") : Effect.never;
233
+ }),
234
+ ),
235
+ );
236
+ const listings = createMergedIssueListAtoms(
237
+ (target) => lists(target.environmentId),
238
+ () => "Tracker unavailable",
239
+ );
240
+ const view = listings.atom(targets);
241
+ const unmount = registry.mount(view);
242
+ try {
243
+ expect(registry.get(view)).toMatchObject({ error: "Tracker unavailable", isPending: true });
244
+
245
+ listings.retry(registry, targets);
246
+
247
+ expect(requests).toEqual(["slow", "flaky", "flaky"]);
248
+ } finally {
249
+ unmount();
250
+ registry.dispose();
251
+ }
252
+ });
253
+
254
it("releases historical search targets when the list closes", async () => {
255
NodeV8.setFlagsFromString("--expose-gc");
256
const gc = NodeVM.runInNewContext("gc") as () => void;
packages/client-runtime/src/state/issues.ts
+18
-8
@@ -281,10 +281,23 @@ export interface MergedIssueList {
281
282
const NO_ISSUE_LISTS: MergedIssueList = { answers: [], error: null, isPending: false };
283
284
+function refreshFailed<Target, A, E>(
285
+ registry: AtomRegistry.AtomRegistry,
286
+ targets: ReadonlyArray<Target>,
287
+ query: (target: Target) => Atom.Atom<AsyncResult.AsyncResult<A, E>>,
288
+) {
289
+ for (const target of targets) {
290
+ const atom = query(target);
291
+ const result = registry.get(atom);
292
+ if (result._tag === "Failure" && !result.waiting) registry.refresh(atom);
293
+ }
294
+}
295
+
296
/**
297
* One listing read across every environment at once: React cannot subscribe to a list of atoms
298
* whose length changes, so the fan-out lives in one derived atom keyed by the targets. An
287
- * environment that fails contributes nothing rather than blanking the list.
299
+ * environment that fails contributes nothing rather than blanking the list. Retry reloads only
300
+ * the environments that failed, so a read still in flight elsewhere is not restarted.
301
*/
302
export function createMergedIssueListAtoms<E>(
303
list: (target: IssueListTarget) => Atom.Atom<AsyncResult.AsyncResult<IssueListResult, E>>,
@@ -323,6 +336,8 @@ export function createMergedIssueListAtoms<E>(
336
return atom;
337
},
338
refresh,
339
+ retry: (registry: AtomRegistry.AtomRegistry, targets: ReadonlyArray<IssueListTarget>) =>
340
+ refreshFailed(registry, targets, list),
341
/** Refreshes each listing of `environmentId` that something still reads. */
342
refreshEnvironment: (registry: AtomRegistry.AtomRegistry, environmentId: EnvironmentId) => {
343
for (const node of registry.getNodes().values()) {
@@ -401,12 +416,7 @@ export function createMergedIssueCandidatesAtoms<E>(
416
return {
417
atom: (targets: ReadonlyArray<IssueCandidatesTarget>) =>
418
targets.length === 0 ? empty : family(JSON.stringify(targets)),
404
- retry: (registry: AtomRegistry.AtomRegistry, targets: ReadonlyArray<IssueCandidatesTarget>) => {
405
- for (const target of targets) {
406
- const atom = candidates(target);
407
- const result = registry.get(atom);
408
- if (result._tag === "Failure" && !result.waiting) registry.refresh(atom);
409
- }
410
- },
419
+ retry: (registry: AtomRegistry.AtomRegistry, targets: ReadonlyArray<IssueCandidatesTarget>) =>
420
+ refreshFailed(registry, targets, candidates),
421
};
422
}
scripts/scenarios/issues-retry-keeps-pending-environment.e2e.ts
new
+153
@@ -0,0 +1,153 @@
1
+/// <reference lib="dom" />
2
+import type { IssueListResult } from "@t3tools/contracts";
3
+import { expect } from "e2e";
4
+
5
+import { SECOND_HOME, startSecondServer } from "./second-server.ts";
6
+import { makeState, test, WEB } from "./t3.ts";
7
+
8
+test(
9
+ "Retrying a failed environment keeps the Issues refresh already in progress",
10
+ WEB,
11
+ async ({ t3, app, screen, browser }) => {
12
+ await t3.project("demo");
13
+ const server = startSecondServer(app.baseUrl ?? "");
14
+ try {
15
+ const { host, token } = await server.ready;
16
+ await makeState(SECOND_HOME).state.project("remote-demo");
17
+ await browser.addInitScript((remoteHost) => {
18
+ const { promise: slowRead, resolve: release } = Promise.withResolvers<void>();
19
+ let refreshing = false;
20
+ let primaryRefreshStarted = false;
21
+ let remoteRefreshStarted = false;
22
+ Object.assign(window, {
23
+ armIssuesRefresh: () => {
24
+ refreshing = true;
25
+ },
26
+ releaseSlowIssuesRead: release,
27
+ });
28
+ const date = "2026-10-01T00:00:00.000Z";
29
+ const tracker = "github" as IssueListResult["trackers"][number]["tracker"];
30
+ const list = (title: string, remote: boolean): IssueListResult => {
31
+ const key = remote ? "2" : "1";
32
+ return {
33
+ entries: [
34
+ {
35
+ tracker,
36
+ host: "github.com",
37
+ scope: "example/demo",
38
+ key,
39
+ displayKey: "#" + key,
40
+ title,
41
+ projectId: (remote
42
+ ? "remote-demo"
43
+ : "demo") as IssueListResult["entries"][number]["projectId"],
44
+ projectTitle: remote ? "remote-demo" : "demo",
45
+ url: "https://github.com/example/demo/issues/" + key,
46
+ author: null,
47
+ state: { category: "open", name: "Open" },
48
+ createdAt: date,
49
+ updatedAt: date,
50
+ closedAt: null,
51
+ assignees: [],
52
+ labels: [],
53
+ commentCount: 0,
54
+ },
55
+ ],
56
+ errors: [],
57
+ nextCursors: {},
58
+ viewers: {},
59
+ trackers: [
60
+ {
61
+ tracker,
62
+ host: "github.com",
63
+ projectCount: 1,
64
+ capabilities: null,
65
+ configured: true,
66
+ detail: null,
67
+ },
68
+ ],
69
+ };
70
+ };
71
+ const send = WebSocket.prototype.send;
72
+ WebSocket.prototype.send = function (data) {
73
+ const request: { _tag: string; id: string; tag: string } | null =
74
+ typeof data === "string" ? JSON.parse(data) : null;
75
+ if (request?._tag !== "Request" || request.tag !== "issues.list")
76
+ return send.call(this, data);
77
+ const remote = new URL(this.url).host === remoteHost;
78
+ const reply = (exit: unknown) =>
79
+ this.dispatchEvent(
80
+ new MessageEvent("message", {
81
+ data: JSON.stringify({ _tag: "Exit", requestId: request.id, exit }),
82
+ }),
83
+ );
84
+ const success = (title: string) => reply({ _tag: "Success", value: list(title, remote) });
85
+
86
+ if (!refreshing) {
87
+ queueMicrotask(() =>
88
+ success(remote ? "Issue from the linked environment" : "Before refresh"),
89
+ );
90
+ } else if (remote && !remoteRefreshStarted) {
91
+ remoteRefreshStarted = true;
92
+ queueMicrotask(() =>
93
+ reply({
94
+ _tag: "Failure",
95
+ cause: [
96
+ {
97
+ _tag: "Fail",
98
+ error: {
99
+ _tag: "IssueOperationError",
100
+ operation: "list",
101
+ detail: "The linked environment could not list issues.",
102
+ },
103
+ },
104
+ ],
105
+ }),
106
+ );
107
+ } else if (remote) {
108
+ queueMicrotask(() => success("Issues recovered on the linked environment"));
109
+ } else if (!primaryRefreshStarted) {
110
+ primaryRefreshStarted = true;
111
+ // Only the original slow read is allowed to finish. Restarting it strands its result.
112
+ void slowRead.then(() => success("Updated issue from the slow environment"));
113
+ }
114
+ };
115
+ }, new URL(host).host);
116
+
117
+ await t3.open("/settings/connections");
118
+ await screen.getByRole("button", "Add environment").tap();
119
+ const dialog = screen.getByRole("dialog");
120
+ await dialog.getByPlaceholder("backend.example.com").fill(host);
121
+ await dialog.getByPlaceholder("PAIRCODE").fill(token);
122
+ await dialog.getByRole("button", "Add environment").tap();
123
+ await screen.getByRole("button", "More actions for Scenario").waitFor({ timeout: 60_000 });
124
+ await app.open("/issues");
125
+
126
+ await screen.getByText("Before refresh", { exact: true }).waitFor({ timeout: 60_000 });
127
+ await screen.getByText("Issue from the linked environment", { exact: true }).waitFor();
128
+ await browser.evaluate(() => {
129
+ (window as unknown as { armIssuesRefresh: () => void }).armIssuesRefresh();
130
+ return null;
131
+ });
132
+ await screen.getByRole("button", "Refresh issues", { exact: true }).tap();
133
+ await screen.getByText(/Showing the issues that loaded/).waitFor();
134
+ await screen.getByRole("button", "Retry", { exact: true }).tap();
135
+ await screen
136
+ .getByText("Issues recovered on the linked environment", { exact: true })
137
+ .waitFor();
138
+ await browser.evaluate(() => {
139
+ (window as unknown as { releaseSlowIssuesRead: () => void }).releaseSlowIssuesRead();
140
+ return null;
141
+ });
142
+ try {
143
+ await expect(
144
+ screen.getByText("Updated issue from the slow environment", { exact: true }),
145
+ ).toBeVisible();
146
+ } finally {
147
+ await app.screenshot("partial-issues-after-retry");
148
+ }
149
+ } finally {
150
+ await server.stop();
151
+ }
152
+ },
153
+);