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.

fix(desktop): open the cloud task composer in command center (#94479)

Dylan Martin2712db9b95a0
diff --git a/products/desktop/packages/ui/src/features/command-center/commandCenterStore.test.ts b/products/desktop/packages/ui/src/features/command-center/commandCenterStore.test.ts
index 3c1727e845ea..0795ce032f98 100644
--- a/products/desktop/packages/ui/src/features/command-center/commandCenterStore.test.ts
+++ b/products/desktop/packages/ui/src/features/command-center/commandCenterStore.test.ts
@@ -286,14 +286,35 @@ describe("commandCenterStore", () => {
});
describe("in-tile composer", () => {
+ it("replaces an unresolved cell only when the caller allows it", () => {
+ useCommandCenterStore.setState({
+ cells: [null, "unresolved-task", null, null],
+ });
+
+ store().startCreating(1, "session-1");
+ expect(store().composer).toBeNull();
+ expect(store().cells[1]).toBe("unresolved-task");
+
+ store().startCreating(1, "session-1", true);
+ expect(store().composer).toEqual({
+ cellIndex: 1,
+ sessionId: "session-1",
+ });
+ expect(store().cells[1]).toBeNull();
+ });
+
it("keeps the first active composer and marks the grid curated", () => {
+ useCommandCenterStore.setState({
+ cells: [null, "unresolved-task", null, null],
+ });
store().startCreating(2, "session-2");
- store().startCreating(1, "session-1");
+ store().startCreating(1, "session-1", true);
expect(store().composer).toEqual({
cellIndex: 2,
sessionId: "session-2",
});
+ expect(store().cells[1]).toBe("unresolved-task");
expect(store().activeCellIndex).toBe(2);
expect(store().hasAutofilled).toBe(true);
diff --git a/products/desktop/packages/ui/src/features/command-center/commandCenterStore.ts b/products/desktop/packages/ui/src/features/command-center/commandCenterStore.ts
index 78b2d07f5a74..ba3a1d7e112e 100644
--- a/products/desktop/packages/ui/src/features/command-center/commandCenterStore.ts
+++ b/products/desktop/packages/ui/src/features/command-center/commandCenterStore.ts
@@ -63,7 +63,11 @@ interface CommandCenterStoreActions {
setZoom: (zoom: number) => void;
zoomIn: () => void;
zoomOut: () => void;
- startCreating: (cellIndex: number, sessionId: string) => void;
+ startCreating: (
+ cellIndex: number,
+ sessionId: string,
+ replaceExisting?: boolean,
+ ) => void;
stopCreating: (sessionId: string) => void;
finishCreating: (sessionId: string, taskId: string) => boolean;
requestPlacement: (placement: CommandCenterPlacement) => void;
@@ -296,13 +300,16 @@ export const useCommandCenterStore = create<CommandCenterStore>()(
zoomOut: () =>
set((state) => ({ zoom: clampZoom(state.zoom - ZOOM_STEP) })),
- startCreating: (cellIndex, sessionId) =>
+ startCreating: (cellIndex, sessionId, replaceExisting = false) =>
set((state) => {
if (cellIndex < 0 || cellIndex >= state.cells.length) return state;
- if (state.cells[cellIndex] != null) return state;
+ if (state.cells[cellIndex] != null && !replaceExisting) return state;
if (state.composer) return state;
+ const cells = [...state.cells];
+ cells[cellIndex] = null;
return {
activeCellIndex: cellIndex,
+ cells,
composer: { cellIndex, sessionId },
pendingPlacement: null,
// Starting to type is curation. It also prevents a late bootstrap
diff --git a/products/desktop/packages/ui/src/features/command-center/components/CommandCenterPanel.stories.tsx b/products/desktop/packages/ui/src/features/command-center/components/CommandCenterPanel.stories.tsx
new file mode 100644
index 000000000000..4cf742b37303
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/command-center/components/CommandCenterPanel.stories.tsx
@@ -0,0 +1,147 @@
+import type { SessionConfigOption } from "@agentclientprotocol/sdk";
+import { Plus, X } from "@phosphor-icons/react";
+import { Button } from "@posthog/quill";
+import { TaskRepositoryChip } from "@posthog/ui/features/canvas/components/TaskRepositoryDialog";
+import { PromptHistoryDialog } from "@posthog/ui/features/message-editor/components/PromptHistoryDialog";
+import { PromptInput } from "@posthog/ui/features/message-editor/components/PromptInput";
+import { ReasoningLevelSelector } from "@posthog/ui/features/sessions/components/ReasoningLevelSelector";
+import { WorkspaceModeSelect } from "@posthog/ui/features/task-detail/components/WorkspaceModeSelect";
+import { DotPatternBackground } from "@posthog/ui/primitives/DotPatternBackground";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { CommandCenterEmptyCell } from "./CommandCenterPanel";
+
+const modelOption = {
+ id: "model",
+ name: "Model",
+ type: "select" as const,
+ currentValue: "gpt-5.6-sol",
+ options: [{ value: "gpt-5.6-sol", name: "GPT-5.6 Sol" }],
+} satisfies SessionConfigOption;
+
+const thoughtOption = {
+ id: "thought",
+ name: "Reasoning",
+ type: "select" as const,
+ currentValue: "high",
+ options: [{ value: "high", name: "High" }],
+} satisfies SessionConfigOption;
+
+const modeOption = {
+ id: "mode",
+ name: "Mode",
+ type: "select" as const,
+ currentValue: "auto",
+ options: [{ value: "auto", name: "Auto" }],
+} satisfies SessionConfigOption;
+
+function EmptyGridCell() {
+ return (
+ <CommandCenterEmptyCell
+ action={
+ <Button type="button" variant="outline" size="default">
+ <Plus size={12} />
+ Add task
+ </Button>
+ }
+ />
+ );
+}
+
+function CloudTaskComposer() {
+ return (
+ <div className="relative min-h-0 flex-1 px-4">
+ <DotPatternBackground className="h-[100.333%]" />
+ <div className="-translate-1/2 absolute top-1/2 left-1/2 z-1 flex w-[calc(100%-2rem)] max-w-[600px] flex-col gap-2">
+ <div className="absolute bottom-full left-0 mb-2 flex min-w-0 items-center gap-1">
+ <WorkspaceModeSelect
+ value="cloud"
+ onChange={() => {}}
+ overrideModes={["cloud"]}
+ />
+ <TaskRepositoryChip
+ cloud
+ repositoryCount={0}
+ hasFolder={false}
+ disabled={false}
+ onOpen={() => {}}
+ />
+ </div>
+ <PromptInput
+ sessionId="storybook-cloud-task"
+ placeholder="What do you want to ship?"
+ editorHeight="large"
+ autoFocus={false}
+ clearOnSubmit={false}
+ enableCommands
+ enableBashMode={false}
+ modeOption={modeOption}
+ onModeChange={() => {}}
+ historyButton={
+ <PromptHistoryDialog
+ onSelect={() => {}}
+ hasPendingDraft={() => false}
+ />
+ }
+ reasoningSelector={
+ <ReasoningLevelSelector
+ thoughtOption={thoughtOption}
+ modelOption={modelOption}
+ adapter="codex"
+ onChange={() => {}}
+ workspaceMode="cloud"
+ />
+ }
+ onSubmit={() => {}}
+ />
+ </div>
+ </div>
+ );
+}
+
+function StartingCloudTaskComposer() {
+ return (
+ <div className="flex h-full flex-col bg-gray-1">
+ <div className="flex shrink-0 items-center gap-3 border-gray-6 border-b px-3 py-2 text-[12px] text-gray-10">
+ <span>2x2</span>
+ <span>Optimize</span>
+ <div className="flex-1" />
+ <span>100%</span>
+ <span>Clear</span>
+ </div>
+ <div className="grid min-h-0 flex-1 grid-cols-2 grid-rows-2 gap-px bg-gray-6">
+ <div className="flex min-h-0 flex-col bg-gray-1">
+ <div className="flex shrink-0 items-center justify-between border-gray-6 border-b px-2 py-1">
+ <span className="font-medium font-mono text-[11px] text-gray-11">
+ New task
+ </span>
+ <X size={12} className="text-gray-10" />
+ </div>
+ <CloudTaskComposer />
+ </div>
+ <EmptyGridCell />
+ <EmptyGridCell />
+ <EmptyGridCell />
+ </div>
+ </div>
+ );
+}
+
+const meta: Meta<typeof StartingCloudTaskComposer> = {
+ title: "Command Center/New Task Composer",
+ component: StartingCloudTaskComposer,
+ parameters: {
+ layout: "fullscreen",
+ },
+ decorators: [
+ (Story) => (
+ <div className="h-[720px] w-[1200px] overflow-hidden border border-gray-6 bg-gray-1">
+ <Story />
+ </div>
+ ),
+ ],
+};
+
+export default meta;
+type Story = StoryObj<typeof StartingCloudTaskComposer>;
+
+export const StartingCloudTask: Story = {};
diff --git a/products/desktop/packages/ui/src/features/command-center/components/CommandCenterPanel.test.tsx b/products/desktop/packages/ui/src/features/command-center/components/CommandCenterPanel.test.tsx
index 67d6d2c8a79f..bf250dd70a75 100644
--- a/products/desktop/packages/ui/src/features/command-center/components/CommandCenterPanel.test.tsx
+++ b/products/desktop/packages/ui/src/features/command-center/components/CommandCenterPanel.test.tsx
@@ -108,13 +108,18 @@ vi.mock("../../task-detail/components/TaskInput", () => ({
TaskInput: ({
onTaskCreated,
showNewTaskSuggestions,
+ allowNoRepo,
}: {
onTaskCreated?: (task: Task) => void;
showNewTaskSuggestions?: boolean;
+ allowNoRepo?: boolean;
}) => {
mocks.taskCreatedCallback = onTaskCreated ?? null;
return (
- <div data-suggestions={showNewTaskSuggestions}>
+ <div
+ data-allow-no-repo={allowNoRepo}
+ data-suggestions={showNewTaskSuggestions}
+ >
<button
type="button"
onClick={() => onTaskCreated?.(mocks.createdTask as Task)}
@@ -219,6 +224,24 @@ describe("CommandCenterPanel", () => {
expect(mocks.store.startCreating).toHaveBeenCalledWith(
2,
"cc-cell-us:2:user-1-2",
+ false,
+ );
+ });
+
+ it("replaces an unresolved task when starting a new task in its empty tile", () => {
+ render(
+ <CommandCenterPanel
+ cell={{ ...emptyCell, taskId: "unresolved-task" }}
+ isActiveSession={false}
+ />,
+ );
+
+ fireEvent.click(screen.getByRole("button", { name: "New task" }));
+
+ expect(mocks.store.startCreating).toHaveBeenCalledWith(
+ 2,
+ "cc-cell-us:2:user-1-2",
+ true,
);
});
@@ -241,6 +264,10 @@ describe("CommandCenterPanel", () => {
"data-suggestions",
"false",
);
+ expect(screen.getByText("Send").parentElement).toHaveAttribute(
+ "data-allow-no-repo",
+ "true",
+ );
});
it("does not open a created task when the auth scope changed", () => {
diff --git a/products/desktop/packages/ui/src/features/command-center/components/CommandCenterPanel.tsx b/products/desktop/packages/ui/src/features/command-center/components/CommandCenterPanel.tsx
index 1cea4c6a6cde..c3e1fad419cc 100644
--- a/products/desktop/packages/ui/src/features/command-center/components/CommandCenterPanel.tsx
+++ b/products/desktop/packages/ui/src/features/command-center/components/CommandCenterPanel.tsx
@@ -13,7 +13,9 @@ import {
import { getAuthIdentity } from "@posthog/core/auth/authIdentity";
import { isBrainrotCell } from "@posthog/core/command-center/grid";
import {
+ Button,
Empty,
+ EmptyContent,
EmptyDescription,
EmptyHeader,
EmptyMedia,
@@ -35,7 +37,13 @@ import { useHostCapabilities } from "@posthog/ui/shell/useHostCapabilities";
import { secureRandomString } from "@posthog/ui/utils/random";
import { Flex, Text } from "@radix-ui/themes";
import { useNavigate } from "@tanstack/react-router";
-import { useCallback, useEffect, useRef, useState } from "react";
+import {
+ type ReactNode,
+ useCallback,
+ useEffect,
+ useRef,
+ useState,
+} from "react";
import { useOptionalAuthenticatedClient } from "../../auth/authClient";
import { useAuthStateValue } from "../../auth/store";
import { useCurrentUser } from "../../auth/useCurrentUser";
@@ -127,7 +135,30 @@ function EnvironmentBadge({ mode }: { mode: WorkspaceMode | null }) {
);
}
-function EmptyCell({ cellIndex }: { cellIndex: number }) {
+export function CommandCenterEmptyCell({ action }: { action: ReactNode }) {
+ return (
+ <Empty className="h-full border-0 bg-gray-1">
+ <EmptyHeader>
+ <EmptyMedia variant="icon">
+ <Plus size={20} />
+ </EmptyMedia>
+ <EmptyTitle>Empty tile</EmptyTitle>
+ <EmptyDescription>
+ Drag a task from the sidebar, or add one.
+ </EmptyDescription>
+ </EmptyHeader>
+ <EmptyContent>{action}</EmptyContent>
+ </Empty>
+ );
+}
+
+function EmptyCell({
+ cellIndex,
+ replaceExisting,
+}: {
+ cellIndex: number;
+ replaceExisting: boolean;
+}) {
const [selectorOpen, setSelectorOpen] = useState(false);
// The command-center terminal is unavailable on cloud-only hosts.
const { localWorkspaces } = useHostCapabilities();
@@ -171,8 +202,8 @@ function EmptyCell({ cellIndex }: { cellIndex: number }) {
);
const handleNewTask = useCallback(() => {
- if (sessionId) startCreating(cellIndex, sessionId);
- }, [startCreating, cellIndex, sessionId]);
+ if (sessionId) startCreating(cellIndex, sessionId, replaceExisting);
+ }, [startCreating, cellIndex, sessionId, replaceExisting]);
// Claiming the tile is what keeps the run in the grid: without it the task
// exists but its session has nowhere to render.
@@ -236,6 +267,7 @@ function EmptyCell({ cellIndex }: { cellIndex: number }) {
sessionId={sessionId}
onTaskCreated={handleTaskCreated}
showNewTaskSuggestions={false}
+ allowNoRepo
/>
</div>
</div>
@@ -243,8 +275,8 @@ function EmptyCell({ cellIndex }: { cellIndex: number }) {
}
return (
- <div className="flex h-full items-center justify-center">
- <div className="flex select-none flex-col items-center gap-2">
+ <CommandCenterEmptyCell
+ action={
<TaskSelector
cellIndex={cellIndex}
open={selectorOpen}
@@ -253,20 +285,18 @@ function EmptyCell({ cellIndex }: { cellIndex: number }) {
onNewTerminal={localWorkspaces ? handleNewTerminal : undefined}
onBrainrot={brainrotMode ? handleBrainrot : undefined}
>
- <button
+ <Button
type="button"
onClick={() => setSelectorOpen(true)}
- className="flex items-center gap-1.5 rounded-md border border-gray-7 border-dashed px-3 py-1.5 text-[12px] text-gray-10 transition-colors hover:border-gray-9 hover:text-gray-12"
+ variant="outline"
+ size="default"
>
<Plus size={12} />
Add task
- </button>
+ </Button>
</TaskSelector>
- <QuillText className="text-[11px] text-gray-9">
- or drag a task from the sidebar
- </QuillText>
- </div>
- </div>
+ }
+ />
);
}
@@ -674,7 +704,12 @@ export function CommandCenterPanel({
}
if (!cell.taskId || !cell.task) {
- return <EmptyCell cellIndex={cell.cellIndex} />;
+ return (
+ <EmptyCell
+ cellIndex={cell.cellIndex}
+ replaceExisting={cell.taskId !== null}
+ />
+ );
}
return (