mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 11:17:27 +00:00
feat(cron): set default enabled state for cron jobs
- Added logic to default the `enabled` property to `true` if not explicitly set as a boolean in the cron job input. - Updated job creation and store functions to ensure consistent handling of the `enabled` state across the application. - Enhanced input normalization to improve job configuration reliability. This update ensures that cron jobs are enabled by default, enhancing user experience and reducing potential misconfigurations.
This commit is contained in:
committed by
Peter Steinberger
parent
3f82daefd8
commit
1409943863
@@ -206,6 +206,9 @@ export function normalizeCronJobInput(
|
||||
if (!next.wakeMode) {
|
||||
next.wakeMode = "next-heartbeat";
|
||||
}
|
||||
if (typeof next.enabled !== "boolean") {
|
||||
next.enabled = true;
|
||||
}
|
||||
if (!next.sessionTarget && isRecord(next.payload)) {
|
||||
const kind = typeof next.payload.kind === "string" ? next.payload.kind : "";
|
||||
if (kind === "systemEvent") {
|
||||
|
||||
@@ -105,12 +105,13 @@ export function createJob(state: CronServiceState, input: CronJobCreate): CronJo
|
||||
: input.schedule.kind === "at"
|
||||
? true
|
||||
: undefined;
|
||||
const enabled = typeof input.enabled === "boolean" ? input.enabled : true;
|
||||
const job: CronJob = {
|
||||
id,
|
||||
agentId: normalizeOptionalAgentId(input.agentId),
|
||||
name: normalizeRequiredName(input.name),
|
||||
description: normalizeOptionalText(input.description),
|
||||
enabled: input.enabled,
|
||||
enabled,
|
||||
deleteAfterRun,
|
||||
createdAtMs: now,
|
||||
updatedAtMs: now,
|
||||
|
||||
@@ -101,6 +101,11 @@ export async function ensureLoaded(state: CronServiceState) {
|
||||
mutated = true;
|
||||
}
|
||||
|
||||
if (typeof raw.enabled !== "boolean") {
|
||||
raw.enabled = true;
|
||||
mutated = true;
|
||||
}
|
||||
|
||||
const payload = raw.payload;
|
||||
if (payload && typeof payload === "object" && !Array.isArray(payload)) {
|
||||
if (migrateLegacyCronPayload(payload as Record<string, unknown>)) {
|
||||
|
||||
Reference in New Issue
Block a user