Repository navigation
fix(files): drop file rows that shadow a same-named directory - #14077
Conversation
UX Review (Fable 5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Verify on a real collision-bearing directory that the Files panel now renders — the PR claims manual verification but ships no before/after capture. [UX-REVIEWED] cb108c8 Description read[DESCRIPTION-READ] df5c8a5ebefbcbd15b14e870e2185946fb6a93573a11bdb39e0f834f3755ba31 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the drop policy is acceptable in Suggestions
[DESIGN-REVIEWED] cb108c8 Description read[DESCRIPTION-READ] 9936a46503ad0d5875eb87f3f24092d927ffaef6d746a686abd8c6e6b96f7352 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the filtered output against the real widget: both new tests run on the recording mock, and only the author's manual repro covers real What this change shipsInventory (3 items) — 3 justifiedIntent: FIX — stop the Files panel crashing to "Something went wrong" when egress redaction makes a file path and a directory path identical. Provenance is checkable: the first new test fails on base by reading (base's
[FIRST-PRINCIPLES-REVIEWED] cb108c8 Description read[DESCRIPTION-READ] 98535f54ab7ce5418f51a77abfe551c30bd6d6803ad488c885c42f6141567dd9 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5 Review (fork) — ✅ no blocking findingsReviewed |
|
🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR has been inactive for 7+ days with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author. Assessment: The branch is 607 commits behind main, which rewrote the same If you'd prefer I don't touch this PR, add the |
Egress redaction can flatten two distinct path segments into one "[REDACTED: ...]" string, so a file and an implied or explicit directory end up sharing a name under the same parent. @pierre/trees indexes a directory's children by name and throws "Path collides with an existing entry" from createFileChild; that throw is uncaught inside the resetPaths layout effect and takes down the whole Files route with the generic "Something went wrong" screen. Extend the existing Set de-dup into dedupeTreePaths(), which also drops a file whose path is a directory (an explicit trailing-slash entry or the parent of another path). The directory wins so its subtree still renders; the shadowed file degrades to a missing row. Apply it to both the full tree and the changed-files branch, which had no de-dup at all.
aed0adb to
cb108c8
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Approved: PR Readiness green on this head, merges cleanly into current main, no outstanding blocking review.
Problem / Motivation
Goal: The Files panel keeps rendering when a project directory contains two paths that redaction flattens to the same name.
Opening the Files panel on some project directories crashes the whole route to the generic "Something went wrong" screen with:
Egress redaction can flatten two different path segments to the same
[REDACTED: ...]string. When that happens a FILE and a DIRECTORY (either an explicitdir/entry or the implied parent of another path) end up sharing one name under the same parent.@pierre/treesindexes a directory's children by name, socreateFileChildthrows. That throw is uncaught inside theresetPathsuseLayoutEffectinPierreWorkspaceTreeImpl, so the error boundary swallows the entire Files route rather than one row.Why it matters
Any project whose tree contains credential-shaped names in more than one place (
token,secrets/, key-like filenames, etc.) makes the Files panel unusable, with an error message that is itself redacted and therefore gives the user nothing to act on. "Try Again" reproduces the same crash. It only takes one such directory to lose the panel for that project.Not a goal
[REDACTED: ... #2]) so colliding paths stay distinct; that is a backend change with its own blast radius and this guard is needed regardless.PierreWorkspaceTreeImplor@pierre/treesinput handling beyond the two throws this diff prevents.What changed (motivation → approach → change)
Path collides with an existing entry.mainalready de-dups identical strings in the full-tree branch (Array.from(new Set(...))) but does not guard the file-vs-directory collision, and thechangedbranch has no de-dup at all.SetwithdedupeTreePaths(), which (1) de-dups identical strings and (2) drops any file whose path is also a directory — explicit trailing-slash entries and every implied ancestor of another path both count. The directory wins so its subtree still renders; the shadowed file degrades to a single missing row instead of a route crash. Order and first occurrence are preserved. Applied to both the full-tree andchangedbranches.The alternative — catching the throw around
resetPaths— would hide the whole tree on a single bad path. Filtering the input keeps every other row rendering.Backwards compatibility
Compatible: the function only removes entries the tree would have thrown on. Every path set that rendered before renders identically; the
changedbranch gains string de-dup, which is already whatstatusEntriesguarantees upstream of it.Tests
website/src/test/PierreWorkspaceTreeImpl.test.tsx, two new cases in "data loading":drops a file row that shadows a directory of the same name (post-redaction collision)— feeds['a/[REDACTED: credential]', 'a/[REDACTED: credential]/x.txt', 'a/[REDACTED: credential]']and asserts onlya/[REDACTED: credential]/x.txtreaches the model (dupe removed, shadowing file removed, directory subtree kept).keeps an explicit directory row over a same-named file—paths: ['secrets', 'README.md']+directories: ['secrets/']asserts['README.md', 'secrets/'].Existing 78 cases in the file still pass (80/80 total, Node 24).
Manual verification
Reproduced the crash on 0.7.1 against a real project directory whose tree contains two credential-shaped segments; after the change the Files panel renders and the affected directory's subtree is browsable. No screenshot section: this is a crash fix, not a visual change. The "before" state is the generic "Something went wrong" error screen with the message quoted above; the "after" state is the ordinary Files panel rendering normally.
Screenshots / video
Why no screenshot: this is a crash fix on a watched frontend path with no rendered delta. Before, the Files route is replaced by the generic "Something went wrong" error screen; after, the panel renders exactly as it does for any other directory, with one shadowed row absent. Nothing new is drawn.
Related Issues
None found for this exact message. Related in spirit to the existing "Duplicate path" de-dup comment in the same
useMemo.Pattern harvest
Rule candidate: review-prompt
Pattern: "third-party data-structure constructor called inside a React layout effect with unfiltered external input — a single bad element takes down the route instead of one row; validate/filter the input before the effect, do not wrap the effect in try/catch."
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement