GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(azure-devops): issue lists reuse each project's states and surviv… · HNRow/r3code@1c41c5e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components/issue
    • IssuesPage.tsx
  • packages/source-control-azure-devops/src/server
    • AzureDevOpsIssueTracker.test.ts
    • AzureDevOpsIssueTracker.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/issue/IssuesPage.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/issue/IssuesPage.tsx
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,13 @@ export function IssuesPage() {
216216
input: listInput,
217217
}));
218218
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+
);
220226

221227
const [pages, setPages] = useState<ReadonlyMap<EnvironmentId, HeldIssuePage>>(new Map());
222228
const held = holdIssuePages(list.answers, pages);
Collapse file

‎packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.test.ts‎

Copy file name to clipboardExpand all lines: packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.test.ts
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ describe("AzureDevOpsIssueTracker", () => {
219219
const fs = yield* FileSystem.FileSystem;
220220
const bodies: string[] = [];
221221
const hydrated: string[] = [];
222+
let typeReads = 0;
222223
const api = yield* AzureDevOpsIssueTracker.make.pipe(
223224
Effect.provide(
224225
Layer.mock(AzureDevOpsCli.AzureDevOpsCli)({
@@ -238,6 +239,7 @@ describe("AzureDevOpsIssueTracker", () => {
238239
);
239240
}
240241
if (resource !== "wiql" && resource !== "workitemsbatch") {
242+
if (resource === "workitemtypes") typeReads += 1;
241243
return Effect.succeed(TestSourceControlHost.processOutput(answer(args)));
242244
}
243245
return fs.readFileString(args[args.indexOf("--in-file") + 1]!).pipe(
@@ -260,7 +262,7 @@ describe("AzureDevOpsIssueTracker", () => {
260262
}),
261263
),
262264
);
263-
const page = yield* api.listIssues({
265+
const list = api.listIssues({
264266
cwd: "/w",
265267
host: "dev.azure.com",
266268
scope: "acme/Web App",
@@ -273,11 +275,16 @@ describe("AzureDevOpsIssueTracker", () => {
273275
limit: 2,
274276
cursor: "2026-07-01T00:00:00Z|7",
275277
});
278+
const page = yield* list;
279+
yield* list;
276280
// 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"]);
278282
expect(page.items.map((item) => item.key)).toEqual(["9", "7"]);
279283
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]);
281288
expect(bodies[0]).toContain("AND [System.State] NOT IN ('shipped')");
282289
const { query } = JSON.parse(bodies[0]!) as { query: string };
283290
// Mentions cannot be asked for over REST, so the filter sends no clause for them.
Collapse file

‎packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.ts‎

Copy file name to clipboardExpand all lines: packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.ts
+21-5Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
* scope is `organization/project` and every call names the organization. Listing is a WIQL
44
* query paged by a `(changedDate, id)` keyset cursor, because WIQL has no offset.
55
*/
6+
import * as Cache from "effect/Cache";
7+
import * as Duration from "effect/Duration";
68
import * as Effect from "effect/Effect";
9+
import * as Exit from "effect/Exit";
710
import * as FileSystem from "effect/FileSystem";
811
import * as Result from "effect/Result";
912
import * as Schema from "effect/Schema";
@@ -67,6 +70,7 @@ const VIEWER_PERMISSIONS: IssueViewerPermissions = {
6770

6871
const REST_API_VERSION = "7.1";
6972
const PAGE_SIZE = 100;
73+
const CLOSED_STATES_TTL = Duration.minutes(10);
7074
/** Updates are read a page per `az` process, oldest first, so a long history is bounded. */
7175
const UPDATE_PAGE_LIMIT = 5;
7276
/** 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<
356360
decode: decodeAs(decodeTypes),
357361
}).pipe(Effect.map((types) => types.value));
358362

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+
);
361376

362377
const workItem = (input: {
363378
readonly cwd: string;
@@ -599,9 +614,10 @@ export const make: Effect.Effect<
599614
const dateField = created ? "[System.CreatedDate]" : "[System.ChangedDate]";
600615
return yield* scoped("listIssues", input).pipe(
601616
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 }))),
605621
),
606622
Effect.flatMap(({ scope, closed }) =>
607623
invokeWithBody({

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.