Skip to content

fix(crons): wire JSONL run logs + fix startedAt/sessionFile fields (#605)#901

Draft
vivekchand wants to merge 1 commit intomainfrom
bot-fix/issue-605-cron-run-timeline-jsonl-fallback
Draft

fix(crons): wire JSONL run logs + fix startedAt/sessionFile fields (#605)#901
vivekchand wants to merge 1 commit intomainfrom
bot-fix/issue-605-cron-run-timeline-jsonl-fallback

Conversation

@vivekchand
Copy link
Copy Markdown
Owner

Summary

The cron expand panel was stuck on "Loading run history…" forever because the backend returned timestamp (epoch ms) and sessionId, but loadCronRuns() in app.js expects startedAt / ts (ISO-8601 string) and sessionFile — so every run was silently dropped by the date renderer. Additionally, the rich per-run JSONL files at ~/.openclaw/cron/runs/{jobId}.jsonl were never consulted; the fallback was deriving synthetic records from session transcripts instead.

Changes

  • dashboard.py — patch _cron_runs_from_transcripts() to emit startedAt, ts, and sessionFile alongside the existing timestamp/sessionId so the 30-day calendar heatmap and run table render correctly.
  • dashboard.py — add _cron_runs_from_jsonl(job_id): reads the dedicated on-disk run logs at ~/.openclaw/cron/runs/{jobId}.jsonl (path-traversal-safe via os.path.basename, graceful on missing file), sorts newest-first, returns up to 50 records with the real status, error, durationMs, costUsd, and deliveryStatus fields from the agent.
  • routes/crons.py — update api_cron_runs() fallback chain to three tiers: gateway RPC → JSONL file → transcript analytics.

Test plan

  • python3 -c 'import ast; ast.parse(open("dashboard.py").read())' — no syntax errors
  • python3 -c 'import ast; ast.parse(open("routes/crons.py").read())' — no syntax errors
  • Expand any cron job in the Crons tab → 30-day calendar heatmap + run table should appear instead of "No run history yet"
  • With a live ~/.openclaw/cron/runs/{jobId}.jsonl file, verify the panel shows actual run data
  • With gateway offline and no JSONL file, verify transcript-derived fallback still populates (with correct fields)

Bot meta

Draft PR opened autonomously based on the plan in #605. Marked draft for human review — mark Ready for Review once happy.

Closes #605


Generated by Claude Code

)

The cron expand panel was stuck on "Loading run history…" because
_cron_runs_from_transcripts() returned `timestamp` (epoch ms) and
`sessionId`, but loadCronRuns() in app.js expects `startedAt` / `ts`
(ISO-8601) and `sessionFile` ({sessionId}.jsonl).

- Patch _cron_runs_from_transcripts() to emit all four field aliases so
  the 30-day calendar heatmap and run table can render them.
- Add _cron_runs_from_jsonl(job_id): reads the dedicated JSONL run logs
  at ~/.openclaw/cron/runs/{jobId}.jsonl (path-traversal-safe, graceful
  on missing file), sorts newest-first, returns up to 50 records.
- Update api_cron_runs() fallback chain: gateway RPC → JSONL file →
  transcript analytics.

Closes #605

Co-Authored-By: ClawMetry Autofix Bot <bot-autofix@clawmetry.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1] Cron run timeline with per-run usage + failure sparkline

1 participant