@@ -26,6 +26,7 @@ import { createLogger } from '@/lib/logs/console/logger'
2626import { useRegisterGlobalCommands } from '@/app/workspace/[workspaceId]/providers/global-commands-provider'
2727import { useUserPermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider'
2828import { Variables } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/variables/variables'
29+ import { useWorkflowExecution } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution'
2930import { useDeleteWorkflow } from '@/app/workspace/[workspaceId]/w/hooks'
3031import { useChatStore } from '@/stores/chat/store'
3132import { usePanelStore } from '@/stores/panel-new/store'
@@ -35,7 +36,7 @@ import { useWorkflowJsonStore } from '@/stores/workflows/json/store'
3536import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
3637import { useWorkflowStore } from '@/stores/workflows/workflow/store'
3738import { Copilot , Deploy , Editor , Toolbar } from './components'
38- import { usePanelResize , useRunWorkflow , useUsageLimits } from './hooks'
39+ import { usePanelResize , useUsageLimits } from './hooks'
3940
4041const logger = createLogger ( 'Panel' )
4142/**
@@ -99,12 +100,43 @@ export function Panel() {
99100 autoRefresh : ! isRegistryLoading ,
100101 } )
101102
102- // Run workflow hook
103- const { runWorkflow , cancelWorkflow , isExecuting } = useRunWorkflow ( { usageExceeded } )
103+ // Workflow execution hook
104+ const { handleRunWorkflow , handleCancelExecution , isExecuting } = useWorkflowExecution ( )
104105
105106 // Panel resize hook
106107 const { handleMouseDown } = usePanelResize ( )
107108
109+ /**
110+ * Opens subscription settings modal
111+ */
112+ const openSubscriptionSettings = ( ) => {
113+ if ( typeof window !== 'undefined' ) {
114+ window . dispatchEvent (
115+ new CustomEvent ( 'open-settings' , {
116+ detail : { tab : 'subscription' } ,
117+ } )
118+ )
119+ }
120+ }
121+
122+ /**
123+ * Runs the workflow with usage limit check
124+ */
125+ const runWorkflow = useCallback ( async ( ) => {
126+ if ( usageExceeded ) {
127+ openSubscriptionSettings ( )
128+ return
129+ }
130+ await handleRunWorkflow ( )
131+ } , [ usageExceeded , handleRunWorkflow ] )
132+
133+ /**
134+ * Cancels the currently executing workflow
135+ */
136+ const cancelWorkflow = useCallback ( async ( ) => {
137+ await handleCancelExecution ( )
138+ } , [ handleCancelExecution ] )
139+
108140 // Chat state
109141 const { isChatOpen, setIsChatOpen } = useChatStore ( )
110142 const { isOpen : isVariablesOpen , setIsOpen : setVariablesOpen } = useVariablesStore ( )
0 commit comments