Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 18, 2025

Fixes #7183

Summary

This PR modifies the diff application logic to treat identical search and replace content as successful no-op operations instead of throwing errors. This addresses the issue where AI providers like Gemini sometimes generate identical diffs.

Changes

  • Modified multi-search-replace.ts to skip identical diffs silently and count them as successful no-ops
  • Modified multi-file-search-replace.ts with the same logic for consistency
  • Added comprehensive test coverage for the new behavior in identical-diff.spec.ts

Testing

  • All existing tests pass
  • New tests added specifically for identical diff handling
  • Tests cover both single and multiple diff scenarios, including mixed cases where some diffs are identical and others are not

Impact

This change makes Roo Code more tolerant of AI-generated diffs, improving the user experience when working with providers that occasionally produce identical search/replace blocks.


Important

Identical diffs are now treated as no-ops in multi-search-replace.ts and multi-file-search-replace.ts, with tests added in identical-diff.spec.ts.

  • Behavior:
    • multi-search-replace.ts and multi-file-search-replace.ts now treat identical search and replace content as successful no-ops, incrementing appliedCount without error.
  • Testing:
    • New tests in identical-diff.spec.ts cover scenarios with identical diffs, including single and multiple diff cases.
  • Impact:
    • Enhances tolerance for AI-generated diffs, improving user experience with providers like Gemini.

This description was created by Ellipsis for 8a86af0. You can customize this summary. It will automatically update as commits are pushed.

- Modified multi-search-replace.ts and multi-file-search-replace.ts to treat identical search/replace content as successful no-op operations
- Added comprehensive tests for the new behavior
- Fixes #7183 where Gemini and other AI providers sometimes generate identical diffs
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 18, 2025 14:23
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Aug 18, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Reviewing my own code is like debugging in a mirror - everything looks backwards but somehow still broken.

// This is a no-op diff, skip it without error
// Some AI providers (like Gemini) sometimes generate identical diffs
// We treat these as successful no-ops rather than errors
appliedCount++ // Count it as applied since it's intentionally a no-op
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Consider adding telemetry here to track how often identical diffs occur. This data could help us understand AI provider behavior patterns and potentially improve the user experience further.

// This is a no-op diff, skip it without error
// Some AI providers (like Gemini) sometimes generate identical diffs
// We treat these as successful no-ops rather than errors
appliedCount++ // Count it as applied since it's intentionally a no-op
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same telemetry suggestion applies here for consistency. Also, could we add debug-level logging when skipping identical diffs? It might help with troubleshooting without affecting production performance.

// Content should remain unchanged
expect(result.content).toBe(originalContent)
}
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test coverage is comprehensive, but consider adding an explicit test that verifies the is correctly incremented for no-op diffs. This would ensure we're properly counting them as successful operations rather than just skipping them.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 18, 2025
@daniel-lxs daniel-lxs closed this Aug 19, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Aug 19, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

"Accept" identical diffs - Gemini sometimes proposes identical diffs, those should be accepted

4 participants