Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Diff view drops intermediate directories for a nested git repo under a non-git project root #12902

ClosedCatalan-1ap(GitHub profile, opens in a new tab) opened this issue 7 comments

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

  1. Open a project whose root is NOT a git repository, e.g. E:\Work\FinBeat.
  2. Inside it keep a git clone two levels deep, e.g. E:\Work\FinBeat\Kubernetes\kubernetes-pak-cl-dev\.git.
  3. Let the agent edit a tracked file in that clone, e.g. Kubernetes/kubernetes-pak-cl-dev/lms-platform/web/backoffice/values.yaml.gotmpl.
  4. 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

  1. Catalan-1ap(GitHub profile, opens in a new tab) added labelsneeds-triage

  2. 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:

    Failed to read workspace file 'kubernetes-pak-cl-dev/lms-platform/web/backoffice/values.yaml.gotmpl' in 'E:\Work\FinBeat'

    Expected location:

    E:\Work\FinBeat\Kubernetes\kubernetes-pak-cl-dev\lms-platform\web\backoffice\values.yaml.gotmpl

    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 ProjectReadFileError in packages/contracts/src/project.ts. Diff-panel open goes through apps/web/src/components/DiffPanel.tsx → openDiffFilePrimaryAction / resolveDiffPathForWorkspace in apps/web/src/diffFileActions.ts → rightPanelStore.openFile → project.readFile with cwd = the project workspace root.

    resolveDiffPathForWorkspace only handles workspace inside repo: it strips the workspace prefix from a repo-relative path. When the repo is inside the workspace (this report), repositoryRelativeWorkspaceSegments returns null and the path is used as-is. Git status, review diffs, and checkpoint numstat in apps/server/src/vcs/GitVcsDriverCore.ts / apps/server/src/orchestration/Layers/CheckpointReactor.ts are repository-relative. RepositoryIdentityResolver also runs git rev-parse --show-toplevel from the project cwd, so a non-git root has no repositoryIdentity.rootPath for 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.json repositories). 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:

    1. When repositoryRoot is under workspaceRoot, build the workspace path as relative(workspaceRoot, repositoryRoot) + the git-relative file path, keeping every intermediate directory (not basename(repoRoot)).
    2. Cover the Windows fixture E:\Work\FinBeat\Kubernetes\kubernetes-pak-cl-dev\lms-platform\web\backoffice\values.yaml.gotmpl.
    3. Keep #9816 in the loop so the multi-repo Diff work uses the same offset.

    Until that lands, the existing workaround stands: open the nested clone as its own T3 Code project, or inspect the change with git diff in the terminal.

    Not a duplicate. Repro is sufficient to implement; no extra reporter info needed.

  3. juliusmarminge added labelsvia-triage

  4. juliusmarminge removed labelsneeds-triage

  5. 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.

  6. 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 FinBeat project with a tracked file at Kubernetes/kubernetes-pak-cl-dev/lms-platform/web/backoffice/values.yaml.gotmpl. Claude edited it successfully. Expanding its tool entry preserved Kubernetes/; 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-dev as 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.

    Two-level nested repository under a non-git project root

    One-level repository control under the non-git project root

    Repository opened as its own project loads the diff

  7. juliusmarminge added labelsneeds more info

  8. juliusmarminge removed labelsneeds more info

  9. @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.

  10. 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 main at 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.

    grafik

    Drafted with Claude Fable 5.2 in T3 Code and reviewed by Claude Opus 5.5. The check was run on my own machine.

  11. juliusmarminge added labelsneeds more info

  12. juliusmarminge removed labelsneeds more info

  13. @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?

  14. juliusmarminge added labelsneeds more info

  15. 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.

  16. juliusmarminge closed this

Sign in to join this conversation.