feat(web): support multi-repository diff workspaces #9816
main fromrefs/pull/9816/head·opened View on GitHubAdds an optional repositories list to t3.json so the Diff panel can inspect separate Git repositories below a shared project folder, even when the parent is not a Git repository.
Diff files open relative to the selected repository, and comparison branches remain independent when switching repositories or changing their configured order. Checkpoint diffs retain the project root. Repository paths are validated in both the runtime and published schema; configured status and diff requests reject symbolic links that leave the project folder.
This covers status and diffs. Commits, pushes, pull requests, worktrees and checkpoints continue to use the project root. User documentation includes configuration and path constraints.
Validation: 226 focused tests passed; web, shared, contracts, client-runtime and server typechecks passed; targeted lint and formatting passed. Four React lint warnings remain in DiffPanel. Browser acceptance and the full CI suite were not run locally.
Prepared in the Codex harness with GPT-5.6 Luna/Sol implementation and GPT-6 Astra review.
Note
Low Risk Changes are mostly UI gating and diff cwd scoping with schema validation on repository paths; no auth or server-side Git workflow changes.
Overview
Adds an optional repositories list to t3.json so shared parent folders can declare nested Git repos (workspace-relative paths with optional display names, validated to block escapes).
Diff availability no longer requires the project root to be a Git repo: isDiffSurfaceAvailable enables the Diff tab on server threads when the workspace is non-Git but t3.json lists at least one repository. ChatView reads that config via useT3ProjectFileState (local threads without a worktree) and wires diffAvailable / addDiffSurface through the new helper.
DiffPanel adds a repository picker for branch/unstaged views, runs status and diff preview against the selected repo’s resolved cwd, and adjusts “open in editor” roots accordingly; turn-based diffs still reset repository selection. useT3ProjectFileState now accepts a nullable environmentId so hooks stay safe while routes resolve.
User docs describe the multi-repo setup; scope stays status and diffs only—commits, PRs, worktrees, and checkpoints remain at the project root.
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d2b8371ef71a95d5cf346e7dfc0d0bb704fe915c. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).Note
Add multi-repository diff support for non-Git workspaces via t3.json config#
- Adds
repositoriesarray (up to 20 entries) to the T3 project-file schema in t3ProjectFile.ts, accepting workspace-relative paths and optional display names while rejecting parent escapes, absolute paths, and backslashes - Updates
DiffPanelin DiffPanel.tsx to load configured repositories, add a repository dropdown for branch-scope views, and resolve Git status, diff previews, and editor paths against the selected repository root - Updates
ChatViewin ChatView.tsx to enable the diff surface for server threads whose T3 project file declares repositories, even when the workspace root is not a Git repository - Fixes
useT3ProjectFileStatein useT3ProjectFileScripts.ts to accept a null environment and skip the project-file query when no environment or cwd is present - Risk: Worktree threads do not contribute configured repositories to diff-surface availability; selecting a turn in
DiffPanelresets the repository selection to the first configured repository, which may surprise users who manually switched repos
📊 Macroscope summarized d2b8371. 6 files reviewed, 4 issues evaluated, 1 issue filtered, 2 comments posted
🗂️ Filtered Issues#
apps/web/src/components/DiffPanel.tsx — 1 comment posted, 2 evaluated, 1 filtered
- line 173:
repositories.pathis validated as a workspace-relative path, and the schema permits~/…as a path whose first directory is literally~. Passing it toresolvePathLinkTargetinstead applies that helper's terminal-link expansion and resolves it relative to the user's home directory instead of the workspace. Thus a valid configured repository such as~/clientis queried outside the workspace rather than at<workspace>/~/client. [ Cross-file consolidated ]
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -59,3 +62,15 @@5962 });6063 export type T3ProjectFileScript = typeof T3ProjectFileScript.Type;616465+/**66+ * A Git repository inside a project workspace. Paths are intentionally relative67+ * so opening a shared workspace cannot grant the UI access outside it.68+ */69+export const T3ProjectFileRepository = Schema.Struct({70+ path: trimmedNonEmpty(71+ {72+ description:73+ 'Workspace-relative Git repository path, such as "frontend" or "services/api". Use "." for the workspace root.',74+ },75+ T3_PROJECT_FILE_PATH_MAX_LENGTH,76+ ).check(Schema.isPattern(WORKSPACE_RELATIVE_PATH_PATTERN)),
🟠 High
src/t3ProjectFile.ts:76repositories.pathaccepts~/...and Windows absolute paths such asC:/..., soresolvePathLinkTargetcan resolve a checked-in repository outside the workspace. The Diff panel then exposes that external repository’s status metadata; reject tilde and drive/UNC absolute forms (and enforce canonical workspace containment) before resolving the path.Also found in 1 other location(s)
apps/web/src/components/DiffPanel.tsx:173repositories.pathis validated as a workspace-relative path, and the schema permits~/…as a path whose first directory is literally~. Passing it toresolvePathLinkTargetinstead applies that helper's terminal-link expansion and resolves it relative to the user's home directory instead of the workspace. Thus a valid configured repository such as~/clientis queried outside the workspace rather than at<workspace>/~/client.🤖 Copy this AI Prompt to have your agent fix this:
In file @packages/contracts/src/t3ProjectFile.ts around line 76: `repositories.path` accepts `~/...` and Windows absolute paths such as `C:/...`, so `resolvePathLinkTarget` can resolve a checked-in repository outside the workspace. The Diff panel then exposes that external repository’s status metadata; reject tilde and drive/UNC absolute forms (and enforce canonical workspace containment) before resolving the path. Also found in 1 other location(s): - apps/web/src/components/DiffPanel.tsx:173 -- `repositories.path` is validated as a workspace-relative path, and the schema permits `~/…` as a path whose first directory is literally `~`. Passing it to `resolvePathLinkTarget` instead applies that helper's terminal-link expansion and resolves it relative to the user's home directory instead of the workspace. Thus a valid configured repository such as `~/client` is queried outside the workspace rather than at `<workspace>/~/client`.@@ -480,2 +503,2 @@480503 threadRef: routeThreadRef,481504 filePath,🟠 High
components/DiffPanel.tsx:504Selecting a nested repository causes
openDiffFilePrimaryActionto open paths relative to the parent workspace, sosrc/foo.tsinfrontendresolves toworkspace/src/foo.tsinstead ofworkspace/frontend/src/foo.ts. The call passesactiveCwdwhilerepositoryRootpoints at the child repository; pass the repository-resolvedactiveGitCwdas the working directory.🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/DiffPanel.tsx around line 504: Selecting a nested repository causes `openDiffFilePrimaryAction` to open paths relative to the parent workspace, so `src/foo.ts` in `frontend` resolves to `workspace/src/foo.ts` instead of `workspace/frontend/src/foo.ts`. The call passes `activeCwd` while `repositoryRoot` points at the child repository; pass the repository-resolved `activeGitCwd` as the working directory. Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d2b8371ef71a95d5cf346e7dfc0d0bb704fe915c. Configure [here](https://www.cursor.com/dashboard/bugbot).@@ -500,4 +526,4 @@500526 },501527 });502528 },503- [activeCwd, activeRepositoryRoot, openInPreferredEditor, routeThreadRef],529+ [activeCwd, activeRepositoryRoot, openInPreferredEditor, routeThreadRef, selectedRepository],Nested diff files open wrong path#
High Severity
Opening a file from a nested-repository diff still treats the git-relative path as workspace-relative.
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d2b8371ef71a95d5cf346e7dfc0d0bb704fe915c. Configure [here](https://www.cursor.com/dashboard/bugbot).repositoryRootis set to the nested repo, butresolveDiffPathForWorkspaceonly strips a repo prefix when the workspace sits inside that root, so it never addsfrontend/(or similar). The file viewer or editor then opens the wrong path, or fails if that path does not exist.@@ -542,3 +569,7 @@542569 if (!routeThreadRef) return;543570 useDiffPanelStore.getState().selectBranchBaseRef(routeThreadRef, baseRef);544571 };572+ const selectRepository = (path: string) => {573+ if (!routeThreadRef) return;574+ setSelectedRepositoryPath(path);575+ };Repo switch keeps stale base ref#
Medium Severity
Changing the Diff repository only updates
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d2b8371ef71a95d5cf346e7dfc0d0bb704fe915c. Configure [here](https://www.cursor.com/dashboard/bugbot).selectedRepositoryPath. The per-threadbaseRefstays indiffPanelStore, so the next preview still compares against the previous repo's ref. If that ref is missing, the nested-repo diff errors; if a same-named ref exists, it silently compares against the wrong history.Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This PR adds an opt-in multi-repository diff workflow that changes production status, diff, and file-opening behavior across several components. Unresolved concerns around nested-repository path resolution, containment, and stale base refs make human review necessary.
Not approved because:
- 2 blocking correctness issues found at or above your repo's Minimum Blocking Severity
Bugbot is paused — on-demand spend limit reached
Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.
A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.
Ready for re-review in d57ecc3ca.
Addressed the reported findings:
- Reject unsafe configured paths in both the runtime and published schema, and enforce canonical project containment for status, diff previews and file contents, including escaping symlinks.
- Open nested-repository files with the correct repository offset while keeping checkpoint files at the project root.
- Keep comparison state per repository, including changes to the configured default and transitions through checkpoint views.
Verification: 226 focused tests passed, all five affected package typechecks passed, and targeted lint/format checks passed. Fresh independent Astra review returned ship with no material findings. Four React lint warnings remain; browser acceptance and the full CI suite were not run locally.
Please re-review the updated commit. GitHub checks and automated reviews should assess this new head.
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
Note
This comment is posted by Julius' dot
Closing for missing UI verification. This adds a repository selector and changes Diff availability and file opening, but the PR has no before and after screenshots or recording of the interaction, and says browser acceptance was not run. The verification requirement requires that evidence for UI changes. Attach before and after images and a short recording showing repository switching and opening files from the selected repository, report the steps and observed results, then request reconsideration.
juliusmarminge closed this
Is this worth reopening now that orchestration V2 is on
main?Use case. I open a non-Git parent folder as the T3 project. It holds ~20 sibling Git repos (services, apps, SDKs, infra) plus shared agent context (
AGENTS.md,.claude/). Agents routinely edit several of those repos in one thread, so the parent folder is the natural project root.workspace/ # T3 project, no .git AGENTS.md .claude/ service-a/.git service-b/.git web-app/.git ... (~20 repos)Current behavior on
main(5b70d81b). The Diff panel is empty in every scope:- Changes / Uncommitted:
ReviewService.getDiffPreviewrunsvcsRegistry.detect({ cwd })on the project root, getsnull, and returnssources: []. - Latest turn:
CheckpointServiceV2.isGitCheckpointable(cwd)is false, so no baseline is captured. - Running
git initin the parent does not help:git add -Arecords child repos as gitlinks, so their uncommitted edits never show up.
Ask. An explicit, opt-in list of member repositories (as in #9816's
t3.jsonrepositoriesfield) with a repository selector in Diff/Changed files. I don't need implicit scanning, and nothing outside the project folder. Checkpoints for the per-turn view could stay per member repo or stay out of scope at first. Even the Changes / Uncommitted scopes alone would cover most of the need.Related: #11251 (closed pending V2), #12089 (sibling repos outside the workspace, a different case), #11528 (V2 turn-start snapshot is still single-cwd).
Happy to help test or provide UI verification if someone picks this up.
- Changes / Uncommitted:
Sign in to join this conversation.

macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed