@@ -7,44 +7,20 @@ import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
77
88export default function WorkflowsPage ( ) {
99 const router = useRouter ( )
10- const { workflows, isLoading, loadWorkflows } = useWorkflowRegistry ( )
10+ const { workflows, isLoading } = useWorkflowRegistry ( )
1111
1212 const params = useParams ( )
13- const workspaceId = params . workspaceId as string
14-
15- // Always load workflows for the current workspace to ensure we have the correct ones
16- useEffect ( ( ) => {
17- if ( ! isLoading ) {
18- loadWorkflows ( workspaceId )
19- }
20- } , [ workspaceId , loadWorkflows , isLoading ] )
13+ const workspaceId = params . workspaceId
2114
2215 useEffect ( ( ) => {
2316 // Wait for workflows to load
2417 if ( isLoading ) return
2518
26- // Filter workflows for this workspace only
27- const workspaceWorkflows = Object . values ( workflows ) . filter (
28- ( workflow ) => workflow . workspaceId === workspaceId
29- )
30-
31- // If we have workflows for this workspace, redirect to the first one
32- if ( workspaceWorkflows . length > 0 ) {
33- // Sort by last modified date (newest first) - same logic as sidebar
34- const sortedWorkflows = workspaceWorkflows . sort ( ( a , b ) => {
35- const dateA =
36- a . lastModified instanceof Date
37- ? a . lastModified . getTime ( )
38- : new Date ( a . lastModified ) . getTime ( )
39- const dateB =
40- b . lastModified instanceof Date
41- ? b . lastModified . getTime ( )
42- : new Date ( b . lastModified ) . getTime ( )
43- return dateB - dateA
44- } )
19+ const workflowIds = Object . keys ( workflows )
4520
46- const firstWorkflowId = sortedWorkflows [ 0 ] . id
47- router . replace ( `/workspace/${ workspaceId } /w/${ firstWorkflowId } ` )
21+ // If we have workflows, redirect to the first one
22+ if ( workflowIds . length > 0 ) {
23+ router . replace ( `/workspace/${ workspaceId } /w/${ workflowIds [ 0 ] } ` )
4824 return
4925 }
5026
0 commit comments