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): pick a space for a new command center task (#97297)

Harley Alexander25749e0d209b
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
index 4cf742b37303..f84ffb9ed33a 100644
--- 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
@@ -1,15 +1,50 @@
import type { SessionConfigOption } from "@agentclientprotocol/sdk";
import { Plus, X } from "@phosphor-icons/react";
import { Button } from "@posthog/quill";
+import type { TaskChannel } from "@posthog/shared/domain-types";
+import { SpaceSelect } from "@posthog/ui/features/canvas/components/SpaceSelect";
import { TaskRepositoryChip } from "@posthog/ui/features/canvas/components/TaskRepositoryDialog";
+import { TASK_CHANNELS_QUERY_KEY } from "@posthog/ui/features/canvas/hooks/useTaskChannels";
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 { useQueryClient } from "@tanstack/react-query";
+import { type ReactNode, useEffect, useState } from "react";
import { CommandCenterEmptyCell } from "./CommandCenterPanel";
+const spaces = [
+ {
+ id: "space-me",
+ name: "me",
+ channel_type: "personal",
+ system_role: "personal",
+ starred: false,
+ created_at: "2026-08-28T00:00:00.000Z",
+ },
+ {
+ id: "space-growth",
+ name: "growth",
+ channel_type: "public",
+ starred: true,
+ created_at: "2026-08-28T00:00:00.000Z",
+ },
+] satisfies TaskChannel[];
+
+// The space chip reads the shared task-channels query, which has no backend
+// here.
+function SeededSpaces({ children }: { children: ReactNode }) {
+ const queryClient = useQueryClient();
+ const [seeded, setSeeded] = useState(false);
+ useEffect(() => {
+ queryClient.setQueryData(TASK_CHANNELS_QUERY_KEY, spaces);
+ setSeeded(true);
+ }, [queryClient]);
+ return seeded ? children : null;
+}
+
const modelOption = {
id: "model",
name: "Model",
@@ -53,6 +88,7 @@ function CloudTaskComposer() {
<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">
+ <SpaceSelect value="space-me" onChange={() => {}} />
<WorkspaceModeSelect
value="cloud"
onChange={() => {}}
@@ -134,9 +170,11 @@ const meta: Meta<typeof StartingCloudTaskComposer> = {
},
decorators: [
(Story) => (
- <div className="h-[720px] w-[1200px] overflow-hidden border border-gray-6 bg-gray-1">
- <Story />
- </div>
+ <SeededSpaces>
+ <div className="h-[720px] w-[1200px] overflow-hidden border border-gray-6 bg-gray-1">
+ <Story />
+ </div>
+ </SeededSpaces>
),
],
};
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 c453b3209446..66d116fbe6cb 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
@@ -16,6 +16,7 @@ const mocks = vi.hoisted(() => ({
currentProjectId: 2,
},
createdTask: { id: "task-2", title: "Composed in a tile" },
+ spacesEnabled: true,
store: {
layout: "2x2",
cells: [null, null, null, null] as (string | null)[],
@@ -100,6 +101,31 @@ vi.mock("../../autoresearch/autoresearchDraftStore", () => ({
getState: () => ({ clearDraft: mocks.clearAutoresearchDraft }),
},
}));
+vi.mock("../../feature-flags/useBluebirdFlag", () => ({
+ useBluebirdFlag: () => mocks.spacesEnabled,
+}));
+vi.mock("../../canvas/hooks/useTaskChannels", () => ({
+ useTaskChannels: () => ({
+ channels: [
+ { id: "me", name: "me" },
+ { id: "space-2", name: "growth" },
+ ],
+ personalChannel: { id: "me", name: "me" },
+ }),
+}));
+vi.mock("../../canvas/components/SpaceSelect", () => ({
+ SpaceSelect: ({
+ value,
+ onChange,
+ }: {
+ value: string;
+ onChange: (id: string) => void;
+ }) => (
+ <button type="button" onClick={() => onChange("space-2")}>
+ Space {value}
+ </button>
+ ),
+}));
vi.mock("../../settings/settingsStore", () => ({
useSettingsStore: (selector: (state: unknown) => unknown) =>
selector({ brainrotMode: false }),
@@ -109,17 +135,23 @@ vi.mock("../../task-detail/components/TaskInput", () => ({
onTaskCreated,
showNewTaskSuggestions,
allowNoRepo,
+ channelId,
+ spaceSelector,
}: {
onTaskCreated?: (task: Task) => void;
showNewTaskSuggestions?: boolean;
allowNoRepo?: boolean;
+ channelId?: string;
+ spaceSelector?: (props: { disabled: boolean }) => ReactNode;
}) => {
mocks.taskCreatedCallback = onTaskCreated ?? null;
return (
<div
data-allow-no-repo={allowNoRepo}
data-suggestions={showNewTaskSuggestions}
+ data-channel-id={channelId}
>
+ {spaceSelector?.({ disabled: false })}
<button
type="button"
onClick={() => onTaskCreated?.(mocks.createdTask as Task)}
@@ -202,6 +234,7 @@ describe("CommandCenterPanel", () => {
mocks.currentUserUuid = "user-1";
mocks.taskCreatedCallback = null;
mocks.store.composer = null;
+ mocks.spacesEnabled = true;
mocks.store.finishCreating.mockReturnValue(true);
});
@@ -282,6 +315,43 @@ describe("CommandCenterPanel", () => {
);
});
+ // The chip only helps if the pick reaches creation; without this the task
+ // silently lands in #me.
+ it("files a task composed in a tile into the space picked in the composer", () => {
+ mocks.store.composer = {
+ cellIndex: 2,
+ sessionId: "cc-cell-us:2:user-1-2",
+ };
+ render(<CommandCenterPanel cell={emptyCell} isActiveSession={false} />);
+ expect(screen.getByText("Send").parentElement).toHaveAttribute(
+ "data-channel-id",
+ "me",
+ );
+
+ fireEvent.click(screen.getByRole("button", { name: "Space me" }));
+
+ expect(screen.getByText("Send").parentElement).toHaveAttribute(
+ "data-channel-id",
+ "space-2",
+ );
+ });
+
+ // A project without spaces has nowhere to file a task, and the shared
+ // task-channels cache can hold spaces another surface loaded.
+ it("hides the space chip when spaces are off", () => {
+ mocks.spacesEnabled = false;
+ mocks.store.composer = {
+ cellIndex: 2,
+ sessionId: "cc-cell-us:2:user-1-2",
+ };
+ render(<CommandCenterPanel cell={emptyCell} isActiveSession={false} />);
+
+ expect(screen.queryByRole("button", { name: "Space me" })).toBeNull();
+ expect(screen.getByText("Send").parentElement).not.toHaveAttribute(
+ "data-channel-id",
+ );
+ });
+
it("does not open a created task when the auth scope changed", () => {
mocks.store.composer = {
cellIndex: 2,
@@ -337,6 +407,7 @@ describe("CommandCenterPanel", () => {
sessionId: "cc-cell-us:2:user-1-2",
};
render(<CommandCenterPanel cell={emptyCell} isActiveSession={false} />);
+ fireEvent.click(screen.getByRole("button", { name: "Space me" }));
fireEvent.click(screen.getByTitle("Cancel"));
@@ -347,5 +418,10 @@ describe("CommandCenterPanel", () => {
expect(mocks.clearAutoresearchDraft).toHaveBeenCalledWith(
"cc-cell-us:2:user-1-2",
);
+ // A space picked for the abandoned task must not carry into the next one.
+ expect(screen.getByText("Send").parentElement).toHaveAttribute(
+ "data-channel-id",
+ "me",
+ );
});
});
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 c74ecb76a523..8ac9a9e06897 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
@@ -50,6 +50,9 @@ import { useOptionalAuthenticatedClient } from "../../auth/authClient";
import { useAuthStateValue } from "../../auth/store";
import { useCurrentUser } from "../../auth/useCurrentUser";
import { useAutoresearchDraftStore } from "../../autoresearch/autoresearchDraftStore";
+import { SpaceSelect } from "../../canvas/components/SpaceSelect";
+import { useTaskChannels } from "../../canvas/hooks/useTaskChannels";
+import { useBluebirdFlag } from "../../feature-flags/useBluebirdFlag";
import { useFolders } from "../../folders/useFolders";
import { useCloudPrUrl } from "../../git-interaction/useCloudPrUrl";
import { useDraftStore } from "../../message-editor/draftStore";
@@ -177,6 +180,18 @@ function EmptyCell({
const layout = useCommandCenterStore((s) => s.layout);
const cells = useCommandCenterStore((s) => s.cells);
const brainrotMode = useSettingsStore((s) => s.brainrotMode);
+ const spacesEnabled = useBluebirdFlag();
+ const { channels, personalChannel } = useTaskChannels({
+ enabled: spacesEnabled,
+ });
+ const [pickedSpaceId, setPickedSpaceId] = useState<string | null>(null);
+ // A task created without a space lands in #me, so the chip starts there. The
+ // flag gates the chip here rather than through the query, whose cache another
+ // surface may have already filled.
+ const spaceId = spacesEnabled
+ ? (pickedSpaceId ?? personalChannel?.id ?? null)
+ : null;
+ const space = channels.find((c) => c.id === spaceId);
const authIdentity = useAuthStateValue(getAuthIdentity);
const client = useOptionalAuthenticatedClient();
const { data: currentUser } = useCurrentUser({ client });
@@ -237,6 +252,8 @@ function EmptyCell({
if (!sessionId) return;
stopCreating(sessionId);
clearComposerDraft(sessionId);
+ // The next task in this tile starts from #me again, like its prompt draft.
+ setPickedSpaceId(null);
}, [stopCreating, sessionId]);
useEffect(() => {
@@ -274,6 +291,20 @@ function EmptyCell({
onTaskCreated={handleTaskCreated}
showNewTaskSuggestions={false}
allowNoRepo
+ channelId={spaceId ?? undefined}
+ channelRepositories={space?.repositories}
+ channelGithubIntegration={space?.github_integration}
+ spaceSelector={
+ spaceId
+ ? ({ disabled }) => (
+ <SpaceSelect
+ value={spaceId}
+ onChange={setPickedSpaceId}
+ disabled={disabled}
+ />
+ )
+ : undefined
+ }
/>
</div>
</div>