Skip to content

Commit a34b8a8

Browse files
authored
fix(cron): preserve implicit delivery on partial edits (#101027)
1 parent 2897c3c commit a34b8a8

3 files changed

Lines changed: 33 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Docs: https://docs.openclaw.ai
2121

2222
### Fixes
2323

24+
- **Cron edit delivery:** preserve each job's implicit delivery mode when applying partial delivery updates, so disabling best-effort delivery no longer turns detached job announcements off. (#100846) Thanks @machine3at.
2425
- **Control UI session creation:** keep newly created sessions at the front of the stable sidebar order after selecting another session. Thanks @shakkernerd.
2526
- **FTS-only memory startup:** skip plugin capability discovery when `memorySearch.provider` is explicitly `none`, avoiding an unnecessary cold-start scan.
2627
- **Control UI agent model labels:** show each selected agent's effective model in the Default picker option instead of the global model. (#100719, #77690, #77440) Thanks @hyspacex.

‎src/cron/service/jobs.apply-patch.test.ts‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Cron job patch tests cover applying partial updates to scheduled jobs.
22
import { describe, expect, it } from "vitest";
3-
import { resolveFailureDestination } from "../delivery-plan.js";
3+
import { resolveCronDeliveryPlan, resolveFailureDestination } from "../delivery-plan.js";
44
import type { CronJob } from "../types.js";
55
import { applyJobPatch } from "./jobs.js";
66

@@ -78,6 +78,32 @@ describe("applyJobPatch delivery merge", () => {
7878
expect(job.delivery).toBeUndefined();
7979
});
8080

81+
it("preserves implicit detached delivery when patching best-effort", () => {
82+
const job = makeJob({ delivery: undefined });
83+
84+
applyJobPatch(job, {
85+
delivery: { bestEffort: false },
86+
});
87+
88+
expect(job.delivery).toEqual({ mode: "announce", bestEffort: false });
89+
expect(resolveCronDeliveryPlan(job).mode).toBe("announce");
90+
});
91+
92+
it("preserves implicit main-session delivery when patching best-effort", () => {
93+
const job = makeJob({
94+
sessionTarget: "main",
95+
payload: { kind: "systemEvent", text: "tick" },
96+
delivery: undefined,
97+
});
98+
99+
applyJobPatch(job, {
100+
delivery: { bestEffort: false },
101+
});
102+
103+
expect(job.delivery).toBeUndefined();
104+
expect(resolveCronDeliveryPlan(job).mode).toBe("none");
105+
});
106+
81107
it("clears nullable failure destination fields", () => {
82108
const job = makeJob({
83109
delivery: {

‎src/cron/service/jobs.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
normalizeOptionalThreadValue,
66
} from "@openclaw/normalization-core/string-coerce";
77
import { normalizeAgentId } from "../../routing/session-key.js";
8+
import { resolveCronDeliveryPlan } from "../delivery-plan.js";
89
import { parseAbsoluteTimeMs } from "../parse.js";
910
import {
1011
coerceFiniteScheduleNumber,
@@ -959,7 +960,8 @@ export function applyJobPatch(
959960
job.payload = mergeCronPayload(job.payload, patch.payload);
960961
}
961962
if (patch.delivery) {
962-
job.delivery = mergeCronDelivery(job.delivery, patch.delivery);
963+
const implicitMode = resolveCronDeliveryPlan(job).mode;
964+
job.delivery = mergeCronDelivery(job.delivery, patch.delivery, implicitMode);
963965
}
964966
if ("failureAlert" in patch) {
965967
job.failureAlert = mergeCronFailureAlert(job.failureAlert, patch.failureAlert);
@@ -1231,10 +1233,11 @@ function buildPayloadFromPatch(patch: CronPayloadPatch): CronPayload {
12311233
function mergeCronDelivery(
12321234
existing: CronDelivery | undefined,
12331235
patch: CronDeliveryPatch,
1236+
implicitMode: CronDelivery["mode"],
12341237
): CronDelivery | undefined {
12351238
const hasCompletionDestinationPatch = "completionDestination" in patch;
12361239
const next: CronDelivery = {
1237-
mode: existing?.mode ?? "none",
1240+
mode: existing?.mode ?? implicitMode,
12381241
channel: existing?.channel,
12391242
to: existing?.to,
12401243
threadId: existing?.threadId,
@@ -1338,7 +1341,6 @@ function mergeCronDelivery(
13381341
if (
13391342
existing === undefined &&
13401343
!("mode" in patch) &&
1341-
next.mode === "none" &&
13421344
next.channel === undefined &&
13431345
next.to === undefined &&
13441346
next.threadId === undefined &&

0 commit comments

Comments
 (0)