Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat(chat): add Stop button to overflow menu — cancel the running task

Gus1361e0ebec12
diff --git a/src/web/src/components/agent-chat/agent-chat-view.tsx b/src/web/src/components/agent-chat/agent-chat-view.tsx
index f8d2698ca..48c1e2dc7 100644
--- a/src/web/src/components/agent-chat/agent-chat-view.tsx
+++ b/src/web/src/components/agent-chat/agent-chat-view.tsx
@@ -16,6 +16,7 @@ import {
getTask,
updateIssue,
getAgentSkills,
+ cancelActiveTask,
} from "@/lib/api";
import { useLatest } from "@/components/agent-chat/chat-message-utils";
import type {
@@ -44,6 +45,7 @@ import {
MessageSquareQuote,
MoreHorizontal,
Paperclip,
+ Square,
X,
} from "lucide-react";
import { useAgentChat } from "@/hooks/use-agent-chat";
@@ -517,6 +519,7 @@ export function AgentChatView({
]);
const [menuOpen, setMenuOpen] = useState(false);
+ const [stopping, setStopping] = useState(false);
const isTaskActive =
!!activeTask &&
@@ -524,6 +527,18 @@ export function AgentChatView({
activeTask.status,
);
+ const handleStop = useCallback(async () => {
+ if (!conversation?.id || stopping) return;
+ setStopping(true);
+ try {
+ await cancelActiveTask(conversation.id, workspaceId);
+ } catch {
+ toast.error("Failed to stop the task");
+ } finally {
+ setStopping(false);
+ }
+ }, [conversation?.id, workspaceId, stopping]);
+
// Rotating capability-hint placeholder for the idle, empty composer. Freezes
// on focus/typing, resumes on empty blur; never rotates while a task is
// active (that path shows the static "Message {Name}" overlay below instead).
@@ -855,6 +870,39 @@ export function AgentChatView({
: `${agentName} is well-rested and ready to go`}
</TooltipContent>
</Tooltip>
+ <Tooltip>
+ <TooltipTrigger
+ render={(props) => (
+ <span
+ {...props}
+ className={cn("inline-flex", props.className)}
+ >
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => {
+ setMenuOpen(false);
+ handleStop();
+ }}
+ disabled={stopping || !isTaskActive}
+ className="w-full justify-start gap-2 rounded-md text-muted-foreground hover:text-foreground"
+ >
+ {stopping ? (
+ <Loader2 className="size-3.5 animate-spin" />
+ ) : (
+ <Square className="size-3.5" />
+ )}
+ <span className="text-xs">Stop</span>
+ </Button>
+ </span>
+ )}
+ />
+ <TooltipContent side="right">
+ {isTaskActive
+ ? "Stop the running task"
+ : "No task running"}
+ </TooltipContent>
+ </Tooltip>
</PopoverContent>
</Popover>
)}