From 81d631ea722f3c063220778381f6843a4a08e5dc Mon Sep 17 00:00:00 2001 From: Cody Seibert Date: Thu, 18 Dec 2025 17:53:37 -0500 Subject: [PATCH] fix: address PR review comments - Fix branch fallback logic: use nullish coalescing (??) instead of || to handle empty strings correctly (empty string represents unassigned features, not main branch) - Refactor branchCardCounts calculation: use reduce instead of forEach for better conciseness and readability - Fix badge semantics in BranchAutocomplete: check branchCardCounts !== undefined first to ensure numeric badges (including 0) only appear when actual count data exists, while 'default' is reserved for when count data is unavailable --- apps/app/src/components/ui/branch-autocomplete.tsx | 4 ++-- apps/app/src/components/views/board-view.tsx | 12 ++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/apps/app/src/components/ui/branch-autocomplete.tsx b/apps/app/src/components/ui/branch-autocomplete.tsx index 1dbd32f0..7b2b5bd5 100644 --- a/apps/app/src/components/ui/branch-autocomplete.tsx +++ b/apps/app/src/components/ui/branch-autocomplete.tsx @@ -33,8 +33,8 @@ export function BranchAutocomplete({ return Array.from(branchSet).map((branch) => { const cardCount = branchCardCounts?.[branch]; // Show card count if available, otherwise show "default" for main branch only - const badge = cardCount !== undefined - ? String(cardCount) + const badge = branchCardCounts !== undefined + ? String(cardCount ?? 0) : branch === "main" ? "default" : undefined; diff --git a/apps/app/src/components/views/board-view.tsx b/apps/app/src/components/views/board-view.tsx index 9cc23636..b1b64247 100644 --- a/apps/app/src/components/views/board-view.tsx +++ b/apps/app/src/components/views/board-view.tsx @@ -272,17 +272,13 @@ export function BoardView() { // Calculate unarchived card counts per branch const branchCardCounts = useMemo(() => { - const counts: Record = {}; - - // Count unarchived features (status !== "completed") per branch - hookFeatures.forEach((feature) => { + return hookFeatures.reduce((counts, feature) => { if (feature.status !== "completed") { - const branch = feature.branchName || "main"; + const branch = feature.branchName ?? "main"; counts[branch] = (counts[branch] || 0) + 1; } - }); - - return counts; + return counts; + }, {} as Record); }, [hookFeatures]); // Custom collision detection that prioritizes columns over cards