[Bug]: Diff view drops intermediate directories for a nested git repo under a non-git project root #12902
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/desktop
Steps to reproduce#
- Open a project whose root is NOT a git repository, e.g.
E:\Work\FinBeat. - Inside it keep a git clone two levels deep, e.g.
E:\Work\FinBeat\Kubernetes\kubernetes-pak-cl-dev\.git. - Let the agent edit a tracked file in that clone, e.g.
Kubernetes/kubernetes-pak-cl-dev/lms-platform/web/backoffice/values.yaml.gotmpl. - Open the changed file in the diff panel.
Expected behavior#
The diff opens; the file is resolved as <project root>/Kubernetes/kubernetes-pak-cl-dev/lms-platform/web/backoffice/values.yaml.gotmpl.
Actual behavior#
Error: Failed to read workspace file 'kubernetes-pak-cl-dev/lms-platform/web/backoffice/values.yaml.gotmpl' in 'E:\Work\FinBeat'.
The path is built as <repo dir name>/<path relative to the repo root> and joined to the project root. The intermediate Kubernetes/ segment between the project root and the repository is lost, so the file does not exist at the resolved location. Works fine when the repo sits directly under the project root (one level deep).
Impact#
Major degradation or frequent failure
Version or commit#
T3 Code (Alpha) 0.0.42, Windows desktop build
Environment#
Windows 11 Pro 10.0.22621, desktop app, Claude Code harness. Project root is a plain folder (no .git); git repos live at <root>/Kubernetes/<name>/.git.
Logs or stack traces#
Screenshots, recordings, or supporting files#
No response
Workaround#
Open the nested repo folder as a separate T3 Code project, or read the diff via git diff in the terminal
Catalan-1ap(GitHub profile, opens in a new tab) added labelsbug
Catalan-1ap(GitHub profile, opens in a new tab) added labelsneeds-triage
juliusmarminge added labelsvia-triage
juliusmarminge removed labelsneeds-triage
Hi, I'd like to take this one.
I'd follow the next step above: when the repo is under the workspace, build the path from
relative(workspaceRoot, repositoryRoot)plus the git-relative path instead of the repo basename, with the Windows fixture as a regression test. I'll keep it small so #9816 can reuse the same offset.Happy to hold off if you'd rather handle it yourselves.
Tested current main b5a226e49c with the real web dev app on Linux, Claude Code 2.1.303 / Opus 5.5, and isolated state.
- Created a non-git
FinBeatproject with a tracked file atKubernetes/kubernetes-pak-cl-dev/lms-platform/web/backoffice/values.yaml.gotmpl. Claude edited it successfully. Expanding its tool entry preservedKubernetes/; clicking Open diff showed “Turn diffs are unavailable because this project is not a git repository.” No truncated-path read error appeared. - Repeated with a repository directly under
FinBeat: same unavailable-diff message. - Opened
Kubernetes/kubernetes-pak-cl-devas its own project, edited the same file, and opened Changes: the diff and file contents loaded correctly.
Windows desktop is unverified here. Does the truncated-path error still occur on the latest Windows build? If so, include that build number and a screenshot or recording showing the exact changed-file entry and action that opens the failing diff; the non-git-root flow above currently stops before that read.
Captures: two-level non-git root, one-level control, and repo-as-project control, respectively.
- Created a non-git
juliusmarminge added labelsneeds more info
juliusmarminge removed labelsneeds more info
@Catalan-1ap Does opening the changed file from the Diff panel still fail with 'Failed to read workspace file' on the latest Windows desktop build, and if so, which entry did you click to open the diff (the 'Open diff' button on the agent's edit entry, the Changes panel, or something else)? A screenshot of that entry would help.
Not the reporter, but I have a Windows machine, so I tried the layout from the report: Windows 11 build 26300, dev server from source on
mainat e0ca4fcecb, Claude provider.Same outcome as the Linux check above: the truncated-path error did not appear. With a non-git project root and the repository two levels down, Open diff on the agent's edit entry opens the Diff panel in the Tool call scope, and clicking the file there opens it with the right contents. As far as I can see in the code, the other diff scopes are unavailable for a non-git root, so I found no way to reach the path construction from the report.
Not checked: a release build, and what the reporter clicked on 0.0.42.
Drafted with Claude Fable 5.2 in T3 Code and reviewed by Claude Opus 5.5. The check was run on my own machine.
farseenmanekhan1232(GitHub profile, opens in a new tab) linked this to #37407
juliusmarminge added labelsneeds more info
juliusmarminge removed labelsneeds more info
@Catalan-1ap On the latest Windows desktop build, does opening that changed file still fail with 'Failed to read workspace file'? If it does, which control did you click (Open diff on the agent's edit entry, a file in the Diff panel, the Changes view, or something else), and could you attach a screenshot of it?
juliusmarminge added labelsneeds more info
Fixed by #35925, now on main: Open the non-Git parent project, edit a tracked file in Kubernetes/kubernetes-pak-cl-dev, and open its turn diff: repository discovery now reaches that clone and file paths retain the full Kubernetes/kubernetes-pak-cl-dev prefix.
juliusmarminge closed this
Sign in to join this conversation.
Triage#
Confirmed as a path-mapping bug, not a bad local setup. Opening a file from the Diff panel for a git repo nested two or more levels under a non-git project root joins the wrong relative path to the project root.
Reported failure:
Expected location:
The
Kubernetes\segment between the project root and the clone is dropped. A clone sitting directly under the project root works, because<repo dir name>/<git-relative path>happens to be the full workspace-relative path.Diagnosis#
The error string is
ProjectReadFileErrorinpackages/contracts/src/project.ts. Diff-panel open goes throughapps/web/src/components/DiffPanel.tsx→openDiffFilePrimaryAction/resolveDiffPathForWorkspaceinapps/web/src/diffFileActions.ts→rightPanelStore.openFile→project.readFilewithcwd= the project workspace root.resolveDiffPathForWorkspaceonly handles workspace inside repo: it strips the workspace prefix from a repo-relative path. When the repo is inside the workspace (this report),repositoryRelativeWorkspaceSegmentsreturnsnulland the path is used as-is. Git status, review diffs, and checkpoint numstat inapps/server/src/vcs/GitVcsDriverCore.ts/apps/server/src/orchestration/Layers/CheckpointReactor.tsare repository-relative.RepositoryIdentityResolveralso runsgit rev-parse --show-toplevelfrom the project cwd, so a non-git root has norepositoryIdentity.rootPathfor the UI to recover the full offset.That matches the reporter’s construction:
<repo dir name>/<path relative to the repo root>joined onto the project root.This is the inverse of #2441 / #9842 (workspace subdirectory of a git repo). Those fixes do not cover a non-git parent with clones underneath.
#9816 is the open multi-repo Diff-panel feature for this layout (
t3.jsonrepositories). Review there already flagged nested-repository path resolution. It is not merged and should not be treated as a fix for 0.0.42.Next step#
Small, targeted fix plus a regression test:
repositoryRootis underworkspaceRoot, build the workspace path asrelative(workspaceRoot, repositoryRoot)+ the git-relative file path, keeping every intermediate directory (notbasename(repoRoot)).E:\Work\FinBeat\Kubernetes\kubernetes-pak-cl-dev\lms-platform\web\backoffice\values.yaml.gotmpl.Until that lands, the existing workaround stands: open the nested clone as its own T3 Code project, or inspect the change with
git diffin the terminal.Not a duplicate. Repro is sufficient to implement; no extra reporter info needed.