diff --git a/apps/mobile/src/state/issues.ts b/apps/mobile/src/state/issues.ts index 9f47acf847520..0d7558979f916 100644 --- a/apps/mobile/src/state/issues.ts +++ b/apps/mobile/src/state/issues.ts @@ -14,15 +14,15 @@ import { formatEnvironmentQueryError } from "./query"; export const issueEnvironment = createIssueEnvironmentAtoms(connectionAtomRuntime); -const mergedIssueLists = createMergedIssueListAtoms( - issueEnvironment.list, - formatEnvironmentQueryError, -); +const mergedIssueLists = createMergedIssueListAtoms(issueEnvironment, formatEnvironmentQueryError); /** One listing read across every environment asked. */ export function useIssueList(targets: ReadonlyArray) { const view = useAtomValue(mergedIssueLists.atom(targets)); - return { ...view, refresh: () => mergedIssueLists.refresh(appAtomRegistry, targets) }; + return { + ...view, + refresh: () => mergedIssueLists.refresh(appAtomRegistry, targets, "manual"), + }; } /** After a write the list cannot see, such as a new issue filed from a sheet. */ diff --git a/apps/server/src/issue/IssueService.ts b/apps/server/src/issue/IssueService.ts index fbf869e562001..239de06ce546d 100644 --- a/apps/server/src/issue/IssueService.ts +++ b/apps/server/src/issue/IssueService.ts @@ -408,6 +408,7 @@ const make = Effect.gen(function* () { assignee: input.assignee, sort: input.sort ?? "updated", cursor, + refresh: input.refresh, }), ), Effect.result, diff --git a/apps/web/src/components/issue/IssuesPage.tsx b/apps/web/src/components/issue/IssuesPage.tsx index 5181a897a1a17..39fd8a0ec60ed 100644 --- a/apps/web/src/components/issue/IssuesPage.tsx +++ b/apps/web/src/components/issue/IssuesPage.tsx @@ -230,7 +230,7 @@ export function IssuesPage() { // Refreshing a list still loading would cancel it and start over, losing the scopes already read. useLiveRefresh( () => { - if (!list.isPending) list.refresh(); + if (!list.isPending) list.reload(); }, { key: JSON.stringify(targets) }, ); diff --git a/apps/web/src/state/issues.ts b/apps/web/src/state/issues.ts index c92bf81154a12..e1d91bfcb3b53 100644 --- a/apps/web/src/state/issues.ts +++ b/apps/web/src/state/issues.ts @@ -38,19 +38,19 @@ export function useLinkedIssueDetail( ).data; } -const mergedIssueLists = createMergedIssueListAtoms( - issueEnvironment.list, - formatEnvironmentQueryError, -); +const mergedIssueLists = createMergedIssueListAtoms(issueEnvironment, formatEnvironmentQueryError); /** The same listing read across every connected environment, as the pull-request page does. */ -export function useIssueList( - targets: ReadonlyArray, -): MergedIssueList & { readonly refresh: () => void; readonly retry: () => void } { +export function useIssueList(targets: ReadonlyArray): MergedIssueList & { + readonly refresh: () => void; + readonly reload: () => void; + readonly retry: () => void; +} { const view = useAtomValue(mergedIssueLists.atom(targets)); return { ...view, - refresh: () => mergedIssueLists.refresh(appAtomRegistry, targets), + refresh: () => mergedIssueLists.refresh(appAtomRegistry, targets, "manual"), + reload: () => mergedIssueLists.refresh(appAtomRegistry, targets, "background"), retry: () => mergedIssueLists.retry(appAtomRegistry, targets), }; } diff --git a/packages/client-runtime/src/state/issues.test.ts b/packages/client-runtime/src/state/issues.test.ts index 587280be65912..6c80d8faf82ba 100644 --- a/packages/client-runtime/src/state/issues.test.ts +++ b/packages/client-runtime/src/state/issues.test.ts @@ -189,7 +189,7 @@ describe("createMergedIssueListAtoms", () => { it("refreshes the open listings of the environment written to", () => { const reads = new Map(); const lists = new Map>>(); - const listings = createMergedIssueListAtoms((target) => { + const list = (target: IssueListTarget) => { const key = `${target.environmentId}:${target.input.query}`; const existing = lists.get(key); if (existing !== undefined) return existing; @@ -199,7 +199,11 @@ describe("createMergedIssueListAtoms", () => { }); lists.set(key, atom); return atom; - }, String); + }; + const listings = createMergedIssueListAtoms( + { list, refreshList: (registry, target) => registry.refresh(list(target)) }, + String, + ); const registry = AtomRegistry.make(); const written = EnvironmentId.make("written"); const other = EnvironmentId.make("other"); @@ -234,7 +238,7 @@ describe("createMergedIssueListAtoms", () => { ), ); const listings = createMergedIssueListAtoms( - (target) => lists(target.environmentId), + { list: (target) => lists(target.environmentId), refreshList: () => {} }, () => "Tracker unavailable", ); const view = listings.atom(targets); @@ -255,7 +259,7 @@ describe("createMergedIssueListAtoms", () => { NodeV8.setFlagsFromString("--expose-gc"); const gc = NodeVM.runInNewContext("gc") as () => void; const listings = createMergedIssueListAtoms( - () => Atom.make(AsyncResult.success(answer)), + { list: () => Atom.make(AsyncResult.success(answer)), refreshList: () => {} }, String, ); const registry = AtomRegistry.make(); diff --git a/packages/client-runtime/src/state/issues.ts b/packages/client-runtime/src/state/issues.ts index b48ec184a7c7e..043a91e564f77 100644 --- a/packages/client-runtime/src/state/issues.ts +++ b/packages/client-runtime/src/state/issues.ts @@ -15,8 +15,9 @@ import { } from "@t3tools/contracts"; import type * as Cause from "effect/Cause"; import * as Effect from "effect/Effect"; +import * as Exit from "effect/Exit"; import * as Option from "effect/Option"; -import { AsyncResult, Atom, type AtomRegistry } from "effect/reactivity"; +import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity"; import { type AtomCommandResult, @@ -24,8 +25,11 @@ import { createEnvironmentRpcCommand, createEnvironmentRpcQueryAtomFamily, createEnvironmentRpcSubscriptionAtomFamily, + createEnvironmentQueryAtomFamily, } from "./runtime.ts"; import type { EnvironmentRegistry } from "../connection/registry.ts"; +import * as EnvironmentSupervisor from "../connection/supervisor.ts"; +import { request } from "../rpc/client.ts"; /** One row's identity across list pages and detail reads; hosts compare case-insensitively. */ export function issueEntryKey( @@ -145,6 +149,8 @@ export function createIssueCommentPager( }; } +type IssueListRefreshMode = "manual" | "background"; + /** * Every read goes to a tracker API over the environment, so results are reused for a short while * and refreshed explicitly. Mutations run serially per environment: changes to one issue are @@ -179,6 +185,40 @@ export function createIssueEnvironmentAtoms( label: "environment-data:issues:linked-thread-refreshes", tag: WS_METHODS.pullRequestsSubscribeLinkedThreadRefreshes, }); + const pendingListRefreshes = new WeakMap< + AtomRegistry.AtomRegistry, + WeakMap, symbol> + >(); + type ListRequest = ReturnType>; + const list = createEnvironmentQueryAtomFamily(runtime, { + label: "environment-data:issues:list", + staleTimeMs: 30_000, + execute: Effect.fnUntraced(function* ( + input: IssueListInput, + ): Effect.fn.Return< + IssueListResult, + Effect.Error, + Effect.Services | AtomRegistry.AtomRegistry + > { + const registry = yield* AtomRegistry.AtomRegistry; + const { + target: { environmentId }, + } = yield* EnvironmentSupervisor.EnvironmentSupervisor; + const pending = pendingListRefreshes.get(registry); + if (pending === undefined) return yield* request(WS_METHODS.issuesList, input); + const atom = list({ environmentId, input }); + const intent = pending.get(atom); + if (intent === undefined) return yield* request(WS_METHODS.issuesList, input); + return yield* request(WS_METHODS.issuesList, { ...input, refresh: true }).pipe( + // Invalidation interrupts the read; its replacement still owes the explicit refresh. + Effect.onExit((exit) => + Effect.sync(() => { + if (!Exit.hasInterrupts(exit) && pending.get(atom) === intent) pending.delete(atom); + }), + ), + ); + }), + }); return { /** The threads an issue is linked to, reread when the server signals a link changed. */ linkedThreads: createEnvironmentRpcQueryAtomFamily(runtime, { @@ -187,11 +227,23 @@ export function createIssueEnvironmentAtoms( staleTimeMs: 0, refreshTrigger: ({ environmentId }) => linkedThreadSignals({ environmentId, input: {} }), }), - list: createEnvironmentRpcQueryAtomFamily(runtime, { - label: "environment-data:issues:list", - tag: WS_METHODS.issuesList, - staleTimeMs: 30_000, - }), + list, + refreshList( + registry: AtomRegistry.AtomRegistry, + target: IssueListTarget, + mode: IssueListRefreshMode, + ) { + const atom = list(target); + if (mode === "manual") { + let pending = pendingListRefreshes.get(registry); + if (pending === undefined) { + pending = new WeakMap(); + pendingListRefreshes.set(registry, pending); + } + pending.set(atom, Symbol()); + } + registry.refresh(atom); + }, /** * A continuation of the listing, run as a command rather than read as a query: a page is * asked for once and laid over the rows held, and a refresh of the first page forgets it. @@ -300,7 +352,19 @@ function refreshFailed( * the environments that failed, so a read still in flight elsewhere is not restarted. */ export function createMergedIssueListAtoms( - list: (target: IssueListTarget) => Atom.Atom>, + { + list, + refreshList, + }: { + readonly list: ( + target: IssueListTarget, + ) => Atom.Atom>; + readonly refreshList: ( + registry: AtomRegistry.AtomRegistry, + target: IssueListTarget, + mode: IssueListRefreshMode, + ) => void; + }, formatError: (cause: Cause.Cause) => string, ) { const empty = Atom.make(NO_ISSUE_LISTS).pipe(Atom.withLabel("issues:merged-list:empty")); @@ -322,8 +386,9 @@ export function createMergedIssueListAtoms( const refresh = ( registry: AtomRegistry.AtomRegistry, targets: ReadonlyArray, + mode: IssueListRefreshMode, ) => { - for (const target of targets) registry.refresh(list(target)); + for (const target of targets) refreshList(registry, target, mode); }; // The targets behind each listing atom, so a write made elsewhere can refresh the ones still // shown. Weak, so a closed search goes with its atom once the registry drops it. @@ -346,6 +411,7 @@ export function createMergedIssueListAtoms( refresh( registry, targets.filter((target) => target.environmentId === environmentId), + "background", ); } }, diff --git a/packages/client-runtime/src/state/runtime.test.ts b/packages/client-runtime/src/state/runtime.test.ts index 59093d2d9dbdc..0265aa5266a6f 100644 --- a/packages/client-runtime/src/state/runtime.test.ts +++ b/packages/client-runtime/src/state/runtime.test.ts @@ -6,6 +6,8 @@ import { DEFAULT_MAX_TERMINAL_BUFFER_BYTES, EnvironmentId, type FilesystemBrowseEntry, + type IssueListInput, + type IssueListResult, ORCHESTRATION_V2_WS_METHODS, type OrchestrationV2ArchivedShellSnapshot, ThreadId, @@ -52,6 +54,7 @@ import { createOrchestrationEnvironmentAtoms } from "./orchestration.ts"; import { createReviewEnvironmentAtoms } from "./review.ts"; import { createPreviewEnvironmentAtoms } from "./preview.ts"; import { createFilesystemEnvironmentAtoms } from "./filesystem.ts"; +import { createIssueEnvironmentAtoms, createMergedIssueListAtoms } from "./issues.ts"; import type { QueryPersistence } from "./queryPersistence.ts"; import type { EnvironmentShellState } from "./shell.ts"; import { v2Now, v2Project, v2ThreadId, v2ThreadShell } from "./orchestrationV2TestFixtures.ts"; @@ -194,8 +197,8 @@ const readEnvironmentQuery = ( Effect.tap(() => Effect.yieldNow), ); -const mountEnvironmentQuery = Effect.fn("TestEnvironmentQuery.mount")(function* ( - atom: Atom.Atom>, +const mountEnvironmentQuery = Effect.fn("TestEnvironmentQuery.mount")(function* ( + atom: Atom.Atom, ) { const registry = AtomRegistry.make(); const unmount = registry.mount(atom); @@ -263,6 +266,50 @@ it.effect("keeps complete review metadata visible while a refresh is held", () = }), ); +it.effect("keeps manual Issues refresh intent through an overlapping write", () => + Effect.gen(function* () { + const requests = yield* Queue.unbounded(); + const release = yield* Deferred.make(); + const answer: IssueListResult = { + viewers: {}, + trackers: [], + entries: [], + errors: [], + nextCursors: {}, + }; + const rpcSession = { + client: { + [WS_METHODS.issuesList]: (input: IssueListInput) => + Queue.offer(requests, input).pipe( + Effect.andThen(input.refresh ? Deferred.await(release) : Effect.void), + Effect.as(answer), + ), + }, + } as unknown as RpcSession.RpcSession; + const { runtime } = yield* makeEnvironmentQueryHarness(Effect.void, { rpcSession }); + const issues = createIssueEnvironmentAtoms(runtime); + const listings = createMergedIssueListAtoms(issues, String); + const target = { + environmentId: QUERY_ENVIRONMENT.environmentId, + input: { state: "all" }, + } as const; + const registry = yield* mountEnvironmentQuery(listings.atom([target])); + expect(yield* Queue.take(requests)).toEqual({ state: "all" }); + yield* readEnvironmentQuery(registry, issues.list(target)); + + listings.refresh(registry, [target], "manual"); + expect(yield* Queue.take(requests)).toEqual({ state: "all", refresh: true }); + + listings.refreshEnvironment(registry, target.environmentId); + expect(yield* Queue.take(requests)).toEqual({ state: "all", refresh: true }); + + yield* Deferred.succeed(release, undefined); + yield* readEnvironmentQuery(registry, issues.list(target)); + listings.refreshEnvironment(registry, target.environmentId); + expect(yield* Queue.take(requests)).toEqual({ state: "all" }); + }), +); + describe("preview event subscriptions", () => { it.effect("delivers every open and close when RPC events arrive in batches", () => Effect.gen(function* () { diff --git a/packages/contracts/src/issue.ts b/packages/contracts/src/issue.ts index d542eef2b1eed..07f2eab6e6a42 100644 --- a/packages/contracts/src/issue.ts +++ b/packages/contracts/src/issue.ts @@ -266,6 +266,8 @@ export const IssueListInput = Schema.Struct({ limit: Schema.optional(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 200 }))), /** Carry on from an earlier answer: only the scopes named here are read, one slice each. */ cursors: Schema.optional(IssueListCursors), + /** An explicit refresh of the first page may also refresh tracker metadata. */ + refresh: Schema.optional(Schema.Boolean), /** Free text the trackers themselves are asked to match. */ query: Schema.optional(TrimmedNonEmptyString.check(Schema.isMaxLength(200))), /** Label names an issue must carry, every one of them. */ diff --git a/packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.test.ts b/packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.test.ts index cc6a1d18cd28f..4177b9a720d81 100644 --- a/packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.test.ts +++ b/packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.test.ts @@ -220,6 +220,8 @@ describe("AzureDevOpsIssueTracker", () => { const bodies: string[] = []; const hydrated: string[] = []; let typeReads = 0; + let finished = "Shipped"; + let workflowUnavailable = false; const api = yield* AzureDevOpsIssueTracker.make.pipe( Effect.provide( Layer.mock(AzureDevOpsCli.AzureDevOpsCli)({ @@ -238,8 +240,28 @@ describe("AzureDevOpsIssueTracker", () => { }), ); } + if (resource === "workitemtypes") { + typeReads += 1; + if (workflowUnavailable) { + return Effect.fail( + new AzureDevOpsCli.AzureDevOpsCommandFailedError({ + operation: "execute", + command: "az", + cwd: "/w", + argumentCount: args.length, + cause: "workflow metadata unavailable", + }), + ); + } + return Effect.succeed( + TestSourceControlHost.processOutput( + encode({ + value: [{ name: "Bug", states: [{ name: finished, category: "Completed" }] }], + }), + ), + ); + } if (resource !== "wiql" && resource !== "workitemsbatch") { - if (resource === "workitemtypes") typeReads += 1; return Effect.succeed(TestSourceControlHost.processOutput(answer(args))); } return fs.readFileString(args[args.indexOf("--in-file") + 1]!).pipe( @@ -294,6 +316,27 @@ describe("AzureDevOpsIssueTracker", () => { " AND ([System.CreatedDate] < '2026-07-01T00:00:00Z' OR ([System.CreatedDate] = '2026-07-01T00:00:00Z' AND [System.Id] < 7))" + " ORDER BY [System.CreatedDate] DESC, [System.Id] DESC", ); + + // An explicit refresh rereads the workflow; a failed one keeps the last good states. + const firstPage = { + cwd: "/w", + host: "dev.azure.com", + scope: "acme/Web App", + state: "open", + involvement: "all", + sort: "updated", + limit: 2, + } as const; + finished = "Released"; + yield* api.listIssues({ ...firstPage, refresh: true }); + expect(typeReads).toBe(2); + expect(bodies[2]).toContain("AND [System.State] NOT IN ('released')"); + workflowUnavailable = true; + const refreshError = yield* Effect.flip(api.listIssues({ ...firstPage, refresh: true })); + expect(refreshError).toMatchObject({ operation: "listIssues", reason: "failed" }); + yield* api.listIssues(firstPage); + expect(typeReads).toBe(3); + expect(bodies[3]).toContain("AND [System.State] NOT IN ('released')"); }).pipe(Effect.provide(NodeFileSystem.layer)), ); diff --git a/packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.ts b/packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.ts index 84212c9ff0ecd..8fbd08feeadd7 100644 --- a/packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.ts +++ b/packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.ts @@ -360,19 +360,23 @@ export const make: Effect.Effect< decode: decodeAs(decodeTypes), }).pipe(Effect.map((types) => types.value)); - // Each `az` call costs seconds of startup, and a project's states rarely change. - const listClosedStates = yield* Cache.makeWith( + // Shares one in-flight workflow read per project; only a success replaces the cached states. + const workflowReads = yield* Cache.makeWith( (key: string) => { const [cwd, organization, project] = JSON.parse(key) as [string, string, string]; return workItemTypes({ cwd, organization, project, operation: "listIssues" }).pipe( Effect.map(closedStateNames), + Effect.tap((closed) => Cache.set(listClosedStates, key, closed)), ); }, - { + { capacity: Infinity, timeToLive: () => Duration.zero }, + ); + // Each `az` call costs seconds of startup, and a project's states rarely change. + const listClosedStates: Cache.Cache = + yield* Cache.makeWith((key: string) => Cache.get(workflowReads, key), { capacity: 256, timeToLive: (exit) => (Exit.isSuccess(exit) ? CLOSED_STATES_TTL : Duration.zero), - }, - ); + }); const workItem = (input: { readonly cwd: string; @@ -613,12 +617,12 @@ export const make: Effect.Effect< const created = input.sort === "created"; const dateField = created ? "[System.CreatedDate]" : "[System.ChangedDate]"; return yield* scoped("listIssues", input).pipe( - Effect.flatMap((scope) => - Cache.get( - listClosedStates, - JSON.stringify([input.cwd, scope.organization, scope.project]), - ).pipe(Effect.map((closed) => ({ scope, closed }))), - ), + Effect.flatMap((scope) => { + const key = JSON.stringify([input.cwd, scope.organization, scope.project]); + const refresh = cursor === undefined && input.refresh === true; + const closed = refresh ? Cache.get(workflowReads, key) : Cache.get(listClosedStates, key); + return closed.pipe(Effect.map((closed) => ({ scope, closed }))); + }), Effect.flatMap(({ scope, closed }) => invokeWithBody({ cwd: input.cwd, diff --git a/packages/source-control-core/src/server/IssueTracker.ts b/packages/source-control-core/src/server/IssueTracker.ts index de1656d22a2f4..b5894ed806363 100644 --- a/packages/source-control-core/src/server/IssueTracker.ts +++ b/packages/source-control-core/src/server/IssueTracker.ts @@ -126,6 +126,8 @@ export interface IssueTrackerApi { readonly sort: IssueListSort; /** A cursor this tracker handed back from an earlier page. Absent asks for the first. */ readonly cursor?: string | undefined; + /** Whether to re-read tracker metadata for a first page. */ + readonly refresh?: boolean | undefined; }, ) => Effect.Effect; diff --git a/scripts/scenarios/issues-refresh-reads-new-azure-state.e2e.ts b/scripts/scenarios/issues-refresh-reads-new-azure-state.e2e.ts new file mode 100644 index 0000000000000..d8b7173938b1e --- /dev/null +++ b/scripts/scenarios/issues-refresh-reads-new-azure-state.e2e.ts @@ -0,0 +1,124 @@ +import { expect } from "e2e"; +import * as Effect from "effect/Effect"; +import * as FileSystem from "effect/FileSystem"; +import * as Path from "effect/Path"; + +import { T3_HOME } from "../e2e.config.ts"; +import { run } from "./shell.ts"; +import { makeState, runPromise, test, WEB } from "./t3.ts"; + +// Stand in for the Azure CLI upstream. The real tracker builds WIQL and decodes its rows. +const azureCli = String.raw`#!/usr/bin/env node +import { existsSync, readFileSync } from "node:fs"; + +const args = process.argv.slice(2); +const argument = (name) => args[args.indexOf(name) + 1]; +const changed = existsSync(new URL("./workflow-changed", import.meta.url)); +const bugFinished = changed ? "Released" : "Done"; +const item = (id, type, title, state) => ({ + id, + url: "https://dev.azure.com/scenario/_apis/wit/workItems/" + id, + fields: { + "System.Title": title, + "System.State": state, + "System.TeamProject": "Release", + "System.WorkItemType": type, + "System.CreatedDate": "2026-10-01T00:00:00Z", + "System.ChangedDate": "2026-10-02T00:00:00Z", + }, +}); +const items = [ + item(7, "Bug", "Verify the release package", changed ? "Released" : "Active"), + item(6, "Task", changed ? "Release notes checked" : "Release notes drafted", "Closed"), +]; +let output; +switch (argument("--resource")) { + case "workitemtypes": + output = { value: [ + { name: "Bug", states: [ + { name: "Active", category: "InProgress" }, + { name: bugFinished, category: "Completed" }, + ] }, + { name: "Task", states: [{ name: "Closed", category: "Completed" }] }, + ] }; + break; + case "wiql": { + const { query } = JSON.parse(readFileSync(argument("--in-file"), "utf8")); + const clause = /\[System\.State\] (NOT )?IN \(([^)]+)\)/.exec(query); + const names = clause?.[2].match(/'[^']*'/g) ?? []; + output = { workItems: items.filter((item) => { + if (!clause) return true; + const listed = names.includes("'" + item.fields["System.State"].toLowerCase() + "'"); + return clause[1] ? !listed : listed; + }).map(({ id }) => ({ id })) }; + break; + } + case "workitemsbatch": { + const { ids } = JSON.parse(readFileSync(argument("--in-file"), "utf8")); + output = { value: items.filter(({ id }) => ids.includes(id)) }; + break; + } + default: + if (args[0] === "repos" && args[1] === "show") { + output = { + name: "release", + project: { name: "Release" }, + webUrl: "https://dev.azure.com/scenario/Release/_git/release", + remoteUrl: "https://dev.azure.com/scenario/Release/_git/release", + sshUrl: "git@ssh.dev.azure.com:v3/scenario/Release/release", + }; + break; + } + process.exit(1); +} +console.log(JSON.stringify(output)); +`; + +test( + "Refreshing Closed issues picks up a new Azure DevOps finished state", + WEB, + async ({ t3, app, screen }) => { + const workspace = await t3.project("demo"); + const { repository, changed } = await runPromise( + Effect.gen(function* () { + const path = yield* Path.Path; + const fs = yield* FileSystem.FileSystem; + const shim = path.join(T3_HOME, "bin", "az"); + yield* fs.writeFileString(shim, azureCli); + yield* fs.chmod(shim, 0o755); + return { + repository: path.join(T3_HOME, "release"), + changed: path.join(T3_HOME, "bin", "workflow-changed"), + }; + }), + ); + await runPromise(run("git", ["clone", "--quiet", workspace, repository])); + await runPromise( + run( + "git", + ["remote", "set-url", "origin", "https://dev.azure.com/scenario/Release/_git/release"], + { + cwd: repository, + }, + ), + ); + const primary = makeState(T3_HOME); + await runPromise(primary.cli(["project", "add", repository, "--title", "Release"])); + try { + await t3.open("/issues?status=closed"); + // The initial Closed list warms the workflow cache. + await screen.getByText("Release notes drafted", { exact: true }).waitFor({ timeout: 60_000 }); + await runPromise( + Effect.flatMap(FileSystem.FileSystem, (fs) => fs.writeFileString(changed, "")), + ); + + await screen.getByRole("button", "Refresh issues", { exact: true }).tap(); + // This title changes with the workflow, so the next assertion sees the completed refresh. + await screen.getByText("Release notes checked", { exact: true }).waitFor(); + await app.screenshot("closed-issues-after-workflow-change"); + await expect(screen.getByText("Verify the release package", { exact: true })).toBeVisible(); + } finally { + await runPromise(primary.cli(["project", "remove", repository, "--force"])); + } + }, +);