Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(desktop): put stop run and archive in a header overflow menu (#90853)

Alessandro Pogliaghif59e0c6e57c3
diff --git a/products/desktop/packages/shared/src/analytics-events.ts b/products/desktop/packages/shared/src/analytics-events.ts
index 94053c3d0a71..c3c68f46a57d 100644
--- a/products/desktop/packages/shared/src/analytics-events.ts
+++ b/products/desktop/packages/shared/src/analytics-events.ts
@@ -50,6 +50,7 @@ export type CommandMenuAction =
| "toggle-theme"
| "toggle-left-sidebar"
| "open-review-panel"
+ | "archive-task"
| "go-back"
| "go-forward"
| "open-task"
diff --git a/products/desktop/packages/ui/src/features/archive/useTaskArchive.tsx b/products/desktop/packages/ui/src/features/archive/useTaskArchive.tsx
new file mode 100644
index 000000000000..2421cbec53ba
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/archive/useTaskArchive.tsx
@@ -0,0 +1,122 @@
+import { PI_SESSION_CONTROLLER } from "@posthog/core/pi-runtime/identifiers";
+import type { PiSessionController } from "@posthog/core/pi-runtime/piSessionController";
+import { isTaskActivelyRunning } from "@posthog/core/sidebar/taskRunning";
+import { useService } from "@posthog/di/react";
+import type { Task } from "@posthog/shared/domain-types";
+import { useArchiveTask } from "@posthog/ui/features/archive/useArchiveTask";
+import { useSessionSelector } from "@posthog/ui/features/sessions/useSession";
+import { useArchivingTasksStore } from "@posthog/ui/features/sidebar/archivingTasksStore";
+import { ArchiveRunningTaskDialog } from "@posthog/ui/features/sidebar/components/ArchiveRunningTaskDialog";
+import { toast } from "@posthog/ui/primitives/toast";
+import { logger } from "@posthog/ui/shell/logger";
+import { type ReactElement, useCallback, useState } from "react";
+import { useStore } from "zustand";
+import { shallow } from "zustand/shallow";
+
+const log = logger.scope("archive-task");
+
+export interface TaskArchive {
+ /** Archives the task, or asks first while it is still running. */
+ requestArchive: () => void;
+ /** An archive request is in flight for this task. */
+ isArchiving: boolean;
+ /** Render once, wherever the surface that asked for it lives. */
+ dialog: ReactElement;
+}
+
+/**
+ * Archiving one open task, with the running-task confirm in front of it. Shared
+ * by the surfaces that act on the task in view — its keyboard shortcut, its
+ * header button, and the command menu — so all of them ask the same question and
+ * report the same failure.
+ *
+ * The task is optional because the command menu outlives it: with no task open
+ * there is nothing to archive, and `requestArchive` does nothing.
+ */
+export function useTaskArchive(
+ task: Task | undefined,
+ options?: {
+ // Ignore the scoped space when the archived task is the active view,
+ // landing on the unscoped new-task screen instead of the space's own.
+ navigateUnscoped?: boolean;
+ },
+): TaskArchive {
+ const taskId = task?.id;
+ const { isPromptPending, cloudStatus } = useSessionSelector(
+ taskId,
+ (session) => ({
+ isPromptPending: session?.isPromptPending ?? false,
+ cloudStatus: session?.cloudStatus ?? null,
+ }),
+ shallow,
+ );
+ const piSessionController = useService<PiSessionController>(
+ PI_SESSION_CONTROLLER,
+ );
+ const isPiGenerating = useStore(piSessionController.store, (state) =>
+ taskId ? (state.sessions[taskId]?.status?.isStreaming ?? false) : false,
+ );
+ const isGenerating =
+ task?.runtime === "pi" ? isPiGenerating : isPromptPending;
+
+ const { archiveTask } = useArchiveTask({
+ navigateUnscoped: options?.navigateUnscoped,
+ });
+ const isArchiving = useArchivingTasksStore((state) =>
+ taskId ? state.archivingTaskIds.has(taskId) : false,
+ );
+ const [confirmOpen, setConfirmOpen] = useState(false);
+
+ const runArchive = useCallback(async () => {
+ if (!taskId) return;
+ const store = useArchivingTasksStore.getState();
+ if (store.isArchiving(taskId)) return;
+
+ store.startArchiving(taskId);
+ try {
+ await archiveTask({ taskId });
+ } catch (error) {
+ log.error("Failed to archive task", error);
+ toast.error("Failed to archive task");
+ throw error;
+ } finally {
+ useArchivingTasksStore.getState().stopArchiving(taskId);
+ }
+ }, [archiveTask, taskId]);
+
+ const requestArchive = useCallback(() => {
+ if (!taskId) return;
+ if (useArchivingTasksStore.getState().isArchiving(taskId)) return;
+ if (
+ isTaskActivelyRunning({
+ isGenerating,
+ taskRunEnvironment: task?.latest_run?.environment,
+ taskRunStatus: cloudStatus ?? task?.latest_run?.status ?? undefined,
+ })
+ ) {
+ setConfirmOpen(true);
+ return;
+ }
+ void runArchive().catch(() => undefined);
+ }, [cloudStatus, isGenerating, runArchive, task?.latest_run, taskId]);
+
+ return {
+ requestArchive,
+ isArchiving,
+ dialog: (
+ <ArchiveRunningTaskDialog
+ open={confirmOpen}
+ taskTitle={task?.title ?? ""}
+ stopsCloudSandbox={task?.latest_run?.environment === "cloud"}
+ onConfirm={async () => {
+ try {
+ await runArchive();
+ } finally {
+ setConfirmOpen(false);
+ }
+ }}
+ onCancel={() => setConfirmOpen(false)}
+ />
+ ),
+ };
+}
diff --git a/products/desktop/packages/ui/src/features/command/CommandMenu.feedQuery.test.tsx b/products/desktop/packages/ui/src/features/command/CommandMenu.feedQuery.test.tsx
index 979214938802..7b91fe46760e 100644
--- a/products/desktop/packages/ui/src/features/command/CommandMenu.feedQuery.test.tsx
+++ b/products/desktop/packages/ui/src/features/command/CommandMenu.feedQuery.test.tsx
@@ -24,6 +24,13 @@ vi.mock("@posthog/ui/features/tasks/useTasks", () => ({
vi.mock("@posthog/ui/features/archive/useArchivedTaskIds", () => ({
useArchivedTaskIds: () => new Set(),
}));
+vi.mock("@posthog/ui/features/archive/useTaskArchive", () => ({
+ useTaskArchive: () => ({
+ requestArchive: vi.fn(),
+ isArchiving: false,
+ dialog: null,
+ }),
+}));
vi.mock("@posthog/ui/features/workspace/useWorkspace", () => ({
useWorkspaces: () => ({ data: [], isFetched: true }),
}));
diff --git a/products/desktop/packages/ui/src/features/command/CommandMenu.tsx b/products/desktop/packages/ui/src/features/command/CommandMenu.tsx
index fe95fd393e86..b92315611841 100644
--- a/products/desktop/packages/ui/src/features/command/CommandMenu.tsx
+++ b/products/desktop/packages/ui/src/features/command/CommandMenu.tsx
@@ -35,6 +35,7 @@ import {
type CommandMenuAction,
} from "@posthog/shared/analytics-events";
import { useArchivedTaskIds } from "@posthog/ui/features/archive/useArchivedTaskIds";
+import { useTaskArchive } from "@posthog/ui/features/archive/useTaskArchive";
import { channelGlyph } from "@posthog/ui/features/canvas/components/channelGlyph";
import {
EDITOR_TEXT_CLASS,
@@ -292,6 +293,13 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
}
}, [reviewTaskId, getReviewMode, setReviewMode]);
+ // Archiving acts on the open task, so the command needs the task itself and
+ // drops out of the list when the palette can't find it.
+ const openedTask = tasks.find((task) => task.id === reviewTaskId);
+ const { requestArchive, dialog: archiveDialog } = useTaskArchive(openedTask, {
+ navigateUnscoped: !openedTask?.channel,
+ });
+
useEffect(() => {
if (open) {
track(ANALYTICS_EVENTS.COMMAND_MENU_OPENED);
@@ -487,6 +495,19 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
},
]
: []),
+ ...(openedTask
+ ? [
+ {
+ id: "archive-task",
+ label: "Archive task",
+ keywords: "archive close remove",
+ icon: <ArchiveIcon size={12} className="text-gray-11" />,
+ action: "archive-task" as CommandMenuAction,
+ shortcut: SHORTCUTS.ARCHIVE_TASK,
+ onRun: requestArchive,
+ },
+ ]
+ : []),
// Last, because the first row is what a stray Enter runs.
...themeOptions,
];
@@ -594,6 +615,8 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
toggleLeftSidebar,
openReviewPanel,
reviewTaskId,
+ openedTask,
+ requestArchive,
canSearchFiles,
openFilePicker,
loopsEnabled,
@@ -1009,6 +1032,8 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
surface="command_menu"
onCreated={(feed) => navigateToFeed(feed.id)}
/>
+ {/* Outlives the palette, which closes as the command runs. */}
+ {archiveDialog}
</>
);
}
diff --git a/products/desktop/packages/ui/src/features/sessions/components/StopCloudRunButton.tsx b/products/desktop/packages/ui/src/features/sessions/components/StopCloudRunButton.tsx
deleted file mode 100644
index 3362b5682d32..000000000000
--- a/products/desktop/packages/ui/src/features/sessions/components/StopCloudRunButton.tsx
+++ /dev/null
@@ -1,53 +0,0 @@
-import { Spinner, StopCircle } from "@phosphor-icons/react";
-import { isTerminalStatus } from "@posthog/core/cloud-task/schemas";
-import { Button as QuillButton } from "@posthog/quill";
-import { useState } from "react";
-import { shallow } from "zustand/shallow";
-import { useSessionSelector } from "../useSession";
-import { StopCloudRunDialog } from "./StopCloudRunDialog";
-
-interface StopCloudRunButtonProps {
- taskId: string;
-}
-
-export function StopCloudRunButton({ taskId }: StopCloudRunButtonProps) {
- const { isCloud, cloudStatus, stopRequested } = useSessionSelector(
- taskId,
- (session) => ({
- isCloud: session?.isCloud ?? false,
- cloudStatus: session?.cloudStatus ?? null,
- stopRequested: session?.stopRequested ?? false,
- }),
- shallow,
- );
- const [confirmOpen, setConfirmOpen] = useState(false);
-
- if (!isCloud || isTerminalStatus(cloudStatus)) return null;
-
- return (
- <>
- <div className="no-drag flex items-center">
- <QuillButton
- variant="outline"
- size="sm"
- disabled={stopRequested}
- onClick={() => setConfirmOpen(true)}
- >
- {stopRequested ? (
- <Spinner size={14} className="shrink-0 animate-spin" />
- ) : (
- <StopCircle size={14} weight="regular" className="shrink-0" />
- )}
- {stopRequested ? "Stopping..." : "Stop run"}
- </QuillButton>
- </div>
- <StopCloudRunDialog
- open={confirmOpen}
- taskId={taskId}
- title="Stop run"
- buttonLabel="Stop run"
- onOpenChange={setConfirmOpen}
- />
- </>
- );
-}
diff --git a/products/desktop/packages/ui/src/features/task-detail/components/TaskDetail.tsx b/products/desktop/packages/ui/src/features/task-detail/components/TaskDetail.tsx
index 5a0bc7e4cd2f..4c8e9c4d5cac 100644
--- a/products/desktop/packages/ui/src/features/task-detail/components/TaskDetail.tsx
+++ b/products/desktop/packages/ui/src/features/task-detail/components/TaskDetail.tsx
@@ -1,17 +1,11 @@
-import { PI_SESSION_CONTROLLER } from "@posthog/core/pi-runtime/identifiers";
-import type { PiSessionController } from "@posthog/core/pi-runtime/piSessionController";
-import { isTaskActivelyRunning } from "@posthog/core/sidebar/taskRunning";
-import { useService } from "@posthog/di/react";
import type { Task } from "@posthog/shared/domain-types";
import { Box, Flex, Text, Tooltip } from "@radix-ui/themes";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useHotkeys, useHotkeysContext } from "react-hotkeys-hook";
-import { useStore } from "zustand";
import { useBlurOnEscape } from "../../../hooks/useBlurOnEscape";
import { useSetHeaderContent } from "../../../hooks/useSetHeaderContent";
-import { toast } from "../../../primitives/toast";
import { logger } from "../../../shell/logger";
-import { useArchiveTask } from "../../archive/useArchiveTask";
+import { useTaskArchive } from "../../archive/useTaskArchive";
import { ChannelBreadcrumb } from "../../canvas/components/ChannelBreadcrumb";
import { CopyThreadLinkButton } from "../../canvas/components/CopyThreadLinkButton";
import { useMarkTaskActivityRead } from "../../canvas/hooks/useMarkTaskActivityRead";
@@ -28,10 +22,7 @@ import { useRightPanelStore } from "../../navigation/rightPanelStore";
import { useReviewInRightPanel } from "../../navigation/useReviewInRightPanel";
import { PanelLayout } from "../../panels/components/PanelLayout";
import { MIN_CHAT_WIDTH } from "../../sessions/constants";
-import { useArchivingTasksStore } from "../../sidebar/archivingTasksStore";
-import { ArchiveRunningTaskDialog } from "../../sidebar/components/ArchiveRunningTaskDialog";
import { useCwd } from "../../sidebar/useCwd";
-import { useSidebarSessionMap } from "../../sidebar/useSidebarSessionMap";
import { useRenameTask } from "../../tasks/useTaskMutations";
import { useWorkspace } from "../../workspace/useWorkspace";
import { useWorkspaceEvents } from "../../workspace/useWorkspaceEvents";
@@ -62,69 +53,28 @@ export function TaskDetail({
}: TaskDetailProps) {
const taskId = initialTask.id;
const { task } = useTaskData({ taskId, initialTask });
- const taskSession = useSidebarSessionMap().get(taskId);
- const piSessionController = useService<PiSessionController>(
- PI_SESSION_CONTROLLER,
- );
- const isPiGenerating = useStore(
- piSessionController.store,
- (state) => state.sessions[taskId]?.status?.isStreaming ?? false,
- );
- const runtime = task.runtime === "pi" ? "pi" : "acp";
const effectiveRepoPath = useCwd(taskId);
const openFilePicker = useFileSearchStore((state) => state.openPicker);
const { enableScope, disableScope } = useHotkeysContext();
- const { archiveTask } = useArchiveTask({
+ const { requestArchive, dialog: archiveDialog } = useTaskArchive(task, {
navigateUnscoped: !channelId,
});
- const [showArchiveConfirm, setShowArchiveConfirm] = useState(false);
-
- const runArchive = useCallback(async () => {
- const store = useArchivingTasksStore.getState();
- if (store.isArchiving(taskId)) return;
-
- store.startArchiving(taskId);
- try {
- await archiveTask({ taskId });
- } catch (error) {
- log.error("Failed to archive task", error);
- toast.error("Failed to archive task");
- throw error;
- } finally {
- useArchivingTasksStore.getState().stopArchiving(taskId);
- }
- }, [archiveTask, taskId]);
useHotkeys(
SHORTCUTS.ARCHIVE_TASK,
(event) => {
event.preventDefault();
- if (useArchivingTasksStore.getState().isArchiving(taskId)) return;
- if (
- isTaskActivelyRunning({
- isGenerating:
- runtime === "pi"
- ? isPiGenerating
- : (taskSession?.isPromptPending ?? false),
- taskRunEnvironment: task.latest_run?.environment,
- taskRunStatus:
- taskSession?.cloudStatus ?? task.latest_run?.status ?? undefined,
- })
- ) {
- setShowArchiveConfirm(true);
- return;
- }
- void runArchive().catch(() => undefined);
+ requestArchive();
},
{
scopes: ["taskDetail"],
enableOnContentEditable: true,
enableOnFormTags: true,
},
- [task, taskId, taskSession, runtime, isPiGenerating, runArchive],
+ [requestArchive],
);
useEffect(() => {
@@ -373,19 +323,7 @@ export function TaskDetail({
</Box>
)}
</Flex>
- <ArchiveRunningTaskDialog
- open={showArchiveConfirm}
- taskTitle={task.title}
- stopsCloudSandbox={task.latest_run?.environment === "cloud"}
- onConfirm={async () => {
- try {
- await runArchive();
- } finally {
- setShowArchiveConfirm(false);
- }
- }}
- onCancel={() => setShowArchiveConfirm(false)}
- />
+ {archiveDialog}
</Box>
);
}
diff --git a/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.test.tsx b/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.test.tsx
index 1b142c982718..9d06ca33d7d5 100644
--- a/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.test.tsx
+++ b/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.test.tsx
@@ -44,11 +44,16 @@ vi.mock(
vi.mock(
"@posthog/ui/features/git-interaction/components/TaskActionsMenu",
() => ({
- TaskActionsMenu: () => <div>task menu</div>,
+ // Renders the cloud verdict, which is what this row derives.
+ TaskActionsMenu: ({ isCloud }: { isCloud: boolean }) => (
+ <div data-testid="task-menu">{isCloud ? "cloud" : "local"}</div>
+ ),
}),
);
-vi.mock("@posthog/ui/features/sessions/components/StopCloudRunButton", () => ({
- StopCloudRunButton: () => <div>stop cloud run</div>,
+// Reads the session store and the pi session controller from the container,
+// which these renders don't wire up.
+vi.mock("./TaskOverflowMenu", () => ({
+ TaskOverflowMenu: () => <div>task actions</div>,
}));
vi.mock("@posthog/ui/features/diff-stats/DiffStatsBadge", () => ({
DiffStatsBadge: () => null,
@@ -81,29 +86,26 @@ describe("TaskHeaderActions", () => {
renderActions();
- expect(screen.queryByText("task menu")).not.toBeInTheDocument();
+ expect(screen.queryByTestId("task-menu")).not.toBeInTheDocument();
+ // The overflow menu needs no workspace, so it is the one part that stays.
+ expect(screen.getByText("task actions")).toBeInTheDocument();
});
- it("shows cloud controls for a loaded cloud workspace", () => {
- useWorkspace.mockReturnValue({ mode: "cloud" });
- useWorkspaceLoaded.mockReturnValue(true);
-
- renderActions();
-
- expect(screen.getByText("stop cloud run")).toBeInTheDocument();
- expect(screen.getByText("task menu")).toBeInTheDocument();
- });
-
- it("shows cloud controls for a cloud run without a local workspace row", () => {
- useWorkspace.mockReturnValue(null);
+ it.each([
+ ["a cloud workspace", { mode: "cloud" }, undefined],
+ ["a cloud run with no local workspace row", null, "cloud"],
+ ])("reads %s as a cloud task", (_case, workspace, runEnvironment) => {
+ useWorkspace.mockReturnValue(workspace);
useWorkspaceLoaded.mockReturnValue(true);
renderActions({
id: "task-1",
title: "Fix the bug",
- latest_run: { environment: "cloud" },
+ ...(runEnvironment
+ ? { latest_run: { environment: runEnvironment } }
+ : {}),
} as Task);
- expect(screen.getByText("stop cloud run")).toBeInTheDocument();
+ expect(screen.getByTestId("task-menu")).toHaveTextContent("cloud");
});
});
diff --git a/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.tsx b/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.tsx
index 9057cd58faea..3d9f57236369 100644
--- a/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.tsx
+++ b/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.tsx
@@ -9,7 +9,6 @@ import { DiffStatsBadge } from "@posthog/ui/features/diff-stats/DiffStatsBadge";
import { BranchSelector } from "@posthog/ui/features/git-interaction/components/BranchSelector";
import { TaskActionsMenu } from "@posthog/ui/features/git-interaction/components/TaskActionsMenu";
import { useReviewInRightPanel } from "@posthog/ui/features/navigation/useReviewInRightPanel";
-import { StopCloudRunButton } from "@posthog/ui/features/sessions/components/StopCloudRunButton";
import {
useIsCloudTask,
useWorkspace,
@@ -17,6 +16,7 @@ import {
} from "@posthog/ui/features/workspace/useWorkspace";
import { Tooltip } from "@posthog/ui/primitives/Tooltip";
import { TaskAnalysisButton } from "./TaskAnalysisButton";
+import { TaskOverflowMenu } from "./TaskOverflowMenu";
function TaskDiffStatsBadge({ task }: { task: Task }) {
const { filesChanged, linesAdded, linesRemoved, isOpen, toggle } =
@@ -66,11 +66,11 @@ export function TaskHeaderActions({ task }: { task: Task }) {
{showDiffBadge && <TaskDiffStatsBadge task={task} />}
{workspaceLoaded && (
- <>
- {isCloudTask && <StopCloudRunButton taskId={task.id} />}
- <TaskActionsMenu taskId={task.id} isCloud={isCloudTask} />
- </>
+ <TaskActionsMenu taskId={task.id} isCloud={isCloudTask} />
)}
+ {/* Acting on the task itself needs nothing from the workspace, so the
+ menu stays put while the rest of the row is still resolving. */}
+ <TaskOverflowMenu task={task} />
</div>
);
}
diff --git a/products/desktop/packages/ui/src/features/task-detail/components/TaskOverflowMenu.tsx b/products/desktop/packages/ui/src/features/task-detail/components/TaskOverflowMenu.tsx
new file mode 100644
index 000000000000..2739dce31cdf
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/task-detail/components/TaskOverflowMenu.tsx
@@ -0,0 +1,89 @@
+import { DotsThree } from "@phosphor-icons/react";
+import { isTerminalStatus } from "@posthog/core/cloud-task/schemas";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuShortcut,
+ DropdownMenuTrigger,
+ Button as QuillButton,
+} from "@posthog/quill";
+import type { Task } from "@posthog/shared/domain-types";
+import { useTaskArchive } from "@posthog/ui/features/archive/useTaskArchive";
+import {
+ formatHotkey,
+ SHORTCUTS,
+} from "@posthog/ui/features/command/keyboard-shortcuts";
+import { StopCloudRunDialog } from "@posthog/ui/features/sessions/components/StopCloudRunDialog";
+import { useSessionSelector } from "@posthog/ui/features/sessions/useSession";
+import { useState } from "react";
+import { shallow } from "zustand/shallow";
+
+/**
+ * The task header's overflow menu: everything that acts on the task itself
+ * rather than on its branch or its diff.
+ */
+export function TaskOverflowMenu({ task }: { task: Task }) {
+ const { isCloud, cloudStatus, stopRequested } = useSessionSelector(
+ task.id,
+ (session) => ({
+ isCloud: session?.isCloud ?? false,
+ cloudStatus: session?.cloudStatus ?? null,
+ stopRequested: session?.stopRequested ?? false,
+ }),
+ shallow,
+ );
+ const [stopConfirmOpen, setStopConfirmOpen] = useState(false);
+ const { requestArchive, dialog: archiveDialog } = useTaskArchive(task, {
+ navigateUnscoped: !task.channel,
+ });
+
+ const canStop = isCloud && !isTerminalStatus(cloudStatus);
+
+ return (
+ <>
+ <div className="no-drag flex items-center">
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <QuillButton
+ variant="outline"
+ size="sm"
+ aria-label="Task actions"
+ className="px-1.5"
+ />
+ }
+ >
+ <DotsThree size={16} weight="bold" className="shrink-0" />
+ </DropdownMenuTrigger>
+ {/* quill pins a menu to its anchor's width, and this anchor is the
+ width of a glyph. */}
+ <DropdownMenuContent align="end" className="w-auto">
+ {canStop && (
+ <DropdownMenuItem
+ disabled={stopRequested}
+ onClick={() => setStopConfirmOpen(true)}
+ >
+ {stopRequested ? "Stopping..." : "Stop run"}
+ </DropdownMenuItem>
+ )}
+ <DropdownMenuItem onClick={requestArchive}>
+ Archive
+ <DropdownMenuShortcut>
+ {formatHotkey(SHORTCUTS.ARCHIVE_TASK)}
+ </DropdownMenuShortcut>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ <StopCloudRunDialog
+ open={stopConfirmOpen}
+ taskId={task.id}
+ title="Stop run"
+ buttonLabel="Stop run"
+ onOpenChange={setStopConfirmOpen}
+ />
+ {archiveDialog}
+ </>
+ );
+}