Файли
openidea/e2e/agentLaunchArguments.spec.ts
T
Mr0Bread 44aeb95993 feat(agents): configure additional launch arguments for built-in ACP agents (#6199) (#6199)
Agent Setup gets an Additional arguments field for built-in ACP agents that launch directly. The arguments are stored as an argv array and appended to the agent's existing launch command; Reset clears only that suffix and keeps the executable, environment and the agent's own arguments. Registry, package-runner, custom ACP and native-driver entries don't show the field.

Co-authored-by: Mr0Bread <[email protected]>
2026-11-27 00:51:24 +08:00

77 рядки
3.1 KiB
TypeScript

import type { Page } from "@playwright/test";
import type { AgentProvider } from "../src/bindings";
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
async function openAgents(page: Page) {
// Load the Settings module in the Vite browser realm, not Playwright's Node process.
const settings = "/src/features/settings/model/staging.ts";
await page.evaluate(async (path) => (await import(/* @vite-ignore */ path)).openSettings("agents.list"), settings);
return page.getByRole("dialog", { name: "Settings", exact: true });
}
test("applies and resets built-in ACP arguments without changing the executable or environment", async ({
workbench: page,
}) => {
await stubDesktop(page);
await page.evaluate(() => {
let extra: string[] = [];
Object.assign(window.__ipc.handlers, {
agent_providers: () => {
const provider = {
id: "omp",
name: "OMP",
command: "/opt/my tools/omp acp",
program: "/opt/my tools/omp",
args: ["acp", ...extra],
additionalArgs: extra,
defaultProgram: "omp",
defaultArgs: ["acp"],
loginHint: null,
commandOverridden: true,
commandEditable: true,
commandReadOnlyReason: null,
installed: true,
env: { OMP_SETTING: "value" },
config: [],
commands: [],
source: { kind: "builtin" },
} satisfies AgentProvider;
return [provider];
},
agent_registry_list: () => ({ agents: [], warning: null }),
agent_set_additional_args: ({ args }: { args: string[] }) => {
extra = args;
return null;
},
settings_get_global: () => ({}),
});
});
const dialog = await openAgents(page);
const launch = dialog.getByRole("region", { name: "Launch" });
await expect(launch.getByRole("textbox", { name: "Executable" })).toHaveValue("/opt/my tools/omp");
const args = launch.getByRole("textbox", { name: "Additional arguments" });
const apply = dialog.getByRole("button", { name: "Apply", exact: true });
await args.fill('--label "two words" ""');
await apply.click();
await expect(launch.getByText("'/opt/my tools/omp' acp --label 'two words' ''", { exact: true })).toBeVisible();
expect(await ipcCalls(page, "agent_set_additional_args")).toEqual([
{ id: "omp", args: ["--label", "two words", ""] },
]);
await args.fill("--discard");
await dialog.getByRole("button", { name: "Cancel", exact: true }).click();
await openAgents(page);
await expect(args).toHaveValue("--label 'two words' ''");
await launch.getByRole("button", { name: "Reset additional arguments" }).click();
await apply.click();
await expect(launch.getByText("'/opt/my tools/omp' acp", { exact: true })).toBeVisible();
await expect(args).toHaveValue("");
await expect(launch.getByRole("textbox", { name: "Executable" })).toHaveValue("/opt/my tools/omp");
await expect(launch.getByRole("textbox", { name: "Environment variables" })).toHaveValue("OMP_SETTING=value");
expect(await ipcCalls(page, "agent_set_additional_args")).toEqual([
{ id: "omp", args: ["--label", "two words", ""] },
{ id: "omp", args: [] },
]);
});