Skip to content

Detect file renames in review diffs - #3916

Closed
jakeleventhal wants to merge 4 commits into
pingdotgg:mainfrom
jakeleventhal:t3code/detect-file-renames
Closed

jakeleventhal wants to merge 4 commits into
pingdotgg:mainfrom
jakeleventhal:t3code/detect-file-renames

Conversation

@jakeleventhal

@jakeleventhal jakeleventhal commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Verification

1. File rename with no changes

Git detects one rename and the viewer renders a single exact-original.ts → exact-renamed.ts entry with -0 +0 and no content hunk.

Exact file rename with no content changes

2. File rename with minimal changes

Git detects an 84% similar rename, so the viewer keeps one minimal-original.ts → minimal-renamed.ts entry and renders the -1 +1 content diff.

File rename with a minimal content diff

3. File rename with too many changes

The files are below Git's rename-similarity threshold, so the viewer correctly renders replaced-new.ts as an addition and replaced-original.ts as a deletion.

Files below the rename threshold shown separately as added and deleted

Summary

  • enable Git rename detection for working-tree and branch review diffs
  • include untracked rename destinations through an isolated temporary index without modifying the user's real index
  • preserve content hunks when a renamed file also has minor edits

Root cause

Working-tree previews generated tracked and untracked patches separately. A normal filesystem rename therefore appeared as an unrelated deletion and addition because Git never saw both paths in the same comparison.

Impact

The diff viewer now renders qualifying file moves as one renamed file while still showing any content changes. Branch comparisons use the same explicit Git rename detection.

Validation

  • pnpm exec vp test apps/server/src/vcs/GitVcsDriverCore.test.ts (27 tests)
  • pnpm exec vp check
  • pnpm exec vp run typecheck
  • git diff --check

Note

Detect file renames in working-tree and branch-range review diffs

  • Replaces the previous approach of per-file --no-index diffs for untracked files with a single unified diff built via a temporary Git index in GitVcsDriverCore.ts.
  • Untracked files are staged as intent-to-add in the temp index, and staged deletions are enumerated so the final diff reflects renames, sparse-checkout entries, and deletion context in one pass.
  • Adds --find-renames to both the working-tree and branch-range diff invocations.
  • Falls back to readTrackedWorkingTreeReviewDiff (tracked changes only, no untracked files) if the temp-index approach fails with a GitCommandError.
  • Behavioral Change: working-tree diffs now include untracked files and report truncation if any intermediate listing or diff is truncated; branch-range diffs now surface renames.

Macroscope summarized e226410.


Note

Medium Risk
Changes core Git diff preview behavior for dirty worktrees (new subprocess/index workflow) with fallbacks, but mistakes could misrepresent staged/untracked or rename state in the review UI.

Overview
Working-tree review previews no longer merge a tracked git diff HEAD with per-file git diff --no-index for untracked paths. They now build one patch via readWorkingTreeReviewDiff: copy the real index into a temp GIT_INDEX_FILE, stage untracked paths with git add --intent-to-add, run a single git diff --find-renames against HEAD (or an empty tree before the first commit), and tear down the temp index without touching the user’s split/shared index. On failure, readTrackedWorkingTreeReviewDiff still returns tracked changes with rename detection.

Branch-range previews add --find-renames to the existing base…HEAD diff so committed renames show as one entry with content hunks.

Integration tests cover pre-first-commit dirty trees, unstaged/committed renames with edits, sparse-checkout, staged index-only deletions (including truncated deletion lists), nested repos, split-index safety, and several fallback paths when temp-index steps fail.

Reviewed by Cursor Bugbot for commit e226410. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

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 Plus

Run ID: e5b7519f-7057-477c-95c5-422663c31e55

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jul 12, 2026
@jakeleventhal
jakeleventhal marked this pull request as ready for review July 12, 2026 17:03
@macroscopeapp

macroscopeapp Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

1 blocking correctness issue found. This PR introduces new rename detection capability in review diffs with substantial implementation complexity (temporary index manipulation, split-index handling, error recovery). The ~200 lines of new implementation logic, runtime behavior changes, and an unresolved High severity finding about silent error handling warrant human review.

You can customize Macroscope's approvability policy. Learn more.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ac42fc27c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/server/src/vcs/GitVcsDriverCore.ts Outdated
Comment thread apps/server/src/vcs/GitVcsDriverCore.ts Outdated
Comment thread apps/server/src/vcs/GitVcsDriverCore.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0fc42d53cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/server/src/vcs/GitVcsDriverCore.ts Outdated
Comment thread apps/server/src/vcs/GitVcsDriverCore.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd2f9f87ba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/server/src/vcs/GitVcsDriverCore.ts Outdated
@jakeleventhal
jakeleventhal force-pushed the t3code/detect-file-renames branch from fd2f9f8 to 5c5c8da Compare August 10, 2026 19:29
Comment thread apps/server/src/vcs/GitVcsDriverCore.ts Outdated

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One error-modeling issue found in apps/server/src/vcs/GitVcsDriverCore.ts: the shared-index copyFile failure is not mapped to the service's domain error.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/server/src/vcs/GitVcsDriverCore.ts Outdated
Comment thread apps/server/src/vcs/GitVcsDriverCore.ts
@jakeleventhal
jakeleventhal force-pushed the t3code/detect-file-renames branch from c762d03 to 1535d69 Compare August 10, 2026 20:23

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1535d69. Configure here.

Comment thread apps/server/src/vcs/GitVcsDriverCore.ts

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the new working-tree review-diff helpers against the Effect service conventions. One unmapped platform failure remains in readWorkingTreeReviewDiff.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/server/src/vcs/GitVcsDriverCore.ts Outdated
Comment thread apps/server/src/vcs/GitVcsDriverCore.ts
@t3dotgg t3dotgg added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. and removed vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Aug 24, 2026
@t3dotgg

t3dotgg commented Aug 24, 2026

Copy link
Copy Markdown
Member

Note

🤖 GPT-5.6 Sol responding on behalf of Theo

Closing this because the branch and screenshots are too far behind the current app.

We are still interested in correct file rename detection. Please open a new, smaller PR based on the latest main, with screenshots of the current UI that show a clear before and after. If the implementation still needs a temporary Git index or extra Git processes, explain why and include its performance impact.

@jakeleventhal

Copy link
Copy Markdown
Contributor Author

[!NOTE]
🤖 GPT-5.6 Sol responding on behalf of Theo

Closing this because the branch and screenshots are too far behind the current app.

We are still interested in correct file rename detection. Please open a new, smaller PR based on the latest main, with screenshots of the current UI that show a clear before and after. If the implementation still needs a temporary Git index or extra Git processes, explain why and include its performance impact.

@t3dotgg #8086 voila

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

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants