Skip to content

fix: nested hidden folders not showing when 'Show Hidden Files' enabled#1213

Closed
michaelgold3n wants to merge 1 commit into
superset-sh:mainfrom
michaelgold3n:fix/nested-hidden-files
Closed

fix: nested hidden folders not showing when 'Show Hidden Files' enabled#1213
michaelgold3n wants to merge 1 commit into
superset-sh:mainfrom
michaelgold3n:fix/nested-hidden-files

Conversation

@michaelgold3n
Copy link
Copy Markdown

@michaelgold3n michaelgold3n commented Feb 5, 2026

Problem

Fixes #1193

When toggling 'Show Hidden Files' in the file browser, hidden folders at the root level would correctly appear, but nested hidden folders inside non-hidden directories would not show.

Root Cause

The useFileTree hook caches children of expanded folders in childrenCache. When showHiddenFiles changed, the root directory query correctly re-fetched with includeHidden: true, but the cached children of expanded folders were not invalidated. This meant nested directories kept using stale cached data that was fetched without hidden files.

Solution

Added a useEffect that clears childrenCache whenever showHiddenFiles changes. This ensures all nested directories will be re-fetched with the correct includeHidden setting when the toggle is changed.

Testing

  • Toggle 'Show Hidden Files' now correctly shows/hides hidden folders at all nesting levels

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where nested hidden files and folders would not display correctly when toggling the show hidden files setting. The file tree now properly refreshes when this preference changes.

Fixes superset-sh#1193

The file tree was not showing nested hidden folders/files when
'Show Hidden Files' was toggled on because the childrenCache was
not invalidated when the showHiddenFiles setting changed.

When a folder's children were loaded with showHiddenFiles=false,
they got cached. When the user toggled showHiddenFiles to true,
the cached children were reused without re-fetching, so hidden
files/folders in nested directories didn't appear.

This fix adds a useEffect that clears the childrenCache whenever
showHiddenFiles changes, ensuring nested directories are re-fetched
with the correct includeHidden setting.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

This change fixes a bug where nested hidden files and folders were not displayed when the "Show Hidden Files" toggle was enabled. A useEffect hook has been added to clear the children cache whenever the showHiddenFiles setting changes, forcing the file tree to recompute and properly respect the visibility setting at all nesting levels.

Changes

Cohort / File(s) Summary
File Tree Cache Invalidation
apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/hooks/useFileTree.ts
Adds useEffect to clear childrenCache when showHiddenFiles toggle changes, ensuring nested hidden items are correctly shown/hidden during tree recomputation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A cache cleared, a secret unfurled,
Nested gems now shown to the world,
No more hiding in folders deep,
The toggle keeps promises it should keep!

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main fix: addressing nested hidden folders not showing when the 'Show Hidden Files' feature is enabled.
Description check ✅ Passed The PR description provides a clear problem statement, root cause analysis, and solution explanation. However, it deviates from the provided template structure and missing sections like Type of Change and Screenshots sections.
Linked Issues check ✅ Passed The PR implementation directly addresses issue #1193 by clearing the childrenCache when showHiddenFiles changes, ensuring nested hidden folders are re-fetched with correct settings.
Out of Scope Changes check ✅ Passed The changes are narrowly scoped to fixing the specific issue with nested hidden files; the addition of useEffect to invalidate childrenCache is directly related to the stated problem and solution.

✏️ 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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/hooks/useFileTree.ts`:
- Around line 59-63: When showHiddenFiles toggles you clear children cache but
in-flight loadChildren calls can still overwrite it; add an epoch guard: create
a mutable epoch ref (e.g., childrenCacheEpochRef) incremented inside the
useEffect that currently calls setChildrenCache({}) and capture the current
epoch when invoking loadChildren in whatever function triggers async loads;
before calling setChildrenCache (or any state update with load results) verify
the captured epoch matches childrenCacheEpochRef.current and ignore the results
if they differ. Update references to loadChildren, setChildrenCache, and the
useEffect that watches showHiddenFiles to use this epoch check so stale
responses don’t repopulate the cleared cache.

Comment on lines +59 to +63
// Clear children cache when showHiddenFiles changes to ensure nested
// hidden files/folders are properly shown or hidden
useEffect(() => {
setChildrenCache({});
}, [showHiddenFiles]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/hooks/useFileTree.ts

Repository: superset-sh/superset

Length of output: 4434


Guard against in‑flight loads repopulating stale cache after toggle.

When showHiddenFiles changes, the cache is cleared but any loadChildren request already in flight can still resolve and overwrite the cleared cache with results fetched using the old includeHidden value. Add an epoch guard to ensure stale in-flight results are ignored.

🛠️ Suggested epoch guard to ignore stale results
-import { useCallback, useEffect, useMemo, useState } from "react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
 const [childrenCache, setChildrenCache] = useState<
 	Record<string, FileTreeNode[]>
 >({});
+const cacheEpochRef = useRef(0);
 useEffect(() => {
+	cacheEpochRef.current += 1;
 	setChildrenCache({});
 }, [showHiddenFiles]);
 const loadChildren = useCallback(
 	async (nodeId: string, nodePath: string): Promise<FileTreeNode[]> => {
 		if (!worktreePath) return [];
+		const requestEpoch = cacheEpochRef.current;
@@
-			setChildrenCache((prev) => ({
-				...prev,
-				[nodeId]: childNodes,
-			}));
+			if (requestEpoch === cacheEpochRef.current) {
+				setChildrenCache((prev) => ({
+					...prev,
+					[nodeId]: childNodes,
+				}));
+			}
🤖 Prompt for AI Agents
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/hooks/useFileTree.ts`
around lines 59 - 63, When showHiddenFiles toggles you clear children cache but
in-flight loadChildren calls can still overwrite it; add an epoch guard: create
a mutable epoch ref (e.g., childrenCacheEpochRef) incremented inside the
useEffect that currently calls setChildrenCache({}) and capture the current
epoch when invoking loadChildren in whatever function triggers async loads;
before calling setChildrenCache (or any state update with load results) verify
the captured epoch matches childrenCacheEpochRef.current and ignore the results
if they differ. Update references to loadChildren, setChildrenCache, and the
useEffect that watches showHiddenFiles to use this epoch check so stale
responses don’t repopulate the cleared cache.

@michaelgold3n
Copy link
Copy Markdown
Author

Closing - submitted in error. Apologies!

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.

[bug] nested hidden folders do not show even when "Show Hidden Files" is enabled

1 participant