From 475d9977d31a89680d8015c11c0d5839c068fc56 Mon Sep 17 00:00:00 2001
From: ali asaria <aliasaria@users.noreply.github.com>
Date: Thu, 27 Feb 2025 15:11:11 -0500
Subject: [PATCH] add a fake start node to all diagrams as we wait for backend
 to do this

---
 .../Experiment/Workflows/WorkflowCanvas.tsx   | 35 +++++++++++++++++--
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/renderer/components/Experiment/Workflows/WorkflowCanvas.tsx b/src/renderer/components/Experiment/Workflows/WorkflowCanvas.tsx
index b4635812..bcb52049 100644
--- a/src/renderer/components/Experiment/Workflows/WorkflowCanvas.tsx
+++ b/src/renderer/components/Experiment/Workflows/WorkflowCanvas.tsx
@@ -19,9 +19,21 @@ const nodeTypes = { customNode: CustomNode };
 
 function generateNodes(workflow: any): any[] {
   const workflowConfig = JSON.parse(workflow?.config);
+  const fakeStartNode = {
+    id: 'start',
+    type: 'input',
+    position: { x: 0, y: -70 },
+    data: {
+      id: 'start',
+      label: 'Start',
+      jobType: 'start',
+      template: 'start',
+      metadata: {},
+    },
+  };
 
   if (workflowConfig.nodes.length == 0) {
-    return [];
+    return [fakeStartNode];
   }
 
   let out: any[] = [];
@@ -30,6 +42,9 @@ function generateNodes(workflow: any): any[] {
 
   // console.log(workflowConfig);
 
+  // Add a fake start node for now -- later the backend will do this
+  out.push(fakeStartNode);
+
   for (let i = 0; i < workflowConfig.nodes.length; i++) {
     const node = workflowConfig.nodes[i];
     // console.log(node);
@@ -56,8 +71,18 @@ function generateNodes(workflow: any): any[] {
 
 function generateEdges(workflow: any) {
   const workflowConfig = JSON.parse(workflow?.config);
-  if (workflowConfig.nodes.length <= 1) {
-    return [];
+
+  let fakeStartNodeEdge = {
+    id: '-100',
+    source: 'start',
+    target: null,
+    markerEnd: {
+      type: 'arrow',
+    },
+  };
+
+  if (workflowConfig.nodes.length < 1) {
+    return [fakeStartNodeEdge];
   }
 
   let out: any[] = [];
@@ -66,6 +91,10 @@ function generateEdges(workflow: any) {
 
   // console.log(workflowConfig);
 
+  // conect the fake start node to the first node:
+  fakeStartNodeEdge.target = currentTask;
+  out.push(fakeStartNodeEdge);
+
   for (let i = 0; i < workflowConfig.nodes.length; i++) {
     const currentNode = workflowConfig.nodes[i];
 
-- 
GitLab