Skip to content

fix: include untracked new files in uncommitted/unstaged code review diffs#227

Merged
backnotprop merged 1 commit intobacknotprop:mainfrom
zerone0x:fix/review-include-new-files-189
Mar 5, 2026
Merged

fix: include untracked new files in uncommitted/unstaged code review diffs#227
backnotprop merged 1 commit intobacknotprop:mainfrom
zerone0x:fix/review-include-new-files-189

Conversation

@zerone0x
Copy link
Contributor

@zerone0x zerone0x commented Mar 5, 2026

Summary

Fixes #189

Newly created files (untracked by git) were missing from the plannotator-review UI because git diff HEAD and git diff only output changes for files that are already tracked. Any file created by the agent but not yet staged with git add was invisible to the code review interface.

Root Cause

In packages/server/git.ts, the runGitDiff() function uses:

  • git diff HEAD for the uncommitted view
  • git diff for the unstaged view

Both commands silently omit untracked files.

Fix

Add a getUntrackedFileDiffs() helper that:

  1. Discovers untracked files via git ls-files --others --exclude-standard
    (respects .gitignore, so node_modules, dist, etc. are excluded automatically)
  2. Generates a standard unified diff for each file via git diff --no-index --src-prefix=a/ --dst-prefix=b/ /dev/null <file>

The resulting diffs are appended to the tracked-file diff in both the uncommitted and unstaged modes. The staged / last-commit / branch modes are not affected (they work correctly as-is).

Changes

  • packages/server/git.ts — add getUntrackedFileDiffs() helper; update uncommitted and unstaged cases in runGitDiff() to include its output (+47/-4 lines)

🤖 Generated with Claude Code

Previously, `git diff HEAD` and `git diff` only show changes to already-tracked
files. Newly created files that haven't been staged with `git add` were
invisible to the code review UI, causing the reported issue where new files
created by the agent simply didn't appear in the review interface.

Add `getUntrackedFileDiffs()` which:
1. Lists untracked files via `git ls-files --others --exclude-standard`
   (respects .gitignore, so node_modules and dist dirs are excluded)
2. Generates a proper unified diff for each via `git diff --no-index`

Append these diffs to the tracked-file diff in both the "uncommitted" and
"unstaged" modes, which are the two views that should represent the full
working-tree state.

Fixes backnotprop#189

Co-Authored-By: Claude <noreply@anthropic.com>
@backnotprop
Copy link
Owner

Nice!

@backnotprop backnotprop merged commit b7bc82c into backnotprop:main Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plannotator-review UI fails to display newly created files

2 participants