From 2d312791cb080723468af5aa14e50f5027c675bd Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 8 Apr 2026 09:40:42 -0700 Subject: [PATCH 1/2] Fix crash when selecting a repo with no branches When the GitHub API returns an empty branches array (e.g. for a newly created repo), BranchSelector would auto-select the defaultBranch even though it didn't exist in the list. This caused the Select component to receive a value with no matching SelectItem, crashing the page. Now we check that the defaultBranch exists in the branches array before auto-selecting, and show a helpful message when no branches are found. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/BranchSelector.tsx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/components/BranchSelector.tsx b/src/components/BranchSelector.tsx index 5a308b75..f22fe5a3 100644 --- a/src/components/BranchSelector.tsx +++ b/src/components/BranchSelector.tsx @@ -33,11 +33,17 @@ export function BranchSelector({ [onSelect] ); + const branches = data?.branches ?? []; + useEffect(() => { - if (data?.defaultBranch && !selectedBranch) { + if ( + data?.defaultBranch && + !selectedBranch && + branches.some((b) => b.name === data.defaultBranch) + ) { handleSelect(data.defaultBranch); } - }, [data, selectedBranch, handleSelect]); + }, [data, selectedBranch, branches, handleSelect]); if (isLoading) { return ( @@ -48,7 +54,16 @@ export function BranchSelector({ ); } - const branches = data?.branches || []; + if (branches.length === 0) { + return ( +
+ +

+ No branches found. The repository may be empty. +

+
+ ); + } return (
From c0b69fe23038153965ae35b6d075e5dd09f78c96 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 8 Apr 2026 09:51:20 -0700 Subject: [PATCH 2/2] Remove redundant branches dependency from useEffect Use data.branches directly inside the effect instead of the derived branches variable. Since branches is recomputed as a new [] on every render when data is undefined, including it in the dependency array caused unnecessary effect re-runs during loading. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/BranchSelector.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/BranchSelector.tsx b/src/components/BranchSelector.tsx index f22fe5a3..e1777c03 100644 --- a/src/components/BranchSelector.tsx +++ b/src/components/BranchSelector.tsx @@ -39,11 +39,11 @@ export function BranchSelector({ if ( data?.defaultBranch && !selectedBranch && - branches.some((b) => b.name === data.defaultBranch) + data.branches.some((b) => b.name === data.defaultBranch) ) { handleSelect(data.defaultBranch); } - }, [data, selectedBranch, branches, handleSelect]); + }, [data, selectedBranch, handleSelect]); if (isLoading) { return (