Fix crash when selecting a repo with no branches#331
Merged
brendanlong merged 2 commits intomainfrom Apr 10, 2026
Merged
Conversation
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) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request enhances the BranchSelector component by ensuring the default branch is only selected if it exists within the retrieved branch list and by adding a user-friendly message when no branches are found. A review comment identifies a potential performance issue where including a derived array in the useEffect dependency array could cause unnecessary re-renders, suggesting a more direct access to the data object instead.
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) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
brendanlong/personal-agent-skills) with no branches, the New Session page would crash{"branches":[],"defaultBranch":"main"}— BranchSelector would auto-select "main" even though it didn't exist in the empty branches list, causing the Select component to crashdefaultBranchactually exists in the branches array before auto-selectingTest plan
🤖 Generated with Claude Code