Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(autopilots): move Edit next to Run now in the detail header (MUL-8480) (#9800)
Bohan Jiangba51f6e3c817
diff --git a/packages/views/autopilots/components/autopilot-detail-page.test.tsx b/packages/views/autopilots/components/autopilot-detail-page.test.tsxindex cf637929f3..5e6b4633ed 100644--- a/packages/views/autopilots/components/autopilot-detail-page.test.tsx+++ b/packages/views/autopilots/components/autopilot-detail-page.test.tsx@@ -166,6 +166,19 @@ describe("AutopilotDetailPage", () => {expect(runNow).toHaveBeenCalledWith("ap-1");});+ it("edits the whole autopilot from the header, next to Run now", async () => {+ const user = userEvent.setup();+ mount();+ const header = await screen.findByRole("banner");+ await within(header).findByText("Daily Sync");++ const edit = within(header).getByRole("button", { name: "Edit" });+ const runNowButton = within(header).getByRole("button", { name: "Run now" });+ expect(edit.compareDocumentPosition(runNowButton) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();+ await user.click(edit);+ expect(await screen.findByRole("dialog")).toHaveTextContent("Edit autopilot dialog");+ });+it("can't run a paused autopilot", async () => {detail.autopilot = makeAutopilot({ status: "paused" });mount();@@ -173,16 +186,14 @@ describe("AutopilotDetailPage", () => {expect(await screen.findByRole("button", { name: "Run now" })).toBeDisabled();});- it("keeps edit, copy link and delete in the ⋯ menu", async () => {- const user = userEvent.setup();+ it("keeps copy link and delete in the ⋯ menu", async () => {mount();await screen.findByRole("heading", { name: "Daily Sync", level: 1 });openMoreActions();expect(await screen.findByRole("menuitem", { name: "Copy link" })).toBeInTheDocument();expect(screen.getByRole("menuitem", { name: "Delete autopilot" })).toBeInTheDocument();- await user.click(screen.getByRole("menuitem", { name: "Edit" }));- expect(await screen.findByRole("dialog")).toHaveTextContent("Edit autopilot dialog");+ expect(screen.queryByRole("menuitem", { name: "Edit" })).toBeNull();});it("pauses from the panel's status switch", async () => {@@ -200,7 +211,7 @@ describe("AutopilotDetailPage", () => {const prompt = screen.getByRole("heading", { name: "Prompt", level: 2 }).closest("section")!;expect(within(prompt).getByText("Summarize what changed yesterday.")).toBeVisible();- expect(within(prompt).getByRole("button", { name: "Edit" })).toBeVisible();+ expect(within(prompt).queryByRole("button", { name: "Edit" })).toBeNull();const triggers = screen.getByRole("heading", { name: "Triggers", level: 2 }).closest("section")!;expect(within(triggers).getByText("1")).toBeVisible();@@ -219,6 +230,7 @@ describe("AutopilotDetailPage", () => {await screen.findByRole("heading", { name: "Daily Sync", level: 1 });expect(screen.queryByRole("button", { name: "Run now" })).toBeNull();+ expect(screen.queryByRole("button", { name: "Edit" })).toBeNull();expect(screen.getByRole("switch", { name: "Pause autopilot" })).toHaveAttribute("aria-disabled", "true");expect(screen.queryByRole("button", { name: "Add trigger" })).toBeNull();openMoreActions();diff --git a/packages/views/autopilots/components/autopilot-detail-page.tsx b/packages/views/autopilots/components/autopilot-detail-page.tsxindex 84e720d6c3..25d9d043b5 100644--- a/packages/views/autopilots/components/autopilot-detail-page.tsx+++ b/packages/views/autopilots/components/autopilot-detail-page.tsx@@ -1079,6 +1079,15 @@ export function AutopilotDetailPage({ autopilotId }: { autopilotId: string }) {leaf={<span className="min-w-0 truncate">{autopilot.title}</span>}actions={<>+ {/* The dialog edits the whole autopilot (title, prompt, agent,+ triggers, access), so Edit sits with Run now rather than on the+ Prompt section. */}+ {canWrite && (+ <Button size="sm" variant="outline" onClick={() => setEditDialogOpen(true)}>+ <Pencil className="size-3.5" />+ {t(($) => $.detail.edit)}+ </Button>+ )}{canWrite && (<Buttonsize="sm"@@ -1106,12 +1115,6 @@ export function AutopilotDetailPage({ autopilotId }: { autopilotId: string }) {<MoreHorizontal /></DropdownMenuTrigger><DropdownMenuContent align="end" className="w-auto min-w-44">- {canWrite && (- <DropdownMenuItem onClick={() => setEditDialogOpen(true)}>- <Pencil className="size-3.5" />- {t(($) => $.detail.edit)}- </DropdownMenuItem>- )}<DropdownMenuItem onClick={copyLink}><Link2 className="size-3.5" />{t(($) => $.detail.copy_link)}@@ -1162,16 +1165,7 @@ export function AutopilotDetailPage({ autopilotId }: { autopilotId: string }) {description={summary.text}/>- <ObjectSection- title={t(($) => $.detail.field_prompt)}- action={- canWrite ? (- <ObjectSectionAction icon={Pencil} onClick={() => setEditDialogOpen(true)}>- {t(($) => $.detail.edit)}- </ObjectSectionAction>- ) : undefined- }- >+ <ObjectSection title={t(($) => $.detail.field_prompt)}>{autopilot.description ? (<ObjectSectionCard className="px-3 py-2.5"><ReadonlyContent content={autopilot.description} />