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): hide sandbox prompts from command center (#93863)

Dylan Martin73d235d41f85
diff --git a/products/desktop/packages/core/src/command-center/eligibility.test.ts b/products/desktop/packages/core/src/command-center/eligibility.test.ts
index 588059472391..36e5bb931b62 100644
--- a/products/desktop/packages/core/src/command-center/eligibility.test.ts
+++ b/products/desktop/packages/core/src/command-center/eligibility.test.ts
@@ -1,13 +1,17 @@
import type { Task } from "@posthog/shared/domain-types";
import { describe, expect, it } from "vitest";
-import { selectAvailableTasks, workspaceIdSet } from "./eligibility";
+import {
+ isSandboxPromptTask,
+ selectAvailableTasks,
+ workspaceIdSet,
+} from "./eligibility";
-function makeTask(id: string): Task {
+function makeTask(id: string, title = id): Task {
return {
id,
task_number: 1,
slug: id,
- title: id,
+ title,
description: "",
created_at: "",
updated_at: "",
@@ -25,4 +29,25 @@ describe("selectAvailableTasks", () => {
});
expect(result.map((t) => t.id)).toEqual(["c"]);
});
+
+ it("excludes internal sandbox prompt tasks", () => {
+ const sandboxPrompt = makeTask(
+ "sandbox-task",
+ "[sandbox_prompt:repo_selection] Choose a repository",
+ );
+ const visibleTask = makeTask("visible-task", "Fix the login flow");
+
+ const result = selectAvailableTasks([sandboxPrompt, visibleTask], {
+ assignedIds: new Set(),
+ archivedIds: new Set(),
+ workspaceIds: workspaceIdSet({
+ "sandbox-task": {},
+ "visible-task": {},
+ }),
+ });
+
+ expect(result.map((task) => task.id)).toEqual(["visible-task"]);
+ expect(isSandboxPromptTask(sandboxPrompt)).toBe(true);
+ expect(isSandboxPromptTask(visibleTask)).toBe(false);
+ });
});
diff --git a/products/desktop/packages/core/src/command-center/eligibility.ts b/products/desktop/packages/core/src/command-center/eligibility.ts
index ee60695d9f1d..5f2e77f9ff40 100644
--- a/products/desktop/packages/core/src/command-center/eligibility.ts
+++ b/products/desktop/packages/core/src/command-center/eligibility.ts
@@ -6,11 +6,17 @@ export interface CellEligibilityInput {
workspaceIds: { has(id: string): boolean };
}
+export function isSandboxPromptTask(task: Task): boolean {
+ // This prefix is a server-owned wire marker for internal sandbox work.
+ return task.title.startsWith("[sandbox_prompt:");
+}
+
export function isTaskEligibleForCell(
task: Task,
input: CellEligibilityInput,
): boolean {
return (
+ !isSandboxPromptTask(task) &&
!input.assignedIds.has(task.id) &&
!input.archivedIds.has(task.id) &&
input.workspaceIds.has(task.id)
diff --git a/products/desktop/packages/ui/src/features/command-center/hooks/useAutofillCommandCenter.test.ts b/products/desktop/packages/ui/src/features/command-center/hooks/useAutofillCommandCenter.test.ts
index da76351b811d..12a56a500c44 100644
--- a/products/desktop/packages/ui/src/features/command-center/hooks/useAutofillCommandCenter.test.ts
+++ b/products/desktop/packages/ui/src/features/command-center/hooks/useAutofillCommandCenter.test.ts
@@ -352,6 +352,37 @@ describe("useAutofillCommandCenter", () => {
]);
});
+ it("removes a persisted sandbox prompt task without refilling the grid", () => {
+ useCommandCenterStore.setState({
+ cells: ["sandbox-task", "existing", null, null],
+ activeTaskId: "sandbox-task",
+ hasAutofilled: true,
+ });
+ setQueries({
+ tasks: [
+ makeTask({
+ id: "sandbox-task",
+ title: "[sandbox_prompt:repo_selection] Choose a repository",
+ }),
+ makeTask({ id: "visible-task" }),
+ ],
+ workspaces: {
+ "sandbox-task": makeWorkspace("sandbox-task"),
+ "visible-task": makeWorkspace("visible-task"),
+ },
+ });
+
+ renderHook(() => useAutofillCommandCenter());
+
+ expect(useCommandCenterStore.getState().cells).toEqual([
+ null,
+ "existing",
+ null,
+ null,
+ ]);
+ expect(useCommandCenterStore.getState().activeTaskId).toBeNull();
+ });
+
it("marks autofilled when the grid is already full so removals do not refill", () => {
useCommandCenterStore.setState({ cells: ["a", "b", "c", "d"] });
setQueries({
diff --git a/products/desktop/packages/ui/src/features/command-center/hooks/useAutofillCommandCenter.ts b/products/desktop/packages/ui/src/features/command-center/hooks/useAutofillCommandCenter.ts
index 511d8f98b767..6122eb2345ae 100644
--- a/products/desktop/packages/ui/src/features/command-center/hooks/useAutofillCommandCenter.ts
+++ b/products/desktop/packages/ui/src/features/command-center/hooks/useAutofillCommandCenter.ts
@@ -1,5 +1,8 @@
import { selectAutofillCandidates } from "@posthog/core/command-center/autofill";
-import { workspaceIdSet } from "@posthog/core/command-center/eligibility";
+import {
+ isSandboxPromptTask,
+ workspaceIdSet,
+} from "@posthog/core/command-center/eligibility";
import { useEffect } from "react";
import { useArchivedTaskIds } from "../../archive/useArchivedTaskIds";
import { useTasks } from "../../tasks/useTasks";
@@ -14,16 +17,30 @@ export function useAutofillCommandCenter(): void {
const cells = useCommandCenterStore((s) => s.cells);
const hasAutofilled = useCommandCenterStore((s) => s.hasAutofilled);
const autofillCells = useCommandCenterStore((s) => s.autofillCells);
+ const removeTaskById = useCommandCenterStore((s) => s.removeTaskById);
useEffect(() => {
+ if (!tasksFetched) return;
+
+ const sandboxPromptIds = new Set(
+ tasks.filter(isSandboxPromptTask).map((task) => task.id),
+ );
+ for (const taskId of sandboxPromptIds) {
+ removeTaskById(taskId);
+ }
+
// One-time bootstrap: the persisted `hasAutofilled` flag stops empty cells
// from being re-filled every time the Command Center remounts.
if (hasAutofilled) return;
if (!workspacesFetched || !workspaces) return;
- if (!tasksFetched) return;
- const emptySlots = cells.filter((id) => id == null).length;
- const assignedIds = new Set(cells.filter((id): id is string => id != null));
+ const visibleCells = cells.map((id) =>
+ id && sandboxPromptIds.has(id) ? null : id,
+ );
+ const emptySlots = visibleCells.filter((id) => id == null).length;
+ const assignedIds = new Set(
+ visibleCells.filter((id): id is string => id != null),
+ );
const candidates = selectAutofillCandidates(tasks, {
assignedIds,
archivedIds: archivedTaskIds,
@@ -42,5 +59,6 @@ export function useAutofillCommandCenter(): void {
tasksFetched,
archivedTaskIds,
autofillCells,
+ removeTaskById,
]);
}