fix: automation still shows "Last run Never" after "Run now" (#31583)

* fix: automation still shows "Last run Never" after "Run now"

Running an automation with "Run now" added the run to its history, but the automation page and the Automations list kept showing "Last run Never" (or the time of the last scheduled run). Only scheduled runs recorded a last run time. A manual run now records it too, so the automation page and the Automations list show the time of the run you just started.

Fixes #31580

* fix: show the new last run time right after Run now

The automation page now takes the automation the server returns after Run now, so the last run time updates on the spot and no reload is needed.
This commit is contained in:
Classic298 2026-09-30 17:01:42 +02:00 • committed by GitHub
parent 6419eca3a2
commit e26da43076
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 0 deletions

View file

@ -244,6 +244,15 @@ class AutomationTable:
await db.commit()
return AutomationModel.model_validate(row)
async def update_last_run_at(self, id: str, db: Optional[AsyncSession] = None) -> Optional[AutomationModel]:
async with get_async_db_context(db) as db:
row = await db.get(Automation, id)
if not row:
return None
row.last_run_at = int(time.time_ns())
await db.commit()
return AutomationModel.model_validate(row)
async def clear_folder_ids(
self,
user_id: str,

View file

@ -341,6 +341,7 @@ async def run_automation_by_id(
await check_automations_permission(request, user)
automation = await Automations.get_by_id(id, db=db)
check_automation_access(automation, user)
automation = await Automations.update_last_run_at(automation.id, db=db)
asyncio.create_task(execute_automation(request.app, automation))
await publish_event(
request,

View file

@ -167,6 +167,7 @@
return null;
});
if (res) {
automation = res;
toast.success($i18n.t('Automation triggered'));
setTimeout(() => loadRuns(false), 2000);
}