feat(cron): add computed status field to --json output#78701
feat(cron): add computed status field to --json output#78701vincentkoc merged 3 commits intoopenclaw:mainfrom
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. Source inspection on current main shows Real behavior proof Next step before merge Security Review detailsBest possible solution: Land the additive CLI JSON enrichment after maintainer review, keeping raw state unchanged and adding focused coverage only if maintainers want stronger regression protection. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection on current main shows Is this the best way to solve the issue? Yes. Enriching only the CLI JSON output boundary is a narrow additive solution that preserves the existing raw What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against b680360fde68. |
|
Addressed the review feedback:
@clawsweeper re-review |
`openclaw cron list --json` and `openclaw cron show <id> --json` now include a top-level `status` field on each job object, computed from enabled + state.runningAtMs + state.lastRunStatus. Values: "disabled" | "running" | "ok" | "error" | "skipped" | "idle" This matches the human-readable status column already shown by `cron list` and `cron show` (without --json), making it easier for external tooling (dashboards, ops gateways) to determine job state without re-implementing the derivation logic. The raw state object is preserved unchanged for backward compatibility.
Address ClawSweeper review findings: - P2: Fall back to deprecated state.lastStatus when lastRunStatus is absent, matching the existing formatStatus behavior for legacy jobs. - P3: Add CHANGELOG.md entry under Unreleased for this user-facing CLI feature.
3e6a6eb to
86c6907
Compare
* feat(cron): add computed status field to --json output `openclaw cron list --json` and `openclaw cron show <id> --json` now include a top-level `status` field on each job object, computed from enabled + state.runningAtMs + state.lastRunStatus. Values: "disabled" | "running" | "ok" | "error" | "skipped" | "idle" This matches the human-readable status column already shown by `cron list` and `cron show` (without --json), making it easier for external tooling (dashboards, ops gateways) to determine job state without re-implementing the derivation logic. The raw state object is preserved unchanged for backward compatibility. * fix: preserve lastStatus fallback + add changelog entry Address ClawSweeper review findings: - P2: Fall back to deprecated state.lastStatus when lastRunStatus is absent, matching the existing formatStatus behavior for legacy jobs. - P3: Add CHANGELOG.md entry under Unreleased for this user-facing CLI feature. * fix: address lint errors - add braces and avoid spread-in-map --------- Co-authored-by: Rodin <rodin@forgedthought.ai> Co-authored-by: claw <claw@weiker.me>
* feat(cron): add computed status field to --json output `openclaw cron list --json` and `openclaw cron show <id> --json` now include a top-level `status` field on each job object, computed from enabled + state.runningAtMs + state.lastRunStatus. Values: "disabled" | "running" | "ok" | "error" | "skipped" | "idle" This matches the human-readable status column already shown by `cron list` and `cron show` (without --json), making it easier for external tooling (dashboards, ops gateways) to determine job state without re-implementing the derivation logic. The raw state object is preserved unchanged for backward compatibility. * fix: preserve lastStatus fallback + add changelog entry Address ClawSweeper review findings: - P2: Fall back to deprecated state.lastStatus when lastRunStatus is absent, matching the existing formatStatus behavior for legacy jobs. - P3: Add CHANGELOG.md entry under Unreleased for this user-facing CLI feature. * fix: address lint errors - add braces and avoid spread-in-map --------- Co-authored-by: Rodin <rodin@forgedthought.ai> Co-authored-by: claw <claw@weiker.me>
* feat(cron): add computed status field to --json output `openclaw cron list --json` and `openclaw cron show <id> --json` now include a top-level `status` field on each job object, computed from enabled + state.runningAtMs + state.lastRunStatus. Values: "disabled" | "running" | "ok" | "error" | "skipped" | "idle" This matches the human-readable status column already shown by `cron list` and `cron show` (without --json), making it easier for external tooling (dashboards, ops gateways) to determine job state without re-implementing the derivation logic. The raw state object is preserved unchanged for backward compatibility. * fix: preserve lastStatus fallback + add changelog entry Address ClawSweeper review findings: - P2: Fall back to deprecated state.lastStatus when lastRunStatus is absent, matching the existing formatStatus behavior for legacy jobs. - P3: Add CHANGELOG.md entry under Unreleased for this user-facing CLI feature. * fix: address lint errors - add braces and avoid spread-in-map --------- Co-authored-by: Rodin <rodin@forgedthought.ai> Co-authored-by: claw <claw@weiker.me>
Summary
openclaw cron list --jsonandopenclaw cron show <id> --jsonnow include a top-levelstatusfield on each job object.Problem
The human-readable
cron listoutput shows a computed "Status" column (disabled/running/ok/error/idle), but--jsonoutput only includes the rawstateobject. External tooling (dashboards, ops gateways, scripts) must re-implement the status derivation logic:Solution
Added
enrichCronJsonWithStatus()inshared.tsthat injects a computedstatusfield into the JSON output for bothcron list --jsonandcron show <id> --json.Values:
"disabled"|"running"|"ok"|"error"|"skipped"|"idle"The status derivation preserves the deprecated
lastStatusfallback for legacy jobs that may not havelastRunStatusset, matching the existingformatStatusbehavior.The raw
stateobject is preserved unchanged for backward compatibility.Changes
src/cli/cron-cli/shared.ts— newenrichCronJsonWithStatus()andcomputeStatus()helperssrc/cli/cron-cli/register.cron-add.ts— wrapcron list --jsonoutputsrc/cli/cron-cli/register.cron-simple.ts— wrapcron show --jsonoutputCHANGELOG.md— added entry under UnreleasedReal Behavior Proof
cron list --jsonandcron show <id> --jsonwere missing the computedstatusfield that the human-readable table output shows. External tools had to re-implement status derivation logic.17863c53on branchfeat/cron-json-status, built and run withnode openclaw.mjsagainst a live gateway with active cron jobs.Terminal output from
node openclaw.mjs cron list --json:[ { "name": "watch-openclaw-pr-78701", "status": "running" }, { "name": "slack-ask-rodin", "status": "ok" }, { "name": "gargoyle-dev-loop", "status": "ok" } ]Terminal output from
node openclaw.mjs cron show watch-openclaw-pr-78701 --json:{ "name": "watch-openclaw-pr-78701", "status": "running" }statusfield is present on all job objects in both list and show JSON outputs. Values match the human-readable Status column:"running"for active jobs (derived fromstate.runningAtMs),"ok"for completed jobs,"disabled"for disabled jobs.lastStatusfield and nolastRunStatus. The fallback path is covered by code inspection but no legacy job was available in the test environment.