feat(desktop): persist show hidden files setting per-project#1223
Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughFile-explorer's showHiddenFiles became project-scoped (Record<string, boolean>) with a legacy key for migration. FilesView now reads per-project value, keeps a synchronous ref for loaders, calls toggleHiddenFiles(projectId), and invalidates/refetches directories when toggling. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as FilesView (UI)
participant Store as FileExplorerStore
participant Loader as QueryClient/Loader
participant Cache as ExpandedTreeCache
UI->>Store: select showHiddenFiles(projectId) (fallback legacy)
Store-->>UI: per-project showHiddenFiles
UI->>UI: set showHiddenFilesRef.current
UI->>Store: toggleHiddenFiles(projectId)
Store-->>UI: updated per-project showHiddenFiles
UI->>Cache: get expanded directories
UI->>Loader: invalidate queries (root + expanded dirs)
Loader-->>UI: refetch entries (includeHidden = showHiddenFilesRef.current)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/FilesView.tsx`:
- Line 18: Update the selector inside useFileExplorerStore that reads
showHiddenFiles for a given projectId so that when showHiddenFiles[projectId] is
undefined it falls back to the migrated legacy default (e.g.,
legacyShowHiddenDefault) instead of treating it as false; locate the
selector/getter referencing showHiddenFiles and projectId and change the
conditional to use (showHiddenFiles?.[projectId] ?? LEGACY_SHOW_HIDDEN_DEFAULT).
Also extract any hardcoded magic strings/numbers used in that logic (like the
legacy default key/name and default boolean) into named constants at the top of
the module to replace inline literals.
In `@apps/desktop/src/renderer/stores/file-explorer.ts`:
- Around line 142-149: Existing migration drops legacy boolean hidden-files
preference and toggleHiddenFiles assumes missing key => false; update the
migration logic that transforms persisted state (migrate function) to copy any
legacy boolean (e.g., a top-level showHiddenFiles boolean) into the new
showHiddenFiles map under a named DEFAULT_PROJECT_KEY constant, and modify
toggleHiddenFiles(projectId) to fall back to get().showHiddenFiles[projectId] ??
get().showHiddenFiles[DEFAULT_PROJECT_KEY] ?? false so migrated users keep their
setting; also extract hardcoded strings/numbers (like the default project key
name and any version number constants used in migrate) into named constants at
the module top and use those constants in both the migrate routine and
toggleHiddenFiles.
6e35608 to
a77032c
Compare
- Change showHiddenFiles from boolean to Record<string, boolean> keyed by project.id so each project remembers its own setting - Add migration for users with legacy boolean in localStorage - Preserve legacy value under LEGACY_SHOW_HIDDEN_KEY so users don't lose their preference when upgrading - Setting persists across app restarts via Zustand persist middleware
a77032c to
33ae3b7
Compare
|
Removed the migration and legacy key since i think it's minor enough. Thanks @de1mat! |
Pleasure! Funny, I only added the legacy key because CodeRabbit told me to 🤣 Looks cleaner without it 👍 |
|
No worries it's a good measure if this was a more important config |
Fixes #1232
Summary
Persists the "Show Hidden Files" setting per-project, so each project remembers its own preference across app restarts.
Changes:
showHiddenFilesfrombooleantoRecord<string, boolean>keyed byproject.idTest plan
Summary by CodeRabbit