Skip to content

Commit

Permalink
Fix the bug of creating a new session on the AutoGen Studio playgroun…
Browse files Browse the repository at this point in the history
…d page (microsoft#3407)

Co-authored-by: linuxYn <[email protected]>
Co-authored-by: Victor Dibia <[email protected]>
  • Loading branch information
3 people authored Sep 8, 2024
1 parent 084a54d commit 2ff2979
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ const SessionsView = ({}: any) => {
<WorkflowSelector
workflow={workflow}
setWorkflow={setWorkflow}
workflow_id={selectedSession?.workflow_id}
disabled={sessionExists}
/>
<div className="my-2 text-xs"> Session Name </div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import { Link } from "gatsby";
const WorkflowSelector = ({
workflow,
setWorkflow,
workflow_id,
disabled,
}: {
workflow: IWorkflow | null;
setWorkflow: (workflow: IWorkflow) => void;
workflow_id: number | undefined;
disabled?: boolean;
}) => {
const [error, setError] = React.useState<IStatus | null>({
Expand Down Expand Up @@ -42,7 +44,15 @@ const WorkflowSelector = ({
// message.success(data.message);
setWorkflows(data.data);
if (data.data.length > 0) {
setWorkflow(data.data[0]);
if (!disabled) {
setWorkflow(data.data[0]);
} else {
const index = data.data.findIndex((item:IWorkflow) => item.id === workflow_id);
if (index !== -1) {
setSelectedWorkflow(index);
setWorkflow(data.data[index]);
}
}
}
} else {
message.error(data.message);
Expand Down

0 comments on commit 2ff2979

Please sign in to comment.