Skip to content

fix(app): allow collapsing parent folder of selected file in explorer#500

Merged
boudra merged 1 commit intomainfrom
debug/file-tree-collapse
Apr 19, 2026
Merged

fix(app): allow collapsing parent folder of selected file in explorer#500
boudra merged 1 commit intomainfrom
debug/file-tree-collapse

Conversation

@boudra
Copy link
Copy Markdown
Collaborator

@boudra boudra commented Apr 19, 2026

Summary

  • Delete a useEffect in file-explorer-pane.tsx that re-enforced expansion of the selected file's ancestor directories on every expandedPaths change. The effect was responsible for the bug where clicking an already-expanded parent folder of a recently-opened file did nothing — the effect immediately re-added the folder to expandedPaths.
  • Selection and expansion are orthogonal; there is no current caller that sets selectedEntryPath from outside the tree, so the reveal-on-external-selection use case the effect was designed for is unused. A future "Reveal in Explorer" action can expand ancestors at the call site.
  • Also deletes two helpers (getParentDirectory, getAncestorDirectories) that had no other consumers.
  • Adds an E2E regression test that reproduces the original scenario.

Test plan

  • Failing E2E added first (TDD): asserts the parent folder's children hide after collapse. Confirmed failing pre-fix, passing post-fix.
  • New test: npm run test:e2e --workspace=@getpaseo/app -- file-explorer-collapse.spec.ts — 1 passed.
  • Monorepo typecheck: green.
  • Biome format:check: green.
  • Browser QA in the real dev app: reproduced the original public/og.png scenario after hard-reload. Parent folder now collapses correctly; unrelated folders still toggle; non-image file open still works.

The file explorer had a useEffect that re-enforced expansion of every
ancestor of `selectedEntryPath` whenever `expandedPaths` changed. As a
result, the moment a user collapsed the parent folder of a file they
had just opened, the effect re-added that folder to the expanded set
and the folder appeared stuck open.

Selection and expansion are orthogonal: clicking a file should not
dictate that its parent folder stays open forever. There is also no
current caller that sets `selectedEntryPath` from outside the tree, so
the reveal-on-external-selection use case the effect was designed for
is unused. Delete the effect and its two now-dead helpers. If a future
"Reveal in Explorer" action is introduced, it can expand ancestors at
the call site.

Adds an E2E regression test that reproduces the original scenario:
expand a folder, open an image, collapse the parent folder, assert
children are hidden. Also asserts an unrelated sibling folder still
expands after the image is open, guarding against any future regression
that makes the bug global.
@boudra boudra force-pushed the debug/file-tree-collapse branch from 668d086 to 3fe755d Compare April 19, 2026 08:28
@boudra boudra merged commit 8991d34 into main Apr 19, 2026
9 checks passed
@boudra boudra deleted the debug/file-tree-collapse branch April 19, 2026 08:49
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