Skip to content

fix: scope inline chat accept/reject lenses to the task document#142

Draft
laileni-aws wants to merge 1 commit into
aws:mainfrom
laileni-aws:fix/inline-chat-codelens-wrong-file
Draft

fix: scope inline chat accept/reject lenses to the task document#142
laileni-aws wants to merge 1 commit into
aws:mainfrom
laileni-aws:fix/inline-chat-codelens-wrong-file

Conversation

@laileni-aws

Copy link
Copy Markdown
Contributor

Problem

When using inline chat, if the user triggers a suggestion and then switches to another file without accepting or rejecting it, the Accept / Reject code lenses (and the "Amazon Q is generating..." lens) appear in that unrelated file.

Root cause

CodelensProvider (in packages/amazonq/src/inlineChat/codeLenses/codeLenseProvider.ts) is registered for all documents:

vscode.languages.registerCodeLensProvider('*', this)

and provideCodeLenses(_document, _token) returned this.codeLenses while ignoring the _document argument. So the lenses built for the active inline task were returned for every document VS Code queried — including whatever file the user switched to.

Fix

Track the document that owns the active inline task (task.document.uri) and only return the lenses when the queried document matches:

public provideCodeLenses(document, _token) {
    if (this.taskDocumentUri === undefined || document.uri.toString() !== this.taskDocumentUri.toString()) {
        return []
    }
    return this.codeLenses
}

The owning document URI is set in updateLenses and cleared when the task completes.

Testing

  • Added packages/amazonq/test/unit/inlineChat/codeLenseProvider.test.ts:
    • decision lenses appear only in the task's document, not other files (regression guard);
    • the in-progress lens is likewise scoped to the task's document;
    • lenses are cleared when the task completes.
  • Added a changelog entry.

Notes

  • No change to when lenses are created — only to which document they are shown in.

The inline chat CodeLens provider is registered for all documents and
returned its lenses regardless of which document was being queried.
When a user triggered inline chat and then switched to another file
before accepting or rejecting, the Accept/Reject (and generating)
lenses appeared in that unrelated file.

Track the document that owns the active inline task and only return
the lenses when the queried document matches it.
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.

1 participant