From 3fd41a9691a165913175349d6091accb1f692451 Mon Sep 17 00:00:00 2001 From: igennova Date: Mon, 6 Jul 2026 09:53:43 +0530 Subject: [PATCH 1/2] fix(ui): exclude archived and deleted tasks from global search --- .../ui/src/features/command/CommandMenu.tsx | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/features/command/CommandMenu.tsx b/packages/ui/src/features/command/CommandMenu.tsx index b7419edc0a..631551ba53 100644 --- a/packages/ui/src/features/command/CommandMenu.tsx +++ b/packages/ui/src/features/command/CommandMenu.tsx @@ -23,6 +23,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 +44,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 +145,8 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) { (state) => state.getReviewMode, ); const { data: tasks = [] } = useTasks(); + const archivedTaskIds = useArchivedTaskIds(); + const { data: workspaces } = useWorkspaces(); const [query, setQuery] = useState(""); const { repoPath } = useFileSearchContext(); const canSearchFiles = !!repoPath; @@ -387,11 +391,14 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) { ]); const taskSections = useMemo(() => { - if (tasks.length === 0) return []; + const visibleTasks = tasks.filter( + (task) => !archivedTaskIds.has(task.id) && Boolean(workspaces?.[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 +424,14 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) { }), }, ]; - }, [tasks, taskChannelMap, bluebirdEnabled, closeSettingsDialog]); + }, [ + tasks, + archivedTaskIds, + workspaces, + taskChannelMap, + bluebirdEnabled, + closeSettingsDialog, + ]); const channelSections = useMemo(() => { if (channels.length === 0) return []; From 6585b3b1c09d31932df8da89957c15823c329bd1 Mon Sep 17 00:00:00 2001 From: igennova Date: Mon, 6 Jul 2026 10:07:28 +0530 Subject: [PATCH 2/2] refactor(ui): reuse workspaceIdSet and guard search during workspace load --- packages/ui/src/features/command/CommandMenu.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/ui/src/features/command/CommandMenu.tsx b/packages/ui/src/features/command/CommandMenu.tsx index 631551ba53..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, @@ -146,7 +147,7 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) { ); const { data: tasks = [] } = useTasks(); const archivedTaskIds = useArchivedTaskIds(); - const { data: workspaces } = useWorkspaces(); + const { data: workspaces, isFetched: workspacesFetched } = useWorkspaces(); const [query, setQuery] = useState(""); const { repoPath } = useFileSearchContext(); const canSearchFiles = !!repoPath; @@ -391,8 +392,11 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) { ]); const taskSections = useMemo(() => { + const workspaceIds = workspaceIdSet(workspaces); const visibleTasks = tasks.filter( - (task) => !archivedTaskIds.has(task.id) && Boolean(workspaces?.[task.id]), + (task) => + !archivedTaskIds.has(task.id) && + (!workspacesFetched || workspaceIds.has(task.id)), ); if (!visibleTasks.length) return []; return [ @@ -428,6 +432,7 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) { tasks, archivedTaskIds, workspaces, + workspacesFetched, taskChannelMap, bluebirdEnabled, closeSettingsDialog,