Skip to content

fix(files): drop file rows that shadow a same-named directory - #14077

Merged
bolichen97 merged 1 commit into
kirodotdev:mainfrom
eakjothundal:fix/files-tree-path-collision
Oct 2, 2026
Merged

bolichen97 merged 1 commit into
kirodotdev:mainfrom
eakjothundal:fix/files-tree-path-collision

Conversation

@eakjothundal

@eakjothundal eakjothundal commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

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:

Path collides with an existing entry: "[REDACTED: credential]"

Egress redaction can flatten two different path segments to the same [REDACTED: ...] string. When that happens a FILE and a DIRECTORY (either an explicit dir/ entry or the implied parent of another path) end up sharing one name under the same parent. @pierre/trees indexes a directory's children by name, so createFileChild throws. That throw is uncaught inside the resetPaths useLayoutEffect in PierreWorkspaceTreeImpl, 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

  • Changing how egress redaction names its placeholders (e.g. numbered [REDACTED: ... #2]) so colliding paths stay distinct; that is a backend change with its own blast radius and this guard is needed regardless.
  • Surfacing the dropped row to the user (a badge or notice); today a shadowed file degrades to a missing row, which is the documented trade-off against losing the whole route.
  • Any other hardening of PierreWorkspaceTreeImpl or @pierre/trees input handling beyond the two throws this diff prevents.

What changed (motivation → approach → change)

  • Symptom: Files route crashes with Path collides with an existing entry.
  • Root cause: post-redaction, a file path can equal a directory path under the same parent. main already de-dups identical strings in the full-tree branch (Array.from(new Set(...))) but does not guard the file-vs-directory collision, and the changed branch has no de-dup at all.
  • Change: replace the inline Set with dedupeTreePaths(), 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 and changed branches.

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 changed branch gains string de-dup, which is already what statusEntries guarantees 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 only a/[REDACTED: credential]/x.txt reaches 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable) — N/A, internal rendering fix with no user-facing behavior beyond removing a crash
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

@eakjothundal
eakjothundal requested review from a team and cixuuz September 26, 2026 01:38
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 26, 2026
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5, fork) — ✅ PASS

UX-level review of cb108c8ecd1ba2b54fedc3938d9561a8af74efc0 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — ✅ PASS

Design-level review of cb108c8ecd1ba2b54fedc3938d9561a8af74efc0 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify the drop policy is acceptable in changed mode: a genuinely changed file that collides post-redaction now vanishes from the Changed panel with no marker.

Suggestions

  • The root cause lives in egress redaction collapsing distinct segments to one string; file a follow-up to make placeholders collision-unique (e.g. numbered), which removes the silent row loss this guard degrades to.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

Reviewed cb108c8ecd1ba2b54fedc3938d9561a8af74efc0 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] cb108c8

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — ✅ PASS

Premise-level review of cb108c8ecd1ba2b54fedc3938d9561a8af74efc0 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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 @pierre/trees.

What this change ships

Inventory (3 items) — 3 justified

Intent: 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 Set de-dup yields two entries, the assert expects one).

  1. Files panel renders instead of crashing when a redacted file name equals a directory name — justified
  2. The shadowed file degrades to a silently missing row; the directory and its subtree win — justified
  3. Changed-files mode gains the same guard (declared; same resetPaths throw is reachable there) — justified

dedupeTreePaths is module-private with 2 consumers (grepped dedupeTreePaths); resetPaths is fed only from the one paths memo both branches share (grepped resetPaths, 4 call sites, one source), so no unfixed siblings. The deeper cause — redaction flattening distinct segments — is named in the description and is plausibly a deliberate property of redaction, so filtering before the name-indexed tree is the cause-level fix available at this layer.

[FIRST-PRINCIPLES-REVIEWED] cb108c8

Description read

[DESCRIPTION-READ] 98535f54ab7ce5418f51a77abfe551c30bd6d6803ad488c885c42f6141567dd9

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review (fork) — ✅ no blocking findings

Reviewed cb108c8ecd1ba2b54fedc3938d9561a8af74efc0 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] cb108c8

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 26, 2026
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 26, 2026
@NicholasRBowers NicholasRBowers added needs-pr-triage PR scanner: awaiting automated triage drive-to-green PR claimed by drive-to-green pipeline and removed needs-pr-triage PR scanner: awaiting automated triage labels Sep 30, 2026
@NicholasRBowers

Copy link
Copy Markdown
Contributor

🤖 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 paths useMemo in PierreWorkspaceTreeImpl.tsx that this PR edits (#14142/#14771/#7068 turned it into a block body that builds a de-duplicated listed and appends fedStateRows.paths) — the conflict is mechanical: keep main's structure and swap its new Set de-dup for dedupeTreePaths(...). The only red test, test_spawn_approval_channel_delivery_2381.py::...::test_it_registers_no_wait_so_the_window_is_never_spent on Backend Tests (Windows) (6), is unreachable from a website/-only diff and reruns after the rebase. First Principles' one CONCERNS item is that dedupeTreePaths is exported with no importers — dropping the export keyword clears it; the UX and Design notes are advisory and get dispositions.

If you'd prefer I don't touch this PR, add the pr-no-autofix label.

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.
@eakjothundal
eakjothundal force-pushed the fix/files-tree-path-collision branch from aed0adb to cb108c8 Compare October 2, 2026 03:09
@eakjothundal
eakjothundal requested a review from a team as a code owner October 2, 2026 03:09
@eakjothundal
eakjothundal requested review from buluoray and removed request for cixuuz October 2, 2026 03:09
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 2, 2026
@github-actions github-actions Bot added the readiness: passed Eligible automated validation passed for the current revision label Oct 2, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved: PR Readiness green on this head, merges cleanly into current main, no outstanding blocking review.

@bolichen97
bolichen97 merged commit 6cbe883 into kirodotdev:main Oct 2, 2026
107 of 108 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 2, 2026
@cruisercohen cruisercohen removed the drive-to-green PR claimed by drive-to-green pipeline label Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants