Skip to content

Commit 3f41b8b

Browse files
committed
Merge remote-tracking branch 'upstream/feature/amazonqLSP-auth' into autoMerge/feature/amazonqLSP-auth
2 parents 327fb56 + 8f0d76a commit 3f41b8b

File tree

116 files changed

+2365
-1802
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+2365
-1802
lines changed

docs/lsp.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ sequenceDiagram
2626

2727
## Language Server Debugging
2828

29-
1. Clone https://github.com/aws/language-servers.git and set it up in the same workspace as this project by cmd+shift+p and "add folder to workspace" and selecting the language-servers folder that you just cloned. Your VS code folder structure should look like below.
30-
31-
29+
1. Clone https://github.com/aws/language-servers.git and set it up in the same workspace as this project by cmd+shift+p and "add folder to workspace" and selecting the language-servers folder that you just cloned. Your VS code folder structure should look like below.
3230

3331
```
3432
/aws-toolkit-vscode
@@ -48,7 +46,6 @@ sequenceDiagram
4846
3. Enable the lsp experiment:
4947
```
5048
"aws.experiments": {
51-
"amazonqLSP": true,
5249
"amazonqLSPInline": true, // optional: enables inline completion from flare
5350
"amazonqLSPChat": true // optional: enables chat from flare
5451
}

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
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": "Previous and subsequent cells are used as context for completion in a Jupyter notebook"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "bugfix",
3+
"description": "/review: disable auto-review by default"
4+
}

packages/amazonq/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"watch": "npm run clean && npm run buildScripts && tsc -watch -p ./",
6060
"testCompile": "npm run clean && npm run buildScripts && npm run compileOnly",
6161
"test": "npm run testCompile && c8 --allowExternal ts-node ../core/scripts/test/launchTest.ts unit dist/test/unit/index.js ../core/dist/src/testFixtures/workspaceFolder",
62-
"testE2E": "npm run testCompile && c8 --allowExternal ts-node ../core/scripts/test/launchTest.ts e2e dist/test/e2e/index.js ../core/dist/src/testFixtures/workspaceFolder",
6362
"testWeb": "npm run compileDev && c8 --allowExternal ts-node ../core/scripts/test/launchTest.ts web dist/test/web/testRunnerWebCore.js",
6463
"webRun": "npx @vscode/test-web --open-devtools --browserOption=--disable-web-security --waitForDebugger=9222 --extensionDevelopmentPath=. .",
6564
"webWatch": "npm run clean && npm run buildScripts && webpack --mode development --watch",

packages/amazonq/src/api.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { GenerateAssistantResponseCommandOutput, GenerateAssistantResponseReques
88
import { AuthUtil } from 'aws-core-vscode/codewhisperer'
99
import { ChatSession } from 'aws-core-vscode/codewhispererChat'
1010
import { api } from 'aws-core-vscode/amazonq'
11+
import { getLogger } from 'aws-core-vscode/shared'
1112

1213
export default {
1314
chatApi: {
@@ -26,8 +27,25 @@ export default {
2627
await AuthUtil.instance.showReauthenticatePrompt()
2728
}
2829
},
30+
/**
31+
* @deprecated use getAuthState() instead
32+
*
33+
* Legacy function for callers who expect auth state to be granular amongst Q features.
34+
* Auth state is consistent between features, so getAuthState() can be consumed safely for all features.
35+
*
36+
*/
2937
async getChatAuthState() {
30-
return AuthUtil.instance.getChatAuthState()
38+
getLogger().warn('Warning: getChatAuthState() is deprecated. Use getAuthState() instead.')
39+
const state = AuthUtil.instance.getAuthState()
40+
const convertedState = state === 'notConnected' ? 'disconnected' : state
41+
return {
42+
codewhispererCore: convertedState,
43+
codewhispererChat: convertedState,
44+
amazonQ: convertedState,
45+
}
46+
},
47+
getAuthState() {
48+
return AuthUtil.instance.getAuthState()
3149
},
3250
},
3351
} satisfies api

packages/amazonq/src/app/amazonqScan/app.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { Messenger } from './chat/controller/messenger/messenger'
1919
import { UIMessageListener } from './chat/views/actions/uiMessageListener'
2020
import { debounce } from 'lodash'
2121
import { Commands, placeholder } from 'aws-core-vscode/shared'
22+
import { auth2 } from 'aws-core-vscode/auth'
2223

