Repository navigation
Done
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
Not sure
Steps to reproduce
- Open the Labels filter on the Issues tab for a GitHub project with the bug and p1 labels.
- Select bug, then p1.
- Close the filter and let the matching list load.
- Reopen the Labels filter.
- Deselect bug.
- Select bug again with p1 still selected.
- Close the filter.
Expected behavior
Returning to the same pair of labels reuses the fresh results.
Actual behavior
The list starts a new GitHub search even though it has already loaded that exact combination.
Impact
Minor bug or occasional failure. People refining a list with multiple labels can send another search to each connected repository whenever they return to a recent selection in a different order.
Version or commit
main at f92c5e8f98. The cause is at packages/client-runtime/src/state/issues.ts:92.
Environment
Linux x64, the repository's own tests.
Logs or stack traces
Issue searches for the same selected labels: expected 2 to be 1Automated repro
Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.
diff --git a/packages/client-runtime/src/state/issues.test.ts b/packages/client-runtime/src/state/issues.test.ts
index cc4bcb8eb1..f2b4699aa3 100644
--- a/packages/client-runtime/src/state/issues.test.ts
+++ b/packages/client-runtime/src/state/issues.test.ts
@@ -1,7 +1,35 @@
-import type { IssueComment, IssueListEntry, IssueTrackerKind, ProjectId } from "@t3tools/contracts";
+import {
+ EnvironmentId,
+ type IssueListResult,
+ type IssueComment,
+ type IssueListEntry,
+ type IssueTrackerKind,
+ type ProjectId,
+ WS_METHODS,
+} 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 { Atom, AtomRegistry } from "effect/reactivity";
import { describe, expect, it } from "vite-plus/test";
-import { issueEntryKey, mergeIssueListPage, prependIssueComments } from "./issues.ts";
+import {
+ AVAILABLE_CONNECTION_STATE,
+ PrimaryConnectionTarget,
+ type PreparedConnection,
+ type SupervisorConnectionState,
+} from "../connection/model.ts";
+import { EnvironmentRegistry } from "../connection/registry.ts";
+import { EnvironmentSupervisor } from "../connection/supervisor.ts";
+import type { RpcSession } from "../rpc/session.ts";
+import {
+ createIssueEnvironmentAtoms,
+ issueEntryKey,
+ mergeIssueListPage,
+ prependIssueComments,
+} from "./issues.ts";
function entry(overrides: Partial<IssueListEntry> & { key: string }): IssueListEntry {
return {
@@ -69,3 +97,88 @@ describe("prependIssueComments", () => {
expect(prependIssueComments(current, older).map((c) => c.id)).toEqual(["c1", "c2", "c3", "c4"]);
});
});
+
+describe("issue listings", () => {
+ it("reuses a fresh listing for the same labels selected in a different order", async () => {
+ await Effect.runPromise(
+ Effect.scoped(
+ Effect.gen(function* () {
+ const environmentId = EnvironmentId.make("env");
+ const target = new PrimaryConnectionTarget({
+ environmentId,
+ label: "Test environment",
+ httpBaseUrl: "https://issues.example.test",
+ wsBaseUrl: "wss://issues.example.test",
+ });
+ const answer: IssueListResult = {
+ viewers: { "github.com": "octocat" },
+ entries: [
+ entry({
+ key: "1",
+ labels: [
+ { name: "bug", color: null },
+ { name: "p1", color: null },
+ ],
+ }),
+ ],
+ trackers: [],
+ nextCursors: {},
+ errors: [],
+ };
+ let reads = 0;
+ const client = {
+ [WS_METHODS.issuesList]: () =>
+ Effect.sync(() => {
+ reads += 1;
+ return answer;
+ }),
+ };
+ const supervisor = EnvironmentSupervisor.of({
+ target,
+ state: yield* SubscriptionRef.make<SupervisorConnectionState>({
+ ...AVAILABLE_CONNECTION_STATE,
+ phase: "connected",
+ network: "online",
+ desired: true,
+ generation: 1,
+ }),
+ session: yield* SubscriptionRef.make(Option.some({ client } as unknown as RpcSession)),
+ prepared: yield* SubscriptionRef.make<Option.Option<PreparedConnection>>(Option.none()),
+ connect: Effect.void,
+ disconnect: Effect.void,
+ retryNow: Effect.void,
+ });
+ const environment = EnvironmentRegistry.of({
+ run: (_id, effect) => Effect.provideService(effect, EnvironmentSupervisor, supervisor),
+ followStream: (_id, stream) =>
+ Stream.provideService(stream, EnvironmentSupervisor, supervisor),
+ } as Pick<
+ EnvironmentRegistry["Service"],
+ "run" | "followStream"
+ > as EnvironmentRegistry["Service"]);
+ const runtime = Atom.runtime(Layer.succeed(EnvironmentRegistry, environment));
+ const { list } = createIssueEnvironmentAtoms(runtime);
+ const registry = AtomRegistry.make();
+ yield* Effect.addFinalizer(() => Effect.sync(() => registry.dispose()));
+ for (const labels of [
+ ["bug", "p1"],
+ ["p1", "bug"],
+ ]) {
+ const atom = list({ environmentId, input: { state: "open", labels } });
+ yield* Effect.acquireRelease(
+ Effect.sync(() => registry.mount(atom)),
+ (closePicker) => Effect.sync(closePicker),
+ ).pipe(
+ Effect.andThen(AtomRegistry.getResult(registry, atom, { suspendOnWaiting: true })),
+ Effect.tap((value) =>
+ Effect.sync(() => expect(value.entries.map((row) => row.key)).toEqual(["1"])),
+ ),
+ Effect.scoped,
+ );
+ }
+ expect(reads, "Issue searches for the same selected labels").toBe(1);
+ }),
+ ),
+ );
+ });
+});cd packages/client-runtime && pnpm exec vp test run src/state/issues.test.tsWorkaround
No response
Metadata
Metadata
Assignees
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Activity