Skip to content

Commit 448bb26

Browse files
dhasani23David Hasani
andauthored
fix(amazonq): remove Transform button (#4617)
* fix(amazonq): remove Transform button and allow retry job from chat * modify changelog * merge with mainline * make job status optional * remove duplicate stop message --------- Co-authored-by: David Hasani <davhasan@amazon.com>
1 parent 3e378da commit 448bb26

File tree

14 files changed

+86
-237
lines changed

14 files changed

+86
-237
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Amazon Q Code Transformation: remove Transform button from side panel, use /transform in chat now"
4+
}

packages/core/src/amazonq/explorer/amazonQChildrenNodes.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ import * as nls from 'vscode-nls'
88
import { Command, Commands, placeholder } from '../../shared/vscode/commands2'
99
import { getIcon } from '../../shared/icons'
1010
import { reconnect } from '../../codewhisperer/commands/basicCommands'
11-
import { transformByQState } from '../../codewhisperer/models/model'
12-
import * as CodeWhispererConstants from '../../codewhisperer/models/constants'
1311
import { amazonQHelpUrl } from '../../shared/constants'
1412
import { cwTreeNodeSource } from '../../codewhisperer/commands/types'
1513
import { telemetry } from '../../shared/telemetry/telemetry'
1614
import { focusAmazonQPanel } from '../../auth/ui/vue/show'
17-
import { showTransformByQ } from '../../amazonqGumby/commands'
1815
import { DataQuickPickItem } from '../../shared/ui/pickerPrompter'
1916
import { TreeNode } from '../../shared/treeview/resourceTreeDataProvider'
2017

@@ -72,30 +69,3 @@ export const enableAmazonQNode = () =>
7269
iconPath: getIcon('vscode-debug-start'),
7370
contextValue: 'awsEnableAmazonQ',
7471
})
75-
76-
export const createTransformByQ = () => {
77-
const prefix = transformByQState.getPrefixTextForButton()
78-
let status = transformByQState.getPolledJobStatus().toLowerCase()
79-
if (transformByQState.isRunning()) {
80-
if (status === '') {
81-
// job is running but polling has not started yet, so display generic message
82-
status = CodeWhispererConstants.transformByQStateRunningMessage
83-
}
84-
} else if (transformByQState.isCancelled()) {
85-
status = CodeWhispererConstants.transformByQStateCancellingMessage
86-
} else if (transformByQState.isFailed()) {
87-
status = CodeWhispererConstants.transformByQStateFailedMessage
88-
} else if (transformByQState.isSucceeded()) {
89-
status = CodeWhispererConstants.transformByQStateSucceededMessage
90-
} else if (transformByQState.isPartiallySucceeded()) {
91-
status = CodeWhispererConstants.transformByQStatePartialSuccessMessage
92-
} else if (transformByQState.isNotStarted()) {
93-
status = ''
94-
}
95-
return showTransformByQ.build(CodeWhispererConstants.transformTreeNode).asTreeNode({
96-
label: status !== '' ? `${prefix} Transform [Job status: ` + status + `]` : `Transform`,
97-
iconPath: transformByQState.getIconForButton(),
98-
tooltip: `${prefix} Transform`,
99-
contextValue: `${prefix}TransformByQ`,
100-
})
101-
}

packages/core/src/amazonq/explorer/amazonQTreeNode.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as vscode from 'vscode'
77
import { createFreeTierLimitMet, createSignIn, createReconnect } from '../../codewhisperer/ui/codeWhispererNodes'
88
import { ResourceTreeDataProvider, TreeNode } from '../../shared/treeview/resourceTreeDataProvider'
99
import { AuthUtil, amazonQScopes, codeWhispererChatScopes } from '../../codewhisperer/util/authUtil'
10-
import { createLearnMoreNode, createTransformByQ, enableAmazonQNode, switchToAmazonQNode } from './amazonQChildrenNodes'
10+
import { createLearnMoreNode, enableAmazonQNode, switchToAmazonQNode } from './amazonQChildrenNodes'
1111
import { Command, Commands } from '../../shared/vscode/commands2'
1212
import { hasScopes, isSsoConnection } from '../../auth/connection'
1313
import { listCodeWhispererCommands } from '../../codewhisperer/ui/statusBarMenu'
@@ -77,15 +77,9 @@ export class AmazonQNode implements TreeNode {
7777
}
7878
}
7979

80-
const transformNode = []
81-
if (AuthUtil.instance.isValidCodeTransformationAuthUser()) {
82-
transformNode.push(createTransformByQ())
83-
}
84-
8580
return [
8681
vsCodeState.isFreeTierLimitReached ? createFreeTierLimitMet('tree') : switchToAmazonQNode('tree'),
8782
createNewMenuButton(),
88-
...transformNode,
8983
]
9084
}
9185

