Skip to content

Commit 09ff396

Browse files
committed
fix: duplicate code
1 parent 81fc46f commit 09ff396

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

packages/amazonq/src/inlineChat/provider/inlineChatProvider.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,13 @@ export class InlineChatProvider {
7474
switch (triggerEvent?.type) {
7575
case 'editor_context_command':
7676
return triggerEvent.command?.triggerType === 'keybinding' ? 'hotkeys' : 'contextMenu'
77-
case 'follow_up':
78-
case 'chat_message':
7977
default:
8078
return 'click'
8179
}
8280
}
8381

8482
public async processPromptMessageLSP(message: PromptMessage): Promise<InlineChatResult> {
85-
const triggerInteraction = this.getTriggerInteractionFromTriggerEvent(
83+
const triggerInteractionLSP = this.getTriggerInteractionFromTriggerEvent(
8684
this.triggerEventsStorage.getLastTriggerEventByTabID(message.tabID)
8785
)
8886
if (!AuthUtil.instance.isSsoSession()) {
@@ -91,7 +89,7 @@ export class InlineChatProvider {
9189
cwsprChatConversationType: 'Chat',
9290
cwsprChatRequestLength: message.message?.length ?? 0,
9391
cwsprChatResponseCode: 401,
94-
cwsprChatTriggerInteraction: triggerInteraction,
92+
cwsprChatTriggerInteraction: triggerInteractionLSP,
9593
reason: 'AuthenticationError',
9694
reasonDesc: 'Inline chat requires SSO authentication, but current session is not',
9795
})

packages/amazonq/test/unit/codewhisperer/util/authUtil.test.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -449,28 +449,36 @@ describe('AuthUtil', async function () {
449449
accessKeyId: 'encrypted-access-key',
450450
secretAccessKey: 'encrypted-secret-key',
451451
sessionToken: 'encrypted-session-token',
452+
roleArn: 'arn:aws:iam::123456789012:role/TestRole',
452453
},
453454
updateCredentialsParams: {
454455
data: 'credential-data',
455456
},
456457
}
457-
458+
458459
const mockIamLogin = {
459460
login: sinon.stub().resolves(mockResponse),
460461
loginType: 'iam',
461462
}
462-
463+
463464
sinon.stub(auth2, 'IamLogin').returns(mockIamLogin as any)
464-
465-
const response = await auth.loginIam('accessKey', 'secretKey', 'sessionToken', 'arn:aws:iam::123456789012:role/TestRole')
466-
465+
466+
const response = await auth.loginIam(
467+
'accessKey',
468+
'secretKey',
469+
'sessionToken',
470+
'arn:aws:iam::123456789012:role/TestRole'
471+
)
472+
467473
assert.ok(mockIamLogin.login.calledOnce)
468-
assert.ok(mockIamLogin.login.calledWith({
469-
accessKey: 'accessKey',
470-
secretKey: 'secretKey',
471-
sessionToken: 'sessionToken',
472-
roleArn: 'arn:aws:iam::123456789012:role/TestRole',
473-
}))
474+
assert.ok(
475+
mockIamLogin.login.calledWith({
476+
accessKey: 'accessKey',
477+
secretKey: 'secretKey',
478+
sessionToken: 'sessionToken',
479+
roleArn: 'arn:aws:iam::123456789012:role/TestRole',
480+
})
481+
)
474482
assert.strictEqual(response, mockResponse)
475483
})
476484
})

packages/core/src/test/amazonq/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ export async function sessionRegisterProvider(session: Session, uri: vscode.Uri,
8787

8888
export function generateVirtualMemoryUri(uploadID: string, filePath: string, scheme: string) {
8989
const generationFilePath = path.join(uploadID, filePath)
90-
const uri = vscode.Uri.from({ scheme, path: generationFilePath })
91-
return uri
90+
const uriNew = vscode.Uri.from({ scheme, path: generationFilePath })
91+
return uriNew
9292
}
9393

9494
export async function sessionWriteFile(session: Session, uri: vscode.Uri, encodedContent: Uint8Array) {

0 commit comments

Comments
 (0)