Skip to content

fix(web): preserve file tree expansion state across reloads - #61

Merged
enisze merged 1 commit into
mainfrom
feature/fix-filetree-auto-expand-on-reload
Aug 18, 2026
Merged

fix(web): preserve file tree expansion state across reloads#61
enisze merged 1 commit into
mainfrom
feature/fix-filetree-auto-expand-on-reload

Conversation

@enisze

@enisze enisze commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Problem

Reloading/refreshing the files in the file browser auto-expanded the file tree, wiping out the user's current expand/collapse state.

Root cause

The effect that syncs file data into the tree guarded with a reference-equality check (previousTreePathsRef.current === treePaths). A refresh (useAtomRefresh) yields a brand-new entries array even when the file list is identical, so treePaths was always a new reference. The guard never short-circuited, so model.resetPaths(treePaths) ran on every reload — and resetPaths re-applies initialExpansion: 1, re-expanding collapsed folders and resetting the collapse toggle.

Fix

Compare treePaths by value instead of by reference. When the reloaded paths are identical, the effect updates its refs but skips resetPaths, leaving the tree's expansion state untouched. resetPaths still runs when the file list actually changes (files added/removed/renamed).

🤖 Generated with Claude Code

Reloading files re-ran resetPaths (a refresh yields a new entries array
even when paths are unchanged), which re-applied initialExpansion and
blew away the user's expand/collapse state. Compare tree paths by value
so resetPaths only runs when the file list actually changes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@enisze
enisze merged commit 867030e into main Aug 18, 2026
@enisze
enisze deleted the feature/fix-filetree-auto-expand-on-reload branch August 18, 2026 13:58
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