From b509e40dcebddd5a095b1173fa15501e9fe6b367 Mon Sep 17 00:00:00 2001 From: amhsirak Date: Sun, 26 Jan 2025 23:48:21 +0530 Subject: [PATCH 1/5] feat: !show developer mode settings --- src/components/run/RunSettings.tsx | 55 ++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/src/components/run/RunSettings.tsx b/src/components/run/RunSettings.tsx index a35d2f28..3da0bab8 100644 --- a/src/components/run/RunSettings.tsx +++ b/src/components/run/RunSettings.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState } from "react"; import { GenericModal } from "../ui/GenericModal"; import { MenuItem, TextField, Typography, Switch, FormControlLabel } from "@mui/material"; import { Dropdown } from "../ui/DropdownMui"; @@ -29,24 +29,38 @@ export const RunSettingsModal = ({ isOpen, handleStart, handleClose, isTask, par const [showInterpreterSettings, setShowInterpreterSettings] = useState(false); + const startImmediately = () => { + handleStart(settings); // Start functionality directly + }; + + // Start directly without opening the modal + if (!showInterpreterSettings) { + startImmediately(); + return null; // Do not render the modal + } + return ( -
+
{isTask && ( - Recording parameters: + + Recording parameters: + {params?.map((item, index) => ( setShowInterpreterSettings(!showInterpreterSettings)} />} + control={ + + setShowInterpreterSettings(!showInterpreterSettings) + } + /> + } label="Developer Mode Settings" - sx={{ margin: '20px 0px' }} + sx={{ margin: "20px 0px" }} /> {showInterpreterSettings && ( )} - +
); From 7be0c2accfa2edae1d7895fd1a0bde8dd8aab78e Mon Sep 17 00:00:00 2001 From: amhsirak Date: Sun, 26 Jan 2025 23:51:45 +0530 Subject: [PATCH 2/5] chore: cleanup --- src/components/run/RunSettings.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/run/RunSettings.tsx b/src/components/run/RunSettings.tsx index 3da0bab8..98cd5720 100644 --- a/src/components/run/RunSettings.tsx +++ b/src/components/run/RunSettings.tsx @@ -30,13 +30,12 @@ export const RunSettingsModal = ({ isOpen, handleStart, handleClose, isTask, par const [showInterpreterSettings, setShowInterpreterSettings] = useState(false); const startImmediately = () => { - handleStart(settings); // Start functionality directly + handleStart(settings); }; - // Start directly without opening the modal if (!showInterpreterSettings) { startImmediately(); - return null; // Do not render the modal + return null; } return ( From 3af63acbe39b01dedac43bb0cbbb7952e31b8d29 Mon Sep 17 00:00:00 2001 From: amhsirak Date: Sun, 26 Jan 2025 23:57:47 +0530 Subject: [PATCH 3/5] feat: avoid re-run during rendering --- src/components/run/RunSettings.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/run/RunSettings.tsx b/src/components/run/RunSettings.tsx index 98cd5720..1f40f60e 100644 --- a/src/components/run/RunSettings.tsx +++ b/src/components/run/RunSettings.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import { GenericModal } from "../ui/GenericModal"; import { MenuItem, TextField, Typography, Switch, FormControlLabel } from "@mui/material"; import { Dropdown } from "../ui/DropdownMui"; @@ -29,12 +29,17 @@ export const RunSettingsModal = ({ isOpen, handleStart, handleClose, isTask, par const [showInterpreterSettings, setShowInterpreterSettings] = useState(false); - const startImmediately = () => { - handleStart(settings); - }; + // Run immediately without modal if settings don't need to be shown + useEffect(() => { + if (!showInterpreterSettings) { + handleStart(settings); // Start the run + } + // Ensure this runs only when the component mounts or settings change + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [showInterpreterSettings]); + // Do not render the modal if settings are not shown if (!showInterpreterSettings) { - startImmediately(); return null; } From b961a371b5ee7857360d37ff202de86eecf60e64 Mon Sep 17 00:00:00 2001 From: amhsirak Date: Sun, 26 Jan 2025 23:58:19 +0530 Subject: [PATCH 4/5] fix: format --- src/components/run/RunSettings.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/run/RunSettings.tsx b/src/components/run/RunSettings.tsx index 1f40f60e..caa20e9b 100644 --- a/src/components/run/RunSettings.tsx +++ b/src/components/run/RunSettings.tsx @@ -29,16 +29,13 @@ export const RunSettingsModal = ({ isOpen, handleStart, handleClose, isTask, par const [showInterpreterSettings, setShowInterpreterSettings] = useState(false); - // Run immediately without modal if settings don't need to be shown useEffect(() => { if (!showInterpreterSettings) { - handleStart(settings); // Start the run + handleStart(settings); } - // Ensure this runs only when the component mounts or settings change // eslint-disable-next-line react-hooks/exhaustive-deps }, [showInterpreterSettings]); - // Do not render the modal if settings are not shown if (!showInterpreterSettings) { return null; } From 71d780f765fc539ccb450f9b03789e5b7f878795 Mon Sep 17 00:00:00 2001 From: Rohit Date: Mon, 27 Jan 2025 12:12:40 +0530 Subject: [PATCH 5/5] feat: avoid rerunning the robot --- src/components/run/RunSettings.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/run/RunSettings.tsx b/src/components/run/RunSettings.tsx index caa20e9b..33427d16 100644 --- a/src/components/run/RunSettings.tsx +++ b/src/components/run/RunSettings.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useRef } from "react"; import { GenericModal } from "../ui/GenericModal"; import { MenuItem, TextField, Typography, Switch, FormControlLabel } from "@mui/material"; import { Dropdown } from "../ui/DropdownMui"; @@ -28,13 +28,19 @@ export const RunSettingsModal = ({ isOpen, handleStart, handleClose, isTask, par }); const [showInterpreterSettings, setShowInterpreterSettings] = useState(false); + const hasRun = useRef(false); useEffect(() => { - if (!showInterpreterSettings) { + if (!isOpen) { + hasRun.current = false; + return; + } + + if (!showInterpreterSettings && !hasRun.current) { + hasRun.current = true; handleStart(settings); } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [showInterpreterSettings]); + }, [isOpen, showInterpreterSettings, settings, handleStart]); if (!showInterpreterSettings) { return null;