From 23edb6619373cd1bb87db3b8f1ab16c636ffd8e3 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Mon, 30 Nov 2026 18:31:37 +0800 Subject: [PATCH] fix(agents): align task controls and questions with workbench styling --- e2e/agentComposerIcons.spec.ts | 65 +++++++ e2e/agentInteractionStyle.spec.ts | 167 ++++++++++++++++++ src/features/agents/AgentsView.tsx | 4 +- src/features/agents/HomeEditor.tsx | 2 +- src/features/agents/Session.module.css | 69 ++++---- src/features/agents/SkillsPicker.test.tsx | 1 + src/features/agents/SkillsPicker.tsx | 2 +- src/features/agents/composerCommands.test.tsx | 11 ++ src/features/agents/session/QuestionForm.tsx | 40 +++-- .../agents/session/SessionComposer.tsx | 8 +- src/features/agents/session/messages.tsx | 2 +- src/features/agents/sessionState.test.tsx | 16 ++ src/features/agents/taskActions.ts | 4 +- src/ui/icons.test.tsx | 26 +++ src/ui/icons.tsx | 2 + src/ui/openidea/agents/resume.svg | 5 + src/ui/openidea/agents/skills.svg | 4 + 17 files changed, 367 insertions(+), 61 deletions(-) create mode 100644 e2e/agentComposerIcons.spec.ts create mode 100644 e2e/agentInteractionStyle.spec.ts create mode 100644 src/ui/openidea/agents/resume.svg create mode 100644 src/ui/openidea/agents/skills.svg diff --git a/e2e/agentComposerIcons.spec.ts b/e2e/agentComposerIcons.spec.ts new file mode 100644 index 0000000000..88f32c4d08 --- /dev/null +++ b/e2e/agentComposerIcons.spec.ts @@ -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(); + }); +} diff --git a/e2e/agentInteractionStyle.spec.ts b/e2e/agentInteractionStyle.spec.ts new file mode 100644 index 0000000000..ddb0347b79 --- /dev/null +++ b/e2e/agentInteractionStyle.spec.ts @@ -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" }); + }); +} diff --git a/src/features/agents/AgentsView.tsx b/src/features/agents/AgentsView.tsx index 569e362308..cce0b19458 100644 --- a/src/features/agents/AgentsView.tsx +++ b/src/features/agents/AgentsView.tsx @@ -424,7 +424,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) => ( {multiple && (
- {position + 1} / {answers.length} -
diff --git a/src/features/agents/session/SessionComposer.tsx b/src/features/agents/session/SessionComposer.tsx index e79cc09299..dc06816a4e 100644 --- a/src/features/agents/session/SessionComposer.tsx +++ b/src/features/agents/session/SessionComposer.tsx @@ -95,7 +95,7 @@ function InterruptedBanner({ task }: { task: AgentTask }) {