-
Notifications
You must be signed in to change notification settings - Fork 751
fix(amazonq): codefix does not do error handling #6307
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
Changes from all commits
04644c2
c74177b
7cdfd50
687ae39
1d8491c
4d0af53
07d98e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "type": "Bug Fix", | ||
| "description": "/review: Improved error handling for code fix operations" | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -27,12 +27,12 @@ export class SecurityIssueWebview extends VueWebview { | |||||
| public readonly onChangeIssue = new vscode.EventEmitter<CodeScanIssue | undefined>() | ||||||
| public readonly onChangeFilePath = new vscode.EventEmitter<string | undefined>() | ||||||
| public readonly onChangeGenerateFixLoading = new vscode.EventEmitter<boolean>() | ||||||
| public readonly onChangeGenerateFixError = new vscode.EventEmitter<boolean>() | ||||||
| public readonly onChangeGenerateFixError = new vscode.EventEmitter<string | null | undefined>() | ||||||
|
|
||||||
| private issue: CodeScanIssue | undefined | ||||||
| private filePath: string | undefined | ||||||
| private isGenerateFixLoading: boolean = false | ||||||
| private isGenerateFixError: boolean = false | ||||||
| private generateFixError: string | null | undefined = undefined | ||||||
|
|
||||||
| public constructor() { | ||||||
| super(SecurityIssueWebview.sourcePath) | ||||||
|
|
@@ -99,13 +99,13 @@ export class SecurityIssueWebview extends VueWebview { | |||||
| this.onChangeGenerateFixLoading.fire(isGenerateFixLoading) | ||||||
| } | ||||||
|
|
||||||
| public getIsGenerateFixError() { | ||||||
| return this.isGenerateFixError | ||||||
| public getGenerateFixError() { | ||||||
| return this.generateFixError | ||||||
| } | ||||||
|
|
||||||
| public setIsGenerateFixError(isGenerateFixError: boolean) { | ||||||
| this.isGenerateFixError = isGenerateFixError | ||||||
| this.onChangeGenerateFixError.fire(isGenerateFixError) | ||||||
| public setGenerateFixError(generateFixError: string | null | undefined) { | ||||||
|
Contributor
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. Can probably drop |
||||||
| this.generateFixError = generateFixError | ||||||
| this.onChangeGenerateFixError.fire(generateFixError) | ||||||
| } | ||||||
|
|
||||||
| public generateFix() { | ||||||
|
|
@@ -201,7 +201,7 @@ export async function showSecurityIssueWebview(ctx: vscode.ExtensionContext, iss | |||||
| activePanel.server.setIssue(issue) | ||||||
| activePanel.server.setFilePath(filePath) | ||||||
| activePanel.server.setIsGenerateFixLoading(false) | ||||||
| activePanel.server.setIsGenerateFixError(false) | ||||||
| activePanel.server.setGenerateFixError(undefined) | ||||||
|
|
||||||
| const webviewPanel = await activePanel.show({ | ||||||
| title: amazonqCodeIssueDetailsTabTitle, | ||||||
|
|
@@ -247,15 +247,15 @@ type WebviewParams = { | |||||
| issue?: CodeScanIssue | ||||||
| filePath?: string | ||||||
| isGenerateFixLoading?: boolean | ||||||
| isGenerateFixError?: boolean | ||||||
| generateFixError?: string | null | ||||||
|
Contributor
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. I think this should be good enough
Suggested change
Contributor
Author
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. I think updateSecurityIssueWebview({
...
generateFixError: null
})while the absence of the field should not remove it updateSecurityIssueWebview({
...
issue: newIssue
}) |
||||||
| shouldRefreshView: boolean | ||||||
| context: vscode.ExtensionContext | ||||||
| } | ||||||
| export async function updateSecurityIssueWebview({ | ||||||
| issue, | ||||||
| filePath, | ||||||
| isGenerateFixLoading, | ||||||
| isGenerateFixError, | ||||||
| generateFixError, | ||||||
| shouldRefreshView, | ||||||
| context, | ||||||
| }: WebviewParams): Promise<void> { | ||||||
|
|
@@ -271,8 +271,8 @@ export async function updateSecurityIssueWebview({ | |||||
| if (isGenerateFixLoading !== undefined) { | ||||||
| activePanel.server.setIsGenerateFixLoading(isGenerateFixLoading) | ||||||
| } | ||||||
| if (isGenerateFixError !== undefined) { | ||||||
| activePanel.server.setIsGenerateFixError(isGenerateFixError) | ||||||
| if (generateFixError !== undefined) { | ||||||
| activePanel.server.setGenerateFixError(generateFixError) | ||||||
| } | ||||||
| if (shouldRefreshView && filePath && issue) { | ||||||
| await showSecurityIssueWebview(context, issue, filePath) | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -48,16 +48,14 @@ | |||||
| </div> | ||||||
|
|
||||||
| <div | ||||||
| v-if="isFixAvailable || isGenerateFixLoading || isGenerateFixError || isFixDescriptionAvailable" | ||||||
| v-if="isFixAvailable || isGenerateFixLoading || generateFixError || isFixDescriptionAvailable" | ||||||
| ref="codeFixSection" | ||||||
| > | ||||||
| <hr /> | ||||||
|
|
||||||
| <h3>Suggested code fix preview</h3> | ||||||
| <pre v-if="isGenerateFixLoading" class="center"><div class="dot-typing"></div></pre> | ||||||
| <pre v-if="isGenerateFixError" class="center error"> | ||||||
| Something went wrong. <a @click="regenerateFix">Retry</a> | ||||||
| </pre> | ||||||
| <pre v-if="generateFixError" class="center error">{{ generateFixError }}</pre> | ||||||
| <div class="code-block"> | ||||||
| <span v-if="isFixAvailable" v-html="suggestedFixHtml"></span> | ||||||
| <div v-if="isFixAvailable" class="code-diff-actions" ref="codeFixAction"> | ||||||
|
|
@@ -195,7 +193,7 @@ export default defineComponent({ | |||||
| endLine: 0, | ||||||
| relativePath: '', | ||||||
| isGenerateFixLoading: false, | ||||||
| isGenerateFixError: false, | ||||||
| generateFixError: undefined as string | null | undefined, | ||||||
|
Contributor
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. This should be good enough. I think the types upstream may need to be modified
Suggested change
|
||||||
| languageId: 'plaintext', | ||||||
| fixedCode: '', | ||||||
| referenceText: '', | ||||||
|
|
@@ -218,8 +216,8 @@ export default defineComponent({ | |||||
| const relativePath = await client.getRelativePath() | ||||||
| this.updateRelativePath(relativePath) | ||||||
| const isGenerateFixLoading = await client.getIsGenerateFixLoading() | ||||||
| const isGenerateFixError = await client.getIsGenerateFixError() | ||||||
| this.updateGenerateFixState(isGenerateFixLoading, isGenerateFixError) | ||||||
| const generateFixError = await client.getGenerateFixError() | ||||||
| this.updateGenerateFixState(isGenerateFixLoading, generateFixError) | ||||||
| const languageId = await client.getLanguageId() | ||||||
| if (languageId) { | ||||||
| this.updateLanguageId(languageId) | ||||||
|
|
@@ -249,16 +247,16 @@ export default defineComponent({ | |||||
| this.isGenerateFixLoading = isGenerateFixLoading | ||||||
| this.scrollTo('codeFixSection') | ||||||
| }) | ||||||
| client.onChangeGenerateFixError((isGenerateFixError) => { | ||||||
| this.isGenerateFixError = isGenerateFixError | ||||||
| client.onChangeGenerateFixError((generateFixError) => { | ||||||
| this.generateFixError = generateFixError | ||||||
| }) | ||||||
| }, | ||||||
| updateRelativePath(relativePath: string) { | ||||||
| this.relativePath = relativePath | ||||||
| }, | ||||||
| updateGenerateFixState(isGenerateFixLoading: boolean, isGenerateFixError: boolean) { | ||||||
| updateGenerateFixState(isGenerateFixLoading: boolean, generateFixError: string | null | undefined) { | ||||||
| this.isGenerateFixLoading = isGenerateFixLoading | ||||||
| this.isGenerateFixError = isGenerateFixError | ||||||
| this.generateFixError = generateFixError | ||||||
| }, | ||||||
| updateLanguageId(languageId: string) { | ||||||
| this.languageId = languageId | ||||||
|
|
||||||
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.
Try