mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 23:28:27 +00:00
feat(cron): enhance delivery modes and job configuration
- Updated isolated cron jobs to support new delivery modes: `announce` and `none`, improving output management. - Refactored job configuration to remove legacy fields and streamline delivery settings. - Enhanced the `CronJobEditor` UI to reflect changes in delivery options, including a new segmented control for delivery mode selection. - Updated documentation to clarify the new delivery configurations and their implications for job execution. - Improved tests to validate the new delivery behavior and ensure backward compatibility with legacy settings. This update provides users with greater flexibility in managing how isolated jobs deliver their outputs, enhancing overall usability and clarity in job configurations.
This commit is contained in:
committed by
Peter Steinberger
parent
ab9f06f4ff
commit
3f82daefd8
@@ -75,7 +75,7 @@ describe("normalizeCronJobCreate", () => {
|
||||
expect(payload.channel).toBe("telegram");
|
||||
});
|
||||
|
||||
it("coerces ISO schedule.at to atMs (UTC)", () => {
|
||||
it("coerces ISO schedule.at to normalized ISO (UTC)", () => {
|
||||
const normalized = normalizeCronJobCreate({
|
||||
name: "iso at",
|
||||
enabled: true,
|
||||
@@ -90,10 +90,10 @@ describe("normalizeCronJobCreate", () => {
|
||||
|
||||
const schedule = normalized.schedule as Record<string, unknown>;
|
||||
expect(schedule.kind).toBe("at");
|
||||
expect(schedule.atMs).toBe(Date.parse("2026-01-12T18:00:00Z"));
|
||||
expect(schedule.at).toBe(new Date(Date.parse("2026-01-12T18:00:00Z")).toISOString());
|
||||
});
|
||||
|
||||
it("coerces ISO schedule.atMs string to atMs (UTC)", () => {
|
||||
it("coerces schedule.atMs string to schedule.at (UTC)", () => {
|
||||
const normalized = normalizeCronJobCreate({
|
||||
name: "iso atMs",
|
||||
enabled: true,
|
||||
@@ -108,7 +108,7 @@ describe("normalizeCronJobCreate", () => {
|
||||
|
||||
const schedule = normalized.schedule as Record<string, unknown>;
|
||||
expect(schedule.kind).toBe("at");
|
||||
expect(schedule.atMs).toBe(Date.parse("2026-01-12T18:00:00Z"));
|
||||
expect(schedule.at).toBe(new Date(Date.parse("2026-01-12T18:00:00Z")).toISOString());
|
||||
});
|
||||
|
||||
it("defaults deleteAfterRun for one-shot schedules", () => {
|
||||
@@ -166,7 +166,7 @@ describe("normalizeCronJobCreate", () => {
|
||||
expect(delivery.mode).toBe("announce");
|
||||
});
|
||||
|
||||
it("does not override explicit legacy delivery fields", () => {
|
||||
it("migrates legacy delivery fields to delivery", () => {
|
||||
const normalized = normalizeCronJobCreate({
|
||||
name: "legacy deliver",
|
||||
enabled: true,
|
||||
@@ -175,14 +175,38 @@ describe("normalizeCronJobCreate", () => {
|
||||
kind: "agentTurn",
|
||||
message: "hi",
|
||||
deliver: true,
|
||||
channel: "telegram",
|
||||
to: "7200373102",
|
||||
bestEffortDeliver: true,
|
||||
},
|
||||
}) as unknown as Record<string, unknown>;
|
||||
|
||||
const delivery = normalized.delivery as Record<string, unknown>;
|
||||
expect(delivery.mode).toBe("announce");
|
||||
expect(delivery.channel).toBe("telegram");
|
||||
expect(delivery.to).toBe("7200373102");
|
||||
expect(delivery.bestEffort).toBe(true);
|
||||
});
|
||||
|
||||
it("maps legacy deliver=false to delivery none", () => {
|
||||
const normalized = normalizeCronJobCreate({
|
||||
name: "legacy off",
|
||||
enabled: true,
|
||||
schedule: { kind: "cron", expr: "* * * * *" },
|
||||
payload: {
|
||||
kind: "agentTurn",
|
||||
message: "hi",
|
||||
deliver: false,
|
||||
channel: "telegram",
|
||||
to: "7200373102",
|
||||
},
|
||||
}) as unknown as Record<string, unknown>;
|
||||
|
||||
expect(normalized.delivery).toBeUndefined();
|
||||
const delivery = normalized.delivery as Record<string, unknown>;
|
||||
expect(delivery.mode).toBe("none");
|
||||
});
|
||||
|
||||
it("does not override legacy isolation settings", () => {
|
||||
it("migrates legacy isolation settings to announce delivery", () => {
|
||||
const normalized = normalizeCronJobCreate({
|
||||
name: "legacy isolation",
|
||||
enabled: true,
|
||||
@@ -194,6 +218,8 @@ describe("normalizeCronJobCreate", () => {
|
||||
isolation: { postToMainPrefix: "Cron" },
|
||||
}) as unknown as Record<string, unknown>;
|
||||
|
||||
expect(normalized.delivery).toBeUndefined();
|
||||
const delivery = normalized.delivery as Record<string, unknown>;
|
||||
expect(delivery.mode).toBe("announce");
|
||||
expect((normalized as { isolation?: unknown }).isolation).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user