Skip to content

Commit f4a05fa

Browse files
authored
Merge branch 'feature/stepfunctions-execution' into feature/stepfunctions-execution
2 parents 195e39a + 0f4dad3 commit f4a05fa

File tree

6 files changed

+54
-22
lines changed

6 files changed

+54
-22
lines changed

packages/amazonq/src/app/inline/recommendationService.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export interface GetAllRecommendationsOptions {
3535
}
3636

3737
export class RecommendationService {
38+
private logger = getLogger()
39+
3840
constructor(
3941
private readonly sessionManager: SessionManager,
4042
private cursorUpdateRecorder?: ICursorUpdateRecorder
@@ -117,7 +119,7 @@ export class RecommendationService {
117119
}
118120

119121
// Handle first request
120-
getLogger().info('Sending inline completion request: %O', {
122+
this.logger.info('Sending inline completion request: %O', {
121123
method: inlineCompletionWithReferencesRequestType.method,
122124
request: {
123125
textDocument: request.textDocument,
@@ -174,7 +176,7 @@ export class RecommendationService {
174176
}
175177
}
176178

177-
getLogger().info('Received inline completion response from LSP: %O', {
179+
this.logger.info('Received inline completion response from LSP: %O', {
178180
sessionId: result.sessionId,
179181
latency: Date.now() - t0,
180182
itemCount: result.items?.length || 0,
@@ -190,12 +192,14 @@ export class RecommendationService {
190192

191193
if (result.items.length > 0 && result.items[0].isInlineEdit === false) {
192194
if (isTriggerByDeletion) {
195+
this.logger.info(`Suggestions were discarded; reason: triggerByDeletion`)
193196
return []
194197
}
195198
// Completion will not be rendered if an edit suggestion has been active for longer than 1 second
196199
if (EditSuggestionState.isEditSuggestionDisplayingOverOneSecond()) {
197200
const session = this.sessionManager.getActiveSession()
198201
if (!session) {
202+
this.logger.error(`Suggestions were discarded; reason: undefined conflicting session`)
199203
return []
200204
}
201205
const params: LogInlineCompletionSessionResultsParams = {
@@ -213,14 +217,14 @@ export class RecommendationService {
213217
}
214218
languageClient.sendNotification('aws/logInlineCompletionSessionResults', params)
215219
this.sessionManager.clear()
216-
getLogger().info(
217-
'Completion discarded due to active edit suggestion displayed longer than 1 second'
220+
this.logger.info(
221+
'Suggetions were discarded; reason: active edit suggestion displayed longer than 1 second'
218222
)
219223
return []
220224
} else if (EditSuggestionState.isEditSuggestionActive()) {
221225
// discard the current edit suggestion if its display time is less than 1 sec
222226
await commands.executeCommand('aws.amazonq.inline.rejectEdit', true)
223-
getLogger().info('Discarding active edit suggestion displaying less than 1 second')
227+
this.logger.info('Discarding active edit suggestion displaying less than 1 second')
224228
}
225229
}
226230

@@ -244,24 +248,25 @@ export class RecommendationService {
244248

245249
// TODO: question, is it possible that the first request returns empty suggestion but has non-empty next token?
246250
if (result.partialResultToken) {
251+
let logstr = `found non null next token; `
247252
if (!isInlineEdit) {
248253
// If the suggestion is COMPLETIONS and there are more results to fetch, handle them in the background
249-
getLogger().info(
250-
'Suggestion type is COMPLETIONS. Start fetching for more items if partialResultToken exists.'
251-
)
254+
logstr += 'Suggestion type is COMPLETIONS. Start pulling more items'
252255
this.processRemainingRequests(languageClient, request, result, token).catch((error) => {
253256
languageClient.warn(`Error when getting suggestions: ${error}`)
254257
})
255258
} else {
256259
// Skip fetching for more items if the suggesion is EDITS. If it is EDITS suggestion, only fetching for more
257260
// suggestions when the user start to accept a suggesion.
258261
// Save editsStreakPartialResultToken for the next EDITS suggestion trigger if user accepts.
259-
getLogger().info('Suggestion type is EDITS. Skip fetching for more items.')
262+
logstr += 'Suggestion type is EDITS. Skip pulling more items'
260263
this.sessionManager.updateActiveEditsStreakToken(result.partialResultToken)
261264
}
265+
266+
this.logger.info(logstr)
262267
}
263268
} catch (error: any) {
264-
getLogger().error('Error getting recommendations: %O', error)
269+
this.logger.error('Error getting recommendations: %O', error)
265270
// bearer token expired
266271
if (error.data && error.data.awsErrorCode === 'E_AMAZON_Q_CONNECTION_EXPIRED') {
267272
// ref: https://github.com/aws/aws-toolkit-vscode/blob/amazonq/v1.74.0/packages/core/src/codewhisperer/service/inlineCompletionService.ts#L104

packages/core/src/awsService/sagemaker/commands.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ export async function deeplinkConnect(
8686
session: string,
8787
wsUrl: string,
8888
token: string,
89-
domain: string
89+
domain: string,
90+
appType?: string
9091
) {
9192
getLogger().debug(
9293
`sm:deeplinkConnect: connectionIdentifier: ${connectionIdentifier} session: ${session} wsUrl: ${wsUrl} token: ${token}`
@@ -107,7 +108,8 @@ export async function deeplinkConnect(
107108
session,
108109
wsUrl,
109110
token,
110-
domain
111+
domain,
112+
appType
111113
)
112114

113115
await startVscodeRemote(

packages/core/src/awsService/sagemaker/credentialMapping.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,16 @@ export async function persistSSMConnection(
9696
domain: string,
9797
session?: string,
9898
wsUrl?: string,
99-
token?: string
99+
token?: string,
100+
appType?: string
100101
): Promise<void> {
101102
const { region } = parseArn(spaceArn)
102103
const endpoint = DevSettings.instance.get('endpoints', {})['sagemaker'] ?? ''
103104

104-
// TODO: Hardcoded to 'jupyterlab' due to a bug in Studio that only supports refreshing
105-
// the token for both CodeEditor and JupyterLab Apps in the jupyterlab subdomain.
106-
// This will be fixed shortly after NYSummit launch to support refresh URL in CodeEditor subdomain.
107-
const appSubDomain = 'jupyterlab'
105+
let appSubDomain = 'jupyterlab'
106+
if (appType && appType.toLowerCase() === 'codeeditor') {
107+
appSubDomain = 'code-editor'
108+
}
108109

109110
let envSubdomain: string
110111

packages/core/src/awsService/sagemaker/model.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export async function prepareDevEnvConnection(
5656
session?: string,
5757
wsUrl?: string,
5858
token?: string,
59-
domain?: string
59+
domain?: string,
60+
appType?: string
6061
) {
6162
const remoteLogger = configureRemoteConnectionLogger()
6263
const { ssm, vsc, ssh } = (await ensureDependencies()).unwrap()
@@ -82,7 +83,7 @@ export async function prepareDevEnvConnection(
8283
await persistSmusProjectCreds(spaceArn, node as SagemakerUnifiedStudioSpaceNode)
8384
}
8485
} else if (connectionType === 'sm_dl') {
85-
await persistSSMConnection(spaceArn, domain ?? '', session, wsUrl, token)
86+
await persistSSMConnection(spaceArn, domain ?? '', session, wsUrl, token, appType)
8687
}
8788

8889
await startLocalServer(ctx)

packages/core/src/awsService/sagemaker/uriHandlers.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export function register(ctx: ExtContext) {
1818
params.session,
1919
`${params.ws_url}&cell-number=${params['cell-number']}`,
2020
params.token,
21-
params.domain
21+
params.domain,
22+
params.app_type
2223
)
2324
})
2425
}
@@ -27,7 +28,7 @@ export function register(ctx: ExtContext) {
2728
}
2829

2930
export function parseConnectParams(query: SearchParams) {
30-
const params = query.getFromKeysOrThrow(
31+
const requiredParams = query.getFromKeysOrThrow(
3132
'connection_identifier',
3233
'domain',
3334
'user_profile',
@@ -36,5 +37,7 @@ export function parseConnectParams(query: SearchParams) {
3637
'cell-number',
3738
'token'
3839
)
39-
return params
40+
const optionalParams = query.getFromKeys('app_type')
41+
42+
return { ...requiredParams, ...optionalParams }
4043
}

packages/core/src/test/awsService/sagemaker/uriHandlers.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ describe('SageMaker URI handler', function () {
4444
ws_url: 'wss://example.com',
4545
'cell-number': '4',
4646
token: 'my-token',
47+
app_type: 'jupyterlab',
4748
}
4849

4950
const uri = createConnectUri(params)
@@ -55,5 +56,24 @@ describe('SageMaker URI handler', function () {
5556
assert.deepStrictEqual(deeplinkConnectStub.firstCall.args[3], 'wss://example.com&cell-number=4')
5657
assert.deepStrictEqual(deeplinkConnectStub.firstCall.args[4], 'my-token')
5758
assert.deepStrictEqual(deeplinkConnectStub.firstCall.args[5], 'my-domain')
59+
assert.deepStrictEqual(deeplinkConnectStub.firstCall.args[6], 'jupyterlab')
60+
})
61+
62+
it('calls deeplinkConnect with undefined app_type when not provided', async function () {
63+
const params = {
64+
connection_identifier: 'abc123',
65+
domain: 'my-domain',
66+
user_profile: 'me',
67+
session: 'sess-xyz',
68+
ws_url: 'wss://example.com',
69+
'cell-number': '4',
70+
token: 'my-token',
71+
}
72+
73+
const uri = createConnectUri(params)
74+
await handler.handleUri(uri)
75+
76+
assert.ok(deeplinkConnectStub.calledOnce)
77+
assert.deepStrictEqual(deeplinkConnectStub.firstCall.args[6], undefined)
5878
})
5979
})

0 commit comments

Comments
 (0)