Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions e2e/agentComposerIcons.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import type { AgentTask } from "../src/bindings";
import { expect, test } from "./fixtures";

const task: AgentTask = {
id: "composer-icons",
title: "Composer icons",
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: [],
};

for (const theme of ["light", "dark"] as const) {
test(`${theme}: Skills uses the same icon colour and size as peer composer actions`, async ({
workbench: page,
}, testInfo) => {
await page.evaluate(
async ({ task, 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);
store.useAgents.setState({
loaded: true,
error: null,
tasks: new Map([[task.id, task]]),
entries: new Map([[task.id, []]]),
sessionLocation: "editor",
});
store.openTask(task.id);
},
{ task, theme },
);

await expect(page.locator("html")).toHaveAttribute("data-theme", theme);
await page.getByRole("button", { name: "Add Context" }).click();
const menu = page.getByRole("menu", { name: "Add Context" });
const skills = menu.getByRole("menuitem", { name: "Skills…" });
const memory = menu.getByRole("menuitem", { name: "Memory…" });
const peerColour = await memory.locator("svg circle").evaluate((el) => getComputedStyle(el).stroke);
await expect(skills.locator("svg path")).toHaveCSS("stroke", peerColour);
const peerSize = await memory.locator("svg").evaluate((el) => {
const { width, height } = getComputedStyle(el);
return { width, height };
});
await expect(skills.locator("svg")).toHaveCSS("width", peerSize.width);
await expect(skills.locator("svg")).toHaveCSS("height", peerSize.height);
await skills.hover();
await expect(skills.locator("svg path")).toHaveCSS("stroke", peerColour);
await menu.screenshot({ path: testInfo.outputPath("add-context.png"), animations: "disabled" });
await page.keyboard.press("Escape");
await expect(menu).toBeHidden();
});
}
167 changes: 167 additions & 0 deletions e2e/agentInteractionStyle.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
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" });
});
}
4 changes: 2 additions & 2 deletions src/features/agents/AgentsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ export function AgentsView() {
}
return [];
};
const rowButton = (label: string, icon: "pin" | "archive" | "resume", run: () => void) => (
const rowButton = (label: string, icon: "pin" | "archive" | "agent-resume", run: () => void) => (
<button
type="button"
className={styles.rowAction}
Expand Down Expand Up @@ -645,7 +645,7 @@ export function AgentsView() {
)}
<span className={styles.rowActions}>
{(interrupted || isWaitingForNetwork(n.task)) &&
rowButton("Resume", "resume", () => void executeAction("agents.resumeTasks", [n.task.id]))}
rowButton("Resume", "agent-resume", () => void executeAction("agents.resumeTasks", [n.task.id]))}
{pinned.has(n.task.id)
? rowButton("Unpin", "pin", () => pinTasks([n.task.id], false))
: rowButton("Pin", "pin", () => pinTasks([n.task.id], true))}
Expand Down
2 changes: 1 addition & 1 deletion src/features/agents/HomeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export function HomeEditor({ docked = false, input }: { docked?: boolean; input?
provider
? [
{ id: "mcp", label: "MCP Servers…", icon: "plugin", run: openMcp },
{ id: "skills", label: "Skills…", icon: "bulb", run: openSkills },
{ id: "skills", label: "Skills…", icon: "skills", run: openSkills },
{ id: "memory", label: "Memory…", icon: "history", run: openMemory },
]
: undefined
Expand Down
Loading
Loading