Improve apply_patch diff UI and atomicity#47
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
apply_patch staging, diff library, and UI patch tool classification
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/apply-patch.test.ts (1)
151-151: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert the patched file content too.
This test can pass on diff shape alone; add a readback assertion so it also catches regressions where the emitted patch has two hunks but the file was not updated correctly.
🧪 Proposed test strengthening
assert.equal(splitHunkResult.patch.match(/^@@ /gm)?.length, 2); +assert.equal( + await readFile(join(splitHunkRoot, "long.txt"), "utf8"), + [ + "1", "two", "3", "4", "5", "6", "7", "8", "9", "10", + "11", "12", "13", "14", "15", "16", "17", "eighteen", "19", "20", + ].join("\n") + "\n", +);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/apply-patch.test.ts` at line 151, The apply-patch test currently only checks patch shape, so strengthen it by asserting the resulting file content after applying the patch as well. In src/apply-patch.test.ts, update the test around splitHunkResult so it reads back the patched file and verifies the expected content, using the existing applyPatch/splitHunkResult flow to ensure the patch emitted by the patching logic actually updates the file correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/apply-patch.ts`:
- Line 434: The diff rendering in apply-patch should preserve intentional
trailing spaces on the final line instead of removing them with trimEnd().
Update the logic around the trimEnd() call to strip only the trailing newline
from the generated diff, keeping any spaces that are part of the last diff line;
use the surrounding diff-building code in apply-patch to locate the exact spot.
---
Nitpick comments:
In `@src/apply-patch.test.ts`:
- Line 151: The apply-patch test currently only checks patch shape, so
strengthen it by asserting the resulting file content after applying the patch
as well. In src/apply-patch.test.ts, update the test around splitHunkResult so
it reads back the patched file and verifies the expected content, using the
existing applyPatch/splitHunkResult flow to ensure the patch emitted by the
patching logic actually updates the file correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 32c094a6-916c-4b71-ad3d-d3e84cd0b17b
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (7)
package.jsonsrc/apply-patch.test.tssrc/apply-patch.tssrc/server.tssrc/ui/card-types.test.tssrc/ui/card-types.tssrc/ui/workspace-app.tsx
Summary
Tests
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Chores