Skip to content

Commit 8c155e6

Browse files
authored
feat(amazonq): add session configuration notification (#5448)
### Problem - need to add a notification to IdC users to contact their admin to configure extended session ### Solution - show the notification once to IdC users when their connection expired
1 parent 9238343 commit 8c155e6

File tree

5 files changed

+48
-1
lines changed

5 files changed

+48
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Add notification for extended session to IdC users"
4+
}

packages/amazonq/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@
106106
"amazonQWelcomePage": {
107107
"type": "boolean",
108108
"default": false
109+
},
110+
"amazonQSessionConfigurationMessage": {
111+
"type": "boolean",
112+
"default": false
109113
}
110114
},
111115
"additionalProperties": false

packages/core/src/codewhisperer/activation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ export async function activate(context: ExtContext): Promise<void> {
302302
const defaulMsg = localize('AWS.generic.message.error', 'Failed to reauth:')
303303
void logAndShowError(localize, e, 'showReauthenticatePrompt', defaulMsg)
304304
})
305+
if (auth.isEnterpriseSsoInUse()) {
306+
await auth.notifySessionConfiguration()
307+
}
305308
}
306309
if (auth.isValidEnterpriseSsoInUse()) {
307310
await notifyNewCustomizations()

packages/core/src/codewhisperer/util/authUtil.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ import { showReauthenticateMessage } from '../../shared/utilities/messages'
3636
import { showAmazonQWalkthroughOnce } from '../../amazonq/onboardingPage/walkthrough'
3737
import { setContext } from '../../shared/vscode/setContext'
3838
import { isInDevEnv } from '../../shared/vscode/env'
39+
import { openUrl } from '../../shared/utilities/vsCodeUtils'
40+
import * as nls from 'vscode-nls'
41+
const localize = nls.loadMessageBundle()
3942
import { telemetry } from '../../shared/telemetry/telemetry'
4043

4144
/** Backwards compatibility for connections w pre-chat scopes */
@@ -345,6 +348,38 @@ export class AuthUtil {
345348
}
346349
}
347350

351+
public async notifySessionConfiguration() {
352+
const suppressId = 'amazonQSessionConfigurationMessage'
353+
const settings = AmazonQPromptSettings.instance
354+
const shouldShow = await settings.isPromptEnabled(suppressId)
355+
if (!shouldShow) {
356+
return
357+
}
358+
359+
const message = localize(
360+
'aws.amazonq.sessionConfiguration.message',
361+
'Your maximum session length for Amazon Q can be extended to 90 days by your administrator. For more information, refer to How to extend the session duration for Amazon Q in the IDE in the IAM Identity Center User Guide.'
362+
)
363+
364+
const learnMoreUrl = vscode.Uri.parse(
365+
'https://docs.aws.amazon.com/singlesignon/latest/userguide/configure-user-session.html#90-day-extended-session-duration'
366+
)
367+
await telemetry.toolkit_showNotification.run(async () => {
368+
telemetry.record({ id: 'sessionExtension' })
369+
void vscode.window.showInformationMessage(message, localizedText.learnMore).then(async (resp) => {
370+
await telemetry.toolkit_invokeAction.run(async () => {
371+
if (resp === localizedText.learnMore) {
372+
telemetry.record({ action: 'learnMore' })
373+
await openUrl(learnMoreUrl)
374+
} else {
375+
telemetry.record({ action: 'dismissSessionExtensionNotification' })
376+
}
377+
await settings.disablePrompt(suppressId)
378+
})
379+
})
380+
})
381+
}
382+
348383
public async notifyReauthenticate(isAutoTrigger?: boolean) {
349384
void this.showReauthenticatePrompt(isAutoTrigger)
350385
await this.setVscodeContextProps()

packages/core/src/shared/settings-amazonq.gen.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export const amazonqSettings = {
1515
"createCredentialsProfile": {},
1616
"codeWhispererNewWelcomeMessage": {},
1717
"codeWhispererConnectionExpired": {},
18-
"amazonQWelcomePage": {}
18+
"amazonQWelcomePage": {},
19+
"amazonQSessionConfigurationMessage": {}
1920
},
2021
"amazonQ.showInlineCodeSuggestionsWithCodeReferences": {},
2122
"amazonQ.importRecommendationForInlineCodeSuggestions": {},

0 commit comments

Comments
 (0)