Skip to content

Conversation

@Naresh-official
Copy link

@Naresh-official Naresh-official commented Feb 1, 2026

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

  1. Backend - Revision Verification (api.ts)
    Added git rev-parse --verify checks in both getTree() and getFolderContents()
    Gracefully handles empty repositories by returning empty data structures instead of throwing errors
  2. File Tree Panel (fileTreePanel.tsx)
    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)
  3. Tree Preview Panel (treePreviewPanel.tsx)
    Added empty state UI for folder preview
    Shows "No commits yet" message with helpful context
    Maintains PathHeader for navigation consistency
  4. Pure File Tree Panel (pureFileTreePanel.tsx)
    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

Screenshot from 2026-02-01 13-19-38

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of empty file trees and commit histories with user-friendly empty-state messaging
    • Enhanced robustness when accessing folder contents and revision data to prevent rendering errors

✏️ Tip: You can customize this high-level summary in your review settings.

- Add empty state UI with clear messaging in file tree and preview panels
- Implement revision verification to gracefully handle empty repos
- Replace generic error messages with user-friendly 'No commits yet' state
- Add FolderOpen icon and helpful text for empty repository indication
- Prevent rendering errors when repository has no children nodes

Fixes sourcebot-dev#821
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 1, 2026

Walkthrough

This PR enhances empty repository UX by adding detection and user-friendly empty-state messages. It implements revision verification in the file tree API, and conditionally renders empty-state UI components in the tree preview panel and file tree panel when repositories contain no commits or files. Additionally, it adds a guard condition in tree rendering to handle nodes without children.

Changes

Cohort / File(s) Summary
Empty-state UI rendering
packages/web/src/app/[domain]/browse/[...path]/components/treePreviewPanel.tsx, packages/web/src/features/fileTree/components/fileTreePanel.tsx
Added FolderOpen icon imports and conditional empty-state UI blocks that display "No commits yet" or similar messages when folder contents or file tree data is empty.
Revision verification
packages/web/src/features/fileTree/api.ts
Added git rev-parse verification in getTree and getFolderContents to detect empty revisions, returning empty data structures when revision is non-existent.
Tree rendering guard
packages/web/src/features/fileTree/components/pureFileTreePanel.tsx
Added null-check guard in renderTree to short-circuit when a node has no children, preventing iteration over undefined or empty child arrays.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #341: Modifies fileTreePanel.tsx with empty-state UI handling alongside other file-tree panel enhancements, sharing the same component modification pattern.
  • PR #617: Modifies file tree API and related type usage patterns for tree/folder content retrieval, overlapping with API-level changes.
  • PR #739: Modifies packages/web/src/features/fileTree/api.ts to adjust getFolderContents and getTree behavior, directly overlapping with revision handling logic.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: improving UX for empty repositories, which is the primary focus of all code modifications.
Linked Issues check ✅ Passed The PR successfully implements all coding objectives from issue #821: detecting empty repositories via git rev-parse verification, displaying clear empty-state UIs with folder icons and user-friendly messages instead of errors, and handling edge cases safely.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the empty repository UX issue; no unrelated modifications to other features or areas were introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR] Improve UX for empty repositories

1 participant