feat: surface cron windows in webapp, cli, sdk - #4572
Conversation
🦋 Changeset detectedLatest commit: 6bd63af The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (17)
WalkthroughThe change adds optional duration or percentage windows to declarative schedules. Scheduling utilities calculate nominal CRON times and effective assigned times. Presenters and APIs return both timestamps and window metadata. Dashboard views and forms display and edit windows. Deployment responses and CLI output include declarative schedule details. Tests cover SDK serialization, timing calculations, API lifecycle behavior, and deployment formatting. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (1)
.server-changes/schedule-windows.md (1)
6-6: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDescribe the user-visible capability.
Replace “server support” with what users can configure and see. This file is published as dashboard-facing release notes.
Proposed text
- Add server support for stable execution windows on scheduled tasks while preserving each occurrence's nominal timestamp. + Configure stable execution windows for scheduled tasks while preserving each occurrence's nominal CRON time.Based on learnings,
.server-changesentries are published verbatim as dashboard-facing release notes and must state user-visible behavior.Source: Learnings
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 85def57d-c643-48eb-9cca-1e2488cf029d
📒 Files selected for processing (53)
.changeset/smooth-schedule-windows.md.server-changes/schedule-windows.mdapps/webapp/app/components/schedules/ScheduleInspector.tsxapps/webapp/app/env.server.tsapps/webapp/app/presenters/v3/EditSchedulePresenter.server.tsapps/webapp/app/presenters/v3/ScheduleListPresenter.server.tsapps/webapp/app/presenters/v3/ViewSchedulePresenter.server.tsapps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.tasks.scheduled.$taskParam/route.tsxapps/webapp/app/routes/api.v1.deployments.$deploymentId.tsapps/webapp/app/routes/api.v1.schedules.$scheduleId.activate.tsapps/webapp/app/routes/api.v1.schedules.$scheduleId.deactivate.tsapps/webapp/app/routes/api.v1.schedules.$scheduleId.tsapps/webapp/app/routes/api.v1.schedules.tsapps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.schedules.new/route.tsxapps/webapp/app/services/runsReplicationService.server.tsapps/webapp/app/v3/scheduleEngine.server.tsapps/webapp/app/v3/scheduleWindow.server.tsapps/webapp/app/v3/schedules.tsapps/webapp/app/v3/services/checkSchedule.server.tsapps/webapp/app/v3/services/createBackgroundWorker.server.tsapps/webapp/app/v3/services/upsertTaskSchedule.server.tsapps/webapp/test/engine/triggerTask.test.tsapps/webapp/test/runsReplicationService.part1.test.tsapps/webapp/test/scheduleWindow.test.tsapps/webapp/test/schedules-api.e2e.full.test.tsinternal-packages/clickhouse/schema/037_add_queue_timestamp_to_task_runs_v2.sqlinternal-packages/clickhouse/src/taskRuns.test.tsinternal-packages/clickhouse/src/taskRuns.tsinternal-packages/database/prisma/migrations/20260810130446_add_cron_spread_fields/migration.sqlinternal-packages/database/prisma/schema.prismainternal-packages/run-engine/src/engine/systems/dequeueSystem.tsinternal-packages/run-engine/src/run-queue/index.tsinternal-packages/run-engine/src/run-queue/tests/enqueueMessage.test.tsinternal-packages/schedule-engine/src/engine/distributedScheduling.tsinternal-packages/schedule-engine/src/engine/index.tsinternal-packages/schedule-engine/src/engine/scheduleCalculation.test.tsinternal-packages/schedule-engine/src/engine/scheduleCalculation.tsinternal-packages/schedule-engine/src/engine/scheduleTiming.test.tsinternal-packages/schedule-engine/src/engine/scheduleTiming.tsinternal-packages/schedule-engine/src/engine/types.tsinternal-packages/schedule-engine/src/engine/workerCatalog.test.tsinternal-packages/schedule-engine/src/engine/workerCatalog.tsinternal-packages/schedule-engine/src/index.tsinternal-packages/schedule-engine/test/scheduleEngine.test.tsinternal-packages/schedule-engine/test/scheduleEngine2.test.tsinternal-packages/schedule-engine/test/scheduleRecovery.test.tspackages/cli-v3/src/commands/deploy.tspackages/cli-v3/src/deploy/schedules.test.tspackages/cli-v3/src/deploy/schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.tspackages/trigger-sdk/src/v3/schedules/index.test.tspackages/trigger-sdk/src/v3/schedules/index.ts
2ba481a to
eb8c3af
Compare
Observability mapAs of Nothing in this pull request moves the report any more. The findings an earlier push reported are gone. The score and findings here are report-only and never gate the merge. Separately, a required test suite keeps this tool's symbol and route lists in sync with the code they name, and can fail a pull request that renames or removes a symbol they reference, or that adds the first route with a segment they anticipate. Each failure names the list to edit. The rules and their reasons: internal-packages/observability-map/README.md. |
@trigger.dev/build
trigger.dev
@trigger.dev/core
@trigger.dev/python
@trigger.dev/react-hooks
@trigger.dev/redis-worker
@trigger.dev/rsc
@trigger.dev/schema-to-json
@trigger.dev/sdk
commit: |
eb8c3af to
9ecb63f
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 7bd283bc-dfe4-4c95-ada0-cceb0e97f5a9
📒 Files selected for processing (23)
.changeset/smooth-schedule-windows.mdapps/webapp/app/components/schedules/ScheduleInspector.tsxapps/webapp/app/presenters/v3/EditSchedulePresenter.server.tsapps/webapp/app/presenters/v3/ScheduleListPresenter.server.tsapps/webapp/app/presenters/v3/ViewSchedulePresenter.server.tsapps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.tasks.scheduled.$taskParam/route.tsxapps/webapp/app/routes/api.v1.deployments.$deploymentId.tsapps/webapp/app/routes/api.v1.schedules.$scheduleId.tsapps/webapp/app/routes/api.v1.schedules.tsapps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.schedules.new/route.tsxapps/webapp/app/v3/scheduleWindow.server.tsapps/webapp/app/v3/schedules.tsapps/webapp/app/v3/services/checkSchedule.server.tsapps/webapp/app/v3/services/upsertTaskSchedule.server.tsapps/webapp/test/scheduleWindow.test.tsapps/webapp/test/schedules-api.e2e.full.test.tspackages/cli-v3/src/commands/deploy.tspackages/cli-v3/src/deploy/schedules.test.tspackages/cli-v3/src/deploy/schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.tspackages/trigger-sdk/src/v3/schedules/index.test.tspackages/trigger-sdk/src/v3/schedules/index.ts
🚧 Files skipped from review as they are similar to previous changes (20)
- packages/cli-v3/src/deploy/schedules.test.ts
- apps/webapp/app/presenters/v3/EditSchedulePresenter.server.ts
- apps/webapp/app/routes/api.v1.deployments.$deploymentId.ts
- apps/webapp/app/v3/schedules.ts
- packages/cli-v3/src/commands/deploy.ts
- packages/trigger-sdk/src/v3/schedules/index.test.ts
- packages/trigger-sdk/src/v3/schedules/index.ts
- apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.schedules.new/route.tsx
- apps/webapp/test/scheduleWindow.test.ts
- apps/webapp/app/components/schedules/ScheduleInspector.tsx
- packages/cli-v3/src/deploy/schedules.ts
- apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.tasks.scheduled.$taskParam/route.tsx
- apps/webapp/app/v3/services/checkSchedule.server.ts
- apps/webapp/app/v3/services/upsertTaskSchedule.server.ts
- apps/webapp/app/presenters/v3/ViewSchedulePresenter.server.ts
- .changeset/smooth-schedule-windows.md
- apps/webapp/app/v3/scheduleWindow.server.ts
- apps/webapp/test/schedules-api.e2e.full.test.ts
- apps/webapp/app/routes/api.v1.schedules.$scheduleId.ts
- apps/webapp/app/presenters/v3/ScheduleListPresenter.server.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (36)
- GitHub Check: report
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 12)
- GitHub Check: sdk-compat / Node.js 24.18 (warp-ubuntu-latest-x64-4x)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 12)
- GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
- GitHub Check: sdk-compat / Node.js 20.20 (warp-ubuntu-latest-x64-4x)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 12)
- GitHub Check: sdk-compat / Node.js 22.23 (warp-ubuntu-latest-x64-4x)
- GitHub Check: sdk-compat / Cloudflare Workers
- GitHub Check: sdk-compat / Node.js 26.4 (warp-ubuntu-latest-x64-4x)
- GitHub Check: e2e / 🧪 CLI v3 tests (warp-windows-latest-x64-8x - npm)
- GitHub Check: packages / 🧪 Unit Tests: Packages (2, 3)
- GitHub Check: typecheck / typecheck
- GitHub Check: sdk-compat / Deno Runtime
- GitHub Check: e2e / 🧪 CLI v3 tests (warp-ubuntu-latest-x64-4x - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (warp-windows-latest-x64-8x - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (warp-ubuntu-latest-x64-4x - npm)
- GitHub Check: obsmap / 🧪 Unit Tests: Observability Map
- GitHub Check: sdk-compat / Bun Runtime
- GitHub Check: runops-guard / runops-guard
- GitHub Check: internal / 🧪 Unit Tests: Internal
- GitHub Check: packages / 🧪 Unit Tests: Packages (1, 3)
- GitHub Check: packages / 🧪 Unit Tests: Packages (3, 3)
- GitHub Check: code-quality / code-quality
- GitHub Check: 🛡️ E2E Auth Tests (full)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Build and publish previews
🧰 Additional context used
📓 Path-based instructions (12)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Use types over interfaces for TypeScript
Avoid using enums; prefer string unions or const objects instead
**/*.{ts,tsx}: Prefer static imports over dynamicimport(); use dynamic imports only for unresolvable circular dependencies, genuine performance code splitting, or conditional runtime loading.
Import Trigger.dev tasks from@trigger.dev/sdk; never use@trigger.dev/sdk/v3or deprecatedclient.defineJob.
Add agentcrumbs while writing code using approved namespaces; mark lines with//@Crumbsor blocks with `// `#region` `@crumbs, and strip them before merging.
Files:
apps/webapp/app/routes/api.v1.schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
{packages/core,apps/webapp}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use zod for validation in packages/core and apps/webapp
Files:
apps/webapp/app/routes/api.v1.schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use function declarations instead of default exports
Files:
apps/webapp/app/routes/api.v1.schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)
**/*.ts: When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs
Do not use high-cardinality attributes in OTEL metrics such as UUIDs/IDs (envId, userId, runId, projectId, organizationId), unbounded integers (itemCount, batchSize, retryCount), timestamps (createdAt, startTime), or free-form strings (errorMessage, taskName, queueName)
When exporting OTEL metrics via OTLP to Prometheus, be aware that the exporter automatically adds unit suffixes to metric names (e.g., 'my_duration_ms' becomes 'my_duration_ms_milliseconds', 'my_counter' becomes 'my_counter_total'). Account for these transformations when writing Grafana dashboards or Prometheus queries
Files:
apps/webapp/app/routes/api.v1.schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
apps/webapp/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)
apps/webapp/**/*.{ts,tsx}: Access environment variables through theenvexport ofenv.server.tsinstead of directly accessingprocess.env
Use subpath exports from@trigger.dev/corepackage instead of importing from the root@trigger.dev/corepathDo not reintroduce the removed v1 execution path;
RunEngineVersion.V1branches may only reject or finalize gracefully so v3 clients receive a clean 4xx, never a 5xx.
Files:
apps/webapp/app/routes/api.v1.schedules.ts
apps/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
For apps, use
typecheckfor verification and never usebuildas the correctness check.
Files:
apps/webapp/app/routes/api.v1.schedules.ts
apps/webapp/app/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/webapp/CLAUDE.md)
apps/webapp/app/**/*.{ts,tsx}: For dashboard changes, visually verify the running Remix app with Chrome DevTools MCP, using snapshots, screenshots, interaction, and console-message checks as appropriate.
UseuseCallbackanduseMemoonly for context provider values, expensive derived data used as a dependency, or stable references required by dependency arrays; do not wrap ordinary event handlers or trivial computations.
Use named constants for sentinel or placeholder values instead of scattering raw string literals across comparisons.
Files:
apps/webapp/app/routes/api.v1.schedules.ts
apps/webapp/app/routes/**/*.ts
📄 CodeRabbit inference engine (apps/webapp/CLAUDE.md)
apps/webapp/app/routes/**/*.ts: Use Remix flat-file route conventions with dot-separated segments; for example,api.v1.tasks.$taskId.trigger.tsmaps to/api/v1/tasks/:taskId/trigger.
PAT-authenticated API routes must resolve their target organization or project within the caller's membership scope, using a membership filter or a helper such asfindProjectByReforresolveOrganizationForApiUser; RBAC authorization alone is insufficient.
Files:
apps/webapp/app/routes/api.v1.schedules.ts
apps/webapp/app/**/*.ts
📄 CodeRabbit inference engine (apps/webapp/CLAUDE.md)
apps/webapp/app/**/*.ts: Never userequest.signalto detect client disconnects. UsegetRequestAbortSignal()fromapp/services/httpAsyncStorage.server.ts, which is wired to Express response close events.
Access environment variables through theenvexport fromapp/env.server.ts; never useprocess.envdirectly.
Always use PrismafindFirstinstead offindUnique.
Always use the$transactionhelper from~/db.server, never callprisma.$transactionor$replica.$transactiondirectly. Pass isolation levels as strings, useSerializablefor correctness-critical read-then-write invariants, and guard possibly undefined helper results when a definite value is required.
Files:
apps/webapp/app/routes/api.v1.schedules.ts
packages/core/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (packages/core/CLAUDE.md)
Never import the root package (
@trigger.dev/core). Always use subpath imports such as@trigger.dev/core/v3,@trigger.dev/core/v3/utils,@trigger.dev/core/logger, or@trigger.dev/core/schemas
Files:
packages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
For public packages, use
buildfor verification.
Files:
packages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
packages/core/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Import
@trigger.dev/coresubpaths only; never import from the package root.
Files:
packages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
🧠 Learnings (27)
📓 Common learnings
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 4577
File: apps/webapp/app/v3/services/createBackgroundWorker.server.ts:779-781
Timestamp: 2026-08-12T06:32:24.127Z
Learning: In `apps/webapp/app/v3/services/createBackgroundWorker.server.ts`, `syncDeclarativeSchedules` has a pre-existing non-serialized read/modify/delete reconciliation flow. Changes that reuse its initial schedule snapshot instead of a redundant re-fetch do not introduce this concurrency risk. Track reconciliation serialization separately from read-side performance changes unless a change modifies the synchronization boundary.
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2026-03-25T15:29:25.889Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `schedules.task()` for scheduled (cron) tasks with either declarative cron patterns or imperative schedule creation
📚 Learning: 2026-03-25T15:29:25.889Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2026-03-25T15:29:25.889Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `schedules.task()` for scheduled (cron) tasks with either declarative cron patterns or imperative schedule creation
Applied to files:
apps/webapp/app/routes/api.v1.schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-08-12T06:32:24.127Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 4577
File: apps/webapp/app/v3/services/createBackgroundWorker.server.ts:779-781
Timestamp: 2026-08-12T06:32:24.127Z
Learning: In `apps/webapp/app/v3/services/createBackgroundWorker.server.ts`, `syncDeclarativeSchedules` has a pre-existing non-serialized read/modify/delete reconciliation flow. Changes that reuse its initial schedule snapshot instead of a redundant re-fetch do not introduce this concurrency risk. Track reconciliation serialization separately from read-side performance changes unless a change modifies the synchronization boundary.
Applied to files:
apps/webapp/app/routes/api.v1.schedules.tspackages/core/src/v3/schemas/api.ts
📚 Learning: 2026-03-22T13:26:12.060Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3244
File: apps/webapp/app/components/code/TextEditor.tsx:81-86
Timestamp: 2026-03-22T13:26:12.060Z
Learning: In the triggerdotdev/trigger.dev codebase, do not flag `navigator.clipboard.writeText(...)` calls for `missing-await`/`unhandled-promise` issues. These clipboard writes are intentionally invoked without `await` and without `catch` handlers across the project; keep that behavior consistent when reviewing TypeScript/TSX files (e.g., usages like in `apps/webapp/app/components/code/TextEditor.tsx`).
Applied to files:
apps/webapp/app/routes/api.v1.schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-03-22T19:24:14.403Z
Learnt from: matt-aitken
Repo: triggerdotdev/trigger.dev PR: 3187
File: apps/webapp/app/v3/services/alerts/deliverErrorGroupAlert.server.ts:200-204
Timestamp: 2026-03-22T19:24:14.403Z
Learning: In the triggerdotdev/trigger.dev codebase, webhook URLs are not expected to contain embedded credentials/secrets (e.g., fields like `ProjectAlertWebhookProperties` should only hold credential-free webhook endpoints). During code review, if you see logging or inclusion of raw webhook URLs in error messages, do not automatically treat it as a credential-leak/secrets-in-logs issue by default—first verify the URL does not contain embedded credentials (for example, no username/password in the URL, no obvious secret/token query params or fragments). If the URL is credential-free per this project’s conventions, allow the logging.
Applied to files:
apps/webapp/app/routes/api.v1.schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-05-18T08:21:27.694Z
Learnt from: d-cs
Repo: triggerdotdev/trigger.dev PR: 3632
File: apps/webapp/sentry.server.ts:4-21
Timestamp: 2026-05-18T08:21:27.694Z
Learning: When handling Prisma error P1001 ("Can't reach database server") in TypeScript, don’t assume a single error shape. Prisma can surface P1001 via two different error classes/fields: `PrismaClientKnownRequestError` exposes it as `err.code === "P1001"` (common during mid-query connection drops), while `PrismaClientInitializationError` exposes it as `err.errorCode === "P1001"` (common on client startup failure). Therefore, predicates should use `err.code === "P1001" || err.errorCode === "P1001"`. Do not flag `err.code === "P1001"` as “unreachable/never matches,” as it is expected in production.
Applied to files:
apps/webapp/app/routes/api.v1.schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-05-18T08:21:27.694Z
Learnt from: d-cs
Repo: triggerdotdev/trigger.dev PR: 3632
File: apps/webapp/sentry.server.ts:4-21
Timestamp: 2026-05-18T08:21:27.694Z
Learning: When handling Prisma errors for P1001 ("Can't reach database server"), do not assume it only appears under a single property name. Prisma may surface P1001 via either `PrismaClientKnownRequestError` (`err.code === "P1001"`, e.g., mid-query connection drops) or `PrismaClientInitializationError` (`err.errorCode === "P1001"`, e.g., client startup connection failure). To reliably detect the condition, check `err.code === "P1001" || err.errorCode === "P1001"`, and avoid review rules that would incorrectly flag `err.code === "P1001"` as unreachable/never-matching.
Applied to files:
apps/webapp/app/routes/api.v1.schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-06-13T19:53:13.759Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3937
File: packages/trigger-sdk/skills/realtime-and-frontend/SKILL.md:258-260
Timestamp: 2026-06-13T19:53:13.759Z
Learning: When reviewing code that uses `trigger.dev/react-hooks`’s `useRealtimeRun`, preserve the call signature where the first argument is the full realtime handle object (not `handle.id`). This is intentional to maintain type-safety and is consistent with the official docs; do not suggest changing the first argument from the handle object to `handle.id`.
Applied to files:
apps/webapp/app/routes/api.v1.schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-06-17T17:13:49.929Z
Learnt from: matt-aitken
Repo: triggerdotdev/trigger.dev PR: 3948
File: apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.bulk-actions.$bulkActionParam/route.tsx:48-62
Timestamp: 2026-06-17T17:13:49.929Z
Learning: In triggerdotdev/trigger.dev, within `dashboardLoader`/`dashboardAction` (or similar context resolver code) whenever you resolve an organization ID from an organization slug for RBAC/enterprise authorization scope, always read from the primary Prisma client (`prisma`), not `$replica`. Using `$replica` can hit replica-lag and cause the RBAC lookup/authorization to run without the correct org scope (bypassing intended role enforcement). Implement the slug→org lookup with `prisma.organization.findFirst(...)` (or equivalent primary-client query) and add an inline comment documenting why the primary client is required (replica lag could lead to unscoped RBAC checks).
Applied to files:
apps/webapp/app/routes/api.v1.schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-06-23T13:04:21.413Z
Learnt from: carderne
Repo: triggerdotdev/trigger.dev PR: 4023
File: apps/webapp/app/services/upsertBranch.server.ts:14-18
Timestamp: 2026-06-23T13:04:21.413Z
Learning: In TypeScript, it’s valid to `import { type X }` and then use `typeof X` in a type-only position, e.g. `type Alias = z.infer<typeof X>`. The `type` modifier suppresses the runtime import, but the type checker still has the full exported type so `z.infer<typeof X>` can resolve correctly. In code reviews, don’t flag this as a TypeScript compile error as long as `typeof X` is used in a type context (e.g., with `z.infer`, `type` aliases, generics), not as a runtime value.
Applied to files:
apps/webapp/app/routes/api.v1.schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-05-12T21:04:05.815Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3542
File: apps/webapp/app/components/sessions/v1/SessionStatus.tsx:1-3
Timestamp: 2026-05-12T21:04:05.815Z
Learning: In this Remix + TypeScript codebase, do not flag a server/client boundary violation when a file imports only types from a module matching `*.server`.
Specifically, it’s safe to import types using `import type { Foo } from "*.server"` or `import { type Foo } from "*.server"` because TypeScript erases type-only imports at compile time and they emit no JavaScript, so they won’t cross the Remix server/client bundle boundary.
Only raise the boundary concern for value imports (e.g., `import { Foo }` without `type`, or `import Foo`), since those produce JavaScript output.
Applied to files:
apps/webapp/app/routes/api.v1.schedules.ts
📚 Learning: 2026-06-25T18:21:51.905Z
Learnt from: carderne
Repo: triggerdotdev/trigger.dev PR: 4039
File: apps/webapp/app/routes/invite-revoke.tsx:0-0
Timestamp: 2026-06-25T18:21:51.905Z
Learning: During the Zod v4 migration in the triggerdotdev/trigger.dev webapp, ensure any imports from `conform-to/zod` use the Zod-4 subpath: `conform-to/zod/v4` (e.g., `import { parseWithZod } from "conform-to/zod/v4"`). Do not import from the package root `conform-to/zod`, because it is the Zod 3 implementation and may load Zod-3-only symbols (e.g., `ZodBranded`, `ZodEffects`), which can throw at module load (notably with `zod4.4.3`). This should be enforced across `apps/webapp/**/*` where helpers like `parseWithZod` and `conformZodMessage` are used.
Applied to files:
apps/webapp/app/routes/api.v1.schedules.ts
📚 Learning: 2026-07-03T17:10:21.498Z
Learnt from: 0ski
Repo: triggerdotdev/trigger.dev PR: 4148
File: apps/webapp/app/models/orgMember.server.ts:149-168
Timestamp: 2026-07-03T17:10:21.498Z
Learning: In triggerdotdev/trigger.dev, `User.email` (Prisma schema: `internal-packages/database/prisma/schema.prisma`) currently does NOT use `citext` and does NOT have a `lower(email)` functional unique index. Therefore, do not introduce Prisma queries like `where: { email: { equals: <value>, mode: "insensitive" } }` (or any case-insensitive lookup) against `User.email`, because it can force sequential scans of the `users` table under load. During review, ensure email is normalized (e.g., lowercased/trimmed) before both writes and subsequent lookups, and if true case-insensitive behavior/uniqueness is required, implement it via a separate app-wide migration (e.g., switch to `citext` and/or add a functional unique index with backfill) rather than bolting it onto individual feature PRs.
Applied to files:
apps/webapp/app/routes/api.v1.schedules.ts
📚 Learning: 2026-06-04T18:16:35.386Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 3836
File: apps/supervisor/src/backpressure/backpressureMonitor.ts:3-5
Timestamp: 2026-06-04T18:16:35.386Z
Learning: When reviewing TypeScript in this repo, apply the rule “prefer type aliases over interfaces” only to data/object shapes and union/intersection type modeling. If an interface is being used as a behavioral contract for collaborators to implement (e.g., method-shape interfaces that define required behavior, such as `BackpressureLogger` / `BackpressureSignalSource` in `apps/supervisor/src/backpressure/backpressureMonitor.ts`), keep it as an `interface` and do not flag it as a type-alias-vs-interface violation.
Applied to files:
apps/webapp/app/routes/api.v1.schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-06-09T17:58:04.699Z
Learnt from: 0ski
Repo: triggerdotdev/trigger.dev PR: 3879
File: apps/webapp/app/models/vercelIntegration.server.ts:619-630
Timestamp: 2026-06-09T17:58:04.699Z
Learning: In this codebase, outbound raw `fetch` calls should typically rely on Node/undici’s default request timeout (about ~300s) rather than adding a per-call `AbortController` + `setTimeout` wrapper inside individual functions (e.g. in files like `apps/webapp/app/models/vercelIntegration.server.ts`). During code review, do not flag the absence of a per-call timeout on a single `fetch` as an issue; if per-call timeouts are needed, they should be implemented via a codebase-wide convention (e.g., a shared fetch wrapper or documented pattern) rather than ad-hoc per-function changes.
Applied to files:
apps/webapp/app/routes/api.v1.schedules.tspackages/core/src/v3/schemas/api.tspackages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-05-12T21:04:13.550Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3542
File: apps/webapp/app/routes/api.v1.deployments.current.ts:19-32
Timestamp: 2026-05-12T21:04:13.550Z
Learning: In triggerdotdev/trigger.dev, `ApiDeploymentListResponseItem` (packages/core/src/v3/schemas/api.ts) does NOT include an `updatedAt` field. Its fields are: id, createdAt, shortCode, version, runtime, runtimeVersion, status, deployedAt, git, error. Do not flag the `api.v1.deployments.current` loader for a missing `updatedAt` field — the response shape matches the schema as-is.
Applied to files:
packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-04-27T16:46:05.550Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 3456
File: apps/webapp/package.json:152-152
Timestamp: 2026-04-27T16:46:05.550Z
Learning: In `apps/webapp`, the `effect` npm package is an intentional runtime dependency used in `apps/webapp/app/utils/updateMetadata.server.ts` (and related modules) for Schedule + Fiber-based metadata update logic. Specifically, the four Effect API usages are: `Duration.divide`, `STM.cond`, namespace exports for `Effect`/`Schedule`/`Duration`/`Fiber`, and the `Fiber.RuntimeFiber` type. Do not flag `effect` as an unused or misplaced dependency in `apps/webapp/package.json`.
Applied to files:
packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-07-02T19:14:58.851Z
Learnt from: d-cs
Repo: triggerdotdev/trigger.dev PR: 4124
File: internal-packages/database/prisma/migrations/20260629120000_drop_run_ops_control_plane_foreign_keys/migration.sql:1-26
Timestamp: 2026-07-02T19:14:58.851Z
Learning: Repo triggerdotdev/trigger.dev: In the run-ops DB split (schema.prisma / internal-packages/database/prisma/migrations), the intentional pattern is to keep Prisma `relation` declarations on models like TaskRun, Waitpoint, TaskRunWaitpoint, TaskRunCheckpoint, TaskRunAttempt, TaskRunTag, and WaitpointTag even after dropping the corresponding DB-level foreign key constraints via migration (e.g., migrations under 20260629120000_drop_run_ops_control_plane_foreign_keys and related). This is not schema drift: on the dedicated run-ops DB, `internal-packages/run-store/src/PostgresRunStore.ts` uses `stripDedicatedRelations` to strip these relation keys from Prisma select/include before querying, then `#hydrateDedicatedRelations` re-populates them from scalar columns or join lookups (e.g., hydrateAssociatedWaitpoint, hydrateBlockingTaskRuns). Do not flag missing schema updates to remove `relation` fields when FK constraints are dropped in this codebase's run-ops split migrations.
Applied to files:
packages/core/src/v3/schemas/api.ts
📚 Learning: 2026-05-12T21:04:02.113Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3542
File: packages/core/src/v3/schemas/runEngine.ts:18-19
Timestamp: 2026-05-12T21:04:02.113Z
Learning: In `packages/core/src/v3/schemas/runEngine.ts` (triggerdotdev/trigger.dev), all exported Zod enum schemas (e.g., `TriggerSource`, `TriggerAction`, `TaskKind`) intentionally use `.or(anyString)` — where `anyString = z.custom<string & {}>((v) => typeof v === "string")` is defined locally — as a forward-compatibility pattern to allow older clients to deserialize unknown future enum values without throwing. Do NOT flag this pattern as a type-safety or validation issue; it is a deliberate, project-wide convention in this file.
Applied to files:
packages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-03-21T21:23:35.117Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3244
File: apps/webapp/app/components/runs/v3/ai/extractAISummarySpanData.ts:149-150
Timestamp: 2026-03-21T21:23:35.117Z
Learning: In `apps/webapp/app/components/runs/v3/ai/extractAISummarySpanData.ts` (and related AI span extraction files in `apps/webapp/app/components/runs/v3/ai/`), manual JSON.parse with typeof guards and type assertions is intentional. These functions are on the hot path for span rendering, so Zod validation is deliberately avoided for performance reasons. Do not suggest replacing manual JSON parsing with Zod schemas in these files.
Applied to files:
packages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-06-25T17:34:23.069Z
Learnt from: carderne
Repo: triggerdotdev/trigger.dev PR: 4039
File: packages/core/src/v3/zodSocket.ts:317-317
Timestamp: 2026-06-25T17:34:23.069Z
Learning: In `triggerdotdev/trigger.dev`, for `packages/core/src/v3/zodSocket.ts` specifically within `ZodSocketMessageSender.sendWithAck()`, do not request adding runtime validation for the socket ack payload as part of the Zod v4 migration when the diff only replaces the previous raw/`ts-expect-error` return with a type cast. That would be a behavior-changing hardening (it could newly throw on mismatched ack payloads) and is considered out of scope for this migration; if desired, suggest it only as a separate follow-up. Also note that `this.#schema[type]?.["callback"]` may be `undefined`, so any validation suggestion must account for that.
Applied to files:
packages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-05-12T21:04:09.475Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3542
File: packages/core/src/v3/schemas/api.ts:1498-1503
Timestamp: 2026-05-12T21:04:09.475Z
Learning: In triggerdotdev/trigger.dev, `TriggerOptions.maxDuration` (in `packages/core/src/v3/schemas/api.ts`, used in `TriggerTaskRequestBody` around line 206 and `BatchTriggerTaskItem` around line 259) has NO minimum value — it is simply `z.number().optional()`. Do not flag `SessionTriggerConfig.maxDuration` (which uses `z.number().int().positive()`) for not matching a "5-second floor" because no such floor exists in `TriggerOptions.maxDuration`.
Applied to files:
packages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-06-16T12:35:11.681Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3963
File: packages/trigger-sdk/src/v3/ai.ts:10136-10141
Timestamp: 2026-06-16T12:35:11.681Z
Learning: In `packages/trigger-sdk/src/v3/ai.ts`, when assembling `SessionTriggerConfig` for `chat.createStartSessionAction`, string-like optional trigger config fields such as `queue`, `machine`, `region`, and `lockToVersion` intentionally use truthiness checks because empty strings are not valid values. Numeric optional fields such as `maxAttempts`, `maxDuration`, and `idleTimeoutInSeconds` should use `!== undefined` so valid numeric falsy values are preserved. Do not flag `lockToVersion` for using a truthiness check in this assembly.
Applied to files:
packages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-05-08T21:00:25.678Z
Learnt from: samejr
Repo: triggerdotdev/trigger.dev PR: 3538
File: apps/webapp/app/components/primitives/Resizable.tsx:60-78
Timestamp: 2026-05-08T21:00:25.678Z
Learning: In the triggerdotdev/trigger.dev codebase, Zod is a project standard at API/storage boundaries, not for inline render-time guards. Small manual type-narrowing checks (e.g., the ~12-line `isValidSnapshot` in `apps/webapp/app/components/primitives/Resizable.tsx`) are preferred over importing Zod into UI primitives for render-time validation, to avoid schema-parse overhead on every render and unnecessary abstraction. Per CLAUDE.md: "Three similar lines is better than a premature abstraction."
Applied to files:
packages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-05-17T08:07:36.624Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3644
File: packages/core/src/v3/apiClient/runStream.ts:385-426
Timestamp: 2026-05-17T08:07:36.624Z
Learning: In triggerdotdev/trigger.dev, do not flag missing per-element Zod validation for S2 v2 batch SSE records (e.g., in `packages/core/src/v3/apiClient/runStream.ts` and `apps/webapp/app/services/realtime/s2realtimeStreams.server.ts`). S2 batch records come from a trusted documented upstream wire protocol; a throw on a malformed field (e.g., `seq_num.toString()`) is intentional behavior to surface wire-protocol violations rather than silently skipping them. Only the container-level guard (`Array.isArray(data.records)`) is expected.
Applied to files:
packages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-05-17T08:07:25.757Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3644
File: apps/webapp/app/services/realtime/s2realtimeStreams.server.ts:261-293
Timestamp: 2026-05-17T08:07:25.757Z
Learning: In `apps/webapp/app/services/realtime/s2realtimeStreams.server.ts`, do NOT suggest adding per-element Zod validation inside `parseSSEBatchRecords()` or `#peekIsSettled()` for S2 batch record entries. S2 records arrive from a trusted upstream in a documented wire format; the existing `try/catch` around `JSON.parse` and the outer batch loop is the intended and sufficient level of defensiveness. Per-element Zod schema validation on every batch record is considered over-engineering for this server-to-server path.
Applied to files:
packages/core/src/v3/schemas/schemas.ts
📚 Learning: 2026-05-20T17:21:21.885Z
Learnt from: d-cs
Repo: triggerdotdev/trigger.dev PR: 3678
File: apps/webapp/app/entry.server.tsx:0-0
Timestamp: 2026-05-20T17:21:21.885Z
Learning: In `triggerdotdev/trigger.dev`, `SENTRY_DSN` was **not** included in the `env.server.ts` Zod schema by default. To access it via the `env` export (as required by the project convention), it must be explicitly declared as `SENTRY_DSN: z.string().optional()` in `apps/webapp/app/env.server.ts`. Without this declaration, switching from `process.env.SENTRY_DSN` to `env.SENTRY_DSN` will fail to typecheck.
Applied to files:
packages/core/src/v3/schemas/schemas.ts
🔇 Additional comments (4)
apps/webapp/app/routes/api.v1.schedules.ts (1)
75-75: LGTM!Also applies to: 134-134
packages/core/src/v3/schemas/schemas.ts (1)
184-184: ConnectScheduleWindowto the Zod output type.Line 184 declares a type alias only. Line 182 remains
z.string().min(1). Therefore,ScheduleMetadataand downstreamScheduleObjectschemas still inferwindowasstring; the alias does not narrow those public types. This repeats the existing public-type mismatch finding.Verification script
#!/bin/bash set -euo pipefail rg -n -C 4 \ 'export const ScheduleWindow|export type ScheduleWindow|window: ScheduleWindow\.optional\(\)|z\.infer<typeof (ScheduleMetadata|ScheduleObject)>' \ packages/core/src/v3/schemas/schemas.ts \ packages/core/src/v3/schemas/api.ts \ packages/trigger-sdk/src/v3/schedules/index.tspackages/core/src/v3/schemas/api.ts (2)
1094-1097: LGTM!
822-833: 🗄️ Data Integrity & IntegrationNo schema change is required. Deployment responses include both fields for default, zero-duration, duration, and percentage windows.
> Likely an incorrect or invalid review comment.
| export const ScheduleWindow = z.string().min(1); | ||
|
|
||
| export type ScheduleWindow = z.infer<typeof ScheduleWindow>; | ||
| export type ScheduleWindow = `${bigint}${"m" | "h" | "%"}`; |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Add the day suffix to ScheduleWindow.
The PR objective supports day windows, but Line 184 permits only m, h, and %. A caller cannot type a valid value such as "1d" through the declarative schedule API. Add "d" here and keep the mirrored alias in packages/trigger-sdk/src/v3/schedules/index.ts aligned.
Proposed fix
-export type ScheduleWindow = `${bigint}${"m" | "h" | "%"}`;
+export type ScheduleWindow = `${bigint}${"m" | "h" | "d" | "%"}`;9ecb63f to
5c706b5
Compare
Summary
Adds execution-window product surfaces for both declarative and imperative schedules.
windowthroughschedules.task(), with support for whole-minute, hour, day, and percentage values.nextRunas the nominal CRON time and exposenextRunEffectiveAtas the stable assigned time.Design
Window validation remains authoritative on the server and ensures each window is compatible with the schedule cadence. Omitting a window uses the default 60-second range, while explicit zero-duration windows remain supported.
Deployment summaries are derived from the deployment's stored task metadata, so they reflect the declarations associated with that deployment.