Skip to content

Conversation

@floralph
Copy link
Contributor

@floralph floralph commented Aug 12, 2025

Problem

Amazon Q edit suggestions remain active even when users navigate far away from the suggestion location, leading to confusion and potential unintended edits when users accept suggestions they can no longer see.

Solution

Added automatic rejection of edit suggestions when the cursor moves more than 25 lines away from the suggestion location. Implemented cursor change listener with proper cleanup to prevent memory leaks and ensure suggestions are only accepted when contextually relevant.

Fixed 2 failing recommendationService.test.ts tests


  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@floralph floralph requested a review from a team as a code owner August 12, 2025 02:42
@amazon-inspector-ohio
Copy link

⏳ I'm reviewing this pull request for security vulnerabilities and code quality issues. I'll provide an update when I'm done

@amazon-inspector-ohio
Copy link

✅ I finished the code review, and didn't find any security or code quality issues.

@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "auto-reject edit suggestions when cursor moves >25 lines away"
Copy link
Contributor

Choose a reason for hiding this comment

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

should we add the changelogs? the feature is not released yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted

getLogger().info('Edit suggestion rejected')
await decorationManager.clearDecorations(editor)
documentChangeListener.dispose()
cursorChangeListener.dispose()
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to add this method for reject case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, both accept and reject code paths represent the end of the suggestion lifecycle, so both must dispose of the listener to prevent memory leaks and ensure the listener doesn't continue running after the suggestion is already handled.

void vscode.commands.executeCommand('aws.amazonq.inline.rejectEdit')
}
})
const cursorChangeListener = vscode.window.onDidChangeTextEditorSelection((e) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you also add a screenshot of your testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shared video with group

andrewyuq
andrewyuq previously approved these changes Aug 12, 2025
@github-actions
Copy link

  • This pull request implements a feat or fix, so it must include a changelog entry (unless the fix is for an unreleased feature). Review the changelog guidelines.
    • Note: beta or "experiment" features that have active users should announce fixes in the changelog.
    • If this is not a feature or fix, use an appropriate type from the title guidelines. For example, telemetry-only changes should use the telemetry type.

@floralph floralph merged commit 3135e98 into master Aug 12, 2025
45 of 46 checks passed
@floralph floralph deleted the floralph/cursor-edit-reject branch August 12, 2025 19:06
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.

3 participants