-
Notifications
You must be signed in to change notification settings - Fork 140
feat(flows): accept --ai-task-id on flows list --remote #1542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Felipe Augusto (felipe-augusto)
merged 1 commit into
main
from
wiz-11836-cli-plumb-ai-task-id-through-flows-list-and-pick-up-the
Sep 3, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@qawolf/cli": minor | ||
| --- | ||
|
|
||
| `qawolf flows list --remote` accepts `--ai-task-id`, listing the flows on that AI task's branch — drafts included — instead of the ones the environment holds at its latest reconciled commit. It defaults to `QAWOLF_AI_TASK_ID`, which an AI task runner already sets, so the flag is only needed to point at another task. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import { afterEach, expect, it } from "bun:test"; | ||
| import { Command } from "commander"; | ||
| import { publicContractsV1 } from "@qawolf/api-contracts/v1"; | ||
|
|
||
| import type { AuthCommandContext } from "~/shell/commandContext.js"; | ||
| import { makeCtx, makeFakeUI } from "~/shell/commandContext.testUtils.js"; | ||
| import { | ||
| makeCallPublicApiMock, | ||
| makeMockPlatformClient, | ||
| } from "~/shell/platform/createPlatformClient.testUtils.js"; | ||
| import { createSignalRegistry } from "~/shell/signals/createSignalRegistry.js"; | ||
|
|
||
| import { registerFlowsCommand } from "./index.js"; | ||
| import type { withResolvedEnv } from "./withResolvedEnv.js"; | ||
|
|
||
| const callPublicApi = makeCallPublicApiMock().mockResolvedValue({ | ||
| ok: true, | ||
| value: { flows: [] }, | ||
| }); | ||
|
|
||
| // The remote listing runs behind withResolvedEnv, which resolves an API key | ||
| // and a real platform client. Standing in for it is the smallest seam that | ||
| // still exercises the command's own option-to-request wiring. | ||
| const fakeWithResolvedEnv: typeof withResolvedEnv = | ||
| (_signals, args, fn) => async (): Promise<void> => { | ||
| const ctx: AuthCommandContext = { | ||
| ...makeCtx("json"), | ||
| ui: { ...makeFakeUI("json"), mode: "json" }, | ||
| apiKeySource: "env", | ||
| platformClient: makeMockPlatformClient({ callPublicApi }), | ||
| }; | ||
| await fn(ctx, args.explicit ?? "environment-id", { | ||
| slug: undefined, | ||
| name: undefined, | ||
| }); | ||
| }; | ||
|
|
||
| const originalAiTaskId = process.env["QAWOLF_AI_TASK_ID"]; | ||
|
|
||
| afterEach(() => { | ||
| process.exitCode = 0; | ||
| callPublicApi.mockClear(); | ||
| if (originalAiTaskId === undefined) { | ||
| delete process.env["QAWOLF_AI_TASK_ID"]; | ||
| } else { | ||
| process.env["QAWOLF_AI_TASK_ID"] = originalAiTaskId; | ||
| } | ||
| }); | ||
|
|
||
| async function listRemote(extraArgs: string[]): Promise<void> { | ||
| const program = new Command().name("qawolf").exitOverride(); | ||
| registerFlowsCommand(program, createSignalRegistry(), { | ||
| withResolvedEnv: fakeWithResolvedEnv, | ||
| }); | ||
| await program.parseAsync( | ||
| ["flows", "list", "--remote", "--env", "staging", ...extraArgs], | ||
| { from: "user" }, | ||
| ); | ||
| } | ||
|
|
||
| function requestedAiTaskId(): unknown { | ||
| const call = callPublicApi.mock.calls[0]; | ||
| if (call === undefined) throw new Error("flow.list was never requested"); | ||
| expect(call[0]).toBe(publicContractsV1.flow.list); | ||
| return (call[1] as { aiTaskId: unknown }).aiTaskId; | ||
| } | ||
|
|
||
| it("forwards --ai-task-id to flow.list", async () => { | ||
| delete process.env["QAWOLF_AI_TASK_ID"]; | ||
|
|
||
| await listRemote(["--ai-task-id", "flag-task-id"]); | ||
|
|
||
| expect(requestedAiTaskId()).toBe("flag-task-id"); | ||
| }); | ||
|
|
||
| it("defaults --ai-task-id from QAWOLF_AI_TASK_ID", async () => { | ||
| process.env["QAWOLF_AI_TASK_ID"] = "environment-task-id"; | ||
|
|
||
| await listRemote([]); | ||
|
|
||
| expect(requestedAiTaskId()).toBe("environment-task-id"); | ||
| }); | ||
|
|
||
| it("prefers an explicit --ai-task-id over QAWOLF_AI_TASK_ID", async () => { | ||
| process.env["QAWOLF_AI_TASK_ID"] = "environment-task-id"; | ||
|
|
||
| await listRemote(["--ai-task-id", "flag-task-id"]); | ||
|
|
||
| expect(requestedAiTaskId()).toBe("flag-task-id"); | ||
| }); | ||
|
|
||
| it("omits aiTaskId when neither the flag nor the variable is set", async () => { | ||
| delete process.env["QAWOLF_AI_TASK_ID"]; | ||
|
|
||
| await listRemote([]); | ||
|
|
||
| expect(requestedAiTaskId()).toBeUndefined(); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.