2324
export function init(appContext: AmazonQAppInitContext) {
2425
const scanChatControllerEventEmitters: ScanChatControllerEventEmitters = {
@@ -52,7 +53,7 @@ export function init(appContext: AmazonQAppInitContext) {
5253
appContext.registerWebViewToAppMessagePublisher(new MessagePublisher<any>(scanChatUIInputEventEmitter), 'review')
5354

5455
const debouncedEvent = debounce(async () => {
55-
const authenticated = (await AuthUtil.instance.getChatAuthState()).amazonQ === 'connected'
56+
const authenticated = AuthUtil.instance.getAuthState() === 'connected'
5657
let authenticatingSessionID = ''
5758

5859
if (authenticated) {
@@ -67,7 +68,7 @@ export function init(appContext: AmazonQAppInitContext) {
6768
messenger.sendAuthenticationUpdate(authenticated, [authenticatingSessionID])
6869
}, 500)
6970

70-
AuthUtil.instance.secondaryAuth.onDidChangeActiveConnection(() => {
71+
AuthUtil.instance.onDidChangeConnectionState((e: auth2.AuthStateEvent) => {
7172
return debouncedEvent()
7273
})
7374
AuthUtil.instance.regionProfileManager.onDidChangeRegionProfile(() => {

packages/amazonq/src/app/amazonqScan/chat/controller/controller.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class ScanController {
104104
telemetry.amazonq_feedback.emit({
105105
featureId: 'amazonQReview',
106106
amazonqConversationId: this.sessionStorage.getSession().scanUuid,
107-
credentialStartUrl: AuthUtil.instance.startUrl,
107+
credentialStartUrl: AuthUtil.instance.connection?.startUrl,
108108
interactionType: data.vote,
109109
})
110110
})
@@ -122,8 +122,8 @@ export class ScanController {
122122
try {
123123
getLogger().debug(`Q - Review: Session created with id: ${session.tabID}`)
124124

125-
const authState = await AuthUtil.instance.getChatAuthState()
126-
if (authState.amazonQ !== 'connected') {
125+
const authState = AuthUtil.instance.getAuthState()
126+
if (authState !== 'connected') {
127127
void this.messenger.sendAuthNeededExceptionMessage(authState, tabID)
128128
session.isAuthenticating = true
129129
return
@@ -161,8 +161,8 @@ export class ScanController {
161161
return
162162
}
163163
// check that the session is authenticated
164-
const authState = await AuthUtil.instance.getChatAuthState()
165-
if (authState.amazonQ !== 'connected') {
164+
const authState = AuthUtil.instance.getAuthState()
165+
if (authState !== 'connected') {
166166
void this.messenger.sendAuthNeededExceptionMessage(authState, message.tabID)
167167
session.isAuthenticating = true
168168
return

packages/amazonq/src/app/amazonqScan/chat/controller/messenger/messenger.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import { AuthFollowUpType, AuthMessageDataMap } from 'aws-core-vscode/amazonq'
1212
import {
13-
FeatureAuthState,
1413
SecurityScanError,
1514
CodeWhispererConstants,
1615
SecurityScanStep,
@@ -34,6 +33,7 @@ import {
3433
import { i18n } from 'aws-core-vscode/shared'
3534
import { ScanAction, scanProgressMessage } from '../../../models/constants'
3635
import path from 'path'
36+
import { auth2 } from 'aws-core-vscode/auth'
3737

3838
export type UnrecoverableErrorType = 'no-project-found' | 'no-open-file-found' | 'invalid-file-type'
3939

@@ -78,19 +78,15 @@ export class Messenger {
7878
this.dispatcher.sendUpdatePromptProgress(new UpdatePromptProgressMessage(tabID, progressField))
7979
}
8080

81-
public async sendAuthNeededExceptionMessage(credentialState: FeatureAuthState, tabID: string) {
81+
public async sendAuthNeededExceptionMessage(credentialState: auth2.AuthState, tabID: string) {
8282
let authType: AuthFollowUpType = 'full-auth'
8383
let message = AuthMessageDataMap[authType].message
8484

85-
switch (credentialState.amazonQ) {
86-
case 'disconnected':
85+
switch (credentialState) {
86+
case 'notConnected':
8787
authType = 'full-auth'
8888
message = AuthMessageDataMap[authType].message
8989
break
90-
case 'unsupported':
91-
authType = 'use-supported-auth'
92-
message = AuthMessageDataMap[authType].message
93-
break
9490
case 'expired':
9591
authType = 're-auth'
9692
message = AuthMessageDataMap[authType].message

packages/amazonq/src/app/chat/activation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export async function activate(context: ExtensionContext) {
1616

1717
const setupLsp = funcUtil.debounce(async () => {
1818
void amazonq.LspController.instance.trySetupLsp(context, {
19-
startUrl: AuthUtil.instance.startUrl,
19+
startUrl: AuthUtil.instance.connection?.startUrl,
2020
maxIndexSize: CodeWhispererSettings.instance.getMaxIndexSize(),
2121
isVectorIndexEnabled: false,
2222
})

0 commit comments

Comments
 (0)