From 91cf66e72ef498521fd361010ead6df887929dd6 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Wed, 2 Dec 2026 18:16:25 +0800 Subject: [PATCH] refactor(agents): simplify the automations dashboard and editor (#7491) The Agents sidebar has a single clock button for Automations, with a dot for unread runs or runs waiting for input. The dashboard puts search and tabs on one row and moves import and pause-all into an Options menu. The automation dialog keeps provider tools with the prompt, moves permissions, continuity and run limits under Advanced, and expands Advanced when an edited schedule uses non-default settings. --- e2e/agentAutomations.spec.ts | 14 +- src/features/agents/AgentsView.tsx | 53 +- src/features/agents/AutomationDialog.tsx | 391 +++++----- src/features/agents/Automations.module.css | 420 +++++++---- src/features/agents/AutomationsEditor.tsx | 783 +++++++++++---------- src/platform/locales/text/en.json | 11 +- src/platform/locales/text/zh.json | 11 +- 7 files changed, 929 insertions(+), 754 deletions(-) diff --git a/e2e/agentAutomations.spec.ts b/e2e/agentAutomations.spec.ts index c39aee180..ef50f0b1d 100644 --- a/e2e/agentAutomations.spec.ts +++ b/e2e/agentAutomations.spec.ts @@ -442,15 +442,13 @@ test("creates, validates cron, runs, inspects provenance, exports/imports .autom await page.setViewportSize({ width: 1320, height: 860 }); await installAutomationDesktopHarness(page); - // Open Agents tool window and click the pinned Automations hub row + // Open Agents tool window and click the Automations header button await page.evaluate(async () => { const actionsModule = "/src/platform/actions.ts"; const { executeAction } = await import(/* @vite-ignore */ actionsModule); await executeAction("agents.showToolWindow"); }); - const hub = page.getByTestId("agents-automations-hub"); - await expect(hub).toBeVisible(); - await hub.getByRole("button", { name: /Automations/ }).click(); + await page.getByRole("button", { name: "Agent Automations" }).click(); const editor = page.getByTestId("automations-editor"); await expect(editor).toBeVisible(); @@ -477,6 +475,7 @@ test("creates, validates cron, runs, inspects provenance, exports/imports .autom await expect(dialog.getByTestId("automation-schedule-preview")).toContainText("Upcoming runs:"); await expect(dialog.getByRole("button", { name: "Create Automation" })).toBeEnabled(); + await dialog.getByRole("button", { name: /Advanced/ }).click(); await dialog.getByLabel("Stop After Runs (optional)").fill("25"); await dialog.getByRole("button", { name: "Create Automation" }).click(); await expect(dialog).toHaveCount(0); @@ -516,7 +515,8 @@ test("creates, validates cron, runs, inspects provenance, exports/imports .autom const exportedMd = await exportDialog.getByLabel("Exported Automation Markdown").inputValue(); await exportDialog.getByRole("button", { name: "Close" }).click(); - await editor.getByRole("button", { name: "Import .automation.md" }).click(); + await editor.getByRole("button", { name: "Options" }).click(); + await page.getByRole("menuitem", { name: "Import .automation.md" }).click(); const importDialog = page.getByRole("dialog", { name: "Import .automation.md" }); await importDialog .getByLabel("Automation Markdown") @@ -570,6 +570,7 @@ test("supports SameTask rolling continuity, NeedsInput approval flow, and sideba dialog = page.getByRole("dialog", { name: "New Automation" }); await dialog.getByLabel("Name").fill("Rolling PR Labeler"); await dialog.getByLabel("Prompt Instructions").fill("NEEDS_APPROVAL label triaged PRs"); + await dialog.getByRole("button", { name: /Advanced/ }).click(); await dialog.getByRole("button", { name: "Session Continuity" }).click(); await page.getByRole("option", { name: "Reuse rolling session" }).click(); await dialog.getByRole("button", { name: "Create Automation" }).click(); @@ -776,8 +777,9 @@ test("supports Weekly day picker, Local Autonomous warning, ChatOnly workspace, await dialog.getByRole("button", { name: "Checkout Isolation" }).click(); await page.getByRole("option", { name: "Local checkout" }).click(); + await dialog.getByRole("button", { name: /Advanced/ }).click(); await dialog.getByRole("button", { name: "Unattended Permissions" }).click(); - await page.getByRole("option", { name: "Allow all (capped by your interactive approval setting)" }).click(); + await page.getByRole("option", { name: /Allow all/ }).click(); await expect(dialog).toContainText( "Warning: Autonomous mode on a local checkout can modify your working files directly.", ); diff --git a/src/features/agents/AgentsView.tsx b/src/features/agents/AgentsView.tsx index e8a7a0486..148498520 100644 --- a/src/features/agents/AgentsView.tsx +++ b/src/features/agents/AgentsView.tsx @@ -62,13 +62,7 @@ import { setFocusedTaskList } from "./taskListFocus"; import { matchTask } from "./taskSearch"; import { SessionEditor } from "./SessionEditor"; import { HomeEditor } from "./HomeEditor"; -import { - automatedTaskVisible, - openAutomationDialog, - openAutomations, - useAutomations, - useAutomationsSync, -} from "./automationsModel"; +import { automatedTaskVisible, useAutomations, useAutomationsSync } from "./automationsModel"; import styles from "./Agents.module.css"; import autoStyles from "./Automations.module.css"; import { basename, useProject } from "@/platform/project"; @@ -76,10 +70,15 @@ import { useTx } from "@/platform/i18n"; import { executeAction } from "@/platform/actions"; export function AgentsHeaderActions() { + const host = useAutomations((s) => s.snapshot.host); + const hasAttention = host.unreadRuns > 0 || host.needsInputRuns > 0; return ( <> - + + + {hasAttention && ); @@ -179,8 +178,6 @@ export function AgentsView() { const providers = useAgents((s) => s.providers); const docked = useAgents((s) => s.docked); const homeOpen = useAgents((s) => s.homeOpen); - const automationHost = useAutomations((s) => s.snapshot.host); - const automationCount = useAutomations((s) => s.snapshot.automations.length); const automatedRunFilter = useAutomations((s) => s.automatedRunFilter); const inline = docked !== null || homeOpen; const historyRef = useRef(null); @@ -535,42 +532,6 @@ export function AgentsView() { setFocusedTaskList(null); }} > -
- - { - setHistoryOpen(false); - openAutomationDialog(); - }} - /> -
{tasks.size > 0 && ( > = [ ]; const PERMISSION_OPTIONS: ReadonlyArray> = [ - { value: "assisted", label: "Accept edits (edit workspace files without asking; ask before commands)" }, - { value: "allowAll", label: "Allow all (capped by your interactive approval setting)" }, - { value: "default", label: "Ask for approval (ask before edits and commands)" }, + { + value: "assisted", + label: "Accept edits", + detail: "Edit workspace files without asking; ask before commands", + }, + { + value: "allowAll", + label: "Allow all", + detail: "Capped by your interactive approval setting", + }, + { + value: "default", + label: "Ask for approval", + detail: "Ask before edits and commands", + }, ]; const CONTINUITY_OPTIONS: ReadonlyArray> = [ @@ -178,6 +190,18 @@ function AutomationDialogBody({ backend }: { backend: AutomationsBackend }) { const [disableAfterStr, setDisableAfterStr] = useState(() => editing?.disableAfterMs ? toDatetimeLocalValue(editing.disableAfterMs).slice(0, 10) : "", ); + // Expand Advanced automatically when editing a schedule with non-default advanced options. + const [advancedOpen, setAdvancedOpen] = useState(() => + Boolean( + editing && + (editing.permissions !== "assisted" || + editing.continuity !== "newTask" || + editing.misfirePolicy != null || + editing.maxRuns != null || + editing.disableAfterMs != null || + (editing.workspace.kind === "project" && !editing.workspace.autoCleanWorktree)), + ), + ); const [fetchedBranches, setFetchedBranches] = useState<{ root: string; list: Branch[] }>({ root: "", list: [] }); const [previewState, setPreviewState] = useState<{ runs: number[]; error: string | null }>({ @@ -249,12 +273,15 @@ function AutomationDialogBody({ backend }: { backend: AutomationsBackend }) { const previewError = currentTrigger.kind === "manual" ? null : previewState.error; const selectedProvider = providers.find((p) => p.id === providerId) ?? providers[0]; + // Exclude interactive permission/approval controls here so they don't conflict with Unattended Permissions. const providerConfig = useMemo( () => - (selectedProvider?.config ?? []).map((opt) => ({ - ...opt, - current: configMap[opt.id] ?? opt.current, - })), + (selectedProvider?.config ?? []) + .filter((opt) => opt.category !== "permissions" && opt.category !== "approval" && opt.category !== "mode") + .map((opt) => ({ + ...opt, + current: configMap[opt.id] ?? opt.current, + })), [selectedProvider, configMap], ); @@ -275,6 +302,9 @@ function AutomationDialogBody({ backend }: { backend: AutomationsBackend }) { [branches, tx], ); + const permissionSummary = tx(PERMISSION_OPTIONS.find((o) => o.value === permissions)?.label ?? "Accept edits"); + const continuitySummary = continuity === "sameTask" ? tx("Rolling session") : tx("Fresh session"); + const toggleWeekday = (day: number) => { setWeeklyDays((cur) => cur.includes(day) ? (cur.length > 1 ? cur.filter((d) => d !== day) : cur) : [...cur, day].sort(), @@ -343,7 +373,7 @@ function AutomationDialogBody({ backend }: { backend: AutomationsBackend }) { open={dialog.open} onClose={closeAutomationDialog} title={editing ? tx("Edit Automation") : tx("New Automation")} - width={620} + width={560} maxHeight={760} resizable="both" footerStart={} @@ -395,107 +425,25 @@ function AutomationDialogBody({ backend }: { backend: AutomationsBackend }) { -