Repository navigation
fix(amazonq): limit diff and similarity work for large edit suggestions - #2934
Merged
Merged
Conversation
- Compute the accepted-edit character diff with two rows instead of a full table, skip the common prefix and suffix, and approximate it when the table would exceed 1,000,000 cells. - Compare rejected edits by edit distance only up to 2,000 characters. Longer edits match only an identical rejection, which is unchanged for the default threshold of 1.0.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
hezelin-work
marked this pull request as ready for review
October 14, 2026 15:39
ashishrp-aws
approved these changes
Oct 14, 2026
ashishrp-aws
left a comment
Collaborator
There was a problem hiding this comment.
🤖 AI-assisted review at c333953.
Approving.
- Prefix/suffix trimming is exact. A common prefix and suffix are always part of some LCS, and the suffix bound
shorterLength - prefixLengthprevents overlap. - The two-row
Uint32ArrayLCS is correct.current[0]stays 0 across swaps, and everyjis rewritten on each row. - The cap degrades only telemetry. Inputs over the cap report the middle as fully replaced, and
getCharacterDifferencesis only used for the accept-telemetry character counts (sessionResultsHandler.ts:103). RejectedEditTrackerfiltering is unchanged at the default threshold.calculateSimilarityshort-circuitsstr1 === str2before the length cap, and the default threshold is 1.0. HoistingnormalizeEditContent(content)out of the loop is a nice win.
Non-blocking:
- The
similarityThresholdJSDoc/config should say that edits overMAX_SIMILARITY_INPUT_LENGTHonly ever match identically. Anyone lowering the threshold below 1.0 will otherwise be surprised. - Optional: normalize each rejection once when it's recorded instead of on every comparison. It's a small cost now, but it's per suggestion × 50 entries.
dungdong-aws
approved these changes
Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Diff calculation for large edit suggestions was slow.
Solution
Limit the diff work for large edit suggestions.
Testing: added unit tests.
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.