Skip to content

Commit 08450be

Browse files
committed
optin @workspace context if a user is in treatment group
1 parent 74b27eb commit 08450be

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/startup/AmazonQStartupActivity.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import software.aws.toolkits.core.utils.warn
1717
import software.aws.toolkits.jetbrains.core.credentials.AwsBearerTokenConnection
1818
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
1919
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
20-
import software.aws.toolkits.jetbrains.core.credentials.sono.isInternalUser
2120
import software.aws.toolkits.jetbrains.core.gettingstarted.emitUserState
21+
import software.aws.toolkits.jetbrains.services.amazonq.CodeWhispererFeatureConfigService
2222
import software.aws.toolkits.jetbrains.services.amazonq.project.ProjectContextController
2323
import software.aws.toolkits.jetbrains.services.amazonq.toolwindow.AmazonQToolWindow
2424
import software.aws.toolkits.jetbrains.services.amazonq.toolwindow.AmazonQToolWindowFactory
@@ -35,9 +35,15 @@ class AmazonQStartupActivity : ProjectActivity {
3535
override suspend fun execute(project: Project) {
3636
if (ApplicationManager.getApplication().isUnitTestMode) return
3737

38+
// Turn on project context if a user is in treatment group and prompt UI to notify them
3839
ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(QConnection.getInstance())?.let {
39-
if (it is AwsBearerTokenConnection && isInternalUser(it.startUrl)) {
40+
if (it is AwsBearerTokenConnection &&
41+
CodeWhispererFeatureConfigService.getInstance().getWorkspaceContext() &&
42+
!CodeWhispererSettings.getInstance().isProjectContextEnabled()
43+
) {
4044
CodeWhispererSettings.getInstance().toggleProjectContextEnabled(value = true, passive = true)
45+
46+
// TODO: toast notification UI
4147
}
4248
}
4349

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/CodeWhispererFeatureConfigService.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ class CodeWhispererFeatureConfigService {
115115

116116
fun getInlineCompletion(): Boolean = getFeatureValueForKey(INLINE_COMPLETION).stringValue() == "TREATMENT"
117117

118+
fun getWorkspaceContext(): Boolean = getFeatureValueForKey(WORKSPACE_CONTEXT_FEATURE).stringValue() == "TREATMENT"
119+
118120
// Get the feature value for the given key.
119121
// In case of a misconfiguration, it will return a default feature value of Boolean false.
120122
private fun getFeatureValueForKey(name: String): FeatureValue =
@@ -133,6 +135,7 @@ class CodeWhispererFeatureConfigService {
133135
private const val INLINE_COMPLETION = "ProjectContextV2"
134136
const val CUSTOMIZATION_ARN_OVERRIDE_NAME = "customizationArnOverride"
135137
private const val NEW_AUTO_TRIGGER_UX = "newAutoTriggerUX"
138+
private const val WORKSPACE_CONTEXT_FEATURE = "WorkspaceContext"
136139
private val LOG = getLogger<CodeWhispererFeatureConfigService>()
137140

138141
// TODO: add real feature later
@@ -158,6 +161,11 @@ class CodeWhispererFeatureConfigService {
158161
INLINE_COMPLETION,
159162
"CONTROL",
160163
FeatureValue.builder().stringValue("CONTROL").build()
164+
),
165+
WORKSPACE_CONTEXT_FEATURE to FeatureContext(
166+
WORKSPACE_CONTEXT_FEATURE,
167+
"CONTROL",
168+
FeatureValue.builder().stringValue("CONTROL").build()
161169
)
162170
)
163171
}

0 commit comments

Comments
 (0)