GeezerVison is showing github.com — fix(cli): find the worktree's project when a Git hook sets GIT_DIR by only21mil · Pull Request #42063 · pingdotgg/t3code
Conversation
Problem
When a t3 thread command inherits a GIT_DIR that points away from the target's repository, a path inside a linked worktree fails with No T3 Code project matches ... instead of resolving to its project.
To find it, the CLI runs git worktree list in the target folder, and Git inherits GIT_DIR. A hook in a linked worktree gets the worktree's absolute Git dir, a receive hook gets GIT_DIR=., and a shell or script can export any value. When it names another repository, or is relative and so names none from the target folder, the target matches no listed checkout.
Change
listGitCheckouts now unsets inherited repository selectors with the existing unsetInheritedRepositoryEnv helper, as the server's other cwd-based Git calls do. Git then finds the repository from the folder it runs in.
Scope
Bug fix for a wrong lookup error. It changes one call site, and the commands below reproduce it, so it needs no issue.
Verification
Setup: Linux, Git 2.53.0, a fresh isolated server (t3 serve --base-dir <base>) on each commit. repo has a tracked pkg/ folder and is added with t3 project add --base-dir <base> repo. Its linked worktree repo-feature sits beside it. t3 is node <checkout>/apps/server/src/bin.ts.
Steps: cd repo → t3 thread list --json --base-dir <base> --project ../repo-feature/pkg → the same with GIT_DIR=.git set by hand, standing in for an inherited value.
Before, 6f15610d5be1:
$ cd /mnt/work/rel-base/repo
$ t3 thread list --json --base-dir /mnt/work/rel-base/base --project ../repo-feature/pkg
[]
exit 0
$ GIT_DIR=.git t3 thread list --json --base-dir /mnt/work/rel-base/base --project ../repo-feature/pkg
No T3 Code project matches '../repo-feature/pkg'. Pass a project id or a path inside a project.
exit 1
After, 54b74fff7f4e:
$ cd /mnt/work/rel-head/repo
$ t3 thread list --json --base-dir /mnt/work/rel-head/base --project ../repo-feature/pkg
[]
exit 0
$ GIT_DIR=.git t3 thread list --json --base-dir /mnt/work/rel-head/base --project ../repo-feature/pkg
[]
exit 0
An AI agent ran each check:
- The worktree test in
thread.test.ts now also resolves the worktree's pkg folder with GIT_DIR set. It fails against 6f15610d5be1's thread.ts, and again on 54b74fff7f4e with only the new env line removed.
- On
54b74fff7f4e, vp test run src/cli/thread.test.ts src/cli/deferredImports.test.ts --maxWorkers=1 passes 3 of 3 runs, and vp run check:changed passes.
Links: the commits above and the regression test in apps/server/src/cli/thread.test.ts.
Not shown:
- Windows and macOS. The helper already matches Windows' case-insensitive variable names, and this change adds no platform-specific code.
Generated with Claude Opus 5.5 in T3 Code Nightly
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 24, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Important
Review skipped
Review was skipped as selected files did not have any reviewable changes.
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 54b74ff and e56fa9f.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review.
Walkthrough
-
listGitCheckouts now removes inherited repository-related environment variables before running Git worktree-list commands. A test sets GIT_DIR and checks that path resolution still selects the sample project.
Changes: Worktree environment cleanup
| Layer / File(s) |
Summary |
Clean the Git environment for worktree listing apps/server/src/cli/thread.ts, apps/server/src/cli/thread.test.ts |
listGitCheckouts passes a cleaned environment to both Git command attempts. The test sets GIT_DIR and checks that resolution selects the sample project. |
Estimated code review effort: 2 (Simple) | ~5 minutes
Change: Bug fix
Suggested reviewers: juliusmarminge, mfazekas
Merge Risk: Minimal · previous review 54b74
-
This fix lets the CLI find a worktree's project when a Git hook sets GIT_DIR. The change is small and tested, and I found no remaining merge-blocking risk.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title names the fix and its scope: the CLI should find the worktree's project when a Git hook sets GIT_DIR. The raw summary confirms that listGitCheckouts now removes inherited repository environm… |
| Description check |
 |
The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section explains the failure and its cause. The Change section names the fix and the helper … |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Title check
-
Explanation
The title names the fix and its scope: the CLI should find the worktree's project when a Git hook sets GIT_DIR. The raw summary confirms that listGitCheckouts now removes inherited repository environment variables before running git worktree list, which matches the title. The title follows conventional commit form and is specific enough for a teammate scanning history.
Full details: Description check
-
Explanation
The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section explains the failure and its cause. The Change section names the fix and the helper it uses. The Scope section says this is a bug fix for one call site and gives a reason for skipping an issue. The Verification section lists the environment, exact commands, before and after output, the regression test result, and the untested platforms. The author also states the model and harness used, as the template asks. The description does not link a separate issue, but it explains why none is needed. The template's Scope guidance is met.
Finishing Touches
-
Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 28d8a63 and 54b74ff.
Files selected for processing: 2
-
apps/server/src/cli/thread.test.ts
apps/server/src/cli/thread.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Evidence
Run the same synthetic repository and linked-worktree setup against independently built CLI/server instances with fresh databases. Register repo, then from inside it run t3 thread list --json --base-dir <data> --project ../repo-feature/pkg, first normally and then with GIT_DIR=.git.
Environment: Linux x86_64, Node v26.13.1, server bound to 127.0.0.1:47391, T3CODE_DEV_SEED=0. Both control commands returned [], exit 0. The inherited relative GIT_DIR command failed on base and returned [], exit 0 on head. Visuals render captured real CLI output; videos replay commands and output rather than recording a desktop.
Reproduction and seed driver · Transcript renderer
Not shown:
- Other inherited Git repository selectors and other operating systems were not exercised; this proof covers the reported relative GIT_DIR=.git reproduction.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:XS
0-9 changed lines (additions + deletions).
vouch:unvouched
Author is not yet trusted in the VOUCHED list.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|