Skip to content

Commit 795d1f0

Browse files
authored
Merge branch 'main' into rli/fix-mockk-cleanup
2 parents 0465bbe + 2f4877a commit 795d1f0

File tree

39 files changed

+569
-256
lines changed

39 files changed

+569
-256
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Fix issue where users are unable to login to Amazon Q if they have previously authenticated (#5214)"
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" : "Fix incorrect text shown while updating documentation in /doc"
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" : "/transform: use correct doc link in SQL conversion help message"
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 /dev: Fix issue when files are deleted while preparing context"
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: Test generation fails for files outside the project"
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" : "Fix incorrect accept and reject buttons shows up while hovering over the generated file"
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" : "Prevent customization override if user has manually selected a customization"
4+
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mockitoKotlin = "5.4.0"
2727
mockk = "1.13.10"
2828
nimbus-jose-jwt = "9.40"
2929
node-gradle = "7.0.2"
30-
telemetryGenerator = "1.0.284"
30+
telemetryGenerator = "1.0.293"
3131
testLogger = "4.0.0"
3232
testRetry = "1.5.10"
3333
# test-only; platform provides slf4j transitively at runtime

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
512512
AmazonqTelemetry.utgGenerateTests(
513513
cwsprChatProgrammingLanguage = session.programmingLanguage.languageId,
514514
hasUserPromptSupplied = session.hasUserPromptSupplied,
515+
isFileInWorkspace = true,
515516
isSupportedLanguage = true,
516517
credentialStartUrl = getStartUrl(project),
517518
jobGroup = session.testGenerationJobGroupName,

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

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.intellij.openapi.application.ApplicationManager
1212
import com.intellij.openapi.fileEditor.FileDocumentManager
1313
import com.intellij.openapi.fileEditor.FileEditorManager
1414
import com.intellij.openapi.project.Project
15+
import com.intellij.openapi.project.guessProjectDir
1516
import com.intellij.openapi.vfs.LocalFileSystem
1617
import com.intellij.openapi.vfs.VirtualFile
1718
import com.intellij.openapi.vfs.VirtualFileManager
@@ -22,6 +23,7 @@ import kotlinx.coroutines.future.await
2223
import kotlinx.coroutines.launch
2324
import kotlinx.coroutines.withContext
2425
import migration.software.aws.toolkits.jetbrains.services.codewhisperer.customization.CodeWhispererModelConfigurator
26+
import software.amazon.awssdk.services.codewhispererruntime.model.IdeCategory
2527
import software.amazon.awssdk.services.codewhispererruntime.model.Position
2628
import software.amazon.awssdk.services.codewhispererruntime.model.Range
2729
import software.amazon.awssdk.services.codewhispererruntime.model.Reference
@@ -87,6 +89,7 @@ import software.aws.toolkits.resources.message
8789
import software.aws.toolkits.telemetry.AmazonqTelemetry
8890
import software.aws.toolkits.telemetry.MetricResult
8991
import software.aws.toolkits.telemetry.UiTelemetry
92+
import java.io.File
9093
import java.nio.file.Files
9194
import java.nio.file.Path
9295
import java.nio.file.Paths
@@ -184,7 +187,7 @@ class CodeTestChatController(
184187
message.tabId,
185188
false
186189
)
187-
if (isLanguageSupported(fileInfo.fileLanguage.languageId)) {
190+
if (fileInfo.fileInWorkspace && isLanguageSupported(fileInfo.fileLanguage.languageId)) {
188191
// Send Capability card to chat
189192
codeTestChatHelper.addNewMessage(
190193
CodeTestChatMessageContent(informationCard = true, message = null, type = ChatMessageType.Answer, canBeVoted = false),
@@ -230,9 +233,15 @@ class CodeTestChatController(
230233
}
231234
.build()
232235

233-
val messageContent = "<span style=\"color: #EE9D28;\">&#9888;<b> ${fileInfo.fileLanguage.languageId} is not a " +
234-
"language I support specialized unit test generation for at the moment.</b><br></span>The languages " +
235-
"I support now are Python and Java. I can still provide examples, instructions and code suggestions."
236+
val messageContent = if (fileInfo.fileInWorkspace) {
237+
"<span style=\"color: #EE9D28;\">&#9888;<b> ${fileInfo.fileLanguage.languageId} is not a " +
238+
"language I support specialized unit test generation for at the moment.</b><br></span>The languages " +
239+
"I support now are Python and Java. I can still provide examples, instructions and code suggestions."
240+
} else {
241+
"<span style=\"color: #EE9D28;\">&#9888;<b> I can't generate tests for ${fileInfo.fileName}" +
242+
" because it's outside the project directory.</b><br></span> " +
243+
"I can still provide examples, instructions and code suggestions."
244+
}
236245

237246
codeTestChatHelper.addNewMessage(
238247
CodeTestChatMessageContent(
@@ -287,7 +296,8 @@ class CodeTestChatController(
287296
AmazonqTelemetry.utgGenerateTests(
288297
cwsprChatProgrammingLanguage = session.programmingLanguage.languageId,
289298
hasUserPromptSupplied = session.hasUserPromptSupplied,
290-
isSupportedLanguage = false,
299+
isFileInWorkspace = fileInfo.fileInWorkspace,
300+
isSupportedLanguage = isLanguageSupported(fileInfo.fileLanguage.languageId),
291301
credentialStartUrl = getStartUrl(project),
292302
result = MetricResult.Succeeded,
293303
perfClientLatency = (Instant.now().toEpochMilli() - session.startTimeOfTestGeneration),
@@ -571,6 +581,7 @@ class CodeTestChatController(
571581
session.testGenerationJob,
572582
session.testGenerationJobGroupName,
573583
session.programmingLanguage,
584+
IdeCategory.JETBRAINS,
574585
session.numberOfUnitTestCasesGenerated,
575586
session.numberOfUnitTestCasesGenerated,
576587
session.linesOfCodeGenerated,
@@ -588,6 +599,7 @@ class CodeTestChatController(
588599
AmazonqTelemetry.utgGenerateTests(
589600
cwsprChatProgrammingLanguage = session.programmingLanguage.languageId,
590601
hasUserPromptSupplied = session.hasUserPromptSupplied,
602+
isFileInWorkspace = true,
591603
isSupportedLanguage = true,
592604
credentialStartUrl = getStartUrl(project = context.project),
593605
jobGroup = session.testGenerationJobGroupName,
@@ -766,6 +778,7 @@ class CodeTestChatController(
766778
session.testGenerationJob,
767779
session.testGenerationJobGroupName,
768780
session.programmingLanguage,
781+
IdeCategory.JETBRAINS,
769782
session.numberOfUnitTestCasesGenerated,
770783
0,
771784
session.linesOfCodeGenerated,
@@ -782,6 +795,7 @@ class CodeTestChatController(
782795
AmazonqTelemetry.utgGenerateTests(
783796
cwsprChatProgrammingLanguage = session.programmingLanguage.languageId,
784797
hasUserPromptSupplied = session.hasUserPromptSupplied,
798+
isFileInWorkspace = true,
785799
isSupportedLanguage = true,
786800
credentialStartUrl = getStartUrl(project = context.project),
787801
jobGroup = session.testGenerationJobGroupName,
@@ -1111,6 +1125,7 @@ class CodeTestChatController(
11111125
val filePath: String,
11121126
val fileName: String,
11131127
val fileLanguage: CodeWhispererProgrammingLanguage,
1128+
val fileInWorkspace: Boolean = true,
11141129
)
11151130

11161131
private suspend fun updateUIState() {
@@ -1142,6 +1157,9 @@ class CodeTestChatController(
11421157
val fileEditorManager = FileEditorManager.getInstance(project)
11431158
val activeEditor = fileEditorManager.selectedEditor
11441159
val activeFile = fileEditorManager.selectedFiles.firstOrNull()
1160+
val projectRoot = project.basePath?.let { Path.of(it) }?.toFile()?.toVirtualFile() ?: run {
1161+
project.guessProjectDir() ?: error("Cannot guess base directory for project ${project.name}")
1162+
}
11451163

11461164
if (activeEditor == null || activeFile == null) {
11471165
handleInvalidFileState(message.tabId)
@@ -1156,6 +1174,7 @@ class CodeTestChatController(
11561174
filePath = activeFile.path,
11571175
fileName = activeFile.name,
11581176
fileLanguage = programmingLanguage,
1177+
fileInWorkspace = activeFile.path.startsWith(projectRoot.path)
11591178
)
11601179
} catch (e: Exception) {
11611180
LOG.debug { "Error checking active file: $e" }
@@ -1169,6 +1188,8 @@ class CodeTestChatController(
11691188
}
11701189
}
11711190

1191+
private fun File.toVirtualFile() = LocalFileSystem.getInstance().findFileByIoFile(this)
1192+
11721193
/* UTG Tab Chat input use cases:
11731194
* 1. If User exits the flow and want to start a new generate unit test cycle.
11741195
* 2. If User clicks on Modify build command option and can enter the build command from chat input

0 commit comments

Comments
 (0)