diff --git a/backend/open_webui/routers/automations.py b/backend/open_webui/routers/automations.py index 091849bc7c..1c2149770d 100644 --- a/backend/open_webui/routers/automations.py +++ b/backend/open_webui/routers/automations.py @@ -439,6 +439,9 @@ async def update_automation_by_id( raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(e)) await check_automation_limits(None, user, schedule.rrule, db) + # Browsers round nanosecond timestamps, so an expiry within a millisecond of the stored one is unchanged. + if form_data.expires_at and automation.expires_at and abs(form_data.expires_at - automation.expires_at) < 1_000_000: + form_data.expires_at = automation.expires_at next_run_at = await schedule_next_run(form_data.data.model_dump(), tz=await get_owner_timezone(automation, user)) # An unchanged expiry, even a passed one, doesn't block other edits. if form_data.expires_at != automation.expires_at: diff --git a/src/lib/components/automations/AutomationEditor.svelte b/src/lib/components/automations/AutomationEditor.svelte index 1722c3d180..d318883a76 100644 --- a/src/lib/components/automations/AutomationEditor.svelte +++ b/src/lib/components/automations/AutomationEditor.svelte @@ -157,6 +157,9 @@ let webhookAllowGet = false; // A local date and time, as the datetime input holds it; empty means it never expires. let expiresAt = ''; + $: savedExpiresAt = automation.expires_at + ? dayjs(automation.expires_at / 1_000_000).format('YYYY-MM-DDTHH:mm') + : ''; $: allowWebhook = !!$config?.features?.enable_automation_webhooks; $: hookUrl = getAutomationHookUrl(automation); let saving = false; @@ -217,10 +220,7 @@ automation.data.triggers.some( (trigger) => trigger.type === 'webhook' && !!trigger.allow_get )) || - expiresAt !== - (automation.expires_at - ? dayjs(automation.expires_at / 1_000_000).format('YYYY-MM-DDTHH:mm') - : '')); + expiresAt !== savedExpiresAt); // Agent models depend on the chosen machine, as in the automation modal. let modelRequest = 0; @@ -297,7 +297,11 @@ }, meta: automation.meta ?? undefined, is_active, - expires_at: expiresAt ? dayjs(expiresAt).valueOf() * 1_000_000 : null + expires_at: expiresAt + ? expiresAt === savedExpiresAt + ? automation.expires_at + : dayjs(expiresAt).valueOf() * 1_000_000 + : null }; await updateAutomationById(localStorage.token, automation.id, form); await editSavedHandler();