Skip to content

Commit bfe0f1a

Browse files
authored
feat(amazonq): add notification to IdC users on extended session (#4802)
1 parent cabbd0b commit bfe0f1a

File tree

5 files changed

+37
-1
lines changed

5 files changed

+37
-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 IdC users on extended session"
4+
}

plugins/amazonq/codewhisperer/jetbrains-community/src/migration/software/aws/toolkits/jetbrains/services/codewhisperer/explorer/CodeWhispererExplorerActionManager.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ class CodeWhispererExplorerActionManager : PersistentStateComponent<CodeWhispere
7070
actionState.value[CodeWhispererExploreStateType.ConnectionExpiredDoNotShowAgain] = doNotShowAgain
7171
}
7272

73+
fun getSessionConfigurationMessageShown(): Boolean = actionState.value.getOrDefault(CodeWhispererExploreStateType.SessionConfigurationMessageShown, false)
74+
75+
fun setSessionConfigurationMessageShown(isShown: Boolean) {
76+
actionState.value[CodeWhispererExploreStateType.SessionConfigurationMessageShown] = isShown
77+
}
78+
7379
fun setAutoSuggestion(project: Project, isAutoEnabled: Boolean) {
7480
setAutoEnabled(isAutoEnabled)
7581
val autoSuggestionState = if (isAutoEnabled) CodeWhispererConstants.AutoSuggestion.ACTIVATED else CodeWhispererConstants.AutoSuggestion.DEACTIVATED

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/explorer/CodeWhispererExplorerActionManager.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ enum class CodeWhispererExploreStateType {
3838
DoNotShowAgainWarn,
3939
DoNotShowAgainError,
4040
AccountlessNullified,
41-
ConnectionExpiredDoNotShowAgain
41+
ConnectionExpiredDoNotShowAgain,
42+
SessionConfigurationMessageShown,
4243
}
4344

4445
interface CodeWhispererActivationChangedListener {

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererUtil.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
package software.aws.toolkits.jetbrains.services.codewhisperer.util
55

6+
import com.intellij.ide.BrowserUtil
67
import com.intellij.notification.NotificationAction
78
import com.intellij.openapi.application.ApplicationManager
89
import com.intellij.openapi.application.runInEdt
@@ -39,6 +40,7 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhisperer
3940
import software.aws.toolkits.jetbrains.settings.AwsSettings
4041
import software.aws.toolkits.jetbrains.utils.isQExpired
4142
import software.aws.toolkits.jetbrains.utils.notifyError
43+
import software.aws.toolkits.jetbrains.utils.notifyInfo
4244
import software.aws.toolkits.jetbrains.utils.pluginAwareExecuteOnPooledThread
4345
import software.aws.toolkits.resources.message
4446
import software.aws.toolkits.telemetry.CodewhispererCompletionType
@@ -194,6 +196,9 @@ object CodeWhispererUtil {
194196
if (!isPluginStarting) {
195197
CodeWhispererService.markReAuthPromptShown()
196198
}
199+
if (!tokenConnection(project).isSono()) {
200+
notifySessionConfiguration(project)
201+
}
197202
}
198203
}
199204
} catch (e: Exception) {
@@ -221,6 +226,24 @@ object CodeWhispererUtil {
221226
)
222227
}
223228

229+
private fun notifySessionConfiguration(project: Project) {
230+
if (CodeWhispererExplorerActionManager.getInstance().getSessionConfigurationMessageShown()) {
231+
return
232+
}
233+
val learnMoreLink = "https://docs.aws.amazon.com/singlesignon/latest/userguide/configure-user-session.html#90-day-extended-session-duration"
234+
notifyInfo(
235+
message("q.session_configuration"),
236+
message("q.session_configuration.description"),
237+
project,
238+
listOf(
239+
NotificationAction.createSimple(message("q.learn.more")) {
240+
BrowserUtil.browse(learnMoreLink)
241+
}
242+
)
243+
)
244+
CodeWhispererExplorerActionManager.getInstance().setSessionConfigurationMessageShown(true)
245+
}
246+
224247
fun getConnectionStartUrl(connection: ToolkitConnection?): String? {
225248
connection ?: return null
226249
if (connection !is ManagedBearerSsoConnection) return null

plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,6 +1517,8 @@ q.onboarding.codewhisperer.description=Amazon Q inline suggestions are also enab
15171517
q.onboarding.description=Amazon Q is your generative-AI powered assistant.
15181518
q.onboarding.title=Meet Amazon Q
15191519
q.reauthenticate=Re-authenticate to connect
1520+
q.session_configuration=Extend your IDE sessions
1521+
q.session_configuration.description=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.
15201522
q.sign.in=Get Started
15211523
q.ui.prompt.transform=/transform
15221524
q.unavailable=\ Not supported in v2023.2.0

0 commit comments

Comments
 (0)