perf(webapp): bound environment loads in the env layout and batches list - #4606
Conversation
Follow-up to #4595. The dominant emitter of the wide RuntimeEnvironment projectId-IN read is the environment-scoped layout loader (env.$envParam/route.tsx), which loaded every environment of a project on every dashboard page just to pick the one named in the URL. On preview-heavy projects that is hundreds of archived branch rows per page load. Scope it to the requested slug (where: { slug: envParam }), which resolves the current environment via the projectId_slug composite index and still allows viewing archived branches by slug. Also bound BatchListPresenter to the current environmentId, since every batch in the list already belongs to it.
|
|
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 (3)
📜 Recent review details⏰ Context from checks skipped due to timeout. (19)
🧰 Additional context used📓 Path-based instructions (8)**/*.{ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
{packages/core,apps/webapp}/**/*.{ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
apps/webapp/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)
Files:
apps/**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
apps/webapp/app/**/*.{ts,tsx}📄 CodeRabbit inference engine (apps/webapp/CLAUDE.md)
Files:
**/*.ts📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)
Files:
apps/webapp/app/**/*.ts📄 CodeRabbit inference engine (apps/webapp/CLAUDE.md)
Files:
🧠 Learnings (41)📓 Common learnings📚 Learning: 2026-07-26T13:14:02.968ZApplied to files:
📚 Learning: 2026-08-12T15:52:12.517ZApplied to files:
📚 Learning: 2026-02-11T16:50:14.167ZApplied to files:
📚 Learning: 2026-05-14T14:54:39.095ZApplied to files:
📚 Learning: 2026-08-08T17:53:29.534ZApplied to files:
📚 Learning: 2025-12-08T15:19:56.823ZApplied to files:
📚 Learning: 2026-02-10T16:18:48.654ZApplied to files:
📚 Learning: 2026-04-02T20:25:54.203ZApplied to files:
📚 Learning: 2026-04-01T13:27:35.831ZApplied to files:
📚 Learning: 2026-07-26T20:37:56.220ZApplied to files:
📚 Learning: 2026-07-26T20:37:50.445ZApplied to files:
📚 Learning: 2026-02-03T18:27:40.429ZApplied to files:
📚 Learning: 2026-05-14T08:21:10.439ZApplied to files:
📚 Learning: 2026-07-22T11:16:06.546ZApplied to files:
📚 Learning: 2026-02-11T16:37:32.429ZApplied to files:
📚 Learning: 2026-07-28T21:57:20.061ZApplied to files:
📚 Learning: 2026-03-22T13:26:12.060ZApplied to files:
📚 Learning: 2026-03-22T19:24:14.403ZApplied to files:
📚 Learning: 2026-05-18T08:21:27.694ZApplied to files:
📚 Learning: 2026-05-18T08:21:27.694ZApplied to files:
📚 Learning: 2026-06-13T19:53:13.759ZApplied to files:
📚 Learning: 2026-06-17T17:13:49.929ZApplied to files:
📚 Learning: 2026-06-23T13:04:21.413ZApplied to files:
📚 Learning: 2026-04-02T19:18:26.255ZApplied to files:
📚 Learning: 2026-05-12T21:04:00.184ZApplied to files:
📚 Learning: 2026-05-08T21:00:20.973ZApplied to files:
📚 Learning: 2026-06-25T18:21:55.847ZApplied to files:
📚 Learning: 2026-05-12T21:04:05.815ZApplied to files:
📚 Learning: 2026-06-25T18:21:51.905ZApplied to files:
📚 Learning: 2026-07-03T17:10:21.498ZApplied to files:
📚 Learning: 2026-06-25T18:21:54.729ZApplied to files:
📚 Learning: 2026-08-12T19:02:33.898ZApplied to files:
📚 Learning: 2026-07-13T14:51:11.844ZApplied to files:
📚 Learning: 2026-04-15T15:39:31.575ZApplied to files:
📚 Learning: 2026-06-06T09:22:01.985ZApplied to files:
📚 Learning: 2026-02-06T19:53:38.843ZApplied to files:
📚 Learning: 2026-05-05T09:38:02.512ZApplied to files:
📚 Learning: 2026-06-04T18:16:35.386ZApplied to files:
📚 Learning: 2026-06-09T17:58:04.699ZApplied to files:
📚 Learning: 2026-06-21T05:35:23.468ZApplied to files:
🔇 Additional comments (3)
WalkthroughThe project lookup now filters related environments by 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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 |
Summary
Follow-up to #4595. Dashboard pages under an environment loaded every environment in the project on each page just to resolve the one named in the URL. On projects with many preview branches that meant reading hundreds of (mostly archived) rows on every page load.
Fix
The environment-scoped layout loader now scopes its lookup to the slug in the URL (
where: { slug: envParam }), resolving the current environment through theprojectId, slugcomposite index instead of loading the whole project. Archived branches stay viewable by slug.BatchListPresenteris bounded to the current environment, since every batch in that list already belongs to it.Verified on a project seeded with 2,000 archived branch environments: the layout lookup drops from all environments to one, and both a normal environment page and an archived branch page render correctly.