Skip to content

fix(webapp): only load env var values for displayed environments#3903

Merged
ericallam merged 2 commits into
mainfrom
fix/env-vars-scope-values-to-visible-environments
Jun 11, 2026
Merged

fix(webapp): only load env var values for displayed environments#3903
ericallam merged 2 commits into
mainfrom
fix/env-vars-scope-values-to-visible-environments

Conversation

@ericallam

Copy link
Copy Markdown
Member

Summary

The environment variables page loaded every variable value in the project, unfiltered by environment. Archiving a preview branch does not delete its environment variable value rows, so projects that churn preview branches accumulate values forever, and every page view loaded all of them. On large projects this made the page loader take many seconds and stalled the server while deserializing the oversized result.

Fix

The presenter now loads the displayed environments first and filters the values relation to those environment IDs. That matches the display semantics exactly (per-user dev environments and active branch environments included), and the lookup is covered by the existing unique index on (variableId, environmentId). Values in archived branch environments are no longer fetched at all.

Covered by a new testcontainers test asserting that values from active environments (including branch environments) are returned while archived branch environments are excluded.

@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d534aa9

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

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fc330172-3698-492b-b03f-2d18649ad3dc

📥 Commits

Reviewing files that changed from the base of the PR and between bd3d417 and d534aa9.

📒 Files selected for processing (5)
  • .server-changes/env-vars-page-scope-values-to-visible-environments.md
  • apps/webapp/app/presenters/v3/EnvironmentVariablesPresenter.server.ts
  • apps/webapp/app/presenters/v3/environmentVariablesEnvironments.server.ts
  • apps/webapp/app/v3/environmentVariables/environmentVariablesRepository.server.ts
  • apps/webapp/test/EnvironmentVariablesPresenter.test.ts

Walkthrough

This PR optimizes the EnvironmentVariablesPresenter to load variable values only for environments displayed on the page. The presenter now computes the set of environment IDs to display immediately after loading environments, then uses this set to filter the Prisma query so only values for non-archived, visible environments are fetched. This prevents loading values created by archived preview branch environments. A new test validates the behavior by setting up production and preview environments, archiving one preview branch, and confirming the presenter excludes archived environment data from results.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description includes a clear Summary section explaining the problem and fix, and mentions the test coverage. However, it does not follow the provided template structure with required sections like Checklist, Testing steps, Changelog, and Screenshots. Reformat the description to follow the repository template: include the checklist, explicitly document testing steps taken, provide a concise changelog entry, and note if screenshots are needed.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(webapp): only load env var values for displayed environments' directly and clearly summarizes the main change—scoping environment variable value loading to only displayed environments instead of all values in the project.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/env-vars-scope-values-to-visible-environments

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


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.

@ericallam ericallam marked this pull request as ready for review June 11, 2026 14:59

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

The environment variables page loaded every value in the project,
including rows left behind by archived preview-branch environments,
which made the loader extremely slow for projects that churn branches.
The values relation is now filtered to the environments the page
actually displays.
@ericallam ericallam force-pushed the fix/env-vars-scope-values-to-visible-environments branch from bd3d417 to d534aa9 Compare June 11, 2026 18:10
@pkg-pr-new

pkg-pr-new Bot commented Jun 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@d534aa9

trigger.dev

npm i https://pkg.pr.new/trigger.dev@d534aa9

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@d534aa9

@trigger.dev/plugins

npm i https://pkg.pr.new/@trigger.dev/plugins@d534aa9

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@d534aa9

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@d534aa9

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@d534aa9

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@d534aa9

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@d534aa9

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@d534aa9

commit: d534aa9

@ericallam ericallam merged commit 8dc77c0 into main Jun 11, 2026
28 checks passed
@ericallam ericallam deleted the fix/env-vars-scope-values-to-visible-environments branch June 11, 2026 18:31
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.

2 participants