fix(cron): treat missing enabled as true in update() (openclaw#15477) thanks @eternauta1337

Verified:
- pnpm exec vitest src/cron/service.issue-regressions.test.ts

Co-authored-by: eternauta1337 <550409+eternauta1337@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
Alejandro Santander
2026-02-15 11:52:02 -03:00
committed by GitHub
parent a7b6555195
commit 9a344da298
5 changed files with 125 additions and 14 deletions

View File

@@ -84,7 +84,7 @@ export async function list(state: CronServiceState, opts?: { includeDisabled?: b
}
}
const includeDisabled = opts?.includeDisabled === true;
const jobs = (state.store?.jobs ?? []).filter((j) => includeDisabled || j.enabled);
const jobs = (state.store?.jobs ?? []).filter((j) => includeDisabled || j.enabled !== false);
return jobs.toSorted((a, b) => (a.state.nextRunAtMs ?? 0) - (b.state.nextRunAtMs ?? 0));
});
}
@@ -151,7 +151,7 @@ export async function update(state: CronServiceState, id: string, patch: CronJob
job.updatedAtMs = now;
if (scheduleChanged || enabledChanged) {
if (job.enabled) {
if (job.enabled !== false) {
job.state.nextRunAtMs = computeJobNextRunAtMs(job, now);
} else {
job.state.nextRunAtMs = undefined;