Skip to content

feat: add repo schedules for recurring agent jobs#156

Open
itz4blitz wants to merge 9 commits intochriswritescode-dev:mainfrom
itz4blitz:feat/scheduler-agent-dashboard
Open

feat: add repo schedules for recurring agent jobs#156
itz4blitz wants to merge 9 commits intochriswritescode-dev:mainfrom
itz4blitz:feat/scheduler-agent-dashboard

Conversation

@itz4blitz
Copy link
Contributor

@itz4blitz itz4blitz commented Mar 9, 2026

Summary

  • add repo-scoped schedules so each repo can run recurring background agent jobs with interval and cron timing, timezone support, reusable prompt templates, and fully editable prompts
  • add a review-first schedules dashboard with linked sessions, logs, markdown preview/raw output, cancellation, and recovery for interrupted runs
  • document the workflow with README/docs updates and screenshots covering the repo entry point, dashboard shell, run history, and editor flow

Why

OpenCode Manager already centralizes repositories, sessions, and agent workflows. This adds the missing proactive layer: recurring repo jobs that can run in the background and be waiting for review the next time you open the app.

That makes workflows like morning repo briefs, dependency watchlists, release-readiness checks, and recurring code-health reviews feel native to the existing product instead of bolted on as a separate automation tool.

Walkthrough

1. Schedules lives in the normal repo workflow

The entry point sits alongside the existing repo actions, and scheduled runs show up in the same session stream as everything else.

Repo detail schedules entry

2. Schedules page is a review shell first

The page is built around a fixed dashboard shell with the jobs list, current job summary, and run history visible without making the whole page scroll.

Schedules dashboard shell

3. Run history supports both readable output and raw markdown

Completed runs keep a linked session, status, logs, rendered markdown output, and the original markdown when you want the exact generated text.

Run history markdown preview

Run history raw markdown

4. Job details stay available without dominating the page

The selected job can expand when you need prompt/settings context, but defaults to a collapsed state so run history stays front and center.

Expanded job details

5. The editor walks through setup in focused tabs

The composer is GUI-first and keeps the core flow on the tabs that matter for everyday use.

General

Schedule editor general tab

Timing

Schedule editor timing tab

Prompt

Templates can seed the job, but the prompt body stays fully editable so teams can fine-tune the generated prompt or replace it with a fully custom one.

Schedule editor prompt tab

What is included

  • repo-level Schedules entry point from the repo detail page
  • schedule CRUD, manual runs, and recurring scheduled runs
  • interval and cron support with timezone handling
  • built-in prompt templates plus fully editable custom prompts
  • run history with linked sessions, logs, errors/details, markdown preview, and raw markdown
  • run cancellation for in-progress jobs
  • recovery for orphaned running jobs after backend restarts
  • immediate background execution so Run now returns quickly instead of waiting on the full assistant response
  • model resolution fallback when a stored model override is no longer available
  • safer handling for OpenCode prompt endpoints that return 200 OK with an empty body before the session finishes
  • docs updates for schedules in the README and docs site

Validation

  • pnpm lint
  • pnpm build in a clean worktree from this branch
  • pnpm --filter backend exec vitest run --coverage (457 tests passing)
  • feature-focused backend coverage now includes:
    • backend/src/db/schedules.ts: 78.44%
    • backend/src/services/schedule-config.ts: 85.08%
    • backend/src/services/opencode-models.ts: 82.88%
    • backend/src/services/schedules.ts: 79.39%
    • backend/src/routes/schedules.ts: 82.92%
    • backend/src/routes/title.ts: 85.81%
  • manual verification in the app, including:
    • repo entry-point flow
    • schedule creation/editing UI
    • manual run start
    • run cancellation
    • orphaned run recovery
    • markdown preview and raw markdown rendering

Type of Change

  • New feature
  • Documentation
  • Bug fix

Checklist

  • Code follows project style (no comments, named imports)
  • TypeScript types are properly defined
  • Tests added/updated
  • pnpm lint passes locally
  • pnpm build passes in a clean worktree from this branch

@itz4blitz itz4blitz marked this pull request as ready for review March 9, 2026 01:22
Copilot AI review requested due to automatic review settings March 9, 2026 01:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds repo-scoped schedules for recurring agent jobs, including shared Zod types/schemas, backend scheduling + run persistence, and a new frontend “Schedules” dashboard + docs to expose and manage the feature.

Changes:

  • Introduces shared schedule schemas/types (jobs, runs, requests) and wires new schedules API routes under repos.
  • Implements backend schedule execution (OpenCode session creation, prompt submission, run monitoring/recovery) plus SQLite persistence + migrations.
  • Adds a new frontend Schedules page with CRUD, manual runs, cancellation, and run history viewing, plus documentation updates.

Reviewed changes

Copilot reviewed 33 out of 42 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
shared/src/types/index.ts Re-exports schedule-related shared types.
shared/src/schemas/schedule.ts Adds Zod schemas/types for schedule jobs, runs, and create/update requests.
shared/src/schemas/index.ts Exposes schedule schemas via shared schema barrel.
pnpm-lock.yaml Locks new deps (cron-parser, cronstrue) and updates Bun type packages.
mkdocs.yml Adds schedules page to docs nav.
frontend/src/pages/Schedules.tsx New schedules dashboard page + editor dialog + rendering for run history output.
frontend/src/pages/RepoDetail.tsx Adds “Schedules” entry point button/menu item from repo detail.
frontend/src/hooks/useSchedules.ts Adds React Query hooks for schedules CRUD/runs/cancellation.
frontend/src/api/schedules.ts Adds frontend API client for schedule endpoints.
frontend/src/App.tsx Registers /repos/:id/schedules route.
frontend/package.json Adds cronstrue dependency.
docs/index.md Mentions schedules feature and links to docs page.
docs/features/schedules.md New documentation page describing schedules, timing, templates, and run history.
docs/features/overview.md Adds schedules to feature overview.
backend/test/services/schedule-config.test.ts Tests schedule persistence normalization and next-run computation logic.
backend/test/services/opencode-models.test.ts Tests model resolution fallback logic.
backend/src/services/schedules.ts Implements schedule service (CRUD + execution + recovery) and schedule runner loop.
backend/src/services/schedule-config.ts Implements cron/interval normalization and next-run computation using cron-parser.
backend/src/services/opencode-models.ts Adds model resolution helper with fallback behavior.
backend/src/routes/title.ts Switches title generation to use resolveOpenCodeModel + adds polling fallback for assistant response.
backend/src/routes/schedules.ts Adds repo-scoped schedules API routes.
backend/src/routes/repos.ts Mounts schedules routes under /:id/schedules.
backend/src/index.ts Starts the schedule runner at backend startup.
backend/src/db/schedules.ts Adds SQLite query layer for schedule jobs and runs.
backend/src/db/migrations/index.ts Registers new migrations 007/008.
backend/src/db/migrations/007-schedules.ts Creates schedule jobs/runs tables and indexes.
backend/src/db/migrations/008-schedule-cron-support.ts Adds cron-related columns to schedule jobs table.
backend/package.json Adds cron-parser dependency.
README.md Mentions schedules feature in top-level feature list.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

You can also share your feedback on Copilot code review. Take the survey.

Keep cron schedules migratable, trim run polling payloads, and expose the health endpoint so Docker preview and PR feedback match the intended behavior.
@chriswritescode-dev
Copy link
Owner

interested in these. Just have not had time to review

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.

3 participants