Skip to content

feat(amazonq): show the opt-in checkbox for server-side context #5894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -25,8 +25,12 @@ import com.intellij.util.concurrency.EdtExecutorService
import com.intellij.util.execution.ParametersListUtil
import kotlinx.coroutines.launch
import org.eclipse.lsp4j.DidChangeConfigurationParams
import software.aws.toolkits.jetbrains.core.credentials.AwsBearerTokenConnection
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnection
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManagerListener
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
import software.aws.toolkits.jetbrains.core.credentials.sono.isInternalUser
import software.aws.toolkits.jetbrains.services.amazonq.lsp.AmazonQLspService
import software.aws.toolkits.jetbrains.services.codewhisperer.credentials.CodeWhispererLoginType
import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.CodeWhispererExplorerActionManager
Expand All @@ -47,6 +51,12 @@ class CodeWhispererConfigurable(private val project: Project) :
private val isSso: Boolean
get() = CodeWhispererExplorerActionManager.getInstance().checkActiveCodeWhispererConnectionType(project) == CodeWhispererLoginType.SSO

private val isInternalUser: Boolean
get() {
val conn = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(QConnection.getInstance()) as? AwsBearerTokenConnection
return conn?.let { isInternalUser(it.startUrl) } ?: false
}

override fun getId() = "aws.codewhisperer"

override fun createPanel() = panel {
Expand Down Expand Up @@ -123,6 +133,21 @@ class CodeWhispererConfigurable(private val project: Project) :
}.enabled(false)
}
}

row {
checkBox(message("aws.settings.codewhisperer.workspace_context")).apply {
connect.subscribe(
ToolkitConnectionManagerListener.TOPIC,
object : ToolkitConnectionManagerListener {
override fun activeConnectionChanged(newConnection: ToolkitConnection?) {
enabled(isCodeWhispererEnabled(project))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
enabled(isCodeWhispererEnabled(project))
enabled(isCodeWhispererEnabled(project))
visibleIf(isInternalUser)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested the proposed changes and it doesn't work actually. That would always make the checkbox showing up no matter logging in with internal user identity or other identities.

}
}
)
enabled(invoke)
bindSelected(codeWhispererSettings::isWorkspaceContextEnabled, codeWhispererSettings::toggleWorkspaceContextEnabled)
}.comment(message("aws.settings.codewhisperer.workspace_context.tooltip"))
}.visible(isInternalUser)
}

group(message("aws.settings.codewhisperer.group.inline_suggestions")) {
Expand Down Expand Up @@ -158,20 +183,6 @@ class CodeWhispererConfigurable(private val project: Project) :
}

group(message("aws.settings.codewhisperer.group.q_chat")) {
row {
checkBox(message("aws.settings.codewhisperer.workspace_context")).apply {
connect.subscribe(
ToolkitConnectionManagerListener.TOPIC,
object : ToolkitConnectionManagerListener {
override fun activeConnectionChanged(newConnection: ToolkitConnection?) {
enabled(isCodeWhispererEnabled(project))
}
}
)
enabled(invoke)
bindSelected(codeWhispererSettings::isWorkspaceContextEnabled, codeWhispererSettings::toggleWorkspaceContextEnabled)
}.comment(message("aws.settings.codewhisperer.workspace_context.tooltip"))
}.visible(false)
row {
checkBox(message("aws.settings.codewhisperer.project_context")).apply {
connect.subscribe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CodeWhispererConfigurableTest : CodeWhispererTestBase() {
message("aws.settings.codewhisperer.include_code_with_reference"),
message("aws.settings.codewhisperer.configurable.opt_out.title"),
message("aws.settings.codewhisperer.automatic_import_adder"),
"Workspace context",
"Server-side context",
message("aws.settings.codewhisperer.project_context"),
message("aws.settings.codewhisperer.project_context_gpu")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ aws.settings.codewhisperer.project_context_index_max_size.tooltip=The maximum si
aws.settings.codewhisperer.project_context_index_thread=Workspace index worker threads
aws.settings.codewhisperer.project_context_index_thread.tooltip=Number of worker threads of Amazon Q local index process. Set to 0 to use system default worker threads for balanced performance. Please restart or reload IntelliJ after changing worker threads.
aws.settings.codewhisperer.warning=To use Amazon Q, login with AWS Builder ID or AWS IAM Identity Center.
aws.settings.codewhisperer.workspace_context=Workspace context
aws.settings.codewhisperer.workspace_context.tooltip=When checked, Amazon Q will enable server side project context.
aws.settings.codewhisperer.workspace_context=Server-side context
aws.settings.codewhisperer.workspace_context.tooltip=Index project files on the server and use as context for higher-quality responses. This feature will activate only if your administrator has opted you in.
aws.settings.dynamic_resources_configurable.clear_all=Clear All
aws.settings.dynamic_resources_configurable.select_all=Select All
aws.settings.dynamic_resources_configurable.suggest_types.dialog.message=Please suggest additional AWS resource types (e.g. AWS::S3::Bucket)\nyou would like to see supported in future releases.\n\n(max length: 2000 chars)
Expand Down
Loading