Skip to content

fix(server): detect git repo from subdirectories so diffs and checkpoints work in monorepos#2443

Open
imabdulazeez wants to merge 3 commits intopingdotgg:mainfrom
imabdulazeez:fix/2441-diffs-missing-git-subdirectory
Open

fix(server): detect git repo from subdirectories so diffs and checkpoints work in monorepos#2443
imabdulazeez wants to merge 3 commits intopingdotgg:mainfrom
imabdulazeez:fix/2441-diffs-missing-git-subdirectory

Conversation

@imabdulazeez
Copy link
Copy Markdown
Contributor

@imabdulazeez imabdulazeez commented May 1, 2026

What Changed

  • isGitRepository(cwd) in apps/server/src/git/Utils.ts now walks up the directory tree until it finds a .git entry or hits the filesystem root, instead of only checking cwd/.git.
  • No behavioral change at the repo root — same result for cwds that already had .git directly inside them.

Why

Closes #2441.

When a workspace cwd points at a sub-package of a git repo (e.g. apps/server in a monorepo), the previous one-level check returned false, 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 status works fine from that same cwd. Walking parents matches git'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

image

Diff view

image

Checklist

Note

Fix isGitRepository to detect git repos from subdirectories for monorepo support

Previously, isGitRepository in Utils.ts only returned true if the provided directory itself contained a .git folder. It now walks up the directory tree using a do-while loop, checking each ancestor until it finds .git or reaches the filesystem root. This fixes diffs and checkpoints when the working directory is a subdirectory within a monorepo.

Macroscope summarized 594fc8d.

… 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
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0ba48bfb-b126-4ef9-b151-e4228727c1ca

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:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels May 1, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes May 1, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 1, 2026

Approvability

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

Comment thread apps/server/src/git/Utils.ts Outdated
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).
@github-actions github-actions Bot added size:XS 0-9 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels May 1, 2026
@macroscopeapp macroscopeapp Bot dismissed their stale review May 1, 2026 12:23

Dismissing prior approval to re-evaluate 352a504

Comment thread apps/server/src/git/Utils.ts
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.
@imabdulazeez
Copy link
Copy Markdown
Contributor Author

Approvability

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

This has been addressed too. thanks

@imabdulazeez
Copy link
Copy Markdown
Contributor Author

Hi @juliusmarminge -- Friendly reminder to review if possible. This is making working with monorepos a bit difficult and this should fix it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Diffs/checkpoints not shown when workspace cwd is a subdirectory of a git repo

2 participants