Skip to content

[Bug]: Retrying an issue filter reloads repositories that already answered #38422

Closed

Description

@StiensWout

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/mobile

Steps to reproduce

  1. On mobile, open Issues with two GitHub repositories in the list.
  2. Open the label filter when one repository cannot load its filter options but the other can.
  3. Tap Retry next to the error.

Expected behavior

Retry fetches options only for the repository that failed.

Actual behavior

Retry requests options from both repositories, including the one whose labels are already shown.

Impact

Minor bug or occasional failure. Every retry after a partial failure spends GitHub quota again on the repositories that already answered.

Version or commit

main at f92c5e8f98. The cause is at apps/mobile/src/state/issues.ts:44.

Environment

Linux x64, the repository's own tests.

Logs or stack traces

to have a length of 3 but got 4
Automated repro

Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.

diff --git a/apps/mobile/src/state/issues.test.ts b/apps/mobile/src/state/issues.test.ts
new file mode 100644
--- /dev/null
+++ b/apps/mobile/src/state/issues.test.ts
@@ -0,0 +1,134 @@
+import { expect, it } from "@effect/vitest";
+import {
+  AVAILABLE_CONNECTION_STATE,
+  EnvironmentRegistry,
+  EnvironmentSupervisor,
+  PrimaryConnectionTarget,
+  type PreparedConnection,
+  type SupervisorConnectionState,
+} from "@t3tools/client-runtime/connection";
+import type { RpcSession } from "@t3tools/client-runtime/rpc";
+import {
+  EnvironmentId,
+  IssueOperationError,
+  ProjectId,
+  WS_METHODS,
+  type IssueCandidates,
+  type IssueScopeRef,
+  IssueTrackerKind,
+} from "@t3tools/contracts";
+import * as Effect from "effect/Effect";
+import * as Layer from "effect/Layer";
+import * as Option from "effect/Option";
+import * as Stream from "effect/Stream";
+import * as SubscriptionRef from "effect/SubscriptionRef";
+import { AtomRegistry } from "effect/reactivity";
+import { vi } from "vite-plus/test";
+
+import { appAtomRegistry } from "./atom-registry";
+import { issueEnvironment, refreshIssueFilterCandidates } from "./issues";
+
+const fixture = vi.hoisted(() => ({
+  environment: undefined as EnvironmentRegistry.EnvironmentRegistry["Service"] | undefined,
+}));
+
+vi.mock("../connection/runtime", async () => {
+  const { Atom } = await import("effect/reactivity");
+  return {
+    connectionAtomRuntime: Atom.runtime(
+      Layer.suspend(() =>
+        Layer.succeed(EnvironmentRegistry.EnvironmentRegistry, fixture.environment!),
+      ),
+    ),
+  };
+});
+
+it.effect("retrying a partially loaded issue filter only requests the failed repository", () =>
+  Effect.gen(function* () {
+    const environmentId = EnvironmentId.make("issues-environment");
+    const scope = (name: string) => ({
+      environmentId,
+      input: {
+        projectId: ProjectId.make(name),
+        tracker: IssueTrackerKind.make("github"),
+        host: "github.com",
+        scope: `acme/${name}`,
+      },
+    });
+    const healthy = scope("healthy");
+    const flaky = scope("flaky");
+    const requests: string[] = [];
+    const client = {
+      [WS_METHODS.issuesCandidates]: (input: IssueScopeRef) =>
+        Effect.suspend(() => {
+          const firstRequest = !requests.includes(input.scope);
+          requests.push(input.scope);
+          if (input.scope === flaky.input.scope && firstRequest) {
+            return Effect.fail(
+              new IssueOperationError({
+                operation: "candidates",
+                detail: "Repository unavailable.",
+              }),
+            );
+          }
+          return Effect.succeed({
+            labels: [{ name: input.scope, color: null, description: null }],
+            assignees: [],
+            truncated: false,
+          } satisfies IssueCandidates);
+        }),
+    };
+    const supervisor = EnvironmentSupervisor.EnvironmentSupervisor.of({
+      target: new PrimaryConnectionTarget({
+        environmentId,
+        label: "Issues environment",
+        httpBaseUrl: "https://issues.test",
+        wsBaseUrl: "wss://issues.test",
+      }),
+      state: yield* SubscriptionRef.make<SupervisorConnectionState>({
+        ...AVAILABLE_CONNECTION_STATE,
+        phase: "connected" as const,
+        desired: true,
+        network: "online" as const,
+        attempt: 1,
+        generation: 1,
+      }),
+      session: yield* SubscriptionRef.make(Option.some({ client } as unknown as RpcSession)),
+      prepared: yield* SubscriptionRef.make(Option.none<PreparedConnection>()),
+      connect: Effect.void,
+      disconnect: Effect.void,
+      retryNow: Effect.void,
+    });
+
+    fixture.environment = {
+      run: (_id, effect) =>
+        Effect.provideService(effect, EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
+      followStream: (_id, stream) =>
+        Stream.provideService(stream, EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
+    } as EnvironmentRegistry.EnvironmentRegistry["Service"];
+
+    const healthyCandidates = issueEnvironment.candidates(healthy);
+    const flakyCandidates = issueEnvironment.candidates(flaky);
+    const unmountHealthy = appAtomRegistry.mount(healthyCandidates);
+    const unmountFlaky = appAtomRegistry.mount(flakyCandidates);
+    yield* Effect.addFinalizer(() =>
+      Effect.sync(() => {
+        unmountHealthy();
+        unmountFlaky();
+        appAtomRegistry.dispose();
+        fixture.environment = undefined;
+      }),
+    );
+    const read = (atom: typeof healthyCandidates) =>
+      AtomRegistry.getResult(appAtomRegistry, atom, { suspendOnWaiting: true });
+    yield* read(healthyCandidates);
+    expect((yield* read(flakyCandidates).pipe(Effect.result))._tag).toBe("Failure");
+
+    refreshIssueFilterCandidates([healthy, flaky]);
+
+    const recovered = yield* read(flakyCandidates);
+    expect(recovered.labels.map((label) => label.name)).toEqual(["acme/flaky"]);
+    yield* read(healthyCandidates);
+    expect(requests, "candidate requests across the first load and one retry").toHaveLength(3);
+  }),
+);
cd apps/mobile && pnpm exec vp test run src/state/issues.test.ts

Workaround

No response

Activity

  1. added
    vouch:trusted
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vouch:trusted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions