diff --git a/extensions/typescript-language-features/src/languageFeatures/quickFix.ts b/extensions/typescript-language-features/src/languageFeatures/quickFix.ts index fa264128727..cd5cd4024f4 100644 --- a/extensions/typescript-language-features/src/languageFeatures/quickFix.ts +++ b/extensions/typescript-language-features/src/languageFeatures/quickFix.ts @@ -321,29 +321,22 @@ class TypeScriptQuickFixProvider implements vscode.CodeActionProvider{ action: action, diagnostic, document }], - title: '' - }; - actions.push(codeAction); - + let message: string | undefined; + let expand: Expand | undefined; + let title = action.description; if (vscode.workspace.getConfiguration('typescript').get('experimental.aiCodeActions')) { - let message: string | undefined; - let expand: Expand | undefined; - if (action.fixName === fixNames.classIncorrectlyImplementsInterface && vscode.workspace.getConfiguration('typescript').get('experimental.aiCodeActions.classIncorrectlyImplementsInterface')) { + title += ' with Copilot'; message = `Implement the stubbed-out class members for ${document.getText(diagnostic.range)} with a useful implementation.`; expand = { kind: 'code-action', action }; } else if (action.fixName === fixNames.fixClassDoesntImplementInheritedAbstractMember && vscode.workspace.getConfiguration('typescript').get('experimental.aiCodeActions.classDoesntImplementInheritedAbstractMember')) { + title += ' with Copilot'; message = `Implement the stubbed-out class members for ${document.getText(diagnostic.range)} with a useful implementation.`; expand = { kind: 'code-action', action }; } else if (action.fixName === fixNames.fixMissingFunctionDeclaration && vscode.workspace.getConfiguration('typescript').get('experimental.aiCodeActions.missingFunctionDeclaration')) { + title += `Implement missing function declaration '${document.getText(diagnostic.range)}' using Copilot`; message = `Provide a reasonable implementation of the function ${document.getText(diagnostic.range)} given its type and the context it's called in.`; expand = { kind: 'code-action', action }; } @@ -364,29 +357,38 @@ class TypeScriptQuickFixProvider implements vscode.CodeActionProvider change.textChanges.map(textChange => textChange.newText).join('')).join(''); + title = 'Add meaningful parameter name with Copilot'; message = `Rename the parameter ${newText} with a more meaningful name.`; expand = { kind: 'navtree-function', pos: diagnostic.range.start }; } - if (expand && message !== undefined) { - codeAction.command.title = 'Copilot: ' + codeAction.command.title; - codeAction.command = { - command: CompositeCommand.ID, - title: '', - arguments: [codeAction.command, { - command: EditorChatFollowUp.ID, - title: '', - arguments: [{ - message, - expand, - document - }], - }], - }; - } } + const codeAction = new VsCodeCodeAction(action, title, vscode.CodeActionKind.QuickFix); + codeAction.edit = getEditForCodeAction(this.client, action); + codeAction.diagnostics = [diagnostic]; + codeAction.command = { + command: ApplyCodeActionCommand.ID, + arguments: [{ action: action, diagnostic, document }], + title: '' + }; + if (expand && message !== undefined) { + codeAction.command = { + command: CompositeCommand.ID, + title: '', + arguments: [codeAction.command, { + command: EditorChatFollowUp.ID, + title: '', + arguments: [{ + message, + expand, + document + }], + }], + }; + } + actions.unshift(codeAction); return actions; } diff --git a/extensions/typescript-language-features/src/languageFeatures/refactor.ts b/extensions/typescript-language-features/src/languageFeatures/refactor.ts index d5222010291..718ebe447f7 100644 --- a/extensions/typescript-language-features/src/languageFeatures/refactor.ts +++ b/extensions/typescript-language-features/src/languageFeatures/refactor.ts @@ -347,14 +347,15 @@ class InlinedCodeAction extends vscode.CodeAction { public readonly range: vscode.Range, public readonly copilotRename?: (info: Proto.RefactorEditInfo) => vscode.Command, ) { - super(action.description, InlinedCodeAction.getKind(action)); + const title = copilotRename ? action.description + ' and suggest a name with Copilot.' : action.description; + super(title, InlinedCodeAction.getKind(action)); if (action.notApplicableReason) { this.disabled = { reason: action.notApplicableReason }; } this.command = { - title: action.description, + title, command: DidApplyRefactoringCommand.ID, arguments: [{ action: action.name }], };