Skip to content
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
fbe77d7
feat (Amazon Q): Add basic UX and logic for generating unit tests
bweedop Aug 27, 2024
8c8701f
Merge branch 'aws:main' into add-generate-tests
bweedop Aug 27, 2024
5596ce6
Merge branch 'aws:main' into add-generate-tests
bweedop Aug 28, 2024
2476e8a
Merge branch 'aws:main' into add-generate-tests
bweedop Sep 4, 2024
a200346
Update cwspr model with GENERATE_UNIT_TESTS user intent
bweedop Sep 4, 2024
2673db8
Merge branch 'add-generate-tests' of github.com:bweedop/aws-toolkit-j…
bweedop Sep 4, 2024
2050c28
fix (Amazon Q): Pass context specific intent and trigger type to chat…
bweedop Aug 28, 2024
665a7c4
Added authType to loginWithBrowser metric (#4843)
manodnyab Aug 29, 2024
9a88b0f
Added UI click metrics on all login options (#4838)
manodnyab Aug 29, 2024
b6e4e7b
Updating version to 3.25
Aug 29, 2024
b884109
Updating SNAPSHOT version to 3.26-SNAPSHOT
Aug 29, 2024
edbde53
Revert open and close sign in webview telemetry (#4850)
manodnyab Aug 30, 2024
3cdb18e
Updating version to 3.26
Aug 30, 2024
4a206c1
Updating SNAPSHOT version to 3.27-SNAPSHOT
Aug 30, 2024
a478c5a
telemetry(amazonq): update telemetry (#4847)
dhasani23 Sep 3, 2024
930e706
feat(amazonq): Reduce @workspace indexing time by 50% (#4846)
leigaol Sep 3, 2024
334e8e1
Hash startUrl
bweedop Sep 4, 2024
ac85a6f
Merge branch 'add-generate-tests' of github.com:bweedop/aws-toolkit-j…
bweedop Sep 4, 2024
29e3613
Merge branch 'aws:main' into add-generate-tests
bweedop Sep 6, 2024
edaecdb
Revert CodeWhisperer endpoint back gamma endpoint
bweedop Sep 6, 2024
54816fb
Revert adding user intent to interact with message metadata
bweedop Sep 6, 2024
a8ba166
Merge branch 'add-generate-tests' of github.com:bweedop/aws-toolkit-j…
bweedop Sep 6, 2024
c25dbe5
Add changelog
bweedop Sep 6, 2024
c8ed616
Refactor for consistent hashing of startUrl
bweedop Sep 6, 2024
673c6e1
Remove hashing logic on startUrl and changelog entry
bweedop Sep 10, 2024
d589b60
Add (Beta) suffix to generate unit tests command
bweedop Sep 11, 2024
0d52a23
Add check for startUrl when getting user intent from prompt
bweedop Sep 11, 2024
2408b8c
Merge branch 'aws:main' into add-generate-tests
bweedop Sep 12, 2024
c07fee0
Merge branch 'aws:main' into add-generate-tests
bweedop Sep 17, 2024
8b5f672
Update TestCodeAction to resolve lint failure
bweedop Sep 17, 2024
3c3d9f3
address comments: Better GenerateUnitTest Action naming
daveln-aws Sep 18, 2024
3124e9a
Refactor to use more specific command for UTG
bweedop Sep 20, 2024
c9f1491
Merge branch 'aws:main' into add-generate-tests
bweedop Sep 23, 2024
4808425
Change name of action to GenerateUnitTests
bweedop Sep 24, 2024
061fd25
Fix linting errors
bweedop Sep 24, 2024
9c83687
Merge branch 'main' into add-generate-tests
bweedop Sep 25, 2024
465b2c9
Merge branch 'add-generate-tests' of github.com:bweedop/aws-toolkit-j…
bweedop Sep 25, 2024
ba4329d
Override 'getActionUpdateThread'
bweedop Sep 25, 2024
5317be3
Reorder MessageBundle.properties
bweedop Sep 25, 2024
2c4fe57
Merge branch 'main' into add-generate-tests
bweedop Sep 25, 2024
f3f324d
Fix syntax error
bweedop Sep 25, 2024
88fb53a
Merge branch 'add-generate-tests' of github.com:bweedop/aws-toolkit-j…
bweedop Sep 25, 2024
5abad70
Merge branch 'aws:main' into add-generate-tests
bweedop Sep 30, 2024
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 @@ -7,7 +7,7 @@

<projectListeners>
<listener class="software.aws.toolkits.jetbrains.services.amazonq.toolwindow.AmazonQToolWindowListener"
topic="com.intellij.openapi.wm.ex.ToolWindowManagerListener"/>
topic="com.intellij.openapi.wm.ex.ToolWindowManagerListener"/>
<listener class="software.aws.toolkits.jetbrains.services.cwc.editor.context.project.ProjectContextEditorListener"
topic="com.intellij.openapi.fileEditor.FileEditorManagerListener"/>
</projectListeners>
Expand Down Expand Up @@ -70,6 +70,11 @@
<keyboard-shortcut keymap="$default" first-keystroke="meta alt A" />
</action>

<action id="aws.toolkit.jetbrains.core.services.cwc.commands.GenerateUnitTestsAction"
class="software.aws.toolkits.jetbrains.services.cwc.commands.GenerateUnitTestsAction">
<keyboard-shortcut keymap="$default" first-keystroke="meta alt T" />
</action>

<action id="aws.toolkit.jetbrains.core.services.cwc.commands.SendToPromptAction"
class="software.aws.toolkits.jetbrains.services.cwc.commands.SendToPromptAction">
<keyboard-shortcut keymap="$default" first-keystroke="meta alt S" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ class ChatSessionV1(
UserIntent.EXPLAIN_LINE_BY_LINE -> FollowUpType.LineByLine
UserIntent.EXPLAIN_CODE_SELECTION -> FollowUpType.ExplainInDetail
UserIntent.UNKNOWN_TO_SDK_VERSION -> FollowUpType.Generated
UserIntent.GENERATE_UNIT_TESTS -> FollowUpType.Generated
null -> FollowUpType.Generated
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ enum class EditorContextCommand(
verb = "Optimize",
actionId = "aws.amazonq.optimizeCode",
),
GenerateUnitTests(
verb = "Generate unit tests for",
actionId = "aws.amazonq.generateUnitTests",
),
SendToPrompt(
verb = "SendToPrompt",
actionId = "aws.amazonq.sendToPrompt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@
var shouldAddIndexInProgressMessage: Boolean = false
var shouldUseWorkspaceContext: Boolean = false
val isDataCollectionGroup = CodeWhispererFeatureConfigService.getInstance().getIsDataCollectionEnabled()
val startUrl = getStartUrl(context.project)

if (prompt.contains("@workspace")) {
if (CodeWhispererSettings.getInstance().isProjectContextEnabled()) {
shouldUseWorkspaceContext = true
Expand All @@ -151,7 +153,7 @@
triggerId = triggerId,
message = prompt,
activeFileContext = contextExtractor.extractContextForTrigger(ExtractionTriggerType.ChatMessage),
userIntent = intentRecognizer.getUserIntentFromPromptChatMessage(message.chatMessage),
userIntent = intentRecognizer.getUserIntentFromPromptChatMessage(message.chatMessage, startUrl),
TriggerType.Click,
projectContextQueryResult = queryResult,
shouldAddIndexInProgressMessage = shouldAddIndexInProgressMessage,
Expand Down Expand Up @@ -332,7 +334,9 @@
}

// Create prompt
val prompt = "${message.command} the following part of my code for me: $codeSelection"
val prompt = if (EditorContextCommand.GenerateUnitTests == message.command)
"${message.command.verb} the following part of my code for me: $codeSelection" else
"${message.command} the following part of my code for me: $codeSelection";

Check warning on line 339 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/controller/ChatController.kt

View workflow job for this annotation

GitHub Actions / qodana

Redundant semicolon

Redundant semicolon
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Redundant Semicolon.

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM, Clear the unused imports.


processPromptActions(prompt, message, triggerId, fileContext)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import kotlinx.coroutines.flow.onStart
import software.amazon.awssdk.awscore.exception.AwsServiceException
import software.amazon.awssdk.services.codewhispererstreaming.model.CodeWhispererStreamingException
import software.amazon.awssdk.services.codewhispererstreaming.model.UserIntent

Check warning on line 13 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/controller/chat/messenger/ChatPromptHandler.kt

View workflow job for this annotation

GitHub Actions / qodana

Unused import directive

Unused import directive
import software.amazon.awssdk.services.codewhispererstreaming.model.ValidationException

Check warning on line 14 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/controller/chat/messenger/ChatPromptHandler.kt

View workflow job for this annotation

GitHub Actions / qodana

Unused import directive

Unused import directive
import software.aws.toolkits.core.utils.convertMarkdownToHTML
import software.aws.toolkits.jetbrains.services.cwc.clients.chat.exceptions.ChatApiException
import software.aws.toolkits.jetbrains.services.cwc.clients.chat.model.ChatRequestData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class TelemetryHelper(private val context: AmazonQAppInitContext, private val se
UserIntent.CITE_SOURCES -> CwsprChatUserIntent.CiteSources
UserIntent.EXPLAIN_LINE_BY_LINE -> CwsprChatUserIntent.ExplainLineByLine
UserIntent.EXPLAIN_CODE_SELECTION -> CwsprChatUserIntent.ExplainCodeSelection
UserIntent.GENERATE_UNIT_TESTS -> CwsprChatUserIntent.GenerateUnitTests
UserIntent.UNKNOWN_TO_SDK_VERSION -> CwsprChatUserIntent.Unknown
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

package software.aws.toolkits.jetbrains.services.cwc.controller.chat.userIntent

import com.intellij.openapi.actionSystem.CommonDataKeys

Check warning on line 6 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/controller/chat/userIntent/UserIntentRecognizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Unused import directive

Unused import directive
import software.amazon.awssdk.services.codewhispererstreaming.model.UserIntent
import software.aws.toolkits.jetbrains.core.credentials.AwsBearerTokenConnection

Check warning on line 8 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/controller/chat/userIntent/UserIntentRecognizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Unused import directive

Unused import directive
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager

Check warning on line 9 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/controller/chat/userIntent/UserIntentRecognizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Unused import directive

Unused import directive
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection

Check warning on line 10 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/controller/chat/userIntent/UserIntentRecognizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Unused import directive

Unused import directive
import software.aws.toolkits.jetbrains.services.amazonq.onboarding.OnboardingPageInteraction
import software.aws.toolkits.jetbrains.services.amazonq.onboarding.OnboardingPageInteractionType
import software.aws.toolkits.jetbrains.services.cwc.clients.chat.model.FollowUpType
Expand All @@ -16,14 +20,16 @@
EditorContextCommand.Fix -> UserIntent.APPLY_COMMON_BEST_PRACTICES
EditorContextCommand.Optimize -> UserIntent.IMPROVE_CODE
EditorContextCommand.ExplainCodeScanIssue -> UserIntent.EXPLAIN_CODE_SELECTION
EditorContextCommand.GenerateUnitTests -> UserIntent.GENERATE_UNIT_TESTS
EditorContextCommand.SendToPrompt -> null
}

fun getUserIntentFromPromptChatMessage(prompt: String) = when {
fun getUserIntentFromPromptChatMessage(prompt: String, startUrl: String?) = when {
prompt.startsWith("Explain") -> UserIntent.EXPLAIN_CODE_SELECTION
prompt.startsWith("Refactor") -> UserIntent.SUGGEST_ALTERNATE_IMPLEMENTATION
prompt.startsWith("Fix") -> UserIntent.APPLY_COMMON_BEST_PRACTICES
prompt.startsWith("Optimize") -> UserIntent.IMPROVE_CODE
prompt.startsWith("Generate unit tests") && isInternalAmazonUser(startUrl) -> UserIntent.GENERATE_UNIT_TESTS
else -> null
}

Expand All @@ -43,4 +49,8 @@
fun getUserIntentFromOnboardingPageInteraction(interaction: OnboardingPageInteraction) = when (interaction.type) {
OnboardingPageInteractionType.CwcButtonClick -> null
}

private fun isInternalAmazonUser(startUrl: String?): Boolean {
return startUrl == "https://amzn.awsapps.com/start"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"showExample",
"citeSources",
"explainLineByLine",
"explainCodeSelection"
"explainCodeSelection",
"generateUnitTests"
],
"description": "Explict user intent associated with a chat message"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ action.aws.toolkit.jetbrains.core.services.cwc.commands.OptimizeCodeAction.descr
action.aws.toolkit.jetbrains.core.services.cwc.commands.OptimizeCodeAction.text = Optimize Code
action.aws.toolkit.jetbrains.core.services.cwc.commands.RefactorCodeAction.description = Refactors the selected code
action.aws.toolkit.jetbrains.core.services.cwc.commands.RefactorCodeAction.text = Refactor Code
action.aws.toolkit.jetbrains.core.services.cwc.commands.GenerateUnitTestsAction.description = Generates unit tests for the selected code
action.aws.toolkit.jetbrains.core.services.cwc.commands.GenerateUnitTestsAction.text = Generate Tests (Beta)
action.aws.toolkit.jetbrains.core.services.cwc.commands.SendToPromptAction.description = Sends selected code to chat
action.aws.toolkit.jetbrains.core.services.cwc.commands.SendToPromptAction.text = Send to Prompt
action.aws.toolkit.open.arn.browser.text=Open ARN in AWS Console
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,8 @@
"SHOW_EXAMPLES",
"CITE_SOURCES",
"EXPLAIN_LINE_BY_LINE",
"EXPLAIN_CODE_SELECTION"
"EXPLAIN_CODE_SELECTION",
"GENERATE_UNIT_TESTS"
]
},
"UserModificationEvent":{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,8 @@
"SHOW_EXAMPLES",
"CITE_SOURCES",
"EXPLAIN_LINE_BY_LINE",
"EXPLAIN_CODE_SELECTION"
"EXPLAIN_CODE_SELECTION",
"GENERATE_UNIT_TESTS"
]
},
"ValidationException":{
Expand Down
Loading