Skip to content

Commit 81320e0

Browse files
authored
Merge branch 'main' into enableFlexibelCustomization
2 parents de72d81 + 991abe2 commit 81320e0

File tree

24 files changed

+758
-217
lines changed

24 files changed

+758
-217
lines changed

.changes/3.54.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"date" : "2025-02-11",
3+
"version" : "3.54",
4+
"entries" : [ {
5+
"type" : "bugfix",
6+
"description" : "Amazon Q: Reverting the behavior of making JetBrains suggestions(IntelliSense) and Q suggestions co-exist"
7+
} ]
8+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Enable syntax highlighting when viewing diff for /test"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Amazon Q /test: Truncating user input to 4096 characters for unit test generation."
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Amazon Q /test: Q identify active test file and infer source file for test generation."
4+
}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# _3.54_ (2025-02-11)
2+
- **(Bug Fix)** Amazon Q: Reverting the behavior of making JetBrains suggestions(IntelliSense) and Q suggestions co-exist
3+
14
# _3.53_ (2025-02-07)
25
- **(Bug Fix)** Amazon Q: Fixed an issue where in a specific scenario when receiving multiple suggestions with JetBrains suggestions visible, users are not able to accept the suggestion.
36

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
# Toolkit Version
5-
toolkitVersion=3.54-SNAPSHOT
5+
toolkitVersion=3.55-SNAPSHOT
66

77
# Publish Settings
88
publishToken=

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/common/clients/AmazonQCodeGenerateClient.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import software.amazon.awssdk.services.codewhispererruntime.model.ContentChecksu
1313
import software.amazon.awssdk.services.codewhispererruntime.model.CreateTaskAssistConversationRequest
1414
import software.amazon.awssdk.services.codewhispererruntime.model.CreateTaskAssistConversationResponse
1515
import software.amazon.awssdk.services.codewhispererruntime.model.CreateUploadUrlResponse
16-
import software.amazon.awssdk.services.codewhispererruntime.model.DocGenerationEvent
16+
import software.amazon.awssdk.services.codewhispererruntime.model.DocV2AcceptanceEvent
17+
import software.amazon.awssdk.services.codewhispererruntime.model.DocV2GenerationEvent
1718
import software.amazon.awssdk.services.codewhispererruntime.model.GetTaskAssistCodeGenerationResponse
1819
import software.amazon.awssdk.services.codewhispererruntime.model.IdeCategory
1920
import software.amazon.awssdk.services.codewhispererruntime.model.OperatingSystem
@@ -49,7 +50,7 @@ class AmazonQCodeGenerateClient(private val project: Project) {
4950
OptOutPreference.OPTOUT
5051
}
5152

