Skip to content

Commit 06f4a99

Browse files
committed
Show context options in prompt
1 parent 09b851f commit 06f4a99

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,21 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC
115115
)
116116
)
117117
}
118+
AmazonQLspConstants.LSP_PROJECT_CONTEXT_KEY -> {
119+
add(
120+
AmazonQLspConfiguration(
121+
optOutTelemetry = AwsSettings.getInstance().isTelemetryEnabled,
122+
customization = CodeWhispererModelConfigurator.getInstance().activeCustomization(project)?.arn,
123+
// local context
124+
enableLocalIndexing = qSettings.isProjectContextEnabled(),
125+
indexWorkerThreads = qSettings.getProjectContextIndexThreadCount(),
126+
enableGpuAcceleration = qSettings.isProjectContextGpu(),
127+
localIndexing = LocalIndexingConfiguration(
128+
maxIndexSizeMB = qSettings.getProjectContextIndexMaxSize()
129+
)
130+
)
131+
)
132+
}
118133
}
119134
}
120135
}

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
@@ -13,4 +13,5 @@ object AmazonQLspConstants {
1313
const val LSP_ENABLE_TELEMETRY_EVENTS_CONFIGURATION_KEY = "enableTelemetryEventsToDestination"
1414
const val LSP_CUSTOMIZATION_CONFIGURATION_KEY = "customization"
1515
const val LSP_WORKSPACE_CONTEXT_ENABLED_KEY = "workspaceContext"
16+
const val LSP_PROJECT_CONTEXT_KEY = "projectContext"
1617
}

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
3+
@file:Suppress("BannedImports")
44
package software.aws.toolkits.jetbrains.services.amazonq.lsp
55

6+
import com.google.gson.Gson
67
import com.google.gson.ToNumberPolicy
78
import com.intellij.execution.configurations.GeneralCommandLine
89
import com.intellij.execution.impl.ExecutionManagerImpl
@@ -43,7 +44,7 @@ import org.eclipse.lsp4j.WorkspaceClientCapabilities
4344
import org.eclipse.lsp4j.jsonrpc.Launcher
4445
import org.eclipse.lsp4j.jsonrpc.Launcher.Builder
4546
import org.eclipse.lsp4j.jsonrpc.MessageConsumer
46-
import org.eclipse.lsp4j.jsonrpc.messages.Message
47+
import org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage
4748
import org.eclipse.lsp4j.jsonrpc.messages.ResponseMessage
4849
import org.eclipse.lsp4j.launch.LSPLauncher
4950
import org.slf4j.event.Level
@@ -56,6 +57,7 @@ import software.aws.toolkits.jetbrains.services.amazonq.lsp.auth.DefaultAuthCred
5657
import software.aws.toolkits.jetbrains.services.amazonq.lsp.dependencies.DefaultModuleDependenciesService
5758
import software.aws.toolkits.jetbrains.services.amazonq.lsp.encryption.JwtEncryptionManager
5859
import software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat.AmazonQLspTypeAdapterFactory
60+
import software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat.AsyncChatUiListener
5961
import software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat.AwsExtendedInitializeResult
6062
import software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat.AwsServerCapabilitiesProvider
6163
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.createExtendedClientMetadata
@@ -287,6 +289,16 @@ private class AmazonQServerInstance(private val project: Project, private val cs
287289
AwsServerCapabilitiesProvider.getInstance(project).setAwsServerCapabilities(result.getAwsServerCapabilities())
288290
AmazonQLspService.getInstance(project).notifyInitializeMessageReceived()
289291
}
292+
if (message is NotificationMessage && message.method == "aws/chat/sendContextCommands") {
293+
val showContextCommands = """
294+
{
295+
"command":"aws/chat/sendContextCommands",
296+
"params": ${Gson().toJson(message.params)}
297+
}
298+
""".trimIndent()
299+
300+
AsyncChatUiListener.notifyPartialMessageUpdate(showContextCommands)
301+
}
290302
consumer?.consume(message)
291303
}
292304
}
@@ -373,18 +385,6 @@ private class AmazonQServerInstance(private val project: Project, private val cs
373385
}
374386
}
375387

376-
class MessageTracer {
377-
private val traceLogger = LOG.atLevel(if (isDeveloperMode()) Level.INFO else Level.DEBUG)
378-
379-
fun trace(direction: String, message: Message) {
380-
traceLogger.log {
381-
buildString {
382-
append("$direction: ")
383-
append(message.toString())
384-
}
385-
}
386-
}
387-
}
388388
companion object {
389389
private val LOG = getLogger<AmazonQServerInstance>()
390390
}

0 commit comments

Comments
 (0)