From c0fa3fea0d59ad0b167c713e9a52118d8450ab74 Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Thu, 13 Aug 2026 15:49:31 +0100 Subject: [PATCH 1/2] perf(webapp): bound environment loads in the env layout and batches list 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. --- apps/webapp/app/presenters/v3/BatchListPresenter.server.ts | 1 + .../route.tsx | 1 + 2 files changed, 2 insertions(+) diff --git a/apps/webapp/app/presenters/v3/BatchListPresenter.server.ts b/apps/webapp/app/presenters/v3/BatchListPresenter.server.ts index 6de786159a..4596b08f02 100644 --- a/apps/webapp/app/presenters/v3/BatchListPresenter.server.ts +++ b/apps/webapp/app/presenters/v3/BatchListPresenter.server.ts @@ -200,6 +200,7 @@ export class BatchListPresenter extends BasePresenter { select: { id: true, environments: { + where: { id: environmentId }, select: { id: true, type: true, diff --git a/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam/route.tsx b/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam/route.tsx index 1af9c9d9cf..50ac6f89f7 100644 --- a/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam/route.tsx +++ b/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam/route.tsx @@ -40,6 +40,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => { externalRef: true, organization: { select: { id: true, featureFlags: true } }, environments: { + where: { slug: envParam }, select: { id: true, type: true, From 225a99306b229bba2750e4bfc43a6b678e7305b0 Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Thu, 13 Aug 2026 15:50:10 +0100 Subject: [PATCH 2/2] docs: server-changes note for bounded env layout load --- .server-changes/bound-env-layout-environment-load.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .server-changes/bound-env-layout-environment-load.md diff --git a/.server-changes/bound-env-layout-environment-load.md b/.server-changes/bound-env-layout-environment-load.md new file mode 100644 index 0000000000..5c658a99e5 --- /dev/null +++ b/.server-changes/bound-env-layout-environment-load.md @@ -0,0 +1,6 @@ +--- +area: webapp +type: improvement +--- + +Dashboard pages load faster on projects with many preview branches by no longer loading every environment on each page.