fix(documents): FolderTreeSidebar surfaces fetch error state

Folder query failures previously rendered identically to an empty
list, hiding network problems from the user. Add an isError branch
that shows "Failed to load folders." in destructive color.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-10 11:53:21 +02:00
parent 104226f967
commit 1b441ca826

View File

@@ -25,12 +25,8 @@ interface FolderTreeSidebarProps {
* Designed for unlimited depth — only the top level renders by default
* so deep trees don't blow out the page; reps drill in by expanding.
*/
export function FolderTreeSidebar({
selectedFolderId,
onSelect,
footer,
}: FolderTreeSidebarProps) {
const { data: tree = [], isLoading } = useDocumentFolders();
export function FolderTreeSidebar({ selectedFolderId, onSelect, footer }: FolderTreeSidebarProps) {
const { data: tree = [], isLoading, isError } = useDocumentFolders();
return (
<aside className="w-full sm:w-60 shrink-0 border-r bg-muted/40 p-2">
@@ -54,6 +50,8 @@ export function FolderTreeSidebar({
<div className="mt-3 space-y-0.5">
{isLoading ? (
<p className="px-2 text-xs text-muted-foreground">Loading</p>
) : isError ? (
<p className="px-2 text-xs text-destructive">Failed to load folders.</p>
) : tree.length === 0 ? (
<p className="px-2 text-xs text-muted-foreground">No folders yet.</p>
) : (