Skip to content

Commit 2959dc6

Browse files
committed
Add useEffect to select the first available workflow
1 parent 6fc7da7 commit 2959dc6

File tree

1 file changed

+10
-1
lines changed
  • src/renderer/components/Experiment/Workflows

1 file changed

+10
-1
lines changed

src/renderer/components/Experiment/Workflows/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
Trash2Icon,
3030
WorkflowIcon,
3131
} from 'lucide-react';
32-
import { useState } from 'react';
32+
import { useEffect, useState } from 'react';
3333

3434
import * as chatAPI from '../../../lib/transformerlab-api-sdk';
3535
import useSWR from 'swr';
@@ -75,6 +75,15 @@ export default function Workflows({ experimentInfo }) {
7575
mutate: mutateWorkflows,
7676
} = useSWR(chatAPI.Endpoints.Workflows.List(), fetcher);
7777

78+
// select the first workflow available:
79+
useEffect(() => {
80+
if (workflowsData && workflowsData.length > 0) {
81+
if (selectedWorkflowId == null && !newWorkflowModalOpen) {
82+
setSelectedWorkflowId(workflowsData[0].id);
83+
}
84+
}
85+
}, [selectedWorkflowId, newWorkflowModalOpen]);
86+
7887
const workflows = workflowsData;
7988

8089
const selectedWorkflow = workflows?.find(

0 commit comments

Comments
 (0)