diff --git a/packages/toolkit/src/amazonq/explorer/amazonQChildrenNodes.ts b/packages/toolkit/src/amazonq/explorer/amazonQChildrenNodes.ts index a27e99fb5f1..79cfd7fbdbf 100644 --- a/packages/toolkit/src/amazonq/explorer/amazonQChildrenNodes.ts +++ b/packages/toolkit/src/amazonq/explorer/amazonQChildrenNodes.ts @@ -7,13 +7,14 @@ import * as vscode from 'vscode' import * as nls from 'vscode-nls' import { Commands, placeholder } from '../../shared/vscode/commands2' import { getIcon } from '../../shared/icons' -import { reconnect, showTransformByQ } from '../../codewhisperer/commands/basicCommands' +import { reconnect } from '../../codewhisperer/commands/basicCommands' import { transformByQState } from '../../codewhisperer/models/model' import * as CodeWhispererConstants from '../../codewhisperer/models/constants' import { amazonQHelpUrl } from '../../shared/constants' import { cwTreeNodeSource } from '../../codewhisperer/commands/types' import { telemetry } from '../../shared/telemetry/telemetry' import { focusAmazonQPanel } from '../../auth/ui/vue/show' +import { showTransformByQ } from '../../amazonqGumby/commands' const localize = nls.loadMessageBundle() diff --git a/packages/toolkit/src/amazonqGumby/activation.ts b/packages/toolkit/src/amazonqGumby/activation.ts index 4769d42ad16..abda9946e03 100644 --- a/packages/toolkit/src/amazonqGumby/activation.ts +++ b/packages/toolkit/src/amazonqGumby/activation.ts @@ -6,7 +6,7 @@ import * as vscode from 'vscode' import { Commands } from '../shared/vscode/commands2' import { TransformationHubViewProvider } from '../codewhisperer/service/transformationHubViewProvider' -import { showTransformByQ, showTransformationHub } from '../codewhisperer/commands/basicCommands' +import { showTransformByQ, showTransformationHub } from './commands' import { ExtContext } from '../shared/extensions' import { startTransformByQWithProgress, confirmStopTransformByQ } from '../codewhisperer/commands/startTransformByQ' import { transformByQState } from '../codewhisperer/models/model' diff --git a/packages/toolkit/src/amazonqGumby/commands.ts b/packages/toolkit/src/amazonqGumby/commands.ts new file mode 100644 index 00000000000..a304389ad5b --- /dev/null +++ b/packages/toolkit/src/amazonqGumby/commands.ts @@ -0,0 +1,47 @@ +/*! + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import * as vscode from 'vscode' +import { telemetry } from '../shared/telemetry/telemetry' +import { ExtContext } from '../shared/extensions' +import { Commands } from '../shared/vscode/commands2' +import * as CodeWhispererConstants from '../codewhisperer/models/constants' +import { startTransformByQWithProgress, confirmStopTransformByQ } from '../codewhisperer/commands/startTransformByQ' +import { transformByQState } from '../codewhisperer/models/model' +import { AuthUtil } from '../codewhisperer/util/authUtil' +import { CancelActionPositions, logCodeTransformInitiatedMetric } from './telemetry/codeTransformTelemetry' + +export const showTransformByQ = Commands.declare( + { id: 'aws.awsq.transform', compositeKey: { 0: 'source' } }, + (context: ExtContext) => async (source: string) => { + if (AuthUtil.instance.isConnectionExpired()) { + await AuthUtil.instance.notifyReauthenticate() + } + + if (transformByQState.isNotStarted()) { + logCodeTransformInitiatedMetric(source) + await startTransformByQWithProgress() + } else if (transformByQState.isCancelled()) { + void vscode.window.showInformationMessage(CodeWhispererConstants.cancellationInProgressMessage) + } else if (transformByQState.isRunning()) { + await confirmStopTransformByQ(transformByQState.getJobId(), CancelActionPositions.DevToolsSidePanel) + } + // emit telemetry if clicked from tree node + if (source === CodeWhispererConstants.transformTreeNode) { + telemetry.ui_click.emit({ + elementId: 'amazonq_transform', + passive: false, + }) + } + await Commands.tryExecute('aws.codeWhisperer.refresh') + } +) + +export const showTransformationHub = Commands.declare( + { id: 'aws.amazonq.showTransformationHub', compositeKey: { 0: 'source' } }, + () => async (source: string) => { + await vscode.commands.executeCommand('workbench.view.extension.aws-codewhisperer-transformation-hub') + } +) diff --git a/packages/toolkit/src/codewhisperer/commands/basicCommands.ts b/packages/toolkit/src/codewhisperer/commands/basicCommands.ts index 5c07e37e402..c6e393808df 100644 --- a/packages/toolkit/src/codewhisperer/commands/basicCommands.ts +++ b/packages/toolkit/src/codewhisperer/commands/basicCommands.ts @@ -10,9 +10,8 @@ import { Commands, VsCodeCommandArg } from '../../shared/vscode/commands2' import * as CodeWhispererConstants from '../models/constants' import { DefaultCodeWhispererClient } from '../client/codewhisperer' import { startSecurityScanWithProgress, confirmStopSecurityScan } from './startSecurityScan' -import { startTransformByQWithProgress, confirmStopTransformByQ } from './startTransformByQ' import { SecurityPanelViewProvider } from '../views/securityPanelViewProvider' -import { CodeScanIssue, codeScanState, CodeSuggestionsState, transformByQState } from '../models/model' +import { CodeScanIssue, codeScanState, CodeSuggestionsState } from '../models/model' import { connectToEnterpriseSso, getStartUrl } from '../util/getStartUrl' import { showCodeWhispererConnectionPrompt } from '../util/showSsoPrompt' import { ReferenceLogViewProvider } from '../service/referenceLogViewProvider' @@ -32,10 +31,6 @@ import { fsCommon } from '../../srcShared/fs' import { Mutable } from '../../shared/utilities/tsUtils' import { CodeWhispererSource } from './types' import { showManageConnections } from '../../auth/ui/vue/show' -import { - CancelActionPositions, - logCodeTransformInitiatedMetric, -} from '../../amazonqGumby/telemetry/codeTransformTelemetry' import { FeatureConfigProvider } from '../service/featureConfigProvider' export const toggleCodeSuggestions = Commands.declare( @@ -113,39 +108,6 @@ export const showSecurityScan = Commands.declare( } ) -export const showTransformByQ = Commands.declare( - { id: 'aws.awsq.transform', compositeKey: { 0: 'source' } }, - (context: ExtContext) => async (source: string) => { - if (AuthUtil.instance.isConnectionExpired()) { - await AuthUtil.instance.notifyReauthenticate() - } - - if (transformByQState.isNotStarted()) { - logCodeTransformInitiatedMetric(source) - await startTransformByQWithProgress() - } else if (transformByQState.isCancelled()) { - void vscode.window.showInformationMessage(CodeWhispererConstants.cancellationInProgressMessage) - } else if (transformByQState.isRunning()) { - await confirmStopTransformByQ(transformByQState.getJobId(), CancelActionPositions.DevToolsSidePanel) - } - // emit telemetry if clicked from tree node - if (source === CodeWhispererConstants.transformTreeNode) { - telemetry.ui_click.emit({ - elementId: 'amazonq_transform', - passive: false, - }) - } - await Commands.tryExecute('aws.codeWhisperer.refresh') - } -) - -export const showTransformationHub = Commands.declare( - { id: 'aws.amazonq.showTransformationHub', compositeKey: { 0: 'source' } }, - () => async (source: string) => { - await vscode.commands.executeCommand('workbench.view.extension.aws-codewhisperer-transformation-hub') - } -) - export const selectCustomizationPrompt = Commands.declare( { id: 'aws.codeWhisperer.selectCustomization', compositeKey: { 1: 'source' } }, () => async (_: VsCodeCommandArg, source: CodeWhispererSource) => {