52-
private val docGenerationUserContext = ClientMetadata.getDefault().let {
53+
private val docUserContext = ClientMetadata.getDefault().let {
5354
val osForFeatureDev: OperatingSystem =
5455
when {
5556
SystemInfo.isWindows -> OperatingSystem.WINDOWS
@@ -75,15 +76,17 @@ class AmazonQCodeGenerateClient(private val project: Project) {
7576
private val amazonQStreamingClient
7677
get() = AmazonQStreamingClient.getInstance(project)
7778

78-
fun sendDocGenerationTelemetryEvent(
79-
docGenerationEvent: DocGenerationEvent,
79+
fun sendDocTelemetryEvent(
80+
generationEvent: DocV2GenerationEvent? = null,
81+
acceptanceEvent: DocV2AcceptanceEvent? = null,
8082
): SendTelemetryEventResponse =
8183
bearerClient().sendTelemetryEvent { requestBuilder ->
8284
requestBuilder.telemetryEvent { telemetryEventBuilder ->
83-
telemetryEventBuilder.docGenerationEvent(docGenerationEvent)
85+
generationEvent?.let { telemetryEventBuilder.docV2GenerationEvent(it) }
86+
acceptanceEvent?.let { telemetryEventBuilder.docV2AcceptanceEvent(it) }
8487
}
8588
requestBuilder.optOutPreference(getTelemetryOptOutPreference())
86-
requestBuilder.userContext(docGenerationUserContext)
89+
requestBuilder.userContext(docUserContext)
8790
}
8891

8992
fun createTaskAssistConversation(): CreateTaskAssistConversationResponse = bearerClient().createTaskAssistConversation(

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/CodeWhispererUTGChatManager.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import java.io.ByteArrayInputStream
5959
import java.io.ByteArrayOutputStream
6060
import java.io.File
6161
import java.io.IOException
62+
import java.nio.file.Path
6263
import java.nio.file.Paths
6364
import java.time.Duration
6465
import java.time.Instant
@@ -249,9 +250,10 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
249250
if (shortAnswer.stopIteration == "true") {
250251
throw CodeTestException("TestGenFailedError: ${shortAnswer.planSummary}", "TestGenFailedError", shortAnswer.planSummary)
251252
}
253+
val fileName = shortAnswer.sourceFilePath?.let { Path.of(it).fileName.toString() } ?: path.fileName.toString()
252254
codeTestChatHelper.updateAnswer(
253255
CodeTestChatMessageContent(
254-
message = generateSummaryMessage(path.fileName.toString()) + shortAnswer.planSummary,
256+
message = generateSummaryMessage(fileName) + shortAnswer.planSummary,
255257
type = ChatMessageType.Answer
256258
),
257259
messageIdOverride = codeTestResponseContext.testSummaryMessageId

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,11 @@ class CodeTestChatController(
201201

202202
session.isCodeBlockSelected = selectionRange !== null
203203

204-
// This check is added to remove /test if user accidentally added while doing Regenerate unit tests.
205-
val userPrompt = if (message.prompt.startsWith("/test")) {
206-
message.prompt.substringAfter("/test ").trim()
207-
} else {
208-
message.prompt
209-
}
204+
// This removes /test if user accidentally added while doing Regenerate unit tests and truncates the user response to 4096 characters.
205+
val userPrompt = message.prompt
206+
.let { if (it.startsWith("/test")) it.substringAfter("/test ").trim() else it }
207+
.take(4096)
208+
210209
CodeWhispererUTGChatManager.getInstance(project).generateTests(userPrompt, codeTestChatHelper, null, selectionRange)
211210
} else {
212211
// Not adding a progress bar to unsupported language cases
@@ -458,6 +457,10 @@ class CodeTestChatController(
458457
when (message.actionID) {
459458
"utg_view_diff" -> {
460459
withContext(EDT) {
460+
// virtual file only needed for syntax highlighting when viewing diff
461+
val tempPath = Files.createTempFile(null, ".${session.testFileName.substringAfterLast('.')}")
462+
val virtualFile = tempPath.toFile().toVirtualFile()
463+
461464
(DiffManager.getInstance() as DiffManagerEx).showDiffBuiltin(
462465
context.project,
463466
SimpleDiffRequest(
@@ -466,13 +469,18 @@ class CodeTestChatController(
466469
getFileContentAtTestFilePath(
467470
session.projectRoot,
468471
session.testFileRelativePathToProjectRoot
469-
)
472+
),
473+
virtualFile
474+
),
475+
DiffContentFactory.getInstance().create(
476+
session.generatedTestDiffs.values.first(),
477+
virtualFile
470478
),
471-
DiffContentFactory.getInstance().create(session.generatedTestDiffs.values.first()),
472479
"Before",
473480
"After"
474481
)
475482
)
483+
Files.deleteIfExists(tempPath)
476484
session.openedDiffFile = FileEditorManager.getInstance(context.project).selectedEditor?.file
477485
ApplicationManager.getApplication().runReadAction {
478486
generatedFileContent = getGeneratedFileContent(session)

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqDoc/controller/DocController.kt

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import com.intellij.openapi.vfs.LocalFileSystem
1818
import com.intellij.openapi.vfs.VfsUtil
1919
import com.intellij.openapi.wm.ToolWindowManager
2020
import kotlinx.coroutines.withContext
21-
import software.amazon.awssdk.services.codewhispererruntime.model.DocGenerationFolderLevel
22-
import software.amazon.awssdk.services.codewhispererruntime.model.DocGenerationInteractionType
23-
import software.amazon.awssdk.services.codewhispererruntime.model.DocGenerationUserDecision
21+
import software.amazon.awssdk.services.codewhispererruntime.model.DocFolderLevel
22+
import software.amazon.awssdk.services.codewhispererruntime.model.DocInteractionType
23+
import software.amazon.awssdk.services.codewhispererruntime.model.DocUserDecision
2424
import software.aws.toolkits.core.utils.debug
2525
import software.aws.toolkits.core.utils.error
2626
import software.aws.toolkits.core.utils.getLogger
@@ -168,25 +168,25 @@ class DocController(
168168
FollowUpTypes.NEW_TASK -> newTask(message.tabId)
169169
FollowUpTypes.CLOSE_SESSION -> closeSession(message.tabId)
170170
FollowUpTypes.CREATE_DOCUMENTATION -> {
171-
docGenerationTask.interactionType = DocGenerationInteractionType.GENERATE_README
171+
docGenerationTask.interactionType = DocInteractionType.GENERATE_README
172172
mode = Mode.CREATE
173173
promptForDocTarget(message.tabId)
174174
}
175175

176176
FollowUpTypes.UPDATE_DOCUMENTATION -> {
177-
docGenerationTask.interactionType = DocGenerationInteractionType.UPDATE_README
177+
docGenerationTask.interactionType = DocInteractionType.UPDATE_README
178178
updateDocumentation(message.tabId)
179179
}
180180

181181
FollowUpTypes.CANCEL_FOLDER_SELECTION -> {
182-
docGenerationTask.reset()
182+
docGenerationTask.folderLevel = DocFolderLevel.ENTIRE_WORKSPACE
183183
newTask(message.tabId)
184184
}
185185

186186
FollowUpTypes.PROCEED_FOLDER_SELECTION -> if (mode == Mode.EDIT) makeChanges(message.tabId) else onDocsGeneration(message)
187187
FollowUpTypes.ACCEPT_CHANGES -> {
188-
docGenerationTask.userDecision = DocGenerationUserDecision.ACCEPT
189-
sendDocGenerationTelemetry(message.tabId)
188+
docGenerationTask.userDecision = DocUserDecision.ACCEPT
189+
sendDocAcceptanceTelemetry(message.tabId)
190190
acceptChanges(message)
191191
}
192192

@@ -196,8 +196,8 @@ class DocController(
196196
}
197197

198198
FollowUpTypes.REJECT_CHANGES -> {
199-
docGenerationTask.userDecision = DocGenerationUserDecision.REJECT
200-
sendDocGenerationTelemetry(message.tabId)
199+
docGenerationTask.userDecision = DocUserDecision.REJECT
200+
sendDocAcceptanceTelemetry(message.tabId)
201201
rejectChanges(message)
202202
}
203203

@@ -208,7 +208,7 @@ class DocController(
208208

209209
FollowUpTypes.EDIT_DOCUMENTATION -> {
210210
mode = Mode.EDIT
211-
docGenerationTask.interactionType = DocGenerationInteractionType.EDIT_README
211+
docGenerationTask.interactionType = DocInteractionType.EDIT_README
212212
promptForDocTarget(message.tabId)
213213
}
214214
}
@@ -454,8 +454,7 @@ class DocController(
454454
session.isAuthenticating = true
455455
return
456456
}
457-
docGenerationTask.userIdentity = session.getUserIdentity()
458-
docGenerationTask.numberOfNavigation += 1
457+
docGenerationTask.numberOfNavigations += 1
459458
messenger.sendUpdatePlaceholder(tabId, message("amazonqDoc.prompt.placeholder"))
460459
} catch (err: Exception) {
461460
val message = createUserFacingErrorMessage(err.message)
@@ -733,7 +732,6 @@ class DocController(
733732
session.isAuthenticating = true
734733
return
735734
}
736-
docGenerationTask.userIdentity = session.getUserIdentity()
737735
session.preloader(message, messenger)
738736

739737
when (session.sessionState.phase) {
@@ -747,6 +745,7 @@ class DocController(
747745
is PrepareDocGenerationState -> state.filePaths
748746
else -> emptyList()
749747
}
748+
sendDocGenerationTelemetry(filePaths, session)
750749
broadcastQEvent(QFeatureEvent.INVOCATION)
751750

752751
if (filePaths.isNotEmpty()) {
@@ -811,6 +810,8 @@ class DocController(
811810
return
812811
}
813812

813+
sendDocGenerationTelemetry(filePaths, session)
814+
814815
messenger.sendAnswer(
815816
message = docGenerationProgressMessage(DocGenerationStep.COMPLETE, mode),
816817
messageType = DocMessageType.AnswerPart,
@@ -988,9 +989,9 @@ class DocController(
988989
}
989990

990991
if (selectedFolder.path == projectRoot.path) {
991-
docGenerationTask.folderLevel = DocGenerationFolderLevel.ENTIRE_WORKSPACE
992+
docGenerationTask.folderLevel = DocFolderLevel.ENTIRE_WORKSPACE
992993
} else {
993-
docGenerationTask.folderLevel = DocGenerationFolderLevel.SUB_FOLDER
994+
docGenerationTask.folderLevel = DocFolderLevel.SUB_FOLDER
994995
}
995996

996997
logger.info { "Selected correct folder inside workspace: ${selectedFolder.path}" }
@@ -1005,7 +1006,18 @@ class DocController(
10051006
}
10061007
}
10071008

1008-
private fun sendDocGenerationTelemetry(tabId: String) {
1009+
private fun sendDocGenerationTelemetry(filePaths: List<NewFileZipInfo>, session: DocSession) {
1010+
docGenerationTask.conversationId = session.conversationId
1011+
val (totalGeneratedChars, totalGeneratedLines, totalGeneratedFiles) = session.countedGeneratedContent(filePaths, docGenerationTask.interactionType)
1012+
docGenerationTask.numberOfGeneratedChars = totalGeneratedChars
1013+
docGenerationTask.numberOfGeneratedLines = totalGeneratedLines
1014+
docGenerationTask.numberOfGeneratedFiles = totalGeneratedFiles
1015+
1016+
val docGenerationEvent = docGenerationTask.docGenerationEventBase()
1017+
session.sendDocTelemetryEvent(docGenerationEvent)
1018+
}
1019+
1020+
private fun sendDocAcceptanceTelemetry(tabId: String) {
10091021
val session = getSessionInfo(tabId)
10101022
var filePaths: List<NewFileZipInfo> = emptyList()
10111023

@@ -1016,12 +1028,12 @@ class DocController(
10161028
}
10171029
docGenerationTask.conversationId = session.conversationId
10181030
val (totalAddedChars, totalAddedLines, totalAddedFiles) = session.countAddedContent(filePaths, docGenerationTask.interactionType)
1019-
docGenerationTask.numberOfAddChars = totalAddedChars
1020-
docGenerationTask.numberOfAddLines = totalAddedLines
1021-
docGenerationTask.numberOfAddFiles = totalAddedFiles
1031+
docGenerationTask.numberOfAddedChars = totalAddedChars
1032+
docGenerationTask.numberOfAddedLines = totalAddedLines
1033+
docGenerationTask.numberOfAddedFiles = totalAddedFiles
10221034

1023-
val docGenerationEvent = docGenerationTask.docGenerationEventBase()
1024-
session.sendDocGenerationEvent(docGenerationEvent)
1035+
val docAcceptanceEvent = docGenerationTask.docAcceptanceEventBase()
1036+
session.sendDocTelemetryEvent(null, docAcceptanceEvent)
10251037
}
10261038

10271039
fun getProject() = context.project

0 commit comments

Comments
 (0)