packages/core/src/amazonqGumby/app.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Messenger } from './chat/controller/messenger/messenger'
1313
import { UIMessageListener } from './chat/views/actions/uiMessageListener'
1414
import { debounce } from 'lodash'
1515
import { AuthUtil, getChatAuthState } from '../codewhisperer/util/authUtil'
16-
import { showTransformByQ, showTransformationHub } from './commands'
16+
import { showTransformationHub } from './commands'
1717
import { transformByQState } from '../codewhisperer/models/model'
1818

1919
export function init(appContext: AmazonQAppInitContext) {
@@ -66,7 +66,6 @@ export function init(appContext: AmazonQAppInitContext) {
6666
return debouncedEvent()
6767
})
6868

69-
showTransformByQ.register(gumbyChatControllerEventEmitters)
7069
showTransformationHub.register()
7170

7271
transformByQState.setChatControllers(gumbyChatControllerEventEmitters)

packages/core/src/amazonqGumby/chat/controller/controller.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ export class GumbyController {
184184
await this.messenger.sendProjectPrompt(validProjects, message.tabID)
185185
}
186186
} catch (err: any) {
187-
// if there was an issue getting the list of valid projects, the error message
188-
// will be shown here
187+
// if there was an issue getting the list of valid projects, the error message will be shown here
189188
this.messenger.sendErrorMessage(err.message, message.tabID)
190189
}
191190
}
@@ -212,7 +211,7 @@ export class GumbyController {
212211
await this.initiateTransformationOnProject(message)
213212
break
214213
case ButtonActions.CANCEL_TRANSFORMATION_FORM:
215-
this.messenger.sendJobFinishedMessage(message.tabId, true, undefined)
214+
this.messenger.sendJobFinishedMessage(message.tabId, true)
216215
break
217216
case ButtonActions.VIEW_TRANSFORMATION_HUB:
218217
await vscode.commands.executeCommand(GumbyCommands.FOCUS_TRANSFORMATION_HUB)
@@ -303,10 +302,10 @@ export class GumbyController {
303302
await this.prepareProjectForSubmission(message)
304303
}
305304

306-
private async transformationFinished(message: { tabID: string; jobStatus: string }) {
305+
private async transformationFinished(tabID: string, jobStatus: string = '') {
307306
this.sessionStorage.getSession().conversationState = ConversationState.IDLE
308307
// at this point job is either completed, partially_completed, cancelled, or failed
309-
this.messenger.sendJobFinishedMessage(message.tabID, false, message.jobStatus)
308+
this.messenger.sendJobFinishedMessage(tabID, false)
310309
}
311310

312311
private async processHumanChatMessage(data: { message: string; tabID: string }) {

packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -296,25 +296,28 @@ export class Messenger {
296296
message = 'To begin, please open a workspace.'
297297
break
298298
case 'no-project-found':
299+
message = `Sorry, I couldn't find any open projects. Currently, I can only upgrade Java projects built on Maven.
300+
301+
For more information, see the [Amazon Q documentation](https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/troubleshooting-code-transformation.html).`
302+
break
299303
case 'no-java-project-found':
300304
message = `Sorry, I can't upgrade any of your open projects. Currently, I can only upgrade Java projects built on Maven.
301305
302-
For more information, see the [Amazon Q documentation.](https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/troubleshooting-code-transformation.html).`
306+
For more information, see the [Amazon Q documentation](https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/troubleshooting-code-transformation.html).`
303307
break
304308
case 'no-maven-java-project-found':
305309
message = `Sorry, I can't upgrade any of your open projects. I couldn't find a pom.xml file in any of your Java projects. Currently, I can only upgrade Java projects built on Maven.
306310
307-
For more information, see the [Amazon Q documentation.](https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/troubleshooting-code-transformation.html).`
311+
For more information, see the [Amazon Q documentation](https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/troubleshooting-code-transformation.html).`
308312
break
309313
case 'could-not-compile-project':
310-
message = `Sorry, I couldn't run the Maven install to build your project. To troubleshoot, see the [Amazon Q documentation.](https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/troubleshooting-code-transformation.html#maven-commands-failing)`
314+
message = `Sorry, I couldn't run Maven clean install to build your project. To troubleshoot, see the [Amazon Q documentation](https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/troubleshooting-code-transformation.html#maven-commands-failing).`
311315
break
312316
case 'invalid-java-home':
313-
message =
314-
"I'm sorry, I could not locate your Java installation. To troubleshoot, see the [Amazon Q documentation.](https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/troubleshooting-code-transformation.html#maven-commands-failing)"
317+
message = `Sorry, I couldn't locate your Java installation. To troubleshoot, see the [Amazon Q documentation](https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/troubleshooting-code-transformation.html#maven-commands-failing).`
315318
break
316319
case 'unsupported-source-jdk-version':
317-
message = `I'm sorry, currently I can only upgrade Java 8 or Java 11 projects.
320+
message = `Sorry, currently I can only upgrade Java 8 or Java 11 projects.
318321
319322
For more information, see the [Amazon Q documentation.](https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/troubleshooting-code-transformation.html).`
320323
}
@@ -342,13 +345,13 @@ For more information, see the [Amazon Q documentation.](https://docs.aws.amazon.
342345
this.dispatcher.sendCommandMessage(new SendCommandMessage(message.command, message.tabId, message.eventId))
343346
}
344347

345-
public sendJobFinishedMessage(tabID: string, cancelled: boolean = false, jobStatus: string = '') {
348+
public sendJobFinishedMessage(tabID: string, cancelled: boolean, jobStatus: string = '') {
346349
let message =
347-
'I stopped your transformation. If you want to start another transformation, choose **Start a new transformation.**'
350+
'I cancelled your transformation. If you want to start another transformation, choose **Start a new transformation**.'
348351

349352
if (!cancelled) {
350353
message =
351-
'The transformation job is over. If you want to start another transformation, choose **Start a new transformation.**'
354+
'The transformation job is over. If you want to start another transformation, choose **Start a new transformation**.'
352355
}
353356

354357
const buttons: ChatItemButton[] = []

packages/core/src/amazonqGumby/commands.ts

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,7 @@
44
*/
55

66
import * as vscode from 'vscode'
7-
import { telemetry } from '../shared/telemetry/telemetry'
87
import { Commands } from '../shared/vscode/commands2'
9-
import * as CodeWhispererConstants from '../codewhisperer/models/constants'
10-
import { stopTransformByQ } from '../codewhisperer/commands/startTransformByQ'
11-
import { transformByQState } from '../codewhisperer/models/model'
12-
import { AuthUtil } from '../codewhisperer/util/authUtil'
13-
import { CancelActionPositions, logCodeTransformInitiatedMetric } from './telemetry/codeTransformTelemetry'
14-
import { ChatControllerEventEmitters } from './chat/controller/controller'
15-
import { focusAmazonQPanel } from '../auth/ui/vue/show'
16-
import { sleep } from '../shared/utilities/timeoutUtils'
17-
import { randomUUID } from 'crypto'
18-
import { ChatSessionManager } from './chat/storages/chatSession'
19-
20-
export const showTransformByQ = Commands.declare(
21-
{ id: 'aws.awsq.transform', compositeKey: { 0: 'source' } },
22-
(controllerEventEmitters: ChatControllerEventEmitters) => async (source: string) => {
23-
if (AuthUtil.instance.isConnectionExpired()) {
24-
await AuthUtil.instance.notifyReauthenticate()
25-
}
26-
27-
if (transformByQState.isNotStarted()) {
28-
logCodeTransformInitiatedMetric(source)
29-
await focusAmazonQPanel().then(async () => {
30-
// non blocking wait for a tenth of a second
31-
// note: we need this because the webview has to be loaded
32-
// before it can listen to events we fire
33-
await sleep(250)
34-
35-
controllerEventEmitters.commandSentFromIDE.fire({
36-
command: 'aws.awsq.transform',
37-
tabId: ChatSessionManager.Instance.getSession().tabID ?? '',
38-
eventId: randomUUID,
39-
})
40-
})
41-
} else if (transformByQState.isCancelled()) {
42-
void vscode.window.showInformationMessage(CodeWhispererConstants.cancellationInProgressMessage)
43-
} else if (transformByQState.isRunning()) {
44-
await stopTransformByQ(transformByQState.getJobId(), CancelActionPositions.DevToolsSidePanel)
45-
}
46-
// emit telemetry if clicked from tree node
47-
if (source === CodeWhispererConstants.transformTreeNode) {
48-
telemetry.ui_click.emit({
49-
elementId: 'amazonq_transform',
50-
passive: false,
51-
})
52-
}
53-
}
54-
)
558

569
export const showTransformationHub = Commands.declare(
5710
{ id: 'aws.amazonq.showTransformationHub', compositeKey: { 0: 'source' } },

packages/core/src/amazonqGumby/entrypoint.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)