[Bug]: Opening PR diff crashes with file/directory path collision

Open
#12,887 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
56/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript

Research direction

Start with PullRequestCodeTab.tsx, diffFileTree.logic.ts, and DiffFileTree.tsx, then trace how parsed diff paths reach model.resetPaths. Reproduce a file-to-directory and directory-to-file transition involving a path prefix, including both initial and refreshed PR contents. Done means the diff opens, every changed file remains selectable, and regression coverage includes both transition directions.

Written by the indexing model from the issue text.

Description

accepted bug via-triage
Before submitting
  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.
Area

apps/web

Steps to reproduce

Observed on T3 Code desktop:

  1. Open an affected pull request in PR view.
  2. Open its diff.
  3. The view fails with Path collides with an existing file while creating directory "office".

The affected PR and its path list have not been supplied, so a deterministic reproduction has not yet been confirmed.

Candidate reproduction based on source inspection, not yet run: compare a base revision containing a tracked file or symlink named office against a head revision that replaces it with a directory containing office/config.ts. Ensure the diff includes both the deleted office entry and the added descendant, then open the PR diff with its file sidebar visible. The conflicting segment could also occur deeper in a path.

Expected behavior

The PR diff opens and every changed file remains accessible, including valid file-to-directory or directory-to-file transitions across revisions.

Actual behavior

Opening the diff throws while the file sidebar builds its in-memory tree. The directory creation in the error refers to the tree model, not a filesystem write.

Source inspection at 1de563c1491c7d82563e4553bf5bf689ce6adbb9 suggests a file/directory prefix collision:

  • PullRequestCodeTab.tsx derives sidebar entries from the parsed diff files.
  • diffFileTreeEntries merges identical paths but retains a file path alongside its descendants.
  • DiffFileTree.tsx passes the paths directly to model.resetPaths, matching the stack trace. A single filesystem tree cannot represent office as both a file and a directory.

The exact conflicting input remains unconfirmed. The shared component is also used by regular diffs in web and desktop, so those paths merit regression coverage.

A possible fix is to detect prefix collisions and use a flat file list for those diffs, preserving every change and its selection target. Initial construction, appended PR slices, refreshes, and both transition directions should be covered.

Related, but different failures: #11074 and #12244 concern duplicate CodeView IDs for same-path type changes. This report fails in the file-tree model while creating a directory. Searches across open and closed issues for the exact error, getOrCreateDirectoryChild, and diff/tree collision terms found no matching report.

Impact

Major degradation or frequent failure

The affected PR diff cannot be opened. Frequency and impact outside that view are unknown.

Version or commit

T3 Code (Alpha) 0.0.42

Environment

T3 Code desktop, identified by the t3code://app asset URLs. OS/version and provider details were not included in the error report.

Logs or stack traces
T3 Code (Alpha) 0.0.42
Time: 2026-09-21T08:21:30.295Z

Error: Path collides with an existing file while creating directory "office"
    at St.getOrCreateDirectoryChild (t3code://app/assets/fileTreeExpansion-DN2oJcLV.js:1671:17435)
    at St.appendPreparedPath (t3code://app/assets/fileTreeExpansion-DN2oJcLV.js:1671:15629)
    at t3code://app/assets/fileTreeExpansion-DN2oJcLV.js:1671:10946
    at I (t3code://app/assets/fileTreeExpansion-DN2oJcLV.js:1671:5114)
    at St.appendPreparedPaths (t3code://app/assets/fileTreeExpansion-DN2oJcLV.js:1671:10862)
    at new e (t3code://app/assets/fileTreeExpansion-DN2oJcLV.js:1671:52283)
    at #le (t3code://app/assets/fileTreeExpansion-DN2oJcLV.js:1671:78951)
    at xi.resetPaths (t3code://app/assets/fileTreeExpansion-DN2oJcLV.js:1671:75911)
    at Ms.resetPaths (t3code://app/assets/fileTreeExpansion-DN2oJcLV.js:1671:148985)
    at de (t3code://app/assets/diffFileContents-CFYwckRB.js:246:3428)
Workaround

No workaround has been verified in T3 Code. The PR can be reviewed outside T3 Code while this is investigated.

Dominant language
TypeScript
Stars
23.3k
Forks
6k
Avg merge
10h 57m
Merged PRs (30d)
365

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pingdotgg/t3code

All issues in pingdotgg/t3code

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.