You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(Projects): Remove N+1 calls to get project environments - #8957
Loading the organisation fetched environments for every project, only so project cards could link to the first one. Large organisations hit rate limits. Environments now load when a project is opened.
N+1 fix: project cards link to /project/:id; ProjectRedirectPage loads that project's environments and redirects to the first by name.
Permission dialogs: load the selected project's environments themselves, with an error and Try again if they fail (EmptyState gets status='error' and onRetry).
Project pages wait for ProjectStore: the App.js loader used to finish after every environment loaded, which also covered ProjectStore. Without the N+1 it finishes first, so it now waits for both.
Chromatic: EmptyState's default icon colour moves from #9DA4AE to the colorIconSecondary token (a little darker in light mode), so every empty state shows a small change.
How did you test this code?
Against staging: the Projects page makes no environment requests; opening a project lands on its first environment; both permission dialogs list the right environments when switching projects, and show Try again on a failed load; with environments/?project= delayed, identity pages and project settings load correctly.
E2E: new user-permissions-test.pw.ts. Unit tests for the landing path and environment sort.
It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.
The organisation store now loads sorted projects without fetching environments for each project. Components retrieve environments through queries or ProjectStore where needed. Permissions components handle environment loading and error states. Project links open the project route, where a redirect selects a landing path from sorted environments. The changes also add sorting and landing-path utilities with tests, and update the end-to-end helper to wait for an environment URL.
The Create Environment page can offer a clone source from the previously viewed project after switching projects. Choosing one creates the environment in the wrong project. Failed environment loads also leave the clone selector and the feature-toggle confirmation without an error or retry. Fix the stale clone-source handling before merging; the failure-state gaps are smaller follow-ups.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
talissoncosta
changed the title
fix(Projects): Remove N+1 calls to get project environments
fix(projects): remove N+1 calls to get project environments
Nov 13, 2026
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
firefox › tests/user-permissions-test.pw.ts › User permissions dialogs › Manage user lists only the picked project's environments @enterprise
firefox › tests/user-permissions-test.pw.ts › User permissions dialogs › Inspect permissions lists only the picked project's environments @enterprise
❌ private-cloud · depot-ubuntu-latest-arm-16 — run #23423 (attempt 1)
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)
firefox › tests/user-permissions-test.pw.ts › User permissions dialogs › Manage user lists only the picked project's environments @enterprise
firefox › tests/user-permissions-test.pw.ts › User permissions dialogs › Inspect permissions lists only the picked project's environments @enterprise
❌ private-cloud · depot-ubuntu-latest-arm-16 — run #23424 (attempt 1)
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)
firefox › tests/user-permissions-test.pw.ts › User permissions dialogs › Manage user lists only the picked project's environments @enterprise
firefox › tests/user-permissions-test.pw.ts › User permissions dialogs › Inspect permissions lists only the picked project's environments @enterprise
✅ oss · depot-ubuntu-latest-arm-16 — run #23425 (attempt 1)
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)
The reason will be displayed to describe this comment to others. Learn more.
0 issues found across 5 files (changes from recent commits).
Confidence score: 5/5
Automated review surfaced no issues in the provided summaries.
No files require special attention.
Requires human review: Removes the per-project environments N+1 by loading environments on project open, but an acknowledged duplicate environments request per project open remains deferred; the request-cost tradeoff needs human sign-off.
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 6 files (changes from recent commits).
Confidence score: 3/5
In useEdgeIdentities.ts, Compare can briefly offer the wrong identities while the project is unresolved. Gate the identity selectors on isReady so they wait for the project to load.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="frontend/common/hooks/useEdgeIdentities.ts">
<violation number="1" location="frontend/common/hooks/useEdgeIdentities.ts:11">
P2: An unresolved project is treated as Core, so Compare can briefly load and offer the wrong identities before switching to Edge. Gate the identity selectors on `isReady` instead of using this value while the project is still loading.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Project cards link to /project/:id, which redirects to the first
environment by name, and the permission dialogs load the selected
project's environments themselves.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The loader used to finish after every project's environments loaded, which
also covered ProjectStore. Without the N+1 it finishes first, so pages
reading Edge from ProjectStore saw false on a direct load.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Zaimwa9 I've cut this PR down to the N+1 fix, as it had grown well past the issue.
The RTK Query moves, modal changes and other clean-ups are dropped, and I'll bring back what's worth it as separate PRs. Identities E2E coverage is in #9011.
The reason will be displayed to describe this comment to others. Learn more.
All reported issues were addressed across 7 files (changes from recent commits).
Requires human review: Auto-approval skipped because cubic reviewed only this push, not the earlier force-push. Comment @cubic review to review the whole pull request.
The reason will be displayed to describe this comment to others. Learn more.
All reported issues were addressed across 5 files (changes from recent commits).
Requires human review: Auto-approval skipped because cubic reviewed only this push, not the earlier force-push. Comment @cubic review to review the whole pull request.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fixfront-endIssue related to the React Front End Dashboard
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Closes #7949
Loading the organisation fetched environments for every project, only so project cards could link to the first one. Large organisations hit rate limits. Environments now load when a project is opened.
/project/:id;ProjectRedirectPageloads that project's environments and redirects to the first by name.EmptyStategetsstatus='error'andonRetry).ProjectStore: theApp.jsloader used to finish after every environment loaded, which also coveredProjectStore. Without the N+1 it finishes first, so it now waits for both.Chromatic:
EmptyState's default icon colour moves from#9DA4AEto thecolorIconSecondarytoken (a little darker in light mode), so every empty state shows a small change.How did you test this code?
environments/?project=delayed, identity pages and project settings load correctly.user-permissions-test.pw.ts. Unit tests for the landing path and environment sort.