From cf8a9647bb7ba501856d984e2fc0a1a9b39ad69f Mon Sep 17 00:00:00 2001 From: Jiayuan Zhang Date: Fri, 17 Apr 2026 10:05:10 +0800 Subject: [PATCH] refactor(autopilot): make status a toggle instead of a pause/activate button (#1228) Replace the Pause/Activate button on the detail page with a Switch next to the title, showing a colored status label. Flipping it toggles between active and paused via the existing updateAutopilot mutation. --- .../components/autopilot-detail-page.tsx | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/packages/views/autopilots/components/autopilot-detail-page.tsx b/packages/views/autopilots/components/autopilot-detail-page.tsx index 23c45bbea..9a03c02a8 100644 --- a/packages/views/autopilots/components/autopilot-detail-page.tsx +++ b/packages/views/autopilots/components/autopilot-detail-page.tsx @@ -1,7 +1,7 @@ "use client"; import { useState, useEffect } from "react"; -import { Zap, Play, Pause, Clock, Plus, Trash2, CheckCircle2, XCircle, Loader2, Pencil } from "lucide-react"; +import { Zap, Play, Clock, Plus, Trash2, CheckCircle2, XCircle, Loader2, Pencil } from "lucide-react"; import { useQuery } from "@tanstack/react-query"; import { autopilotDetailOptions, autopilotRunsOptions } from "@multica/core/autopilots/queries"; import { @@ -20,6 +20,7 @@ import { PageHeader } from "../../layout/page-header"; import { ActorAvatar } from "../../common/actor-avatar"; import { Skeleton } from "@multica/ui/components/ui/skeleton"; import { Button } from "@multica/ui/components/ui/button"; +import { Switch } from "@multica/ui/components/ui/switch"; import { cn } from "@multica/ui/lib/utils"; import { toast } from "sonner"; import { @@ -420,9 +421,8 @@ export function AutopilotDetailPage({ autopilotId }: { autopilotId: string }) { } }; - const handleToggleStatus = () => { - const newStatus = autopilot.status === "active" ? "paused" : "active"; - updateAutopilot.mutate({ id: autopilotId, status: newStatus }); + const handleToggleStatus = (checked: boolean) => { + updateAutopilot.mutate({ id: autopilotId, status: checked ? "active" : "paused" }); }; return ( @@ -435,27 +435,29 @@ export function AutopilotDetailPage({ autopilotId }: { autopilotId: string }) { /

{autopilot.title}

- - {autopilot.status} - +
+ + + {autopilot.status} + +
-