| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
The browse file-tree panel previously rendered a blank scroll area when the folder contents were empty (e.g. for a freshly-created, uncommitted repository) and the generic "Error loading tree preview" text for service errors — including 404s from a typo in the repo name. Both are unhelpful. Three changes: - `pureTreePreviewPanel.tsx`: render a centered "This directory is empty." message when `items.length === 0`. The same component covers both the sub-directory case (path != '') and the repo-root case (path == ''), because a repo is just a directory at the root. - `treePreviewPanelClient.tsx`: when the folder-contents response is `[]` AND `path === ''`, render a more emphatic "This repository is empty." message (no path header, no separator) that takes the full panel. The sub-directory case still falls through to PureTreePreviewPanel with the "directory" copy. This avoids showing a path header for a non-existent root and matches the user's intent of distinguishing "no files in this repo" from "no files in this sub-directory". - `treePreviewPanel.tsx`: distinguish 404 from other service errors on `getRepoInfoByName`. A 404 means the user hit a typo in a repo name (or a config that's no longer indexed) and now shows "Repository not found." instead of the generic error text. Other status codes keep the existing "Error loading tree preview". Fixes #1530 (and addresses the user-reported screenshots in #821).
Adds `pureTreePreviewPanel.test.tsx` with one vitest case asserting
that the component renders the "This directory is empty." message
when `items={[]}`. The real FileTreeItemComponent is stubbed to a
plain `<li>` since the test only exercises the empty-state branch
(not the list rendering, which has its own coverage via the
end-to-end browse flow).
Plus a one-line CHANGELOG entry under [Unreleased] -> Fixed.
Refs #1530.
WalkthroughThe browse tree preview now shows dedicated messages for empty repositories, empty paths, and missing repositories. Tests cover empty and error states, and the changelog records the updated behavior. ChangesTree preview state handling
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant TreePreviewPanel
participant TreePreviewPanelClient
participant PureTreePreviewPanel
participant FileTree
TreePreviewPanel->>TreePreviewPanelClient: Render repository tree preview
TreePreviewPanelClient->>TreePreviewPanelClient: Check folder contents and path
alt Root path with no items
TreePreviewPanelClient-->>TreePreviewPanelClient: Render "This repository is empty."
else Non-root path with no items
TreePreviewPanelClient->>PureTreePreviewPanel: Pass empty items
PureTreePreviewPanel-->>TreePreviewPanelClient: Render empty-path message
else Non-empty path
TreePreviewPanelClient->>PureTreePreviewPanel: Pass file tree items
PureTreePreviewPanel->>FileTree: Render items
end
alt Repository lookup returns NOT_FOUND
TreePreviewPanel-->>TreePreviewPanel: Render "Repository not found."
end
Possibly related PRs
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. ❤️ ShareComment @coderabbitai help to get the list of available commands. |
Sorry, something went wrong.
There was a problem hiding this comment.
packages/web/src/app/(app)/browse/[...path]/components/treePreviewPanel/pureTreePreviewPanel.test.tsx (1)🤖 Prompt for all review comments with AI agents28-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Add tests for the other new branches.
This test exercises only PureTreePreviewPanel. It does not detect regressions in the root branch that omits PathHeader and Separator, or in the NOT_FOUND branch that renders Repository not found.. Add focused tests for the root empty response, NOT_FOUND, and non-404 service errors.
🤖 Prompt for AI AgentsVerify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/web/src/app/`(app)/browse/[...path]/components/treePreviewPanel/pureTreePreviewPanel.test.tsx around lines 28 - 39, Add focused tests covering the remaining empty-state branches in the relevant tree preview panel test suite: verify the root empty response omits PathHeader and Separator, the NOT_FOUND response renders “Repository not found.”, and a non-404 service error follows its expected error behavior. Reuse the existing render/wrap helpers and assertions without changing the current directory-empty test.
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Nitpick comments: In `@packages/web/src/app/`(app)/browse/[...path]/components/treePreviewPanel/pureTreePreviewPanel.test.tsx: - Around line 28-39: Add focused tests covering the remaining empty-state branches in the relevant tree preview panel test suite: verify the root empty response omits PathHeader and Separator, the NOT_FOUND response renders “Repository not found.”, and a non-404 service error follows its expected error behavior. Reuse the existing render/wrap helpers and assertions without changing the current directory-empty test.
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cea463fb-85ac-4dae-bc40-d9a8ac6d69a5
📥 CommitsReviewing files that changed from the base of the PR and between 39bf1a0 and b176c63.
📒 Files selected for processing (5)
Sorry, something went wrong.
Bugbot finding on PR #1531: the previous copy "This directory is empty." was misleading because `git ls-tree` returns empty output for both an empty directory AND a path that doesn't exist in the tree (typo, deleted, etc.). A user navigating to a non-existent path would be told the directory is empty when in fact the path was never found. Switch to "This path has no contents in this revision." which is intentionally ambiguous — we can't tell the cases apart at this layer. The user can verify the path by looking at the repo on the code host. The root-path case ("This repository is empty.") is unchanged: a path of `''` is unambiguously the repo root, so the stronger "empty repo" copy is still accurate. Updated the test and the CHANGELOG entry to match the new copy. Refs #1531.
|
Bugbot finding addressed in 43f29491: The previous copy "This directory is empty." was misleading because git ls-tree returns empty output for both an empty directory AND a path that doesn't exist in the tree. A user navigating to a non-existent path would have been told the directory is empty when the path was never found. Switched to "This path has no contents in this revision." which is intentionally ambiguous — we can't tell the cases apart at this layer. The user can verify the path by looking at the repo on the code host. The root-path case ("This repository is empty.") is unchanged: a path of '' is unambiguously the repo root, so the stronger copy is still accurate there. Test + CHANGELOG updated to match the new copy. 1/1 treePreview test passes; full suite 998/998. |
Sorry, something went wrong.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 43f2949. Configure here.
Sorry, something went wrong.
| <p className="text-xs"> | ||
| Once a commit lands on the default branch, its files will appear here. | ||
| </p> | ||
| </div> |
There was a problem hiding this comment.
Medium Severity
The new root empty-state UI runs whenever folderContentsResponse is [] and path === '', but the fetch uses the browse URL’s revisionName (or HEAD). An empty tree at that ref still shows “This repository is empty.” and copy about the default branch, even when the repo has files on other refs or the user is viewing a non-default revision.
Reviewed by Cursor Bugbot for commit 43f2949. Configure here.
Sorry, something went wrong.
…viewPanelClient CodeRabbit nitpick on PR #1531: the original test only covered PureTreePreviewPanel (the directory-empty case). Add focused tests for the two other new branches in treePreviewPanelClient: - Renders the "This repository is empty." message at the root path when the folder-contents response is `[]` AND `path === ''`. Asserts that the PathHeader and Separator are NOT rendered (the root empty-state takes the full panel). - Renders the "Error loading tree preview" message on a non-404 service error. The folder-contents client returns the service error object for any non-NOT_FOUND error, and the component keeps the existing copy for that case. The third new branch (NOT_FOUND in treePreviewPanel.tsx) is in a server component that imports the prisma client at module load — testing it would require mocking prisma and the `getRepoInfoByName` action, which is heavy infrastructure for a one-line branch. The NOT_FOUND case is covered by the existing pattern in the rest of the browse UI and is the same message that's used for "repo not found" elsewhere. 3/3 treePreview tests pass; full suite 999/999 (1 new test since the 998 baseline). Refs #1531.
|
CodeRabbit nitpick addressed in 15550f2e: Added two more vitest cases covering the remaining new branches in treePreviewPanelClient.tsx:
Skipped: the NOT_FOUND branch in treePreviewPanel.tsx is a server component that imports the prisma client at module load. Testing it would require mocking prisma and the getRepoInfoByName action, which is heavy infrastructure for a one-line branch. The NOT_FOUND case is covered by the existing pattern in the rest of the browse UI and is the same message that's used for "repo not found" elsewhere. 3/3 treePreview tests pass; full suite 999/999. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
The browse file-tree panel previously rendered a blank scroll area when the folder contents were empty (e.g. for a freshly-created, uncommitted repository) and the generic "Error loading tree preview" text for service errors — including 404s from a typo in the repo name. Both are unhelpful.
Three changes that distinguish the cases and surface user-friendly messages:
Fixes #1530 (and addresses the user-reported screenshots in #821).
Files
Why this is in scope
The user-facing issue is reported as confusing UX for an empty repository. The fix is purely a UI change — the data layer (getFolderContents) already returns [] for empty repos, and the getRepoInfoByName 404 is a real user-facing condition (typo, missing config) that's been confused with a sync error. No API, no schema, no migration.
Why three messages, not one
A single "This folder has no items" message would lose the distinction between the three cases the user is likely to encounter:
Test coverage
1 vitest case in pureTreePreviewPanel.test.tsx:
The test stubs useIsMobile and usePathname (the latter to keep the route context stable; the empty-state branch doesn't read either, but the wrapping SidebarProvider does for the resize listener). The other heavy hooks the panel uses are pulled in via the import path but not exercised by the empty-state branch.
1/1 test pass; full suite 998/998 (the 7 pre-existing OTel-setup failures in ee/askmcp/... and ee/permissionSyncStatus/... are unchanged by this PR).
Backward compatibility
Pure UI change. The data layer is unchanged — same API responses, same shape, same error codes. Only the rendered text changes for the three empty/error cases. Existing users on non-empty repos see no change.
Risks
Minimal. The empty-state messages don't conflict with any existing copy. The 404 distinction is a small UX win. The "Once a commit lands..." copy is informative without being alarming.
Future work
Note
Low Risk
Browse UI copy and conditional rendering only; APIs and data shapes are unchanged.
Overview
Improves browse file-tree UX when folder data is missing or empty, instead of a blank panel or a single generic error.
TreePreviewPanel now shows "Repository not found." when getRepoInfoByName returns NOT_FOUND; other service errors still use "Error loading tree preview".
TreePreviewPanelClient treats an empty folder list at the repo root (path === '') as a dedicated full-panel state: "This repository is empty." plus guidance that files appear after a commit on the default branch (no path header).
PureTreePreviewPanel shows "This path has no contents in this revision." when items is empty (sub-path tree view). The copy is deliberately vague because empty dirs and missing paths both look like [] from git ls-tree.
Vitest coverage was added for the empty-root and non-404 error paths on the client, and for the pure panel empty list. CHANGELOG documents the fix (#1530).
Reviewed by Cursor Bugbot for commit 15550f2. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
New Features
Tests