fix: a duplicated automation loses the start date of its schedule (#35047)

Duplicating an automation whose repeating schedule has a start date, such as one the model created in a chat, saved the copy without that start date. A copy of a schedule meant to start later began running right away, so it ran on other dates than the original. The copy now keeps the schedule exactly as it was unless the schedule is changed before the copy is created.

Fixes #35044
This commit is contained in:
Classic298 authored and GitHub committed 2026-11-25 12:40:19 +04:00
1 parent 3725657c84
commit 9cb24a5306
1 file changed
+6 -1
+6 -1
View File
@@ -104,6 +104,7 @@
// Schedule dropdown ref
let scheduleDropdown: ScheduleDropdown;
let savedRrule = '';
$: allowWebhook = !!$config?.features?.enable_automation_webhooks;
const submitHandler = async () => {
@@ -128,13 +129,16 @@
}
loading = true;
try {
const rrule = scheduleDropdown.buildRrule();
const sourceRrule = (automation ?? cloneFrom)?.data.rrule;
const form: AutomationForm = {
name: name.trim(),
folder_id: target_type === 'channel' ? null : folder_id || null,
data: {
prompt: prompt.trim(),
model_id: model_id.trim(),
rrule: scheduleDropdown.buildRrule(),
// An untouched schedule keeps its stored start date.
rrule: sourceRrule && rrule === savedRrule ? sourceRrule : rrule,
webhook: webhookEnabled ? { allow_get: webhookAllowGet } : null,
machine: machineServerId
? { server_id: machineServerId, cwd: machineCwd.trim() || undefined }
@@ -227,6 +231,7 @@
webhookEnabled = false;
webhookAllowGet = false;
}
savedRrule = scheduleDropdown?.buildRrule?.() ?? '';
initialized = true;
};