1+ import { HashIcon } from "@phosphor-icons/react" ;
12import {
23 Autocomplete ,
34 AutocompleteCollection ,
@@ -15,6 +16,8 @@ import {
1516 type CommandMenuAction ,
1617} from "@posthog/shared/analytics-events" ;
1718import type { Task } from "@posthog/shared/domain-types" ;
19+ import { useChannels } from "@posthog/ui/features/canvas/hooks/useChannels" ;
20+ import { useTaskChannelMap } from "@posthog/ui/features/canvas/hooks/useTaskChannelMap" ;
1821import { useReviewNavigationStore } from "@posthog/ui/features/code-review/reviewNavigationStore" ;
1922import { CommandKeyHints } from "@posthog/ui/features/command/CommandKeyHints" ;
2023import { useFolders } from "@posthog/ui/features/folders/useFolders" ;
@@ -26,6 +29,7 @@ import { TaskIcon } from "@posthog/ui/features/sidebar/components/items/TaskIcon
2629import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore" ;
2730import { useTaskPrStatus } from "@posthog/ui/features/sidebar/useTaskPrStatus" ;
2831import { useTasks } from "@posthog/ui/features/tasks/useTasks" ;
32+ import { navigateToChannel } from "@posthog/ui/router/navigationBridge" ;
2933import { useAppView } from "@posthog/ui/router/useAppView" ;
3034import { openTask , openTaskInput } from "@posthog/ui/router/useOpenTask" ;
3135import { track } from "@posthog/ui/shell/analytics" ;
@@ -49,6 +53,8 @@ interface CommandMenuProps {
4953type Command = {
5054 id : string ;
5155 label : string ;
56+ /** Muted trailing detail shown after a middot, e.g. a task's channel. */
57+ detail ?: string ;
5258 keywords ?: string ;
5359 icon : React . ReactNode ;
5460 action : CommandMenuAction ;
@@ -89,6 +95,8 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
8995 const openSettingsDialog = openSettings ;
9096 const closeSettingsDialog = closeSettings ;
9197 const { folders } = useFolders ( ) ;
98+ const { channels } = useChannels ( ) ;
99+ const taskChannelMap = useTaskChannelMap ( { enabled : open } ) ;
92100 const { theme, setTheme } = useThemeStore ( ) ;
93101 const toggleLeftSidebar = useSidebarStore ( ( state ) => state . toggle ) ;
94102 const view = useAppView ( ) ;
@@ -254,24 +262,50 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
254262 return [
255263 {
256264 label : "Tasks" ,
257- items : tasks . map ( ( task ) => ( {
258- id : `task-${ task . id } ` ,
259- label : task . title ,
260- icon : < TaskCommandIcon task = { task } /> ,
261- action : "open-task" as CommandMenuAction ,
265+ items : tasks . map ( ( task ) => {
266+ const channel = taskChannelMap . get ( task . id ) ;
267+ return {
268+ id : `task-${ task . id } ` ,
269+ label : task . title ,
270+ detail : channel ?. name ,
271+ // Include the channel name so searching it surfaces filed tasks.
272+ keywords : channel ?. name ,
273+ icon : < TaskCommandIcon task = { task } /> ,
274+ action : "open-task" as CommandMenuAction ,
275+ onRun : ( ) => {
276+ closeSettingsDialog ( ) ;
277+ void openTask ( task ) ;
278+ } ,
279+ } ;
280+ } ) ,
281+ } ,
282+ ] ;
283+ } , [ tasks , taskChannelMap , closeSettingsDialog ] ) ;
284+
285+ const channelSections = useMemo < CommandSection [ ] > ( ( ) => {
286+ if ( channels . length === 0 ) return [ ] ;
287+ return [
288+ {
289+ label : "Channels" ,
290+ items : channels . map ( ( channel ) => ( {
291+ id : `channel-${ channel . id } ` ,
292+ label : channel . name ,
293+ keywords : "channel" ,
294+ icon : < HashIcon size = { 12 } className = "text-gray-11" /> ,
295+ action : "open-channel" as CommandMenuAction ,
262296 onRun : ( ) => {
263297 closeSettingsDialog ( ) ;
264- void openTask ( task ) ;
298+ navigateToChannel ( channel . id ) ;
265299 } ,
266300 } ) ) ,
267301 } ,
268302 ] ;
269- } , [ tasks , closeSettingsDialog ] ) ;
303+ } , [ channels , closeSettingsDialog ] ) ;
270304
271- // Commands and tasks share a single filterable list.
305+ // Commands, channels, and tasks share a single filterable list.
272306 const sections = useMemo (
273- ( ) => [ ...commandSections , ...taskSections ] ,
274- [ commandSections , taskSections ] ,
307+ ( ) => [ ...commandSections , ...channelSections , ... taskSections ] ,
308+ [ commandSections , channelSections , taskSections ] ,
275309 ) ;
276310
277311 const allCommands = useMemo (
@@ -314,7 +348,7 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
314348 } }
315349 >
316350 < AutocompleteInput
317- placeholder = "Search commands and tasks…"
351+ placeholder = "Search commands, channels, and tasks…"
318352 autoFocus
319353 showClear
320354 />
@@ -343,6 +377,11 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
343377 < span className = "wrap-break-word min-w-0 whitespace-normal" >
344378 { cmd . label }
345379 </ span >
380+ { cmd . detail && (
381+ < span className = "shrink-0 text-gray-9" >
382+ · #{ cmd . detail }
383+ </ span >
384+ ) }
346385 </ AutocompleteItem >
347386 ) }
348387 </ AutocompleteCollection >
0 commit comments