Skip to content

Commit fe7a04c

Browse files
committed
add sspc
1 parent 60a5f37 commit fe7a04c

File tree

6 files changed

+27
-0
lines changed

6 files changed

+27
-0
lines changed

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/settings/CodeWhispererConfigurable.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,20 @@ class CodeWhispererConfigurable(private val project: Project) :
138138
}
139139

140140
group(message("aws.settings.codewhisperer.group.q_chat")) {
141+
row {
142+
checkBox(message("aws.settings.codewhisperer.workspace_context")).apply {
143+
connect.subscribe(
144+
ToolkitConnectionManagerListener.TOPIC,
145+
object : ToolkitConnectionManagerListener {
146+
override fun activeConnectionChanged(newConnection: ToolkitConnection?) {
147+
enabled(isCodeWhispererEnabled(project))
148+
}
149+
}
150+
)
151+
enabled(invoke)
152+
bindSelected(codeWhispererSettings::isWorkspaceContextEnabled, codeWhispererSettings::toggleWorkspaceContextEnabled)
153+
}.comment(message("aws.settings.codewhisperer.workspace_context.tooltip"))
154+
}
141155
row {
142156
checkBox(message("aws.settings.codewhisperer.project_context")).apply {
143157
connect.subscribe(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC
8484
CodeWhispererLspConfiguration(
8585
shouldShareData = CodeWhispererSettings.getInstance().isMetricOptIn(),
8686
shouldShareCodeReferences = CodeWhispererSettings.getInstance().isIncludeCodeWithReference(),
87+
shouldEnableWorkspaceContext = CodeWhispererSettings.getInstance().isWorkspaceContextEnabled()
8788
)
8889
)
8990
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ object AmazonQLspConstants {
88
const val LSP_CW_CONFIGURATION_KEY = "aws.codeWhisperer"
99
const val LSP_CW_OPT_OUT_KEY = "shareCodeWhispererContentWithAWS"
1010
const val LSP_CODE_REFERENCES_OPT_OUT_KEY = "includeSuggestionsWithCodeReferences"
11+
const val LSP_WORKSPACE_CONTEXT_ENABLED_KEY = "workspaceContext"
1112
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ data class CodeWhispererLspConfiguration(
99
@SerializedName(AmazonQLspConstants.LSP_CW_OPT_OUT_KEY)
1010
val shouldShareData: Boolean? = null,
1111

12+
@SerializedName(AmazonQLspConstants.LSP_WORKSPACE_CONTEXT_ENABLED_KEY)
13+
val shouldEnableWorkspaceContext: Boolean? = null,
14+
1215
@SerializedName(AmazonQLspConstants.LSP_CODE_REFERENCES_OPT_OUT_KEY)
1316
val shouldShareCodeReferences: Boolean? = null,
1417
)

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/settings/CodeWhispererSettings.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ class CodeWhispererSettings : PersistentStateComponent<CodeWhispererConfiguratio
9191
}
9292
}
9393

94+
fun toggleWorkspaceContextEnabled(value: Boolean, passive: Boolean = false) {
95+
state.value[CodeWhispererConfigurationType.IsWorkspaceContextEnabled] = value
96+
}
97+
98+
fun isWorkspaceContextEnabled() = state.value.getOrDefault(CodeWhispererConfigurationType.IsWorkspaceContextEnabled, true)
9499
fun isProjectContextEnabled() = state.value.getOrDefault(CodeWhispererConfigurationType.IsProjectContextEnabled, false)
95100

96101
private fun hasEnabledProjectContextOnce() = state.value.getOrDefault(CodeWhispererConfigurationType.HasEnabledProjectContextOnce, false)
@@ -199,6 +204,7 @@ enum class CodeWhispererConfigurationType {
199204
HasEnabledProjectContextOnce,
200205
IsQPrioritizedForTabAccept,
201206
IsTabAcceptPriorityNotificationShownOnce,
207+
IsWorkspaceContextEnabled
202208
}
203209

204210
enum class CodeWhispererStringConfigurationType {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ aws.settings.codewhisperer.group.plugin_settings=Plugin Settings
288288
aws.settings.codewhisperer.group.q_chat=Chat
289289
aws.settings.codewhisperer.include_code_with_reference=Include suggestions with code references
290290
aws.settings.codewhisperer.include_code_with_reference.tooltip=When checked, Amazon Q will include suggestions with code references. If you authenticate through IAM Identity Center, this setting is controlled by your Amazon Q Developer Pro administrator. <a href="https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/code-reference.html">Learn more<a/>
291+
aws.settings.codewhisperer.workspace_context=Workspace context
292+
aws.settings.codewhisperer.workspace_context.tooltip=When checked, Amazon Q will enable server side project context.
291293
aws.settings.codewhisperer.project_context=Workspace index
292294
aws.settings.codewhisperer.project_context.tooltip=When you add @workspace to your questions in Amazon Q chat, Amazon Q will index your workspace files locally to use as context for its response. Extra CPU usage is expected while indexing a workspace. This will not impact Amazon Q features or your IDE, but you may manage CPU usage by setting the number of local threads below.
293295
aws.settings.codewhisperer.project_context_gpu=Workspace index uses GPU

0 commit comments

Comments
 (0)