44 ChartLine ,
55 EnvelopeSimple ,
66} from "@phosphor-icons/react" ;
7+ import { workspaceIdSet } from "@posthog/core/command-center/eligibility" ;
78import { resolveService } from "@posthog/di/container" ;
89import {
910 HOST_TRPC_CLIENT ,
@@ -28,6 +29,7 @@ import {
2829 type CommandMenuAction ,
2930} from "@posthog/shared/analytics-events" ;
3031import type { Task } from "@posthog/shared/domain-types" ;
32+ import { useArchivedTaskIds } from "@posthog/ui/features/archive/useArchivedTaskIds" ;
3133import { useChannels } from "@posthog/ui/features/canvas/hooks/useChannels" ;
3234import { useTaskChannelMap } from "@posthog/ui/features/canvas/hooks/useTaskChannelMap" ;
3335import { useReviewNavigationStore } from "@posthog/ui/features/code-review/reviewNavigationStore" ;
@@ -40,6 +42,7 @@ import {
4042import { useFileSearchContext } from "@posthog/ui/features/command/useFileSearchContext" ;
4143import { useFeatureFlag } from "@posthog/ui/features/feature-flags/useFeatureFlag" ;
4244import { useFolders } from "@posthog/ui/features/folders/useFolders" ;
45+ import { useProvisioningStore } from "@posthog/ui/features/provisioning/store" ;
4346import {
4447 closeSettings ,
4548 openSettings ,
@@ -48,6 +51,7 @@ import { TaskIcon } from "@posthog/ui/features/sidebar/components/items/TaskIcon
4851import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore" ;
4952import { useTaskPrStatus } from "@posthog/ui/features/sidebar/useTaskPrStatus" ;
5053import { useTasks } from "@posthog/ui/features/tasks/useTasks" ;
54+ import { useWorkspaces } from "@posthog/ui/features/workspace/useWorkspace" ;
5155import {
5256 goBackInHistory ,
5357 goForwardInHistory ,
@@ -152,6 +156,11 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
152156 ( state ) => state . getReviewMode ,
153157 ) ;
154158 const { data : tasks = [ ] } = useTasks ( ) ;
159+ const archivedTaskIds = useArchivedTaskIds ( ) ;
160+ const { data : workspaces , isFetched : workspacesFetched } = useWorkspaces ( ) ;
161+ const provisioningTaskIds = useProvisioningStore (
162+ ( state ) => state . activeTasks ,
163+ ) ;
155164 const [ query , setQuery ] = useState ( "" ) ;
156165 const { repoPath } = useFileSearchContext ( ) ;
157166 const canSearchFiles = ! ! repoPath ;
@@ -447,11 +456,19 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
447456 ] ) ;
448457
449458 const taskSections = useMemo < CommandSection [ ] > ( ( ) => {
450- if ( tasks . length === 0 ) return [ ] ;
459+ const workspaceIds = workspaceIdSet ( workspaces ) ;
460+ const visibleTasks = tasks . filter (
461+ ( task ) =>
462+ ! archivedTaskIds . has ( task . id ) &&
463+ ( ! workspacesFetched ||
464+ workspaceIds . has ( task . id ) ||
465+ provisioningTaskIds . has ( task . id ) ) ,
466+ ) ;
467+ if ( visibleTasks . length === 0 ) return [ ] ;
451468 return [
452469 {
453470 label : "Tasks" ,
454- items : tasks . map ( ( task ) => {
471+ items : visibleTasks . map ( ( task ) => {
455472 const channel = taskChannelMap . get ( task . id ) ;
456473 return {
457474 id : `task-${ task . id } ` ,
@@ -477,7 +494,16 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
477494 } ) ,
478495 } ,
479496 ] ;
480- } , [ tasks , taskChannelMap , bluebirdEnabled , closeSettingsDialog ] ) ;
497+ } , [
498+ tasks ,
499+ archivedTaskIds ,
500+ workspaces ,
501+ workspacesFetched ,
502+ provisioningTaskIds ,
503+ taskChannelMap ,
504+ bluebirdEnabled ,
505+ closeSettingsDialog ,
506+ ] ) ;
481507
482508 const channelSections = useMemo < CommandSection [ ] > ( ( ) => {
483509 if ( channels . length === 0 ) return [ ] ;
0 commit comments