@@ -88,21 +88,21 @@ const WorkflowBuilder: React.FC<WorkflowBuilderProps> = ({
8888 } ,
8989 ) ;
9090
91+ // Initialize state with workflow data
92+ const workflowState = useWorkflowState ( {
93+ currentWorkflowData,
94+ userTimezone : timezone ,
95+ } ) ;
96+
9197 // Query the latest execution result for step outputs
9298 const { data : latestExecutionData , refetch : refetchLatestExecution } =
9399 useLatestWorkflowExecutionQuery ( currentWorkflowId || '' , {
94100 enabled : ! ! currentWorkflowId ,
95101 refetchOnWindowFocus : false ,
96- refetchInterval : false ,
97- staleTime : 10000 ,
102+ refetchInterval : workflowState . isTesting ? 1000 : false , // Poll every 1s during testing
103+ staleTime : workflowState . isTesting ? 0 : 10000 , // Fresh data during testing
98104 } ) ;
99105
100- // Initialize state with workflow data
101- const workflowState = useWorkflowState ( {
102- currentWorkflowData,
103- userTimezone : timezone ,
104- } ) ;
105-
106106 // Fetch triggers for selected app - MOVED HERE so we can access workflowState
107107 const {
108108 data : appTriggersData ,
@@ -186,9 +186,21 @@ const WorkflowBuilder: React.FC<WorkflowBuilderProps> = ({
186186 setTestingWorkflows ( ( prev ) => new Set ( prev ) . add ( testWorkflowId ) ) ;
187187 }
188188 } ,
189- onStepUpdate : ( testWorkflowId ) => {
189+ onStepUpdate : ( testWorkflowId , stepData ) => {
190190 if ( testWorkflowId === currentWorkflowId ) {
191- // Handle step updates
191+ // Map step name to step ID
192+ const step = workflowState . steps . find ( ( s ) => s . name === stepData . stepName ) ;
193+
194+ if ( step ) {
195+ if ( stepData . status === 'running' ) {
196+ workflowState . setCurrentRunningStepId ( step . id ) ;
197+ } else if ( stepData . status === 'completed' ) {
198+ workflowState . setCurrentRunningStepId ( null ) ;
199+ workflowState . setCompletedStepIds ( ( prev ) => new Set ( prev ) . add ( step . id ) ) ;
200+ } else if ( stepData . status === 'failed' ) {
201+ workflowState . setCurrentRunningStepId ( null ) ;
202+ }
203+ }
192204 }
193205 } ,
194206 onTestComplete : ( testWorkflowId ) => {
@@ -438,11 +450,12 @@ const WorkflowBuilder: React.FC<WorkflowBuilderProps> = ({
438450 } ) ;
439451 } ;
440452
441- // Get step status for styling
453+ // Get step status for styling - restored original logic
442454 const getStepStatus = ( stepId : string ) => {
443455 if ( ! workflowState . isTesting ) return 'idle' ;
444456 if ( workflowState . completedStepIds . has ( stepId ) ) return 'completed' ;
445457
458+ // Check if this step is currently running by matching name from execution data
446459 const step = workflowState . steps . find ( ( s ) => s . id === stepId ) ;
447460 const actualExecutionData = latestExecutionData as any ;
448461 const currentExecStep = actualExecutionData ?. steps ?. find ( ( s : any ) => s . name === step ?. name ) ;
0 commit comments