@devries-cameron20 / t3code-1 / commits / 60e54867fc
Fork 0

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

fix(azure-devops): refreshing Issues reads each project's current finished states (#38986)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Wout Stiens committed Nov 19, 2026 at 08:32 UTC 60e54867fcafd36a9a6340f627bd6e6e4b699635
12 files changed +333 -40
apps/mobile/src/state/issues.ts
+5 -5
@@ -14,15 +14,15 @@ import { formatEnvironmentQueryError } from "./query";
14
15 export const issueEnvironment = createIssueEnvironmentAtoms(connectionAtomRuntime);
16
17 -const mergedIssueLists = createMergedIssueListAtoms(
18 - issueEnvironment.list,
19 - formatEnvironmentQueryError,
20 -);
17 +const mergedIssueLists = createMergedIssueListAtoms(issueEnvironment, formatEnvironmentQueryError);
18
19 /** One listing read across every environment asked. */
20 export function useIssueList(targets: ReadonlyArray<IssueListTarget>) {
21 const view = useAtomValue(mergedIssueLists.atom(targets));
25 - return { ...view, refresh: () => mergedIssueLists.refresh(appAtomRegistry, targets) };
22 + return {
23 + ...view,
24 + refresh: () => mergedIssueLists.refresh(appAtomRegistry, targets, "manual"),
25 + };
26 }
27
28 /** After a write the list cannot see, such as a new issue filed from a sheet. */
apps/server/src/issue/IssueService.ts
+1
@@ -408,6 +408,7 @@ const make = Effect.gen(function* () {
408 assignee: input.assignee,
409 sort: input.sort ?? "updated",
410 cursor,
411 + refresh: input.refresh,
412 }),
413 ),
414 Effect.result,
apps/web/src/components/issue/IssuesPage.tsx
+1 -1
@@ -230,7 +230,7 @@ export function IssuesPage() {
230 // Refreshing a list still loading would cancel it and start over, losing the scopes already read.
231 useLiveRefresh(
232 () => {
233 - if (!list.isPending) list.refresh();
233 + if (!list.isPending) list.reload();
234 },
235 { key: JSON.stringify(targets) },
236 );
apps/web/src/state/issues.ts
+8 -8
@@ -38,19 +38,19 @@ export function useLinkedIssueDetail(
38 ).data;
39 }
40
41 -const mergedIssueLists = createMergedIssueListAtoms(
42 - issueEnvironment.list,
43 - formatEnvironmentQueryError,
44 -);
41 +const mergedIssueLists = createMergedIssueListAtoms(issueEnvironment, formatEnvironmentQueryError);
42
43 /** 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; readonly retry: () => void } {
44 +export function useIssueList(targets: ReadonlyArray<IssueListTarget>): MergedIssueList & {
45 + readonly refresh: () => void;
46 + readonly reload: () => void;
47 + readonly retry: () => void;
48 +} {
49 const view = useAtomValue(mergedIssueLists.atom(targets));
50 return {
51 ...view,
53 - refresh: () => mergedIssueLists.refresh(appAtomRegistry, targets),
52 + refresh: () => mergedIssueLists.refresh(appAtomRegistry, targets, "manual"),
53 + reload: () => mergedIssueLists.refresh(appAtomRegistry, targets, "background"),
54 retry: () => mergedIssueLists.retry(appAtomRegistry, targets),
55 };
56 }
packages/client-runtime/src/state/issues.test.ts
+8 -4
@@ -189,7 +189,7 @@ describe("createMergedIssueListAtoms", () => {
189 it("refreshes the open listings of the environment written to", () => {
190 const reads = new Map<string, number>();
191 const lists = new Map<string, Atom.Atom<AsyncResult.AsyncResult<IssueListResult>>>();
192 - const listings = createMergedIssueListAtoms((target) => {
192 + const list = (target: IssueListTarget) => {
193 const key = `${target.environmentId}:${target.input.query}`;
194 const existing = lists.get(key);
195 if (existing !== undefined) return existing;
@@ -199,7 +199,11 @@ describe("createMergedIssueListAtoms", () => {
199 });
200 lists.set(key, atom);
201 return atom;
202 - }, String);
202 + };
203 + const listings = createMergedIssueListAtoms(
204 + { list, refreshList: (registry, target) => registry.refresh(list(target)) },
205 + String,
206 + );
207 const registry = AtomRegistry.make();
208 const written = EnvironmentId.make("written");
209 const other = EnvironmentId.make("other");
@@ -234,7 +238,7 @@ describe("createMergedIssueListAtoms", () => {
238 ),
239 );
240 const listings = createMergedIssueListAtoms(
237 - (target) => lists(target.environmentId),
241 + { list: (target) => lists(target.environmentId), refreshList: () => {} },
242 () => "Tracker unavailable",
243 );
244 const view = listings.atom(targets);
@@ -255,7 +259,7 @@ describe("createMergedIssueListAtoms", () => {
259 NodeV8.setFlagsFromString("--expose-gc");
260 const gc = NodeVM.runInNewContext("gc") as () => void;
261 const listings = createMergedIssueListAtoms(
258 - () => Atom.make(AsyncResult.success(answer)),
262 + { list: () => Atom.make(AsyncResult.success(answer)), refreshList: () => {} },
263 String,
264 );
265 const registry = AtomRegistry.make();
packages/client-runtime/src/state/issues.ts
+74 -8
@@ -15,8 +15,9 @@ import {
15 } from "@t3tools/contracts";
16 import type * as Cause from "effect/Cause";
17 import * as Effect from "effect/Effect";
18 +import * as Exit from "effect/Exit";
19 import * as Option from "effect/Option";
19 -import { AsyncResult, Atom, type AtomRegistry } from "effect/reactivity";
20 +import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity";
21
22 import {
23 type AtomCommandResult,
@@ -24,8 +25,11 @@ import {
25 createEnvironmentRpcCommand,
26 createEnvironmentRpcQueryAtomFamily,
27 createEnvironmentRpcSubscriptionAtomFamily,
28 + createEnvironmentQueryAtomFamily,
29 } from "./runtime.ts";
30 import type { EnvironmentRegistry } from "../connection/registry.ts";
31 +import * as EnvironmentSupervisor from "../connection/supervisor.ts";
32 +import { request } from "../rpc/client.ts";
33
34 /** One row's identity across list pages and detail reads; hosts compare case-insensitively. */
35 export function issueEntryKey(
@@ -145,6 +149,8 @@ export function createIssueCommentPager<E>(
149 };
150 }
151
152 +type IssueListRefreshMode = "manual" | "background";
153 +
154 /**
155 * Every read goes to a tracker API over the environment, so results are reused for a short while
156 * and refreshed explicitly. Mutations run serially per environment: changes to one issue are
@@ -179,6 +185,40 @@ export function createIssueEnvironmentAtoms<R, E>(
185 label: "environment-data:issues:linked-thread-refreshes",
186 tag: WS_METHODS.pullRequestsSubscribeLinkedThreadRefreshes,
187 });
188 + const pendingListRefreshes = new WeakMap<
189 + AtomRegistry.AtomRegistry,
190 + WeakMap<Atom.Atom<unknown>, symbol>
191 + >();
192 + type ListRequest = ReturnType<typeof request<typeof WS_METHODS.issuesList>>;
193 + const list = createEnvironmentQueryAtomFamily(runtime, {
194 + label: "environment-data:issues:list",
195 + staleTimeMs: 30_000,
196 + execute: Effect.fnUntraced(function* (
197 + input: IssueListInput,
198 + ): Effect.fn.Return<
199 + IssueListResult,
200 + Effect.Error<ListRequest>,
201 + Effect.Services<ListRequest> | AtomRegistry.AtomRegistry
202 + > {
203 + const registry = yield* AtomRegistry.AtomRegistry;
204 + const {
205 + target: { environmentId },
206 + } = yield* EnvironmentSupervisor.EnvironmentSupervisor;
207 + const pending = pendingListRefreshes.get(registry);
208 + if (pending === undefined) return yield* request(WS_METHODS.issuesList, input);
209 + const atom = list({ environmentId, input });
210 + const intent = pending.get(atom);
211 + if (intent === undefined) return yield* request(WS_METHODS.issuesList, input);
212 + return yield* request(WS_METHODS.issuesList, { ...input, refresh: true }).pipe(
213 + // Invalidation interrupts the read; its replacement still owes the explicit refresh.
214 + Effect.onExit((exit) =>
215 + Effect.sync(() => {
216 + if (!Exit.hasInterrupts(exit) && pending.get(atom) === intent) pending.delete(atom);
217 + }),
218 + ),
219 + );
220 + }),
221 + });
222 return {
223 /** The threads an issue is linked to, reread when the server signals a link changed. */
224 linkedThreads: createEnvironmentRpcQueryAtomFamily(runtime, {
@@ -187,11 +227,23 @@ export function createIssueEnvironmentAtoms<R, E>(
227 staleTimeMs: 0,
228 refreshTrigger: ({ environmentId }) => linkedThreadSignals({ environmentId, input: {} }),
229 }),
190 - list: createEnvironmentRpcQueryAtomFamily(runtime, {
191 - label: "environment-data:issues:list",
192 - tag: WS_METHODS.issuesList,
193 - staleTimeMs: 30_000,
194 - }),
230 + list,
231 + refreshList(
232 + registry: AtomRegistry.AtomRegistry,
233 + target: IssueListTarget,
234 + mode: IssueListRefreshMode,
235 + ) {
236 + const atom = list(target);
237 + if (mode === "manual") {
238 + let pending = pendingListRefreshes.get(registry);
239 + if (pending === undefined) {
240 + pending = new WeakMap();
241 + pendingListRefreshes.set(registry, pending);
242 + }
243 + pending.set(atom, Symbol());
244 + }
245 + registry.refresh(atom);
246 + },
247 /**
248 * A continuation of the listing, run as a command rather than read as a query: a page is
249 * asked for once and laid over the rows held, and a refresh of the first page forgets it.
@@ -300,7 +352,19 @@ function refreshFailed<Target, A, E>(
352 * the environments that failed, so a read still in flight elsewhere is not restarted.
353 */
354 export function createMergedIssueListAtoms<E>(
303 - list: (target: IssueListTarget) => Atom.Atom<AsyncResult.AsyncResult<IssueListResult, E>>,
355 + {
356 + list,
357 + refreshList,
358 + }: {
359 + readonly list: (
360 + target: IssueListTarget,
361 + ) => Atom.Atom<AsyncResult.AsyncResult<IssueListResult, E>>;
362 + readonly refreshList: (
363 + registry: AtomRegistry.AtomRegistry,
364 + target: IssueListTarget,
365 + mode: IssueListRefreshMode,
366 + ) => void;
367 + },
368 formatError: (cause: Cause.Cause<E>) => string,
369 ) {
370 const empty = Atom.make(NO_ISSUE_LISTS).pipe(Atom.withLabel("issues:merged-list:empty"));
@@ -322,8 +386,9 @@ export function createMergedIssueListAtoms<E>(
386 const refresh = (
387 registry: AtomRegistry.AtomRegistry,
388 targets: ReadonlyArray<IssueListTarget>,
389 + mode: IssueListRefreshMode,
390 ) => {
326 - for (const target of targets) registry.refresh(list(target));
391 + for (const target of targets) refreshList(registry, target, mode);
392 };
393 // The targets behind each listing atom, so a write made elsewhere can refresh the ones still
394 // shown. Weak, so a closed search goes with its atom once the registry drops it.
@@ -346,6 +411,7 @@ export function createMergedIssueListAtoms<E>(
411 refresh(
412 registry,
413 targets.filter((target) => target.environmentId === environmentId),
414 + "background",
415 );
416 }
417 },
packages/client-runtime/src/state/runtime.test.ts
+49 -2
@@ -6,6 +6,8 @@ import {
6 DEFAULT_MAX_TERMINAL_BUFFER_BYTES,
7 EnvironmentId,
8 type FilesystemBrowseEntry,
9 + type IssueListInput,
10 + type IssueListResult,
11 ORCHESTRATION_V2_WS_METHODS,
12 type OrchestrationV2ArchivedShellSnapshot,
13 ThreadId,
@@ -52,6 +54,7 @@ import { createOrchestrationEnvironmentAtoms } from "./orchestration.ts";
54 import { createReviewEnvironmentAtoms } from "./review.ts";
55 import { createPreviewEnvironmentAtoms } from "./preview.ts";
56 import { createFilesystemEnvironmentAtoms } from "./filesystem.ts";
57 +import { createIssueEnvironmentAtoms, createMergedIssueListAtoms } from "./issues.ts";
58 import type { QueryPersistence } from "./queryPersistence.ts";
59 import type { EnvironmentShellState } from "./shell.ts";
60 import { v2Now, v2Project, v2ThreadId, v2ThreadShell } from "./orchestrationV2TestFixtures.ts";
@@ -194,8 +197,8 @@ const readEnvironmentQuery = <A, E>(
197 Effect.tap(() => Effect.yieldNow),
198 );
199
197 -const mountEnvironmentQuery = Effect.fn("TestEnvironmentQuery.mount")(function* <A, E>(
198 - atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>,
200 +const mountEnvironmentQuery = Effect.fn("TestEnvironmentQuery.mount")(function* <A>(
201 + atom: Atom.Atom<A>,
202 ) {
203 const registry = AtomRegistry.make();
204 const unmount = registry.mount(atom);
@@ -263,6 +266,50 @@ it.effect("keeps complete review metadata visible while a refresh is held", () =
266 }),
267 );
268
269 +it.effect("keeps manual Issues refresh intent through an overlapping write", () =>
270 + Effect.gen(function* () {
271 + const requests = yield* Queue.unbounded<IssueListInput>();
272 + const release = yield* Deferred.make<void>();
273 + const answer: IssueListResult = {
274 + viewers: {},
275 + trackers: [],
276 + entries: [],
277 + errors: [],
278 + nextCursors: {},
279 + };
280 + const rpcSession = {
281 + client: {
282 + [WS_METHODS.issuesList]: (input: IssueListInput) =>
283 + Queue.offer(requests, input).pipe(
284 + Effect.andThen(input.refresh ? Deferred.await(release) : Effect.void),
285 + Effect.as(answer),
286 + ),
287 + },
288 + } as unknown as RpcSession.RpcSession;
289 + const { runtime } = yield* makeEnvironmentQueryHarness(Effect.void, { rpcSession });
290 + const issues = createIssueEnvironmentAtoms(runtime);
291 + const listings = createMergedIssueListAtoms(issues, String);
292 + const target = {
293 + environmentId: QUERY_ENVIRONMENT.environmentId,
294 + input: { state: "all" },
295 + } as const;
296 + const registry = yield* mountEnvironmentQuery(listings.atom([target]));
297 + expect(yield* Queue.take(requests)).toEqual({ state: "all" });
298 + yield* readEnvironmentQuery(registry, issues.list(target));
299 +
300 + listings.refresh(registry, [target], "manual");
301 + expect(yield* Queue.take(requests)).toEqual({ state: "all", refresh: true });
302 +
303 + listings.refreshEnvironment(registry, target.environmentId);
304 + expect(yield* Queue.take(requests)).toEqual({ state: "all", refresh: true });
305 +
306 + yield* Deferred.succeed(release, undefined);
307 + yield* readEnvironmentQuery(registry, issues.list(target));
308 + listings.refreshEnvironment(registry, target.environmentId);
309 + expect(yield* Queue.take(requests)).toEqual({ state: "all" });
310 + }),
311 +);
312 +
313 describe("preview event subscriptions", () => {
314 it.effect("delivers every open and close when RPC events arrive in batches", () =>
315 Effect.gen(function* () {
packages/contracts/src/issue.ts
+2
@@ -266,6 +266,8 @@ export const IssueListInput = Schema.Struct({
266 limit: Schema.optional(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 200 }))),
267 /** Carry on from an earlier answer: only the scopes named here are read, one slice each. */
268 cursors: Schema.optional(IssueListCursors),
269 + /** An explicit refresh of the first page may also refresh tracker metadata. */
270 + refresh: Schema.optional(Schema.Boolean),
271 /** Free text the trackers themselves are asked to match. */
272 query: Schema.optional(TrimmedNonEmptyString.check(Schema.isMaxLength(200))),
273 /** Label names an issue must carry, every one of them. */
packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.test.ts
+44 -1
@@ -220,6 +220,8 @@ describe("AzureDevOpsIssueTracker", () => {
220 const bodies: string[] = [];
221 const hydrated: string[] = [];
222 let typeReads = 0;
223 + let finished = "Shipped";
224 + let workflowUnavailable = false;
225 const api = yield* AzureDevOpsIssueTracker.make.pipe(
226 Effect.provide(
227 Layer.mock(AzureDevOpsCli.AzureDevOpsCli)({
@@ -238,8 +240,28 @@ describe("AzureDevOpsIssueTracker", () => {
240 }),
241 );
242 }
243 + if (resource === "workitemtypes") {
244 + typeReads += 1;
245 + if (workflowUnavailable) {
246 + return Effect.fail(
247 + new AzureDevOpsCli.AzureDevOpsCommandFailedError({
248 + operation: "execute",
249 + command: "az",
250 + cwd: "/w",
251 + argumentCount: args.length,
252 + cause: "workflow metadata unavailable",
253 + }),
254 + );
255 + }
256 + return Effect.succeed(
257 + TestSourceControlHost.processOutput(
258 + encode({
259 + value: [{ name: "Bug", states: [{ name: finished, category: "Completed" }] }],
260 + }),
261 + ),
262 + );
263 + }
264 if (resource !== "wiql" && resource !== "workitemsbatch") {
242 - if (resource === "workitemtypes") typeReads += 1;
265 return Effect.succeed(TestSourceControlHost.processOutput(answer(args)));
266 }
267 return fs.readFileString(args[args.indexOf("--in-file") + 1]!).pipe(
@@ -294,6 +316,27 @@ describe("AzureDevOpsIssueTracker", () => {
316 " AND ([System.CreatedDate] < '2026-07-01T00:00:00Z' OR ([System.CreatedDate] = '2026-07-01T00:00:00Z' AND [System.Id] < 7))" +
317 " ORDER BY [System.CreatedDate] DESC, [System.Id] DESC",
318 );
319 +
320 + // An explicit refresh rereads the workflow; a failed one keeps the last good states.
321 + const firstPage = {
322 + cwd: "/w",
323 + host: "dev.azure.com",
324 + scope: "acme/Web App",
325 + state: "open",
326 + involvement: "all",
327 + sort: "updated",
328 + limit: 2,
329 + } as const;
330 + finished = "Released";
331 + yield* api.listIssues({ ...firstPage, refresh: true });
332 + expect(typeReads).toBe(2);
333 + expect(bodies[2]).toContain("AND [System.State] NOT IN ('released')");
334 + workflowUnavailable = true;
335 + const refreshError = yield* Effect.flip(api.listIssues({ ...firstPage, refresh: true }));
336 + expect(refreshError).toMatchObject({ operation: "listIssues", reason: "failed" });
337 + yield* api.listIssues(firstPage);
338 + expect(typeReads).toBe(3);
339 + expect(bodies[3]).toContain("AND [System.State] NOT IN ('released')");
340 }).pipe(Effect.provide(NodeFileSystem.layer)),
341 );
342
packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.ts
+15 -11
@@ -360,19 +360,23 @@ export const make: Effect.Effect<
360 decode: decodeAs(decodeTypes),
361 }).pipe(Effect.map((types) => types.value));
362
363 - // Each `az` call costs seconds of startup, and a project's states rarely change.
364 - const listClosedStates = yield* Cache.makeWith(
363 + // Shares one in-flight workflow read per project; only a success replaces the cached states.
364 + const workflowReads = 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 + Effect.tap((closed) => Cache.set(listClosedStates, key, closed)),
370 );
371 },
371 - {
372 + { capacity: Infinity, timeToLive: () => Duration.zero },
373 + );
374 + // Each `az` call costs seconds of startup, and a project's states rarely change.
375 + const listClosedStates: Cache.Cache<string, ClosedStates, IssueTrackerError> =
376 + yield* Cache.makeWith((key: string) => Cache.get(workflowReads, key), {
377 capacity: 256,
378 timeToLive: (exit) => (Exit.isSuccess(exit) ? CLOSED_STATES_TTL : Duration.zero),
374 - },
375 - );
379 + });
380
381 const workItem = (input: {
382 readonly cwd: string;
@@ -613,12 +617,12 @@ export const make: Effect.Effect<
617 const created = input.sort === "created";
618 const dateField = created ? "[System.CreatedDate]" : "[System.ChangedDate]";
619 return yield* scoped("listIssues", input).pipe(
616 - Effect.flatMap((scope) =>
617 - Cache.get(
618 - listClosedStates,
619 - JSON.stringify([input.cwd, scope.organization, scope.project]),
620 - ).pipe(Effect.map((closed) => ({ scope, closed }))),
621 - ),
620 + Effect.flatMap((scope) => {
621 + const key = JSON.stringify([input.cwd, scope.organization, scope.project]);
622 + const refresh = cursor === undefined && input.refresh === true;
623 + const closed = refresh ? Cache.get(workflowReads, key) : Cache.get(listClosedStates, key);
624 + return closed.pipe(Effect.map((closed) => ({ scope, closed })));
625 + }),
626 Effect.flatMap(({ scope, closed }) =>
627 invokeWithBody({
628 cwd: input.cwd,
packages/source-control-core/src/server/IssueTracker.ts
+2
@@ -126,6 +126,8 @@ export interface IssueTrackerApi {
126 readonly sort: IssueListSort;
127 /** A cursor this tracker handed back from an earlier page. Absent asks for the first. */
128 readonly cursor?: string | undefined;
129 + /** Whether to re-read tracker metadata for a first page. */
130 + readonly refresh?: boolean | undefined;
131 },
132 ) => Effect.Effect<TrackerIssuePage, IssueTrackerError>;
133
scripts/scenarios/issues-refresh-reads-new-azure-state.e2e.ts new
+124
@@ -0,0 +1,124 @@
1 +import { expect } from "e2e";
2 +import * as Effect from "effect/Effect";
3 +import * as FileSystem from "effect/FileSystem";
4 +import * as Path from "effect/Path";
5 +
6 +import { T3_HOME } from "../e2e.config.ts";
7 +import { run } from "./shell.ts";
8 +import { makeState, runPromise, test, WEB } from "./t3.ts";
9 +
10 +// Stand in for the Azure CLI upstream. The real tracker builds WIQL and decodes its rows.
11 +const azureCli = String.raw`#!/usr/bin/env node
12 +import { existsSync, readFileSync } from "node:fs";
13 +
14 +const args = process.argv.slice(2);
15 +const argument = (name) => args[args.indexOf(name) + 1];
16 +const changed = existsSync(new URL("./workflow-changed", import.meta.url));
17 +const bugFinished = changed ? "Released" : "Done";
18 +const item = (id, type, title, state) => ({
19 + id,
20 + url: "https://dev.azure.com/scenario/_apis/wit/workItems/" + id,
21 + fields: {
22 + "System.Title": title,
23 + "System.State": state,
24 + "System.TeamProject": "Release",
25 + "System.WorkItemType": type,
26 + "System.CreatedDate": "2026-10-01T00:00:00Z",
27 + "System.ChangedDate": "2026-10-02T00:00:00Z",
28 + },
29 +});
30 +const items = [
31 + item(7, "Bug", "Verify the release package", changed ? "Released" : "Active"),
32 + item(6, "Task", changed ? "Release notes checked" : "Release notes drafted", "Closed"),
33 +];
34 +let output;
35 +switch (argument("--resource")) {
36 + case "workitemtypes":
37 + output = { value: [
38 + { name: "Bug", states: [
39 + { name: "Active", category: "InProgress" },
40 + { name: bugFinished, category: "Completed" },
41 + ] },
42 + { name: "Task", states: [{ name: "Closed", category: "Completed" }] },
43 + ] };
44 + break;
45 + case "wiql": {
46 + const { query } = JSON.parse(readFileSync(argument("--in-file"), "utf8"));
47 + const clause = /\[System\.State\] (NOT )?IN \(([^)]+)\)/.exec(query);
48 + const names = clause?.[2].match(/'[^']*'/g) ?? [];
49 + output = { workItems: items.filter((item) => {
50 + if (!clause) return true;
51 + const listed = names.includes("'" + item.fields["System.State"].toLowerCase() + "'");
52 + return clause[1] ? !listed : listed;
53 + }).map(({ id }) => ({ id })) };
54 + break;
55 + }
56 + case "workitemsbatch": {
57 + const { ids } = JSON.parse(readFileSync(argument("--in-file"), "utf8"));
58 + output = { value: items.filter(({ id }) => ids.includes(id)) };
59 + break;
60 + }
61 + default:
62 + if (args[0] === "repos" && args[1] === "show") {
63 + output = {
64 + name: "release",
65 + project: { name: "Release" },
66 + webUrl: "https://dev.azure.com/scenario/Release/_git/release",
67 + remoteUrl: "https://dev.azure.com/scenario/Release/_git/release",
68 + sshUrl: "git@ssh.dev.azure.com:v3/scenario/Release/release",
69 + };
70 + break;
71 + }
72 + process.exit(1);
73 +}
74 +console.log(JSON.stringify(output));
75 +`;
76 +
77 +test(
78 + "Refreshing Closed issues picks up a new Azure DevOps finished state",
79 + WEB,
80 + async ({ t3, app, screen }) => {
81 + const workspace = await t3.project("demo");
82 + const { repository, changed } = await runPromise(
83 + Effect.gen(function* () {
84 + const path = yield* Path.Path;
85 + const fs = yield* FileSystem.FileSystem;
86 + const shim = path.join(T3_HOME, "bin", "az");
87 + yield* fs.writeFileString(shim, azureCli);
88 + yield* fs.chmod(shim, 0o755);
89 + return {
90 + repository: path.join(T3_HOME, "release"),
91 + changed: path.join(T3_HOME, "bin", "workflow-changed"),
92 + };
93 + }),
94 + );
95 + await runPromise(run("git", ["clone", "--quiet", workspace, repository]));
96 + await runPromise(
97 + run(
98 + "git",
99 + ["remote", "set-url", "origin", "https://dev.azure.com/scenario/Release/_git/release"],
100 + {
101 + cwd: repository,
102 + },
103 + ),
104 + );
105 + const primary = makeState(T3_HOME);
106 + await runPromise(primary.cli(["project", "add", repository, "--title", "Release"]));
107 + try {
108 + await t3.open("/issues?status=closed");
109 + // The initial Closed list warms the workflow cache.
110 + await screen.getByText("Release notes drafted", { exact: true }).waitFor({ timeout: 60_000 });
111 + await runPromise(
112 + Effect.flatMap(FileSystem.FileSystem, (fs) => fs.writeFileString(changed, "")),
113 + );
114 +
115 + await screen.getByRole("button", "Refresh issues", { exact: true }).tap();
116 + // This title changes with the workflow, so the next assertion sees the completed refresh.
117 + await screen.getByText("Release notes checked", { exact: true }).waitFor();
118 + await app.screenshot("closed-issues-after-workflow-change");
119 + await expect(screen.getByText("Verify the release package", { exact: true })).toBeVisible();
120 + } finally {
121 + await runPromise(primary.cli(["project", "remove", repository, "--force"]));
122 + }
123 + },
124 +);