Skip to content

Regions – dashboard page, switching default, allowedMasterQueues #2354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Aug 6, 2025

Conversation

matt-aitken
Copy link
Member

@matt-aitken matt-aitken commented Aug 6, 2025

Untitled
  • Initial implementation of the Regions dashboard page
  • Projects can be locked to allowedMasterQueues
  • Switch to a different default region, with permission checks

Copy link

changeset-bot bot commented Aug 6, 2025

⚠️ No Changeset found

Latest commit: 3f3e808

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.

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

Copy link
Contributor

coderabbitai bot commented Aug 6, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This set of changes introduces a new Regions management feature to the web application. It adds new database columns to the WorkerInstanceGroup and Project tables to support metadata such as cloud provider, location, static IPs, and allowed master queues. Corresponding Prisma schema updates and migration scripts are included. New React components for cloud provider and region flag icons are added. A presenter and a service are implemented to fetch region data and set a default region with appropriate validation. The UI is extended with a new Regions page accessible from the side menu, displaying region details and enabling default region selection via a dialog. The feedback system is expanded to include region suggestions, and a new path helper for regions is added.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

  • Complexity: Multiple new features spanning backend (database migrations, schema updates, presenter and service logic), frontend (new icon components, UI components, and a Remix route), and integration into navigation and feedback systems.
  • Scope: Changes affect database schema, server-side logic, UI components, routing, and user interaction flows.
  • Volume: Several new files and modifications with detailed SVG icons, non-trivial validation and error handling, and comprehensive UI for managing regions.
  • Estimated review time: ~40 minutes for a thorough review covering schema changes, backend logic, frontend components, and integration points.

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 20f1e66 and 3f3e808.

