Skip to content

Commit 37835a5

Browse files
fix: brought back the testing visualisation for workflows
1 parent b768702 commit 37835a5

2 files changed

Lines changed: 46 additions & 11 deletions

File tree

client/src/components/SidePanel/WorkflowBuilder/WorkflowBuilder.tsx

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

client/src/hooks/Chat/useChatHelpers.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,28 @@ export default function useChatHelpers(index = 0, paramId?: string) {
518518
queryClient.invalidateQueries([QueryKeys.schedulerTasks]);
519519
} else if (data.type === 'task_status_update' || data.type === 'task_notification') {
520520
console.log('[SchedulerSSE] 📋 Processing task status update:', data);
521+
522+
// Check if this is a workflow task and convert to workflow notification
523+
if (data.taskId && data.taskId.startsWith('workflow_')) {
524+
const workflowNotificationData = {
525+
type: 'workflow_status_update',
526+
workflowId: data.taskId,
527+
notificationType: data.notificationType === 'started' ? 'test_started' :
528+
data.notificationType === 'completed' ? 'execution_completed' :
529+
data.notificationType === 'failed' ? 'execution_failed' :
530+
data.notificationType,
531+
details: data.details,
532+
timestamp: data.timestamp,
533+
taskName: data.taskName
534+
};
535+
536+
// Dispatch as workflow notification
537+
const workflowEvent = new CustomEvent('workflowNotification', {
538+
detail: workflowNotificationData
539+
});
540+
window.dispatchEvent(workflowEvent);
541+
}
542+
521543
// Handle task status updates (started, failed, cancelled, etc.)
522544
// These don't necessarily create new messages but do update task status
523545
queryClient.invalidateQueries([QueryKeys.schedulerTasks]);

0 commit comments

Comments
 (0)