Skip to content

Commit a8a6d6b

Browse files
refactor: move some gumby out of CW files (#4425)
We are moving gumby commands since this causes CW to import gumby, and gumby code uses fs-extra, and this breaks browser mode Signed-off-by: nkomonen <[email protected]>
1 parent 772c53f commit a8a6d6b

File tree

4 files changed

+51
-41
lines changed

4 files changed

+51
-41
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import * as vscode from 'vscode'
77
import * as nls from 'vscode-nls'
88
import { Commands, placeholder } from '../../shared/vscode/commands2'
99
import { getIcon } from '../../shared/icons'
10-
import { reconnect, showTransformByQ } from '../../codewhisperer/commands/basicCommands'
10+
import { reconnect } from '../../codewhisperer/commands/basicCommands'
1111
import { transformByQState } from '../../codewhisperer/models/model'
1212
import * as CodeWhispererConstants from '../../codewhisperer/models/constants'
1313
import { amazonQHelpUrl } from '../../shared/constants'
1414
import { cwTreeNodeSource } from '../../codewhisperer/commands/types'
1515
import { telemetry } from '../../shared/telemetry/telemetry'
1616
import { focusAmazonQPanel } from '../../auth/ui/vue/show'
17+
import { showTransformByQ } from '../../amazonqGumby/commands'
1718

1819
const localize = nls.loadMessageBundle()
1920

packages/toolkit/src/amazonqGumby/activation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import * as vscode from 'vscode'
77
import { Commands } from '../shared/vscode/commands2'
88
import { TransformationHubViewProvider } from '../codewhisperer/service/transformationHubViewProvider'
9-
import { showTransformByQ, showTransformationHub } from '../codewhisperer/commands/basicCommands'
9+
import { showTransformByQ, showTransformationHub } from './commands'
1010
import { ExtContext } from '../shared/extensions'
1111
import { startTransformByQWithProgress, confirmStopTransformByQ } from '../codewhisperer/commands/startTransformByQ'
1212
import { transformByQState } from '../codewhisperer/models/model'
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import * as vscode from 'vscode'
7+
import { telemetry } from '../shared/telemetry/telemetry'
8+
import { ExtContext } from '../shared/extensions'
9+
import { Commands } from '../shared/vscode/commands2'
10+
import * as CodeWhispererConstants from '../codewhisperer/models/constants'
11+
import { startTransformByQWithProgress, confirmStopTransformByQ } from '../codewhisperer/commands/startTransformByQ'
12+
import { transformByQState } from '../codewhisperer/models/model'
13+
import { AuthUtil } from '../codewhisperer/util/authUtil'
14+
import { CancelActionPositions, logCodeTransformInitiatedMetric } from './telemetry/codeTransformTelemetry'
15+
16+
export const showTransformByQ = Commands.declare(
17+
{ id: 'aws.awsq.transform', compositeKey: { 0: 'source' } },
18+
(context: ExtContext) => async (source: string) => {
19+
if (AuthUtil.instance.isConnectionExpired()) {
20+
await AuthUtil.instance.notifyReauthenticate()
21+
}
22+
23+
if (transformByQState.isNotStarted()) {
24+
logCodeTransformInitiatedMetric(source)
25+
await startTransformByQWithProgress()
26+
} else if (transformByQState.isCancelled()) {
27+
void vscode.window.showInformationMessage(CodeWhispererConstants.cancellationInProgressMessage)
28+
} else if (transformByQState.isRunning()) {
29+
await confirmStopTransformByQ(transformByQState.getJobId(), CancelActionPositions.DevToolsSidePanel)
30+
}
31+
// emit telemetry if clicked from tree node
32+
if (source === CodeWhispererConstants.transformTreeNode) {
33+
telemetry.ui_click.emit({
34+
elementId: 'amazonq_transform',
35+
passive: false,
36+
})
37+
}
38+
await Commands.tryExecute('aws.codeWhisperer.refresh')
39+
}
40+
)
41+
42+
export const showTransformationHub = Commands.declare(
43+
{ id: 'aws.amazonq.showTransformationHub', compositeKey: { 0: 'source' } },
44+
() => async (source: string) => {
45+
await vscode.commands.executeCommand('workbench.view.extension.aws-codewhisperer-transformation-hub')
46+
}
47+
)

packages/toolkit/src/codewhisperer/commands/basicCommands.ts

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ import { Commands, VsCodeCommandArg } from '../../shared/vscode/commands2'
1010
import * as CodeWhispererConstants from '../models/constants'
1111
import { DefaultCodeWhispererClient } from '../client/codewhisperer'
1212
import { startSecurityScanWithProgress, confirmStopSecurityScan } from './startSecurityScan'
13-
import { startTransformByQWithProgress, confirmStopTransformByQ } from './startTransformByQ'
1413
import { SecurityPanelViewProvider } from '../views/securityPanelViewProvider'
15-
import { CodeScanIssue, codeScanState, CodeSuggestionsState, transformByQState } from '../models/model'
14+
import { CodeScanIssue, codeScanState, CodeSuggestionsState } from '../models/model'
1615
import { connectToEnterpriseSso, getStartUrl } from '../util/getStartUrl'
1716
import { showCodeWhispererConnectionPrompt } from '../util/showSsoPrompt'
1817
import { ReferenceLogViewProvider } from '../service/referenceLogViewProvider'
@@ -32,10 +31,6 @@ import { fsCommon } from '../../srcShared/fs'
3231
import { Mutable } from '../../shared/utilities/tsUtils'
3332
import { CodeWhispererSource } from './types'
3433
import { showManageConnections } from '../../auth/ui/vue/show'
35-
import {
36-
CancelActionPositions,
37-
logCodeTransformInitiatedMetric,
38-
} from '../../amazonqGumby/telemetry/codeTransformTelemetry'
3934
import { FeatureConfigProvider } from '../service/featureConfigProvider'
4035

4136
export const toggleCodeSuggestions = Commands.declare(
@@ -113,39 +108,6 @@ export const showSecurityScan = Commands.declare(
113108
}
114109
)
115110

116-
export const showTransformByQ = Commands.declare(
117-
{ id: 'aws.awsq.transform', compositeKey: { 0: 'source' } },
118-
(context: ExtContext) => async (source: string) => {
119-
if (AuthUtil.instance.isConnectionExpired()) {
120-
await AuthUtil.instance.notifyReauthenticate()
121-
}
122-
123-
if (transformByQState.isNotStarted()) {
124-
logCodeTransformInitiatedMetric(source)
125-
await startTransformByQWithProgress()
126-
} else if (transformByQState.isCancelled()) {
127-
void vscode.window.showInformationMessage(CodeWhispererConstants.cancellationInProgressMessage)
128-
} else if (transformByQState.isRunning()) {
129-
await confirmStopTransformByQ(transformByQState.getJobId(), CancelActionPositions.DevToolsSidePanel)
130-
}
131-
// emit telemetry if clicked from tree node
132-
if (source === CodeWhispererConstants.transformTreeNode) {
133-
telemetry.ui_click.emit({
134-
elementId: 'amazonq_transform',
135-
passive: false,
136-
})
137-
}
138-
await Commands.tryExecute('aws.codeWhisperer.refresh')
139-
}
140-
)
141-
142-
export const showTransformationHub = Commands.declare(
143-
{ id: 'aws.amazonq.showTransformationHub', compositeKey: { 0: 'source' } },
144-
() => async (source: string) => {
145-
await vscode.commands.executeCommand('workbench.view.extension.aws-codewhisperer-transformation-hub')
146-
}
147-
)
148-
149111
export const selectCustomizationPrompt = Commands.declare(
150112
{ id: 'aws.codeWhisperer.selectCustomization', compositeKey: { 1: 'source' } },
151113
() => async (_: VsCodeCommandArg, source: CodeWhispererSource) => {

0 commit comments

Comments
 (0)