Skip to content

fix(desktop): fix show hidden files toggle being inverted on first use#1229

Merged
Kitenite merged 1 commit into
superset-sh:mainfrom
Kitenite:kitenite/show-hide-toggle-is-wrong-first-time
Feb 5, 2026
Merged

fix(desktop): fix show hidden files toggle being inverted on first use#1229
Kitenite merged 1 commit into
superset-sh:mainfrom
Kitenite:kitenite/show-hide-toggle-is-wrong-first-time

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Feb 5, 2026

Summary

  • Fixed the "Show Hidden Files" toggle in the file explorer being inverted on first use — clicking it would fetch with the previous toggle value, making the tree always one step behind
  • Root cause: FilesView used local useState(false) with a ref-based workaround to pass state into the headless-tree data loader. When invalidateChildrenIds() fired synchronously in the click handler, the ref was still stale (only updated during React render)
  • Switched to useFileExplorerStore (Zustand) which updates synchronously, and read getState().showHiddenFiles directly in the data loader to avoid stale ref issues
  • Bonus: the show hidden files preference now persists across sessions

Test plan

  • Open the file explorer sidebar (Files tab)
  • Click the show/hide hidden files toggle (eye icon)
  • Verify hidden files (dotfiles) appear/disappear correctly on the first click
  • Verify subsequent toggles continue to work correctly
  • Close and reopen the app — verify the hidden files preference is preserved

Summary by CodeRabbit

  • Refactor
    • Improved internal state management for file visibility settings to use a centralized store, ensuring consistent behavior across the application.

FilesView used local useState(false) for showHiddenFiles instead of the
persisted useFileExplorerStore. The data loader read this value via a ref
that was only updated during React render, so when invalidateChildrenIds()
fired synchronously in the click handler, the tree always fetched with the
previous toggle value.

Switch to useFileExplorerStore which updates synchronously via Zustand's
set(), and read getState().showHiddenFiles directly in the data loader
to avoid stale ref issues. This also persists the preference across
sessions.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 5, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The PR migrates showHiddenFiles state management from local component state to a centralized file-explorer store. Handlers are updated to use the store's toggle function, and directory-loading logic now reads includeHidden from the store instead of local state.

Changes

Cohort / File(s) Summary
State Centralization
apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/FilesView.tsx
Replaces local showHiddenFiles state and ref with useFileExplorerStore hook; updates toggle handlers to use store's toggleHiddenFiles; adjusts dependency arrays and reads includeHidden from centralized store when loading directory children.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 Hidden files once scattered in the view,
Now dance together in a store so true!
One shared home, no local state to chase,
The warren's files find their central place! 📁✨

✨ 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.

@Kitenite Kitenite merged commit ebc4949 into superset-sh:main Feb 5, 2026
4 of 5 checks passed
@Kitenite Kitenite deleted the kitenite/show-hide-toggle-is-wrong-first-time branch February 5, 2026 08:48
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.

1 participant