11'use client'
22
3- import { useCallback , useEffect , useMemo , useState } from 'react'
3+ import { useCallback , useMemo } from 'react'
44import { ArrowUp , Bell , Library , Loader2 , MoreHorizontal , RefreshCw } from 'lucide-react'
55import { useParams } from 'next/navigation'
66import {
@@ -19,6 +19,7 @@ import { getTriggerOptions } from '@/lib/logs/get-trigger-options'
1919import { getBlock } from '@/blocks/registry'
2020import { useFolderStore } from '@/stores/folders/store'
2121import { useFilterStore } from '@/stores/logs/filters/store'
22+ import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
2223import { AutocompleteSearch } from './components/search'
2324
2425const CORE_TRIGGER_TYPES = [ 'manual' , 'api' , 'schedule' , 'chat' , 'webhook' ] as const
@@ -155,22 +156,17 @@ export function LogsToolbar({
155156 } = useFilterStore ( )
156157 const folders = useFolderStore ( ( state ) => state . folders )
157158
158- const [ workflows , setWorkflows ] = useState < Array < { id : string ; name : string ; color : string } > > ( [ ] )
159-
160- useEffect ( ( ) => {
161- const fetchWorkflows = async ( ) => {
162- try {
163- const res = await fetch ( `/api/workflows?workspaceId=${ encodeURIComponent ( workspaceId ) } ` )
164- if ( res . ok ) {
165- const body = await res . json ( )
166- setWorkflows ( Array . isArray ( body ?. data ) ? body . data : [ ] )
167- }
168- } catch {
169- setWorkflows ( [ ] )
170- }
171- }
172- if ( workspaceId ) fetchWorkflows ( )
173- } , [ workspaceId ] )
159+ // Use the same workflow source as the dashboard's WorkflowsList
160+ const allWorkflows = useWorkflowRegistry ( ( state ) => state . workflows )
161+
162+ // Transform registry workflows to the format needed for combobox options
163+ const workflows = useMemo ( ( ) => {
164+ return Object . values ( allWorkflows ) . map ( ( w ) => ( {
165+ id : w . id ,
166+ name : w . name ,
167+ color : w . color ,
168+ } ) )
169+ } , [ allWorkflows ] )
174170
175171 const folderList = useMemo ( ( ) => {
176172 return Object . values ( folders ) . filter ( ( f ) => f . workspaceId === workspaceId )
0 commit comments