дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +02:00
The agent composer, recovery notices and question forms used one-off styles. Skills and agent Resume get dedicated monochrome icons that inherit the menu, toolbar or button colour, leaving the editor intention bulb and debugger Resume icons unchanged. Interrupted, network-retry and archived notices share one inset geometry with warning colours from the theme, and question forms use the standard control styles.
168 рядки
6.7 KiB
TypeScript
168 рядки
6.7 KiB
TypeScript
import type { AgentEntry, AgentTask } from "../src/bindings";
|
|
import { expect, test } from "./fixtures";
|
|
|
|
const base: AgentTask = {
|
|
id: "recovery-style",
|
|
title: "Recovery",
|
|
provider: "codex",
|
|
status: "ready",
|
|
isolation: "local",
|
|
model: null,
|
|
cwd: "/dev/acme-api",
|
|
branch: null,
|
|
base: null,
|
|
baseCommit: null,
|
|
error: null,
|
|
createdMs: 0,
|
|
updatedMs: 0,
|
|
config: [],
|
|
commands: [],
|
|
usage: null,
|
|
queue: [],
|
|
};
|
|
|
|
const question: AgentEntry = {
|
|
type: "question",
|
|
id: "question-style",
|
|
title: "Choose the implementation",
|
|
chosen: null,
|
|
questions: [
|
|
{
|
|
header: "Implementation",
|
|
question: "Which approach should I use?",
|
|
options: [
|
|
{
|
|
label: "Reuse existing controls (Recommended)",
|
|
description: "Keep the existing behavior and theme.",
|
|
preview: "Use shared Button and Input components.",
|
|
},
|
|
{
|
|
label: "Create a custom control",
|
|
description: "Requires additional maintenance.",
|
|
preview: "Introduce a new component.",
|
|
},
|
|
],
|
|
},
|
|
{
|
|
header: "Tests",
|
|
question: "Which tests should I run?",
|
|
multiSelect: true,
|
|
options: [
|
|
{ label: "Unit tests", description: "Run focused component tests." },
|
|
{ label: "Browser tests", description: "Verify the rendered workflow." },
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|
|
for (const theme of ["light", "dark"] as const) {
|
|
test(`${theme}: agent recovery and question controls follow the workbench style`, async ({
|
|
workbench: page,
|
|
}, testInfo) => {
|
|
await page.evaluate(
|
|
async ({ base, question, theme }) => {
|
|
const storePath = "/src/features/agents/store.ts";
|
|
const themePath = "/src/workbench/theme.ts";
|
|
const store = await import(storePath);
|
|
await (await import(themePath)).setTheme(theme);
|
|
const recovery: AgentTask = { ...base, interrupted: { reason: "quit", atMs: Date.now() - 120_000 } };
|
|
const ask: AgentTask = { ...base, id: "ask-style", title: "Question" };
|
|
const entries: AgentEntry[] = [
|
|
{ type: "user", text: "Continue with the implementation.", attachments: [], recovery: "windowClose" },
|
|
{ type: "agent", text: "The implementation is ready to continue." },
|
|
];
|
|
store.useAgents.setState({
|
|
loaded: true,
|
|
error: null,
|
|
tasks: new Map([
|
|
[recovery.id, recovery],
|
|
[ask.id, ask],
|
|
]),
|
|
entries: new Map([
|
|
[recovery.id, entries],
|
|
[ask.id, [question]],
|
|
]),
|
|
sessionLocation: "editor",
|
|
});
|
|
store.openTask(recovery.id);
|
|
},
|
|
{ base, question, theme },
|
|
);
|
|
const resume = page.getByRole("button", { name: "Resume", exact: true });
|
|
await expect(resume).toBeVisible();
|
|
const resumeColor = await resume.evaluate((el) => getComputedStyle(el).color);
|
|
await expect(resume.locator("svg path")).toHaveCSS("stroke", resumeColor);
|
|
const record = page.getByRole("separator").filter({ hasText: "Resumed after window close" });
|
|
const recordColor = await record.evaluate((el) => getComputedStyle(el).color);
|
|
await expect(record.locator("svg path")).toHaveCSS("stroke", recordColor);
|
|
await page
|
|
.getByRole("tabpanel", { name: "Recovery" })
|
|
.screenshot({ path: testInfo.outputPath("recovery.png"), animations: "disabled" });
|
|
await page.evaluate(async () => {
|
|
const storePath = "/src/features/agents/store.ts";
|
|
const { useAgents } = await import(storePath);
|
|
const tasks = new Map(useAgents.getState().tasks);
|
|
const current = tasks.get("recovery-style") as AgentTask;
|
|
tasks.set(current.id, {
|
|
...current,
|
|
status: "running",
|
|
interrupted: null,
|
|
retry: {
|
|
attempt: 1,
|
|
maxRetries: null,
|
|
retryAtMs: Date.now() + 30_000,
|
|
deadlineMs: Date.now() + 3_600_000,
|
|
error: "Connection lost",
|
|
},
|
|
});
|
|
useAgents.setState({ tasks });
|
|
});
|
|
const resumeNow = page.getByRole("button", { name: "Resume Now", exact: true });
|
|
await expect(resumeNow).toBeVisible();
|
|
await expect(resumeNow.locator("svg path")).toHaveCSS("stroke", resumeColor);
|
|
await page.evaluate(async () => {
|
|
const storePath = "/src/features/agents/store.ts";
|
|
(await import(storePath)).openTask("ask-style");
|
|
});
|
|
const card = page.getByRole("form", { name: "Choose the implementation" });
|
|
await expect(card).toBeVisible();
|
|
await expect(card.getByRole("button", { name: "Submit" })).toBeDisabled();
|
|
const buttonHeight = await card
|
|
.getByRole("button", { name: "Submit" })
|
|
.evaluate((el) => getComputedStyle(el).height);
|
|
await expect(card.getByRole("button", { name: "Next" })).toHaveCSS("height", buttonHeight);
|
|
await expect(card.getByRole("button", { name: "Previous" })).toHaveCSS("height", buttonHeight);
|
|
await expect(card.getByText("Implementation", { exact: true })).toHaveCount(1);
|
|
const choice = card.getByRole("radio", { name: /^Reuse existing controls/ });
|
|
const row = choice.locator("xpath=ancestor::label");
|
|
await expect(row).toHaveCSS("border-top-width", "0px");
|
|
await card.screenshot({ path: testInfo.outputPath("question.png"), animations: "disabled" });
|
|
await row.click();
|
|
await expect(card.getByRole("tab", { name: "Tests" })).toHaveAttribute("aria-selected", "true");
|
|
const checkbox = card.getByRole("checkbox", { name: /^Unit tests/ });
|
|
const checkboxRow = checkbox.locator("xpath=ancestor::label");
|
|
await checkboxRow.click();
|
|
await expect(checkbox).toBeChecked();
|
|
const selectionColor = await page.evaluate(() => {
|
|
const probe = document.createElement("span");
|
|
probe.style.backgroundColor = "var(--bg-tree-selected)";
|
|
document.body.append(probe);
|
|
const color = getComputedStyle(probe).backgroundColor;
|
|
probe.remove();
|
|
return color;
|
|
});
|
|
await expect(checkboxRow).toHaveCSS("background-color", selectionColor);
|
|
await expect(card.getByRole("button", { name: "Submit" })).toBeEnabled();
|
|
await card.screenshot({ path: testInfo.outputPath("question-selected.png"), animations: "disabled" });
|
|
await page.setViewportSize({ width: 900, height: 800 });
|
|
const composer = card.locator("xpath=following-sibling::div[1]").locator("[data-owns-file-drop]:visible");
|
|
const cardBounds = await card.boundingBox();
|
|
const composerBounds = await composer.boundingBox();
|
|
expect(cardBounds).not.toBeNull();
|
|
expect(composerBounds).not.toBeNull();
|
|
expect(Math.abs(cardBounds!.x - composerBounds!.x)).toBeLessThan(2);
|
|
expect(Math.abs(cardBounds!.width - composerBounds!.width)).toBeLessThan(2);
|
|
await card.screenshot({ path: testInfo.outputPath("question-narrow.png"), animations: "disabled" });
|
|
});
|
|
}
|