@devries-cameron20 / t3code Mirror · read-only / commits / 1c41c5ed89
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 07:15 UTC

fix(azure-devops): issue lists reuse each project's states and survive a refresh while loading (#38508)

Julius Marminge committed Nov 18, 2026 at 01:53 UTC 1c41c5ed898434f97dae7815f57b0914c9aeb0b5
3 files changed +38 -9
apps/web/src/components/issue/IssuesPage.tsx
+7 -1
@@ -216,7 +216,13 @@ export function IssuesPage() {
216 input: listInput,
217 }));
218 const list = useIssueList(targets);
219 - useLiveRefresh(list.refresh, { key: JSON.stringify(targets) });
219 + // Refreshing a list still loading would cancel it and start over, losing the scopes already read.
220 + useLiveRefresh(
221 + () => {
222 + if (!list.isPending) list.refresh();
223 + },
224 + { key: JSON.stringify(targets) },
225 + );
226
227 const [pages, setPages] = useState<ReadonlyMap<EnvironmentId, HeldIssuePage>>(new Map());
228 const held = holdIssuePages(list.answers, pages);
packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.test.ts
+10 -3
@@ -219,6 +219,7 @@ describe("AzureDevOpsIssueTracker", () => {
219 const fs = yield* FileSystem.FileSystem;
220 const bodies: string[] = [];
221 const hydrated: string[] = [];
222 + let typeReads = 0;
223 const api = yield* AzureDevOpsIssueTracker.make.pipe(
224 Effect.provide(
225 Layer.mock(AzureDevOpsCli.AzureDevOpsCli)({
@@ -238,6 +239,7 @@ describe("AzureDevOpsIssueTracker", () => {
239 );
240 }
241 if (resource !== "wiql" && resource !== "workitemsbatch") {
242 + if (resource === "workitemtypes") typeReads += 1;
243 return Effect.succeed(TestSourceControlHost.processOutput(answer(args)));
244 }
245 return fs.readFileString(args[args.indexOf("--in-file") + 1]!).pipe(
@@ -260,7 +262,7 @@ describe("AzureDevOpsIssueTracker", () => {
262 }),
263 ),
264 );
263 - const page = yield* api.listIssues({
265 + const list = api.listIssues({
266 cwd: "/w",
267 host: "dev.azure.com",
268 scope: "acme/Web App",
@@ -273,11 +275,16 @@ describe("AzureDevOpsIssueTracker", () => {
275 limit: 2,
276 cursor: "2026-07-01T00:00:00Z|7",
277 });
278 + const page = yield* list;
279 + yield* list;
280 // The rows come back in WIQL's order, and the cursor is the last one of the page.
277 - expect(hydrated).toEqual(["9,7"]);
281 + expect(hydrated).toEqual(["9,7", "9,7"]);
282 expect(page.items.map((item) => item.key)).toEqual(["9", "7"]);
283 expect(page.nextCursor).toBe("2026-07-01T00:00:00Z|7");
280 - expect(bodies).toHaveLength(1);
284 + // Each `az` call costs seconds, so a second list reuses the project's states.
285 + expect(typeReads).toBe(1);
286 + expect(bodies).toHaveLength(2);
287 + expect(bodies[1]).toBe(bodies[0]);
288 expect(bodies[0]).toContain("AND [System.State] NOT IN ('shipped')");
289 const { query } = JSON.parse(bodies[0]!) as { query: string };
290 // Mentions cannot be asked for over REST, so the filter sends no clause for them.
packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.ts
+21 -5
@@ -3,7 +3,10 @@
3 * scope is `organization/project` and every call names the organization. Listing is a WIQL
4 * query paged by a `(changedDate, id)` keyset cursor, because WIQL has no offset.
5 */
6 +import * as Cache from "effect/Cache";
7 +import * as Duration from "effect/Duration";
8 import * as Effect from "effect/Effect";
9 +import * as Exit from "effect/Exit";
10 import * as FileSystem from "effect/FileSystem";
11 import * as Result from "effect/Result";
12 import * as Schema from "effect/Schema";
@@ -67,6 +70,7 @@ const VIEWER_PERMISSIONS: IssueViewerPermissions = {
70
71 const REST_API_VERSION = "7.1";
72 const PAGE_SIZE = 100;
73 +const CLOSED_STATES_TTL = Duration.minutes(10);
74 /** Updates are read a page per `az` process, oldest first, so a long history is bounded. */
75 const UPDATE_PAGE_LIMIT = 5;
76 /** Linked pull requests are read one `az` process each, so a work item's links are bounded. */
@@ -356,8 +360,19 @@ export const make: Effect.Effect<
360 decode: decodeAs(decodeTypes),
361 }).pipe(Effect.map((types) => types.value));
362
359 - const closedStates = (input: Parameters<typeof workItemTypes>[0]) =>
360 - workItemTypes(input).pipe(Effect.map(closedStateNames));
363 + // Each `az` call costs seconds of startup, and a project's states rarely change.
364 + const listClosedStates = yield* Cache.makeWith(
365 + (key: string) => {
366 + const [cwd, organization, project] = JSON.parse(key) as [string, string, string];
367 + return workItemTypes({ cwd, organization, project, operation: "listIssues" }).pipe(
368 + Effect.map(closedStateNames),
369 + );
370 + },
371 + {
372 + capacity: 256,
373 + timeToLive: (exit) => (Exit.isSuccess(exit) ? CLOSED_STATES_TTL : Duration.zero),
374 + },
375 + );
376
377 const workItem = (input: {
378 readonly cwd: string;
@@ -599,9 +614,10 @@ export const make: Effect.Effect<
614 const dateField = created ? "[System.CreatedDate]" : "[System.ChangedDate]";
615 return yield* scoped("listIssues", input).pipe(
616 Effect.flatMap((scope) =>
602 - closedStates({ ...scope, cwd: input.cwd, operation: "listIssues" }).pipe(
603 - Effect.map((closed) => ({ scope, closed })),
604 - ),
617 + Cache.get(
618 + listClosedStates,
619 + JSON.stringify([input.cwd, scope.organization, scope.project]),
620 + ).pipe(Effect.map((closed) => ({ scope, closed }))),
621 ),
622 Effect.flatMap(({ scope, closed }) =>
623 invokeWithBody({