fix(server): detect git repo from subdirectories so diffs and checkpoints work in monorepos#2443
Conversation
… a git repo are detected Previously isGitRepository only checked cwd/.git, so opening t3code at a sub-package of a monorepo (e.g. apps/server) was treated as non-git, silently disabling checkpoints and the diff panel. Walk up to the filesystem root to match git's own behavior. Fixes pingdotgg#2441
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review An unresolved review comment identifies a critical bug: the loop structure skips checking the initial directory for .git, which would break detection when the starting path is the repo root. This logic error needs to be addressed before merging. You can customize Macroscope's approvability policy. Learn more. |
Apply review suggestion: collapse the parent-walk into a single while loop using the dirname-equals-self termination check, and drop the redundant parse(cwd).root guard. Behavior is unchanged for every cwd the codebase actually passes in (always a sub-path of the repo).
Dismissing prior approval to re-evaluate 352a504
The previous while-loop form advanced current to its parent in the loop condition before the existsSync check ran, so the input directory was never tested. Calling isGitRepository on a path that itself contains .git returned false. Switch to do...while so the check runs before the advance, without duplicating the existsSync call.
This has been addressed too. thanks |
|
Hi @juliusmarminge -- Friendly reminder to review if possible. This is making working with monorepos a bit difficult and this should fix it :) |
What Changed
isGitRepository(cwd)inapps/server/src/git/Utils.tsnow walks up the directory tree until it finds a.gitentry or hits the filesystem root, instead of only checkingcwd/.git..gitdirectly inside them.Why
Closes #2441.
When a workspace cwd points at a sub-package of a git repo (e.g.
apps/serverin a monorepo), the previous one-level check returnedfalse, so:CheckpointReactor(apps/server/src/orchestration/Layers/CheckpointReactor.ts:152) treated the workspace as non-git and skipped checkpoint capture.ProviderRuntimeIngestion(apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts:569) skipped git ingestion.CheckpointStore.isGitRepository(apps/server/src/checkpointing/Layers/CheckpointStore.ts:78) inherited the same blind spot.The user-visible symptom is an empty diff panel and missing checkpoints for any thread whose cwd isn't the repo root, even though
git statusworks fine from that same cwd. Walking parents matchesgit's own discovery behavior and fixes the gated features without changing any other code paths.UI Changes
Not directly, but the visible effect is that the existing diff panel and checkpoint UI now start populating for sub-package workspaces. Tested the change based on the same repo in the issue #2441
Checkpoint button
Diff view
Checklist
Note
Fix
isGitRepositoryto detect git repos from subdirectories for monorepo supportPreviously,
isGitRepositoryin Utils.ts only returnedtrueif the provided directory itself contained a.gitfolder. It now walks up the directory tree using a do-while loop, checking each ancestor until it finds.gitor reaches the filesystem root. This fixes diffs and checkpoints when the working directory is a subdirectory within a monorepo.Macroscope summarized 594fc8d.