feat: enrich GET /api/tasks with recent_runs and upcoming from Trigger.dev

Merged
SW
8mo ago
+277-146

Summary

GET /api/tasks now returns recent_runs and upcoming for each task, sourced directly from the Trigger.dev API:

  • recent_runs — Last 5 runs from runs.list({ filter: { schedule } })
  • upcoming — Next scheduled times from the latest run's payload

New files:

  • lib/trigger/listScheduleRuns.ts — Fetches runs by schedule ID
  • lib/tasks/enrichTaskWithTriggerInfo.ts — Enriches tasks with Trigger.dev data

Matches docs: https://developers.recoupable.com/api-reference/tasks/list

Test plan

  • GET /api/tasks?id=<uuid> returns recent_runs array and upcoming array
  • Tasks without trigger_schedule_id return empty arrays
  • Trigger.dev API failures gracefully return empty arrays

šŸ¤– Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Tasks now show recent run history (IDs, status, timestamps, durations) and upcoming schedule info from the external scheduling API.
  • Reliability Improvements
    • If schedule data or run details cannot be retrieved, tasks still load normally and show empty recent/upcoming lists instead of failing.