Skip to content

Commit b0e20d8

Browse files
authored
fix(gumby): do not check auth when initializing transformation hub aws#5252
Problem: When VSCode is opened without having first been signed into `Amazon Q` and the user attempts a code transformation, the Transformation Hub window opens, but does not update, and Code Transform appears to hang. Solution: There is some initialization code that registers commands that other parts of Gumby uses to update the Transformation Hub, but this code was locked behind an auth check; if it fails, the commands are simply never registered, even if the user signs in again later. This portion of the code is not necessary to lock behind an auth check (it doesn't save memory or make anything run faster to not have it run), so the check has been removed. Testing: 1. User opens VSCode without already being signed in; the user signs in and then transforms a project successfully 2. User opens VSCode without already being signed in; the user signs in and then transforms a project unsuccessfully (partial success) 3. User opens VSCode without already being signed in; the user signs in and then is not able to submit a project to be transformed (fails to build locally) 4. User opens VSCode without already being signed in; the user signs in and then transforms a project that triggers HIL 5. User opens VSCode already having been signed in; the user transforms a project successfully
1 parent 93396cc commit b0e20d8

File tree

1 file changed

+41
-44
lines changed

1 file changed

+41
-44
lines changed

packages/core/src/amazonqGumby/activation.ts

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -13,62 +13,59 @@ import { ProposedTransformationExplorer } from '../codewhisperer/service/transfo
1313
import { CodeTransformTelemetryState } from './telemetry/codeTransformTelemetryState'
1414
import { telemetry } from '../shared/telemetry/telemetry'
1515
import { CancelActionPositions } from './telemetry/codeTransformTelemetry'
16-
import { AuthUtil } from '../codewhisperer/util/authUtil'
1716

1817
export async function activate(context: ExtContext) {
1918
void vscode.commands.executeCommand('setContext', 'gumby.wasQCodeTransformationUsed', false)
20-
// If the user is codewhisperer eligible, activate the plugin
21-
if (AuthUtil.instance.isValidCodeTransformationAuthUser()) {
22-
const transformationHubViewProvider = new TransformationHubViewProvider()
23-
new ProposedTransformationExplorer(context.extensionContext)
24-
// Register an activation event listener to determine when the IDE opens, closes or users
25-
// select to open a new workspace
26-
const workspaceChangeEvent = vscode.workspace.onDidChangeWorkspaceFolders(event => {
27-
// A loophole to register the IDE closed. This is when no folders were added nor
28-
// removed, but the event still fired. This assumes the user closed the workspace
29-
if (event.added.length === 0 && event.removed.length === 0) {
30-
// Only fire closed during running/active job status
31-
if (transformByQState.isRunning()) {
32-
telemetry.codeTransform_jobIsClosedDuringIdeRun.emit({
33-
codeTransformJobId: transformByQState.getJobId(),
34-
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
35-
codeTransformStatus: transformByQState.getStatus(),
36-
})
37-
}
38-
} else {
39-
telemetry.codeTransform_jobIsResumedAfterIdeClose.emit({
19+
20+
const transformationHubViewProvider = new TransformationHubViewProvider()
21+
new ProposedTransformationExplorer(context.extensionContext)
22+
// Register an activation event listener to determine when the IDE opens, closes or users
23+
// select to open a new workspace
24+
const workspaceChangeEvent = vscode.workspace.onDidChangeWorkspaceFolders(event => {
25+
// A loophole to register the IDE closed. This is when no folders were added nor
26+
// removed, but the event still fired. This assumes the user closed the workspace
27+
if (event.added.length === 0 && event.removed.length === 0) {
28+
// Only fire closed during running/active job status
29+
if (transformByQState.isRunning()) {
30+
telemetry.codeTransform_jobIsClosedDuringIdeRun.emit({
4031
codeTransformJobId: transformByQState.getJobId(),
4132
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
4233
codeTransformStatus: transformByQState.getStatus(),
4334
})
4435
}
45-
})
36+
} else {
37+
telemetry.codeTransform_jobIsResumedAfterIdeClose.emit({
38+
codeTransformJobId: transformByQState.getJobId(),
39+
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
40+
codeTransformStatus: transformByQState.getStatus(),
41+
})
42+
}
43+
})
4644

47-
context.extensionContext.subscriptions.push(
48-
vscode.window.registerWebviewViewProvider('aws.amazonq.transformationHub', transformationHubViewProvider),
45+
context.extensionContext.subscriptions.push(
46+
vscode.window.registerWebviewViewProvider('aws.amazonq.transformationHub', transformationHubViewProvider),
4947

50-
Commands.register('aws.amazonq.stopTransformationInHub', async (cancelSrc: CancelActionPositions) => {
51-
if (transformByQState.isRunning()) {
52-
void stopTransformByQ(transformByQState.getJobId(), cancelSrc)
53-
}
54-
}),
48+
Commands.register('aws.amazonq.stopTransformationInHub', async (cancelSrc: CancelActionPositions) => {
49+
if (transformByQState.isRunning()) {
50+
void stopTransformByQ(transformByQState.getJobId(), cancelSrc)
51+
}
52+
}),
5553

56-
Commands.register('aws.amazonq.showHistoryInHub', async () => {
57-
await transformationHubViewProvider.updateContent('job history')
58-
}),
54+
Commands.register('aws.amazonq.showHistoryInHub', async () => {
55+
await transformationHubViewProvider.updateContent('job history')
56+
}),
5957

60-
Commands.register('aws.amazonq.showPlanProgressInHub', async (startTime: number) => {
61-
await transformationHubViewProvider.updateContent('plan progress', startTime)
62-
}),
58+
Commands.register('aws.amazonq.showPlanProgressInHub', async (startTime: number) => {
59+
await transformationHubViewProvider.updateContent('plan progress', startTime)
60+
}),
6361

64-
Commands.register('aws.amazonq.showTransformationPlanInHub', async () => {
65-
void vscode.commands.executeCommand(
66-
'markdown.showPreview',
67-
vscode.Uri.file(transformByQState.getPlanFilePath())
68-
)
69-
}),
62+
Commands.register('aws.amazonq.showTransformationPlanInHub', async () => {
63+
void vscode.commands.executeCommand(
64+
'markdown.showPreview',
65+
vscode.Uri.file(transformByQState.getPlanFilePath())
66+
)
67+
}),
7068

71-
workspaceChangeEvent
72-
)
73-
}
69+
workspaceChangeEvent
70+
)
7471
}

0 commit comments

Comments
 (0)