Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import software.aws.toolkits.core.utils.warn
import software.aws.toolkits.jetbrains.core.credentials.AwsBearerTokenConnection
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
import software.aws.toolkits.jetbrains.core.credentials.sono.isInternalUser
import software.aws.toolkits.jetbrains.core.gettingstarted.emitUserState
import software.aws.toolkits.jetbrains.services.amazonq.CodeWhispererFeatureConfigService
import software.aws.toolkits.jetbrains.services.amazonq.project.ProjectContextController
import software.aws.toolkits.jetbrains.services.amazonq.toolwindow.AmazonQToolWindow
import software.aws.toolkits.jetbrains.services.amazonq.toolwindow.AmazonQToolWindowFactory
Expand All @@ -36,7 +36,7 @@ class AmazonQStartupActivity : ProjectActivity {
if (ApplicationManager.getApplication().isUnitTestMode) return

ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(QConnection.getInstance())?.let {
if (it is AwsBearerTokenConnection && isInternalUser(it.startUrl)) {
if (it is AwsBearerTokenConnection && CodeWhispererFeatureConfigService.getInstance().getChatWSContext()) {
CodeWhispererSettings.getInstance().toggleProjectContextEnabled(value = true, passive = true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ amazonqInlineChat.popup.generating = Generating...
amazonqInlineChat.popup.reject=Reject \u238B
amazonqInlineChat.popup.title=Enter Instructions for Q
amazonq.refresh.panel=Refresh Chat Session
amazonq.title=Amazon Q
amazonq.workspace.settings.open.prompt=Workspace index is now enabled. You can disable it from Amazon Q settings.
q.hello=Hello
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class CodeWhispererFeatureConfigService {

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

fun getChatWSContext(): Boolean = getFeatureValueForKey(CHAT_WS_CONTEXT).stringValue() == "TREATMENT"

// Get the feature value for the given key.
// In case of a misconfiguration, it will return a default feature value of Boolean false.
private fun getFeatureValueForKey(name: String): FeatureValue =
Expand All @@ -136,6 +138,7 @@ class CodeWhispererFeatureConfigService {
private const val CUSTOMIZATION_ARN_OVERRIDE_NAME = "customizationArnOverride"
private const val HIGHLIGHT_COMMAND_NAME = "highlightCommand"
private const val NEW_AUTO_TRIGGER_UX = "newAutoTriggerUX"
private const val CHAT_WS_CONTEXT = "WorkspaceContext"
private val LOG = getLogger<CodeWhispererFeatureConfigService>()

// Also serve as default values in case server-side config isn't there yet
Expand All @@ -160,7 +163,12 @@ class CodeWhispererFeatureConfigService {
INLINE_COMPLETION,
"CONTROL",
FeatureValue.builder().stringValue("CONTROL").build()
)
),
CHAT_WS_CONTEXT to FeatureContext(
CHAT_WS_CONTEXT,
"CONTROL",
FeatureValue.builder().stringValue("CONTROL").build()
),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@

package software.aws.toolkits.jetbrains.settings

import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.components.BaseState
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.openapi.components.service
import com.intellij.util.xmlb.annotations.Property
import software.aws.toolkits.jetbrains.utils.notifyInfo
import software.aws.toolkits.resources.AmazonQBundle

@Service
@State(name = "codewhispererSettings", storages = [Storage("aws.xml")])
Expand Down Expand Up @@ -48,6 +51,14 @@ class CodeWhispererSettings : PersistentStateComponent<CodeWhispererConfiguratio
if (!hasEnabledProjectContextOnce()) {
toggleEnabledProjectContextOnce(true)
state.value[CodeWhispererConfigurationType.IsProjectContextEnabled] = value
// todo: hack to bypass module dependency issue (codewhisperer -> shared), should pass [CodeWhispererShowSettingsAction] instead when it's resolved
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will follow up in this wip pr #5304

val actions = ActionManager.getInstance().getAction("codewhisperer.settings")?.let { listOf(it) } ?: emptyList()

notifyInfo(
AmazonQBundle.message("amazonq.title"),
AmazonQBundle.message("amazonq.workspace.settings.open.prompt"),
notificationActions = actions
)
}
} else {
state.value[CodeWhispererConfigurationType.IsProjectContextEnabled] = value
Expand Down
Loading