From ce46c8d2cf3b26c7a01279b537d66df9a1f36745 Mon Sep 17 00:00:00 2001 From: Chris Arderne Date: Fri, 17 Jul 2026 16:36:29 +0100 Subject: [PATCH 1/3] fix: only count preview branches toward the preview branch limit The Limits page counted development branches toward the preview-branch limit, showing inflated and sometimes over-limit values. Filter the count on type PREVIEW with a parent environment to mirror checkBranchLimit. Closes #4281 --- .server-changes/fix-preview-branch-limit-count.md | 6 ++++++ apps/webapp/app/presenters/v3/LimitsPresenter.server.ts | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .server-changes/fix-preview-branch-limit-count.md diff --git a/.server-changes/fix-preview-branch-limit-count.md b/.server-changes/fix-preview-branch-limit-count.md new file mode 100644 index 00000000000..aae94b08f4c --- /dev/null +++ b/.server-changes/fix-preview-branch-limit-count.md @@ -0,0 +1,6 @@ +--- +area: webapp +type: fix +--- + +The "Preview branches" usage on the Limits page now counts only preview branches, so it no longer includes development branches or show over-limit values. diff --git a/apps/webapp/app/presenters/v3/LimitsPresenter.server.ts b/apps/webapp/app/presenters/v3/LimitsPresenter.server.ts index cbf3abc5ce3..92ee01bacab 100644 --- a/apps/webapp/app/presenters/v3/LimitsPresenter.server.ts +++ b/apps/webapp/app/presenters/v3/LimitsPresenter.server.ts @@ -151,11 +151,14 @@ export class LimitsPresenter extends BasePresenter { }, }); - // Get active branches count for this org (uses @@index([organizationId])) + // Get active preview branches count for this org (uses @@index([organizationId])) + // Mirror checkBranchLimit: only PREVIEW branches (exclude the branchable parent). + // DEVELOPMENT branches have a separate limit and must not be counted here. const activeBranchCount = await this._replica.runtimeEnvironment.count({ where: { projectId, - branchName: { + type: "PREVIEW", + parentEnvironmentId: { not: null, }, archivedAt: null, From 7854acaf3d1e70a72f3fadaad3251ca2fc613bea Mon Sep 17 00:00:00 2001 From: Chris Arderne Date: Fri, 17 Jul 2026 16:39:06 +0100 Subject: [PATCH 2/3] chore: remove added comments --- apps/webapp/app/presenters/v3/LimitsPresenter.server.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/webapp/app/presenters/v3/LimitsPresenter.server.ts b/apps/webapp/app/presenters/v3/LimitsPresenter.server.ts index 92ee01bacab..e468efd9217 100644 --- a/apps/webapp/app/presenters/v3/LimitsPresenter.server.ts +++ b/apps/webapp/app/presenters/v3/LimitsPresenter.server.ts @@ -151,9 +151,7 @@ export class LimitsPresenter extends BasePresenter { }, }); - // Get active preview branches count for this org (uses @@index([organizationId])) - // Mirror checkBranchLimit: only PREVIEW branches (exclude the branchable parent). - // DEVELOPMENT branches have a separate limit and must not be counted here. + // Get active branches count for this org (uses @@index([organizationId])) const activeBranchCount = await this._replica.runtimeEnvironment.count({ where: { projectId, From d1451764f9111ab5c470f2df612ecb17244f0a64 Mon Sep 17 00:00:00 2001 From: Chris Arderne Date: Fri, 17 Jul 2026 16:40:08 +0100 Subject: [PATCH 3/3] Update fix-preview-branch-limit-count.md --- .server-changes/fix-preview-branch-limit-count.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.server-changes/fix-preview-branch-limit-count.md b/.server-changes/fix-preview-branch-limit-count.md index aae94b08f4c..d5f5b26d74d 100644 --- a/.server-changes/fix-preview-branch-limit-count.md +++ b/.server-changes/fix-preview-branch-limit-count.md @@ -3,4 +3,4 @@ area: webapp type: fix --- -The "Preview branches" usage on the Limits page now counts only preview branches, so it no longer includes development branches or show over-limit values. +The "Preview branches" usage on the Limits page now counts only preview branches.