diff --git a/packages/ui/src/features/command/CommandMenu.tsx b/packages/ui/src/features/command/CommandMenu.tsx index b7419edc0a..cc9f3fe748 100644 --- a/packages/ui/src/features/command/CommandMenu.tsx +++ b/packages/ui/src/features/command/CommandMenu.tsx @@ -4,6 +4,7 @@ import { EnvelopeSimple, HashIcon, } from "@phosphor-icons/react"; +import { workspaceIdSet } from "@posthog/core/command-center/eligibility"; import { Autocomplete, AutocompleteCollection, @@ -23,6 +24,7 @@ import { type CommandMenuAction, } from "@posthog/shared/analytics-events"; import type { Task } from "@posthog/shared/domain-types"; +import { useArchivedTaskIds } from "@posthog/ui/features/archive/useArchivedTaskIds"; import { useChannels } from "@posthog/ui/features/canvas/hooks/useChannels"; import { useTaskChannelMap } from "@posthog/ui/features/canvas/hooks/useTaskChannelMap"; import { useReviewNavigationStore } from "@posthog/ui/features/code-review/reviewNavigationStore"; @@ -43,6 +45,7 @@ import { TaskIcon } from "@posthog/ui/features/sidebar/components/items/TaskIcon import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore"; import { useTaskPrStatus } from "@posthog/ui/features/sidebar/useTaskPrStatus"; import { useTasks } from "@posthog/ui/features/tasks/useTasks"; +import { useWorkspaces } from "@posthog/ui/features/workspace/useWorkspace"; import { goBackInHistory, goForwardInHistory, @@ -143,6 +146,8 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) { (state) => state.getReviewMode, ); const { data: tasks = [] } = useTasks(); + const archivedTaskIds = useArchivedTaskIds(); + const { data: workspaces, isFetched: workspacesFetched } = useWorkspaces(); const [query, setQuery] = useState(""); const { repoPath } = useFileSearchContext(); const canSearchFiles = !!repoPath; @@ -387,11 +392,17 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) { ]); const taskSections = useMemo(() => { - if (tasks.length === 0) return []; + const workspaceIds = workspaceIdSet(workspaces); + const visibleTasks = tasks.filter( + (task) => + !archivedTaskIds.has(task.id) && + (!workspacesFetched || workspaceIds.has(task.id)), + ); + if (!visibleTasks.length) return []; return [ { label: "Tasks", - items: tasks.map((task) => { + items: visibleTasks.map((task) => { const channel = taskChannelMap.get(task.id); return { id: `task-${task.id}`, @@ -417,7 +428,15 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) { }), }, ]; - }, [tasks, taskChannelMap, bluebirdEnabled, closeSettingsDialog]); + }, [ + tasks, + archivedTaskIds, + workspaces, + workspacesFetched, + taskChannelMap, + bluebirdEnabled, + closeSettingsDialog, + ]); const channelSections = useMemo(() => { if (channels.length === 0) return [];