fix: make file tree loading more reliable

Avoid gitignore filtering during folder browsing
Show folder load errors instead of empty folders
Add timeout fallback for gitignore checks
This commit is contained in:
Bohdan Triapitsyn
2026-06-05 18:58:50 +03:00
parent 3e0a105dfe
commit de0ebbac8b
5 changed files with 146 additions and 16 deletions
@@ -419,14 +419,13 @@ export const SidebarFilesTree: React.FC = () => {
inFlightDirsRef.current = new Set(inFlightDirsRef.current);
inFlightDirsRef.current.add(normalizedDir);
const respectGitignore = !showGitignored;
const listPromise = files.listDirectory
? files.listDirectory(normalizedDir, { respectGitignore }).then((result) => result.entries.map((entry) => ({
? files.listDirectory(normalizedDir).then((result) => result.entries.map((entry) => ({
name: entry.name,
path: entry.path,
isDirectory: entry.isDirectory,
})))
: opencodeClient.listLocalDirectory(normalizedDir, { respectGitignore }).then((result) => result.map((entry) => ({
: opencodeClient.listLocalDirectory(normalizedDir).then((result) => result.map((entry) => ({
name: entry.name,
path: entry.path,
isDirectory: entry.isDirectory,
@@ -458,7 +457,7 @@ export const SidebarFilesTree: React.FC = () => {
inFlightDirsRef.current = new Set(inFlightDirsRef.current);
inFlightDirsRef.current.delete(normalizedDir);
});
}, [files, mapDirectoryEntries, showGitignored]);
}, [files, mapDirectoryEntries]);
const refreshRoot = React.useCallback(async () => {
if (!root) return;
@@ -809,6 +808,15 @@ export const SidebarFilesTree: React.FC = () => {
/>
{isDir && isExpanded && (
<ul className="flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative">
{loadErrorsByDir[node.path] ? (
<li className="flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground">
<span className="min-w-0 flex-1 truncate text-[var(--status-error)]" title={loadErrorsByDir[node.path]}>{loadErrorsByDir[node.path]}</span>
<Button variant="ghost" size="xs" className="h-6 gap-1" onClick={() => void refreshDirectory(node.path)}>
<Icon name="refresh" className="h-3.5 w-3.5" />
{t('sidebarFilesTree.actions.refreshTitle')}
</Button>
</li>
) : null}
{renderTree(node.path, depth + 1)}
</ul>
)}