fix: improve UX for empty repositories (#821) #836
+54
−2
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.
Fix: Improve UX for empty repositories
Fixes #821
Problem
When viewing an empty repository, Sourcebot displayed generic error messages like "Error loading tree preview" or "Error loading file tree". This confused users by suggesting sync issues or internal errors when the repository simply had no commits yet.
Solution
This PR improves the user experience by:
Detecting empty repositories through revision verification
Displaying clear, user-friendly empty state UI
Replacing misleading error messages with helpful context
Changes Made
Added git rev-parse --verify checks in both getTree() and getFolderContents()
Gracefully handles empty repositories by returning empty data structures instead of throwing errors
Added empty state UI with FolderOpen icon
Displays "No files yet" message with explanatory text
Only shown when tree has no children (distinct from loading or error states)
Added empty state UI for folder preview
Shows "No commits yet" message with helpful context
Maintains PathHeader for navigation consistency
Added null check to prevent rendering errors
Safely handles nodes with no children
User Experience
Before: Generic error message suggesting a problem
After: Clear "No commits yet" / "No files yet" message with folder icon
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.