-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(chat): Improve diff appearance in main chat view #8932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1bac383
18ab7b2
1fb2da7
56882e4
e3f09e3
cebd646
2c39a93
1b86bab
5f17d50
15589b0
960fe90
408e9fb
a4fac50
5256aed
356a3e0
f7b99d5
4693132
7906320
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -173,6 +173,15 @@ export async function writeToFileTool( | |
|
|
||
| if (isPreventFocusDisruptionEnabled) { | ||
| // Direct file write without diff view | ||
| // Set up diffViewProvider properties needed for diff generation and saveDirectly | ||
| cline.diffViewProvider.editType = fileExists ? "modify" : "create" | ||
| if (fileExists) { | ||
| const absolutePath = path.resolve(cline.cwd, relPath) | ||
| cline.diffViewProvider.originalContent = await fs.readFile(absolutePath, "utf-8") | ||
| } else { | ||
| cline.diffViewProvider.originalContent = "" | ||
| } | ||
|
|
||
| // Check for code omissions before proceeding | ||
| if (detectCodeOmission(cline.diffViewProvider.originalContent || "", newContent, predictedLineCount)) { | ||
| if (cline.diffStrategy) { | ||
|
|
@@ -204,7 +213,10 @@ export async function writeToFileTool( | |
|
|
||
| const completeMessage = JSON.stringify({ | ||
| ...sharedMessageProps, | ||
| content: newContent, | ||
| content: fileExists ? undefined : newContent, | ||
| diff: fileExists | ||
| ? formatResponse.createPrettyPatch(relPath, cline.diffViewProvider.originalContent, newContent) | ||
| : undefined, | ||
| } satisfies ClineSayTool) | ||
|
Comment on lines
+216
to
220
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Fix it with Roo Code or mention @roomote and request a fix. |
||
|
|
||
| const didApprove = await askApproval("tool", completeMessage, undefined, isWriteProtected) | ||
|
|
@@ -213,15 +225,6 @@ export async function writeToFileTool( | |
| return | ||
| } | ||
|
|
||
| // Set up diffViewProvider properties needed for saveDirectly | ||
| cline.diffViewProvider.editType = fileExists ? "modify" : "create" | ||
| if (fileExists) { | ||
| const absolutePath = path.resolve(cline.cwd, relPath) | ||
| cline.diffViewProvider.originalContent = await fs.readFile(absolutePath, "utf-8") | ||
| } else { | ||
| cline.diffViewProvider.originalContent = "" | ||
| } | ||
|
|
||
| // Save directly without showing diff view or opening the file | ||
| await cline.diffViewProvider.saveDirectly(relPath, newContent, false, diagnosticsEnabled, writeDelayMs) | ||
| } else { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When editing an existing file, the
completeMessagenow omits 'content' in favor of a 'diff' field generated fromcline.diffViewProvider.originalContent. Ensure thatoriginalContentis reliably loaded before this call (especially in thepreventFocusDisruptionbranch) so the diff patch is accurate. Consider moving the original file read before constructingcompleteMessageif needed.