Skip to content

Conversation

@matt-aitken
Copy link
Member

@matt-aitken matt-aitken commented Jan 29, 2026

  • Renamed FeatureFlag functions to be singular where it makes sense.
  • Added function to handle multiple feature flags
  • canAccessQuery now checks the global feature flag and environment variable as well

Open with Devin

@changeset-bot
Copy link

changeset-bot bot commented Jan 29, 2026

⚠️ No Changeset found

Latest commit: 78b9b92

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

Walkthrough

Adds a global environment flag QUERY_FEATURE_ENABLED (string, default "1") to the environment schema (appears twice in the file). Introduces a new canAccessQuery server helper that centralizes query access checks using global flag, admin/impersonation, or org-level feature flags. Refactors feature-flag API: renames plural helpers (makeFlags, setFlags) to singular (makeFlag, makeSetFlag), adds a new makeFlags that returns all flags, and exposes flag, flags, and setFlag exports. Updates multiple modules to use the new flag API and merges global + org feature flags when presenting organizations. Query route now uses canAccessQuery and expands scope options.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete. It lacks required sections from the template including: issue reference (Closes #), testing steps, changelog details, and screenshot sections. The checklist is also not filled out. Complete the PR description by adding: issue reference, checking all checklist items, describing testing steps, providing a detailed changelog, and adding any relevant screenshots.
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Query enabled via feature flag' clearly summarizes the main change: introducing feature flag-based control for query access, which is reflected across multiple files in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 069415e and 78b9b92.

📒 Files selected for processing (1)
  • apps/webapp/app/v3/eventRepository/index.server.ts
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{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}: Always import tasks from @trigger.dev/sdk, never use @trigger.dev/sdk/v3 or deprecated client.defineJob pattern
Every Trigger.dev task must be exported and have a unique id property with no timeouts in the run function

Files:

  • apps/webapp/app/v3/eventRepository/index.server.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/v3/eventRepository/index.server.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use function declarations instead of default exports

Import from @trigger.dev/core using subpaths only, never import from root

Files:

  • apps/webapp/app/v3/eventRepository/index.server.ts
apps/webapp/app/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

Access all environment variables through the env export of env.server.ts instead of directly accessing process.env in the Trigger.dev webapp

Files:

  • apps/webapp/app/v3/eventRepository/index.server.ts
apps/webapp/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

apps/webapp/**/*.{ts,tsx}: When importing from @trigger.dev/core in the webapp, use subpath exports from the package.json instead of importing from the root path
Follow the Remix 2.1.0 and Express server conventions when updating the main trigger.dev webapp

Access environment variables via env export from apps/webapp/app/env.server.ts, never use process.env directly

Files:

  • apps/webapp/app/v3/eventRepository/index.server.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/v3/eventRepository/index.server.ts
**/*.{js,ts,jsx,tsx,json,md,yaml,yml}

📄 CodeRabbit inference engine (AGENTS.md)

Format code using Prettier before committing

Files:

  • apps/webapp/app/v3/eventRepository/index.server.ts
🧠 Learnings (1)
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Applies to apps/webapp/**/*.{ts,tsx} : Follow the Remix 2.1.0 and Express server conventions when updating the main trigger.dev webapp

Applied to files:

  • apps/webapp/app/v3/eventRepository/index.server.ts
🧬 Code graph analysis (1)
apps/webapp/app/v3/eventRepository/index.server.ts (1)
apps/webapp/app/v3/featureFlags.server.ts (2)
  • flag (135-135)
  • FEATURE_FLAG (4-10)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (22)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
🔇 Additional comments (3)
apps/webapp/app/v3/eventRepository/index.server.ts (3)

8-10: LGTM!

Import changes correctly align with the refactored feature flag API, switching from flags to the singular flag export.


27-33: LGTM!

Formatting and type expression changes are stylistically consistent. The use of a const object with as const assertion for EVENT_STORE_TYPES correctly aligns with the coding guideline to avoid enums.


122-140: Variable rename to avoid shadowing is correct; type safety concern is unfounded.

The rename from flag to flagResult properly resolves the shadowing issue. However, the type safety concern at line 139 is incorrect. The function's return type of "clickhouse" | "clickhouse_v2" | "postgres" is safe because:

  1. env.EVENT_REPOSITORY_DEFAULT_STORE is constrained by zod to ["postgres", "clickhouse", "clickhouse_v2"]
  2. The flag() function with a defaultValue parameter returns Promise<z.infer<(typeof FeatureFlagCatalog)["taskEventRepository"]>>, which is Promise<"clickhouse" | "clickhouse_v2" | "postgres">
  3. Therefore, flagResult is guaranteed to be one of the valid return type values

Returning flagResult directly at line 139 is type-safe and correct. Hardcoding "postgres" as a fallback would be incorrect, as it would ignore legitimate values from the feature flag system.

Likely an incorrect or invalid review comment.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View issue and 4 additional flags in Devin Review.

Open in Devin Review

@vibe-kanban-cloud
Copy link

Review Complete

Your review story is ready!

View Story

Comment !reviewfast on this PR to re-generate the story.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/webapp/app/v3/eventRepository/index.server.ts (1)

125-129: Critical: Variable shadowing causes runtime error.

Line 125 declares a local variable flag that shadows the imported flag function. This creates a temporal dead zone (TDZ) error because flag is referenced before its declaration in the same statement.

The static analysis tool correctly identified this: "This variable is used before its declaration."

🐛 Proposed fix: Rename the local variable
 async function resolveTaskEventRepositoryFlag(
   featureFlags: Record<string, unknown> | undefined
 ): Promise<"clickhouse" | "clickhouse_v2" | "postgres"> {
-  const flag = await flag({
+  const taskEventRepositoryFlag = await flag({
     key: FEATURE_FLAG.taskEventRepository,
     defaultValue: env.EVENT_REPOSITORY_DEFAULT_STORE,
     overrides: featureFlags,
   });
 
-  if (flag === "clickhouse_v2") {
+  if (taskEventRepositoryFlag === "clickhouse_v2") {
     return "clickhouse_v2";
   }
 
-  if (flag === "clickhouse") {
+  if (taskEventRepositoryFlag === "clickhouse") {
     return "clickhouse";
   }
 
-  return flag;
+  return taskEventRepositoryFlag;
 }
🧹 Nitpick comments (3)
apps/webapp/app/v3/featureFlags.server.ts (1)

85-88: Type reference ordering concern.

AllFlagsOptions references Partial<FeatureFlagCatalog> but FeatureFlagCatalog is defined later at line 141. While TypeScript's type hoisting handles this, consider reordering for clarity, or note that this works because types are hoisted.

apps/webapp/app/v3/services/worker/workerGroupService.server.ts (1)

169-173: Inconsistent variable naming.

The variable is named flags but it's actually makeFlag (singular flag accessor). This is inconsistent with line 50 where the same pattern uses getFlag. Consider renaming for clarity and consistency.

♻️ Proposed fix for naming consistency
   async getGlobalDefaultWorkerGroup() {
-    const flags = makeFlag(this._prisma);
+    const getFlag = makeFlag(this._prisma);
 
-    const defaultWorkerInstanceGroupId = await flags({
+    const defaultWorkerInstanceGroupId = await getFlag({
       key: FEATURE_FLAG.defaultWorkerInstanceGroupId,
     });
apps/webapp/app/v3/canAccessQuery.server.ts (1)

35-40: Consider using the pre-exported flag function instead of creating a new instance.

The featureFlags.server.ts file already exports a pre-instantiated flag function at line 134 (export const flag = makeFlag();). Using it directly would be more consistent with other usages in the codebase.

♻️ Suggested refactor
-import { FEATURE_FLAG, makeFlag } from "~/v3/featureFlags.server";
+import { FEATURE_FLAG, flag } from "~/v3/featureFlags.server";

...

-  const flag = makeFlag();
-  const flagResult = await flag({
+  const flagResult = await flag({
     key: FEATURE_FLAG.hasQueryAccess,
     defaultValue: false,
     overrides: (org?.featureFlags as Record<string, unknown>) ?? {},
   });
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0674d74 and 069415e.

📒 Files selected for processing (9)
  • apps/webapp/app/env.server.ts
  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx
  • apps/webapp/app/services/runsRepository/runsRepository.server.ts
  • apps/webapp/app/v3/canAccessQuery.server.ts
  • apps/webapp/app/v3/eventRepository/index.server.ts
  • apps/webapp/app/v3/featureFlags.server.ts
  • apps/webapp/app/v3/services/worker/workerGroupService.server.ts
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{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}: Always import tasks from @trigger.dev/sdk, never use @trigger.dev/sdk/v3 or deprecated client.defineJob pattern
Every Trigger.dev task must be exported and have a unique id property with no timeouts in the run function

Files:

  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
  • apps/webapp/app/v3/canAccessQuery.server.ts
  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
  • apps/webapp/app/v3/services/worker/workerGroupService.server.ts
  • apps/webapp/app/v3/eventRepository/index.server.ts
  • apps/webapp/app/services/runsRepository/runsRepository.server.ts
  • apps/webapp/app/v3/featureFlags.server.ts
  • apps/webapp/app/env.server.ts
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx
{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/presenters/v3/RegionsPresenter.server.ts
  • apps/webapp/app/v3/canAccessQuery.server.ts
  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
  • apps/webapp/app/v3/services/worker/workerGroupService.server.ts
  • apps/webapp/app/v3/eventRepository/index.server.ts
  • apps/webapp/app/services/runsRepository/runsRepository.server.ts
  • apps/webapp/app/v3/featureFlags.server.ts
  • apps/webapp/app/env.server.ts
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use function declarations instead of default exports

Import from @trigger.dev/core using subpaths only, never import from root

Files:

  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
  • apps/webapp/app/v3/canAccessQuery.server.ts
  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
  • apps/webapp/app/v3/services/worker/workerGroupService.server.ts
  • apps/webapp/app/v3/eventRepository/index.server.ts
  • apps/webapp/app/services/runsRepository/runsRepository.server.ts
  • apps/webapp/app/v3/featureFlags.server.ts
  • apps/webapp/app/env.server.ts
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx
apps/webapp/app/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

Access all environment variables through the env export of env.server.ts instead of directly accessing process.env in the Trigger.dev webapp

Files:

  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
  • apps/webapp/app/v3/canAccessQuery.server.ts
  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
  • apps/webapp/app/v3/services/worker/workerGroupService.server.ts
  • apps/webapp/app/v3/eventRepository/index.server.ts
  • apps/webapp/app/services/runsRepository/runsRepository.server.ts
  • apps/webapp/app/v3/featureFlags.server.ts
  • apps/webapp/app/env.server.ts
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx
apps/webapp/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

apps/webapp/**/*.{ts,tsx}: When importing from @trigger.dev/core in the webapp, use subpath exports from the package.json instead of importing from the root path
Follow the Remix 2.1.0 and Express server conventions when updating the main trigger.dev webapp

Access environment variables via env export from apps/webapp/app/env.server.ts, never use process.env directly

Files:

  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
  • apps/webapp/app/v3/canAccessQuery.server.ts
  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
  • apps/webapp/app/v3/services/worker/workerGroupService.server.ts
  • apps/webapp/app/v3/eventRepository/index.server.ts
  • apps/webapp/app/services/runsRepository/runsRepository.server.ts
  • apps/webapp/app/v3/featureFlags.server.ts
  • apps/webapp/app/env.server.ts
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx
**/*.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/presenters/v3/RegionsPresenter.server.ts
  • apps/webapp/app/v3/canAccessQuery.server.ts
  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
  • apps/webapp/app/v3/services/worker/workerGroupService.server.ts
  • apps/webapp/app/v3/eventRepository/index.server.ts
  • apps/webapp/app/services/runsRepository/runsRepository.server.ts
  • apps/webapp/app/v3/featureFlags.server.ts
  • apps/webapp/app/env.server.ts
**/*.{js,ts,jsx,tsx,json,md,yaml,yml}

📄 CodeRabbit inference engine (AGENTS.md)

Format code using Prettier before committing

Files:

  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
  • apps/webapp/app/v3/canAccessQuery.server.ts
  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
  • apps/webapp/app/v3/services/worker/workerGroupService.server.ts
  • apps/webapp/app/v3/eventRepository/index.server.ts
  • apps/webapp/app/services/runsRepository/runsRepository.server.ts
  • apps/webapp/app/v3/featureFlags.server.ts
  • apps/webapp/app/env.server.ts
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx
apps/webapp/app/v3/services/**/*.server.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

Organize services in the webapp following the pattern app/v3/services/*/*.server.ts

Files:

  • apps/webapp/app/v3/services/worker/workerGroupService.server.ts
apps/webapp/app/services/**/*.server.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

Separate testable services from configuration files; follow the pattern of realtimeClient.server.ts (testable service) and realtimeClientGlobal.server.ts (configuration) in the webapp

Files:

  • apps/webapp/app/services/runsRepository/runsRepository.server.ts
🧠 Learnings (17)
📚 Learning: 2025-08-06T14:25:20.438Z
Learnt from: matt-aitken
Repo: triggerdotdev/trigger.dev PR: 2354
File: apps/webapp/app/presenters/v3/RegionsPresenter.server.ts:117-131
Timestamp: 2025-08-06T14:25:20.438Z
Learning: In RegionsPresenter.server.ts, the final sort by name that removes the "default first" ordering is intentional behavior as a way to prefer the default, as clarified by matt-aitken.

Applied to files:

  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Applies to apps/webapp/app/v3/presenters/**/*.server.{ts,tsx} : Organize presenters in the webapp following the pattern `app/v3/presenters/*/*.server.ts` to move complex loader code into classes

Applied to files:

  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Leverage the PostgreSQL database through the `trigger.dev/database` Prisma 6.14.0 client in the webapp for all data access patterns

Applied to files:

  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to internal-packages/database/**/*.{ts,tsx} : Use Prisma for database interactions in internal-packages/database with PostgreSQL

Applied to files:

  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
  • apps/webapp/app/services/runsRepository/runsRepository.server.ts
  • apps/webapp/app/v3/featureFlags.server.ts
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Applies to apps/webapp/app/**/*.{ts,tsx} : Access all environment variables through the `env` export of `env.server.ts` instead of directly accessing `process.env` in the Trigger.dev webapp

Applied to files:

  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
  • apps/webapp/app/env.server.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to packages/trigger-sdk/**/*.{ts,tsx} : In the Trigger.dev SDK (packages/trigger-sdk), prefer isomorphic code like fetch and ReadableStream instead of Node.js-specific code

Applied to files:

  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger.config.ts : Specify runtime environment (node or bun) in trigger.config.ts using the `runtime` property

Applied to files:

  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: The SDK at packages/trigger-sdk is an isomorphic TypeScript SDK

Applied to files:

  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
📚 Learning: 2025-11-27T16:26:58.661Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-11-27T16:26:58.661Z
Learning: Applies to apps/webapp/**/*.{ts,tsx} : Follow the Remix 2.1.0 and Express server conventions when updating the main trigger.dev webapp

Applied to files:

  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
  • apps/webapp/app/v3/eventRepository/index.server.ts
  • apps/webapp/app/services/runsRepository/runsRepository.server.ts
📚 Learning: 2025-11-27T16:27:35.304Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-11-27T16:27:35.304Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use `trigger.dev/sdk/v3` for all imports in Trigger.dev tasks

Applied to files:

  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
📚 Learning: 2025-08-14T10:09:02.528Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 2390
File: internal-packages/run-engine/src/engine/index.ts:466-467
Timestamp: 2025-08-14T10:09:02.528Z
Learning: In the triggerdotdev/trigger.dev codebase, it's acceptable to pass `string | undefined` types directly to Prisma operations (both create and update). The codebase consistently uses this pattern and the team is comfortable with how Prisma handles undefined values.

Applied to files:

  • apps/webapp/app/presenters/OrganizationsPresenter.server.ts
📚 Learning: 2025-07-12T18:06:04.133Z
Learnt from: matt-aitken
Repo: triggerdotdev/trigger.dev PR: 2264
File: apps/webapp/app/services/runsRepository.server.ts:172-174
Timestamp: 2025-07-12T18:06:04.133Z
Learning: In apps/webapp/app/services/runsRepository.server.ts, the in-memory status filtering after fetching runs from Prisma is intentionally used as a workaround for ClickHouse data delays. This approach is acceptable because the result set is limited to a maximum of 100 runs due to pagination, making the performance impact negligible.

Applied to files:

  • apps/webapp/app/services/runsRepository/runsRepository.server.ts
📚 Learning: 2025-11-27T16:26:37.432Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T16:26:37.432Z
Learning: Applies to {packages/core,apps/webapp}/**/*.{ts,tsx} : Use zod for validation in packages/core and apps/webapp

Applied to files:

  • apps/webapp/app/services/runsRepository/runsRepository.server.ts
📚 Learning: 2026-01-15T11:50:06.067Z
Learnt from: CR
Repo: triggerdotdev/trigger.dev PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-15T11:50:06.067Z
Learning: Applies to apps/webapp/**/*.{ts,tsx} : Access environment variables via `env` export from `apps/webapp/app/env.server.ts`, never use `process.env` directly

Applied to files:

  • apps/webapp/app/env.server.ts
📚 Learning: 2025-08-14T18:35:44.370Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 2390
File: apps/webapp/app/env.server.ts:764-765
Timestamp: 2025-08-14T18:35:44.370Z
Learning: The BoolEnv helper in apps/webapp/app/utils/boolEnv.ts uses z.preprocess with inconsistent default value types across the codebase - some usages pass boolean defaults (correct) while others pass string defaults (incorrect), leading to type confusion. The helper should enforce boolean-only defaults or have clearer documentation.

Applied to files:

  • apps/webapp/app/env.server.ts
📚 Learning: 2025-12-08T15:19:56.823Z
Learnt from: 0ski
Repo: triggerdotdev/trigger.dev PR: 2760
File: apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx:278-281
Timestamp: 2025-12-08T15:19:56.823Z
Learning: In apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx, the tableState search parameter uses intentional double-encoding: the parameter value contains a URL-encoded URLSearchParams string, so decodeURIComponent(value("tableState") ?? "") is required to fully decode it before parsing with new URLSearchParams(). This pattern allows bundling multiple filter/pagination params as a single search parameter.

Applied to files:

  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx
📚 Learning: 2025-09-03T14:35:52.384Z
Learnt from: myftija
Repo: triggerdotdev/trigger.dev PR: 2464
File: apps/webapp/app/utils/pathBuilder.ts:144-146
Timestamp: 2025-09-03T14:35:52.384Z
Learning: In the trigger.dev codebase, organization slugs are safe for URL query parameters and don't require URL encoding, as confirmed by the maintainer in apps/webapp/app/utils/pathBuilder.ts.

Applied to files:

  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx
🧬 Code graph analysis (7)
apps/webapp/app/presenters/v3/RegionsPresenter.server.ts (1)
apps/webapp/app/v3/featureFlags.server.ts (1)
  • makeFlag (28-64)
apps/webapp/app/v3/canAccessQuery.server.ts (2)
apps/webapp/app/env.server.ts (1)
  • env (1324-1324)
apps/webapp/app/v3/featureFlags.server.ts (3)
  • flag (135-135)
  • makeFlag (28-64)
  • FEATURE_FLAG (4-10)
apps/webapp/app/presenters/OrganizationsPresenter.server.ts (2)
apps/webapp/app/v3/featureFlags.server.ts (2)
  • flags (136-136)
  • validatePartialFeatureFlags (157-159)
apps/webapp/app/components/primitives/Avatar.tsx (2)
  • parseAvatar (37-50)
  • defaultAvatar (105-108)
apps/webapp/app/v3/services/worker/workerGroupService.server.ts (1)
apps/webapp/app/v3/featureFlags.server.ts (5)
  • makeFlag (28-64)
  • FEATURE_FLAG (4-10)
  • setFlag (137-137)
  • makeSetFlag (66-83)
  • flags (136-136)
apps/webapp/app/v3/eventRepository/index.server.ts (1)
apps/webapp/app/v3/featureFlags.server.ts (1)
  • flag (135-135)
apps/webapp/app/services/runsRepository/runsRepository.server.ts (1)
apps/webapp/app/v3/featureFlags.server.ts (1)
  • makeFlag (28-64)
apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx (1)
apps/webapp/app/v3/canAccessQuery.server.ts (1)
  • canAccessQuery (5-47)
🪛 Biome (2.3.13)
apps/webapp/app/v3/eventRepository/index.server.ts

[error] 125-125: This variable is used before its declaration.

The variable is declared here:

(lint/correctness/noInvalidUseBeforeDeclaration)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (23)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (11)
apps/webapp/app/v3/featureFlags.server.ts (1)

90-133: LGTM!

The new makeFlags function correctly implements the precedence logic (overrides > database > defaults) for retrieving all feature flags. The as any casts are acceptable for dynamic key assignment in this context.

apps/webapp/app/presenters/v3/RegionsPresenter.server.ts (1)

3-3: LGTM!

The import and usage have been correctly updated to use makeFlag (singular) for retrieving a single feature flag value.

Also applies to: 51-54

apps/webapp/app/services/runsRepository/runsRepository.server.ts (1)

11-11: LGTM!

The import and usage have been correctly updated to use makeFlag for retrieving the runsListRepository feature flag.

Also applies to: 166-170

apps/webapp/app/presenters/OrganizationsPresenter.server.ts (1)

156-166: LGTM!

The implementation correctly fetches global flags once and merges them with organization-specific flags, giving org flags precedence via spread order { ...globalFlags, ...orgFlags }. This is an efficient and clean pattern for global defaults with per-org overrides.

apps/webapp/app/v3/services/worker/workerGroupService.server.ts (1)

5-5: LGTM!

The import and usage in createWorkerGroup have been correctly updated to use the singular makeFlag and makeSetFlag functions with appropriate variable naming (getFlag, setFlag).

Also applies to: 50-61

apps/webapp/app/env.server.ts (1)

1193-1195: LGTM!

The new QUERY_FEATURE_ENABLED environment variable follows the established pattern in this file for feature flags (string "1"/"0" convention). The placement near other query-related settings is logical.

apps/webapp/app/v3/canAccessQuery.server.ts (1)

5-47: LGTM - Well-structured access control logic.

The cascading access check (global flag → admin/impersonation → org feature flag → deny) is clear and follows the principle of least privilege. The implicit membership verification via the Prisma query is a good pattern that ensures non-members cannot access the feature.

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx (4)

78-78: LGTM - Clean import of centralized access control.

The import follows the established pattern and correctly references the new canAccessQuery function from the v3 module.


100-112: LGTM - Access control properly integrated in loader.

The canAccessQuery function is called early in the loader before expensive database operations, with appropriate redirect behavior for unauthorized access.


165-190: LGTM - Consistent access control in action.

The action appropriately returns a 403 JSON response for unauthorized access, which is correct for form submissions (as opposed to the loader's redirect behavior).


94-98: LGTM - Organization scope correctly added.

The new "organization" scope option aligns with the ActionSchema validation and the enforcedWhereClause logic at lines 299-305, which correctly handles tenant isolation for all three scope levels.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@matt-aitken matt-aitken merged commit 72c3571 into main Jan 29, 2026
34 checks passed
@matt-aitken matt-aitken deleted the query-enabled-flag branch January 29, 2026 15:30
NERLOE pushed a commit to NERLOE/trigger.dev that referenced this pull request Jan 30, 2026
- Renamed FeatureFlag functions to be singular where it makes sense.
- Added function to handle multiple feature flags
- canAccessQuery now checks the global feature flag and environment
variable as well
<!-- devin-review-badge-begin -->

---

<a
href="https://app.devin.ai/review/triggerdotdev/trigger.dev/pull/2968">
  <picture>
<source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
<img
src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1"
alt="Open with Devin">
  </picture>
</a>
<!-- devin-review-badge-end -->
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