📒 Files selected for processing (3)
  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts (1 hunks)
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.regions/route.tsx (1 hunks)
  • apps/webapp/app/v3/services/setDefaultRegion.server.ts (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch regions-dashboard

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 3

🧹 Nitpick comments (3)
internal-packages/database/prisma/migrations/20250805161650_worker_instance_group_added_cloud_provider_location_static_ips_columns/migration.sql (1)

1-5: LGTM! Well-structured metadata addition.

The migration correctly adds the necessary cloud provider metadata fields. All columns are appropriately nullable for backward compatibility.

Consider documenting the expected format for staticIPs (comma-separated, JSON, etc.) to ensure consistent data entry across the application.

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

25-32: Consider refactoring for improved readability.

The access control logic is correct but could be more readable. Consider restructuring for clarity:

-    // If their project is restricted, only allow them to set default regions that are allowed
-    if (project.allowedMasterQueues.length > 0) {
-      if (!project.allowedMasterQueues.includes(workerGroup.masterQueue)) {
-        throw new ServiceValidationError("You're not allowed to set this region as default");
-      }
-    } else if (workerGroup.hidden) {
-      throw new ServiceValidationError("This region is not available to you");
-    }
+    // Check access permissions
+    const hasRestrictedQueues = project.allowedMasterQueues.length > 0;
+    
+    if (hasRestrictedQueues) {
+      if (!project.allowedMasterQueues.includes(workerGroup.masterQueue)) {
+        throw new ServiceValidationError("You're not allowed to set this region as default");
+      }
+    } else if (workerGroup.hidden) {
+      throw new ServiceValidationError("This region is not available to you");
+    }
apps/webapp/app/assets/icons/CloudProviderIcon.tsx (1)

8-15: Consider using an object map for better maintainability.

The switch statement works correctly, but as more providers are added, an object map pattern would be more maintainable and scalable.

+const providerComponents = {
+  aws: AWS,
+  digitalocean: DigitalOcean,
+} as const;
+
 export function CloudProviderIcon({
   provider,
   className,
 }: {
   provider: "aws" | "digitalocean" | (string & {});
   className?: string;
 }) {
-  switch (provider) {
-    case "aws":
-      return <AWS className={className} />;
-    case "digitalocean":
-      return <DigitalOcean className={className} />;
-    default:
-      return null;
-  }
+  const Component = providerComponents[provider as keyof typeof providerComponents];
+  return Component ? <Component className={className} /> : null;
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d950a96 and d59dbe3.

📒 Files selected for processing (13)
  • apps/webapp/app/assets/icons/CloudProviderIcon.tsx (1 hunks)
  • apps/webapp/app/assets/icons/RegionIcons.tsx (1 hunks)
  • apps/webapp/app/components/CloudProvider.tsx (1 hunks)
  • apps/webapp/app/components/navigation/SideMenu.tsx (4 hunks)
  • apps/webapp/app/components/primitives/Badge.tsx (1 hunks)
  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts (1 hunks)
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.regions/route.tsx (1 hunks)
  • apps/webapp/app/routes/resources.feedback.ts (1 hunks)
  • apps/webapp/app/utils/pathBuilder.ts (1 hunks)
  • apps/webapp/app/v3/services/setDefaultRegion.server.ts (1 hunks)
  • internal-packages/database/prisma/migrations/20250805161650_worker_instance_group_added_cloud_provider_location_static_ips_columns/migration.sql (1 hunks)
  • internal-packages/database/prisma/migrations/20250806124301_project_allowed_master_queues_column/migration.sql (1 hunks)
  • internal-packages/database/prisma/schema.prisma (3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations

Files:

  • apps/webapp/app/components/primitives/Badge.tsx
  • apps/webapp/app/components/CloudProvider.tsx
  • apps/webapp/app/components/navigation/SideMenu.tsx
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.regions/route.tsx
  • apps/webapp/app/assets/icons/RegionIcons.tsx
  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
  • apps/webapp/app/routes/resources.feedback.ts
  • apps/webapp/app/utils/pathBuilder.ts
  • apps/webapp/app/v3/services/setDefaultRegion.server.ts
  • apps/webapp/app/assets/icons/CloudProviderIcon.tsx
{packages/core,apps/webapp}/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

We use zod a lot in packages/core and in the webapp

Files:

  • apps/webapp/app/components/primitives/Badge.tsx
  • apps/webapp/app/components/CloudProvider.tsx
  • apps/webapp/app/components/navigation/SideMenu.tsx
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.regions/route.tsx
  • apps/webapp/app/assets/icons/RegionIcons.tsx
  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
  • apps/webapp/app/routes/resources.feedback.ts
  • apps/webapp/app/utils/pathBuilder.ts
  • apps/webapp/app/v3/services/setDefaultRegion.server.ts
  • apps/webapp/app/assets/icons/CloudProviderIcon.tsx
apps/webapp/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/webapp.mdc)

apps/webapp/**/*.{ts,tsx}: In the webapp, all environment variables must be accessed through the env export of env.server.ts, instead of directly accessing process.env.
When importing from @trigger.dev/core in the webapp, never import from the root @trigger.dev/core path; always use one of the subpath exports as defined in the package's package.json.

Files:

  • apps/webapp/app/components/primitives/Badge.tsx
  • apps/webapp/app/components/CloudProvider.tsx
  • apps/webapp/app/components/navigation/SideMenu.tsx
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.regions/route.tsx
  • apps/webapp/app/assets/icons/RegionIcons.tsx
  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
  • apps/webapp/app/routes/resources.feedback.ts
  • apps/webapp/app/utils/pathBuilder.ts
  • apps/webapp/app/v3/services/setDefaultRegion.server.ts
  • apps/webapp/app/assets/icons/CloudProviderIcon.tsx
🧠 Learnings (4)
📚 Learning: applies to internal-packages/database/**/*.{ts,tsx} : we use prisma in internal-packages/database fo...
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-18T17:49:24.468Z
Learning: Applies to internal-packages/database/**/*.{ts,tsx} : We use prisma in internal-packages/database for our database interactions using PostgreSQL

Applied to files:

  • internal-packages/database/prisma/migrations/20250806124301_project_allowed_master_queues_column/migration.sql
  • internal-packages/database/prisma/migrations/20250805161650_worker_instance_group_added_cloud_provider_location_static_ips_columns/migration.sql
  • internal-packages/database/prisma/schema.prisma
📚 Learning: in modern postgresql versions (11+), adding a column with a constant default value (like default fal...
Learnt from: ericallam
PR: triggerdotdev/trigger.dev#2086
File: internal-packages/database/prisma/migrations/20250511145836_runtime_environment_add_is_branchable_environment/migration.sql:1-3
Timestamp: 2025-05-27T19:30:34.004Z
Learning: In modern PostgreSQL versions (11+), adding a column with a constant default value (like DEFAULT false, DEFAULT 0, DEFAULT 'text') does NOT require a table rewrite. PostgreSQL stores the default value in the catalog and applies it virtually when reading rows. Only non-constant defaults or more complex scenarios require table rewrites. Avoid suggesting multi-step migrations for simple constant defaults.

Applied to files:

  • internal-packages/database/prisma/migrations/20250806124301_project_allowed_master_queues_column/migration.sql
📚 Learning: applies to apps/webapp/app/v3/presenters/**/*.server.ts : favor the use of 'presenters' to move comp...
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-07-18T17:49:47.180Z
Learning: Applies to apps/webapp/app/v3/presenters/**/*.server.ts : Favor the use of 'presenters' to move complex loader code into a class, as seen in `app/v3/presenters/**/*.server.ts`.

Applied to files:

  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.regions/route.tsx
  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
📚 Learning: applies to apps/webapp/app/services/**/*.server.ts : for testable services, separate service logic a...
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-07-18T17:49:47.180Z
Learning: Applies to apps/webapp/app/services/**/*.server.ts : For testable services, separate service logic and configuration, as exemplified by `realtimeClient.server.ts` (service) and `realtimeClientGlobal.server.ts` (configuration).

Applied to files:

  • apps/webapp/app/v3/services/setDefaultRegion.server.ts
🧬 Code Graph Analysis (1)
apps/webapp/app/components/navigation/SideMenu.tsx (3)
apps/webapp/app/components/navigation/SideMenuItem.tsx (1)
  • SideMenuItem (7-53)
apps/webapp/app/utils/pathBuilder.ts (1)
  • regionsPath (456-462)
apps/webapp/app/components/V4Badge.tsx (1)
  • V4Badge (5-17)
⏰ 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: Analyze (javascript-typescript)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
🔇 Additional comments (19)
internal-packages/database/prisma/migrations/20250806124301_project_allowed_master_queues_column/migration.sql (1)

1-2: LGTM! Clean and efficient migration.

The migration correctly adds the allowedMasterQueues column with a proper default value. Using ARRAY[]::TEXT[] provides a clean empty array default, and modern PostgreSQL will handle this efficiently without requiring a table rewrite.

apps/webapp/app/components/primitives/Badge.tsx (1)

9-10: LGTM! Consistent variant addition.

The new "small" variant follows the established styling pattern and provides appropriate size progression between "extra-small" and the default variants.

apps/webapp/app/utils/pathBuilder.ts (1)

456-462: LGTM! Perfect consistency with existing patterns.

The regionsPath function follows the established conventions exactly, using the same parameter types and path-building approach as other environment-level functions.

apps/webapp/app/routes/resources.feedback.ts (1)

18-18: LGTM! Clean integration with existing feedback system.

The new "region" feedback type integrates seamlessly with the existing dynamic schema construction. The label is clear and descriptive.

apps/webapp/app/components/CloudProvider.tsx (1)

1-10: LGTM! Clean and type-safe cloud provider mapping.

The function correctly maps known cloud providers to human-readable titles and falls back gracefully for unknown providers. The union type with string extension (string & {}) is a good pattern for allowing specific known values while maintaining flexibility.

apps/webapp/app/components/navigation/SideMenu.tsx (4)

13-13: Good import cleanup.

The addition of GlobeAmericasIcon import is appropriate for the new regions feature.


26-26: Correct import retained.

The ListCheckedIcon import is correctly kept as it's used in the "Bulk actions" menu item.


51-51: Proper path utility import.

The regionsPath import follows the established pattern for route path builders.


315-322: LGTM! Consistent navigation item implementation.

The new "Regions" menu item follows the established patterns:

  • Appropriate icon (GlobeAmericasIcon) and active color (text-green-500)
  • Consistent with other V4 features by including the V4Badge
  • Proper data-action attribute for tracking
  • Uses the correct path builder function
internal-packages/database/prisma/schema.prisma (3)

338-340: Well-documented access control field.

The allowedMasterQueues field with descriptive comment clearly explains its purpose for controlling project permissions. The default empty array is appropriate for backward compatibility.


1148-1149: Good documentation update.

The enhanced comment for the description field clarifies its display purpose with concrete examples.


1166-1170: Well-designed metadata fields.

The new optional fields provide useful region metadata:

  • cloudProvider: Clear purpose for identifying the cloud service
  • location: Well-documented as pseudo-enum for geographic flags
  • staticIPs: Useful for displaying network information

All fields are optional, ensuring backward compatibility.

apps/webapp/app/v3/services/setDefaultRegion.server.ts (3)

4-13: LGTM! Proper validation with clear error handling.

The region lookup and error handling follow good practices with descriptive error messages.


15-23: LGTM! Consistent project validation.

The project lookup follows the same pattern as the region validation with appropriate error handling.


34-47: LGTM! Clean update operation with appropriate return value.

The database update and return value provide exactly what's needed for the calling code.

apps/webapp/app/assets/icons/RegionIcons.tsx (3)

1-16: LGTM! Clean conditional icon rendering.

The FlagIcon component follows the same pattern as CloudProvider.tsx with proper type safety and graceful fallback for unknown regions.


18-66: LGTM! Well-structured SVG component.

The FlagUSA component provides a detailed and accurate representation with proper className support for styling.


68-106: LGTM! Consistent SVG implementation.

The FlagEurope component follows the same pattern as FlagUSA with appropriate styling support and accurate flag representation.

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

63-69: allowedMasterQueues is always a non-null array

In schema.prisma (line 339) the field is declared as:

allowedMasterQueues String[] @default([])

which guarantees a default empty array rather than null—calling .length is safe.

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

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

17-40: Consider using more specific error types.

The project fetching logic is secure and efficient with proper user membership validation. However, the generic Error could be replaced with a more specific error type for better error handling upstream.

-    if (!project) {
-      throw new Error("Project not found");
-    }
+    if (!project) {
+      throw new Response("Project not found", { status: 404 });
+    }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d59dbe3 and 20f1e66.

📒 Files selected for processing (2)
  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts (1 hunks)
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.regions/route.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.regions/route.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations

Files:

  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
{packages/core,apps/webapp}/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

We use zod a lot in packages/core and in the webapp

Files:

  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
apps/webapp/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/webapp.mdc)

apps/webapp/**/*.{ts,tsx}: In the webapp, all environment variables must be accessed through the env export of env.server.ts, instead of directly accessing process.env.
When importing from @trigger.dev/core in the webapp, never import from the root @trigger.dev/core path; always use one of the subpath exports as defined in the package's package.json.

Files:

  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
🧠 Learnings (2)
📚 Learning: in regionspresenter.server.ts, the final sort by name that removes the "default first" ordering is i...
Learnt from: matt-aitken
PR: triggerdotdev/trigger.dev#2354
File: apps/webapp/app/presenters/v3/RegionsPresenter.server.ts:117-131
Timestamp: 2025-08-06T14:25:20.389Z
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: applies to apps/webapp/app/v3/presenters/**/*.server.ts : favor the use of 'presenters' to move comp...
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/webapp.mdc:0-0
Timestamp: 2025-07-18T17:49:47.180Z
Learning: Applies to apps/webapp/app/v3/presenters/**/*.server.ts : Favor the use of 'presenters' to move complex loader code into a class, as seen in `app/v3/presenters/**/*.server.ts`.

Applied to files:

  • apps/webapp/app/presenters/v3/RegionsPresenter.server.ts
⏰ 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). (2)
  • GitHub Check: units / internal / 📊 Merge Reports
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
🔇 Additional comments (8)
apps/webapp/app/presenters/v3/RegionsPresenter.server.ts (8)

1-15: LGTM! Clean imports and type definition.

The imports follow the coding guidelines correctly, and the Region type definition properly uses type instead of interface as preferred in the codebase.


42-49: LGTM! Proper feature flag usage.

The feature flag retrieval follows the established pattern and includes appropriate error handling for a critical system dependency.


51-72: LGTM! Well-implemented access control logic.

The conditional query properly restricts region visibility based on project permissions, allowing restricted projects to access their allowed master queues while limiting unrestricted projects to non-hidden regions.


74-82: LGTM! Clean data mapping.

The mapping properly handles null coalescing to undefined for optional fields and correctly assigns the default flag based on the feature flag value.


84-114: LGTM! Proper default region override handling.

The logic correctly handles project-specific default worker groups by unsetting the previous default and adding the new one, maintaining data consistency.


116-127: LGTM! Sorting and deduplication logic is correct.

The sorting properly places the default region first, and the deduplication correctly removes later duplicates by ID while preserving the first occurrence.


129-138: LGTM! Appropriate business logic for plan-based features.

The filtering correctly hides static IPs from non-paying users to avoid confusion, while properly handling both null and undefined cases.


140-144: LGTM! Return statement with intentional sorting.

The final alphabetical sort and return structure are correct. As previously clarified, the alphabetical sorting that removes "default first" ordering is intentional behavior.

@matt-aitken matt-aitken merged commit a782813 into main Aug 6, 2025
27 of 28 checks passed
@matt-aitken matt-aitken deleted the regions-dashboard branch August 6, 2025 14:56
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.

4 participants