#19998: macOS: harden cron editor updates and compatibility
app: macos
size: L
Cluster:
Cron Job Enhancements
## Summary
- harden macOS cron model decoding to preserve unknown/future enum values for `sessionTarget`, `wakeMode`, and `delivery.mode`
- make cron editor updates non-lossy by sending diff-only `cron.update` patches instead of full overwrites
- add compatibility fallback for `postRun`-only jobs so wake behavior still decodes safely
- extend editor UI to handle webhook delivery and preserve unknown/raw delivery modes
- add tests covering non-clobbering edit behavior and unknown/postRun decode compatibility
## Why
Current edit flow can unintentionally clobber fields introduced by other cron PRs (for example webhook/raw delivery, custom session targets, or postRun-based jobs). This change makes edit operations resilient and merge-friendly.
## Testing
- `swift test --filter Cron` (from `apps/macos`) was attempted
- blocked in this environment by upstream dependency macro plugin resolution in `swiftui-math` (`SwiftUIMacros` / `PreviewsMacros` not found)
- added targeted unit coverage in:
- `apps/macos/Tests/OpenClawIPCTests/CronJobEditorSmokeTests.swift`
- `apps/macos/Tests/OpenClawIPCTests/CronModelsTests.swift`
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR hardens macOS cron job editing to be non-lossy and forward-compatible. The three main changes are:
- **Enum hardening**: `CronSessionTarget`, `CronWakeMode`, and `CronDeliveryMode` are refactored from raw-value enums to manual `Codable` types with `.unknown(String)` catch-all cases, preserving unrecognized values during decode/re-encode round-trips.
- **Diff-only patches**: The editor now computes a JSON diff between the current job state and the edited state, sending only changed fields via `cron.update` instead of full overwrites. This prevents clobbering fields set by other cron PRs (e.g., webhook delivery, custom session targets).
- **Backward compatibility**: A `postRun` fallback in the `CronJob` decoder maps legacy `"trigger-heartbeat"` values to `.nextHeartbeat`, and the UI gracefully handles webhook, raw, and unknown delivery modes.
The implementation is well-structured with targeted test coverage. One concern: delivery settings are visible in the UI for non-isolated session targets (e.g., `current`) but silently excluded from the payload — this could confuse users who configure delivery for a `current`-target job.
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with minor UI/UX concern around delivery visibility for non-isolated session targets.
- The code changes are well-structured, the diff-only patching logic is correct, and backward-compatibility is properly handled. The enum hardening pattern is clean and idiomatic. The only concern is a UI/logic mismatch where delivery settings are editable but silently dropped for non-isolated targets. Tests cover the key scenarios but could not be run in CI due to dependency issues.
- `apps/macos/Sources/OpenClaw/CronJobEditor+Helpers.swift` — delivery gating logic in `shouldIncludeDeliveryInRoot()` may silently discard user-configured delivery for non-isolated session targets.
<sub>Last reviewed commit: 109f947</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#18743: Cron Tool Hardening: Normalize Gateway Params and Enforce Valid Sch...
by cccat6 · 2026-02-17
79.5%
#14391: feat(cron): add raw delivery mode for verbatim output
by therealZpoint-bot · 2026-02-12
78.7%
#19767: cron: validate webhook delivery targets on create
by advaitpaliwal · 2026-02-18
76.1%
#19191: fix(security): harden cron file permissions to 0o600
by Kropiunig · 2026-02-17
75.6%
#17606: feat(ui): add Edit button for cron jobs in Control UI [AI-assisted]
by jgstaal · 2026-02-16
75.0%
#20329: Fix cron.run WS blocking and harden delivery recovery
by guirguispierre · 2026-02-18
74.8%
#5498: Cron: honor next-heartbeat
by sebslight · 2026-01-31
74.7%
#12303: fix(cron): correct nextRunAtMs calculation and prevent timer stall
by colddonkey · 2026-02-09
74.5%
#23329: feat: Add Markdown support for cron job payload
by HeXavi8 · 2026-02-22
74.2%
#16511: feat(cron): support custom session IDs and auto-bind to current ses...
by kkhomej33-netizen · 2026-02-14
74.2%