diff --git a/llmstack/client/src/components/schedule/AddAppRunScheduleModal.jsx b/llmstack/client/src/components/schedule/AddAppRunScheduleModal.jsx index 406117e0166..063f14a43f4 100644 --- a/llmstack/client/src/components/schedule/AddAppRunScheduleModal.jsx +++ b/llmstack/client/src/components/schedule/AddAppRunScheduleModal.jsx @@ -14,6 +14,18 @@ import { axios } from "../../data/axios"; import AddAppRunScheduleConfigForm from "./AddAppRunScheduleConfigForm"; import InputDataTable from "./InputDataTable"; +function checkIfColumnFieldsAreSame(prevColumns, newColumns) { + if (prevColumns && newColumns && prevColumns.length === newColumns.length) { + for (let i = 0; i < prevColumns.length; i++) { + if (prevColumns[i].field !== newColumns[i].field) { + return false; + } + } + return true; + } + return false; +} + export default function AddAppRunScheduleModal(props) { const [columns, setColumns] = useState([]); const [configuration, setConfiguration] = useState({}); @@ -34,10 +46,18 @@ export default function AddAppRunScheduleModal(props) { }; }, ); - setColumns(columnFields); - setAppRunData([]); + + const hasSameColumnFields = checkIfColumnFieldsAreSame( + columns, + columnFields, + ); + + if (!hasSameColumnFields) { + setColumns(columnFields); + setAppRunData([]); + } } - }, [configuration]); + }, [configuration?.appDetail, columns]); return ( diff --git a/llmstack/client/src/components/schedule/FrequencyPickerWidget.jsx b/llmstack/client/src/components/schedule/FrequencyPickerWidget.jsx index 35a6b0e147e..a432cc8e811 100644 --- a/llmstack/client/src/components/schedule/FrequencyPickerWidget.jsx +++ b/llmstack/client/src/components/schedule/FrequencyPickerWidget.jsx @@ -34,6 +34,7 @@ export default function FrequencyPickerWidget(props) { variant="filled" sx={{ lineHeight: "0.5em" }} > + Run Now Run Once Repeat Cron Job diff --git a/llmstack/client/src/components/schedule/InputDataTable.jsx b/llmstack/client/src/components/schedule/InputDataTable.jsx index 18475f18e20..57a868bef0d 100644 --- a/llmstack/client/src/components/schedule/InputDataTable.jsx +++ b/llmstack/client/src/components/schedule/InputDataTable.jsx @@ -86,6 +86,7 @@ export default function InputDataTable({ columnData, rowData, onChange }) { const handleRowEditStop = (params, event) => { if (params.reason === GridRowEditStopReasons.rowFocusOut) { event.defaultMuiPrevented = true; + handleSaveClick(params.id)(); } }; diff --git a/llmstack/jobs/apis.py b/llmstack/jobs/apis.py index f4ba7d8995b..2a5a7247972 100644 --- a/llmstack/jobs/apis.py +++ b/llmstack/jobs/apis.py @@ -334,7 +334,7 @@ def create(self, request): if batch_size > len(data["app_run_data"]): return DRFResponse(status=400, data={"message": "Batch size cannot be greater than total rows"}) - if frequency_type not in ["run_once", "repeat", "cron"]: + if frequency_type not in ["run_now", "run_once", "repeat", "cron"]: return DRFResponse( status=400, data={ @@ -343,7 +343,10 @@ def create(self, request): ) scheduled_time = None - if frequency_type == "run_once" or frequency_type == "repeat": + if frequency_type == "run_now": + scheduled_time = timezone.now() + + elif frequency_type == "run_once" or frequency_type == "repeat": if ( not frequency.get("start_date") or not frequency.get( @@ -390,7 +393,12 @@ def create(self, request): "task_category": "app_run", } - if frequency_type == "run_once": + if frequency_type == "run_now": + job = ScheduledJob(**job_args) + job.save() + job.schedule_now() + + elif frequency_type == "run_once": job = ScheduledJob(**job_args) job.save()