Skip to content

Commit 4c57e65

Browse files
committed
Fix right click
1 parent 048f464 commit 4c57e65

File tree

2 files changed

+15
-26
lines changed
  • plugins/amazonq
    • chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/commands
    • mynah-ui/src/mynah-ui/ui/quickActions

2 files changed

+15
-26
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/commands/ActionRegistrar.kt

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,21 @@ class ActionRegistrar {
2828
val flow = _messages.asSharedFlow()
2929

3030
fun reportMessageClick(command: EditorContextCommand, project: Project) {
31-
if (command == EditorContextCommand.GenerateUnitTests) {
32-
AsyncChatUiListener.notifyPartialMessageUpdate(project, Gson().toJson(TestCommandMessage()))
33-
} else {
34-
// new agentic chat route
35-
ApplicationManager.getApplication().executeOnPooledThread {
36-
runBlocking {
37-
val contextExtractor = ActiveFileContextExtractor.create(fqnWebviewAdapter = null, project = project)
38-
val fileContext = contextExtractor.extractContextForTrigger(ExtractionTriggerType.ContextMenu)
39-
val codeSelection = "\n```\n${fileContext.focusAreaContext?.codeSelection?.trimIndent()?.trim()}\n```\n"
40-
var uiMessage: FlareUiMessage? = null
41-
if (command.verb != SEND_TO_PROMPT) {
42-
val params = GenericCommandParams(selection = codeSelection, triggerType = TriggerType.CONTEXT_MENU, genericCommand = command.name)
43-
uiMessage = FlareUiMessage(command = GENERIC_COMMAND, params = params)
44-
} else {
45-
val params = SendToPromptParams(selection = codeSelection, triggerType = TriggerType.CONTEXT_MENU)
46-
uiMessage = FlareUiMessage(command = SEND_TO_PROMPT, params = params)
47-
}
48-
AsyncChatUiListener.notifyPartialMessageUpdate(project, uiMessage)
31+
// new agentic chat route
32+
ApplicationManager.getApplication().executeOnPooledThread {
33+
runBlocking {
34+
val contextExtractor = ActiveFileContextExtractor.create(fqnWebviewAdapter = null, project = project)
35+
val fileContext = contextExtractor.extractContextForTrigger(ExtractionTriggerType.ContextMenu)
36+
val codeSelection = "\n```\n${fileContext.focusAreaContext?.codeSelection?.trimIndent()?.trim()}\n```\n"
37+
var uiMessage: FlareUiMessage? = null
38+
if (command.verb != SEND_TO_PROMPT) {
39+
val params = GenericCommandParams(selection = codeSelection, triggerType = TriggerType.CONTEXT_MENU, genericCommand = command.name)
40+
uiMessage = FlareUiMessage(command = GENERIC_COMMAND, params = params)
41+
} else {
42+
val params = SendToPromptParams(selection = codeSelection, triggerType = TriggerType.CONTEXT_MENU)
43+
uiMessage = FlareUiMessage(command = SEND_TO_PROMPT, params = params)
4944
}
45+
AsyncChatUiListener.notifyPartialMessageUpdate(project, uiMessage)
5046
}
5147
}
5248
}

plugins/amazonq/mynah-ui/src/mynah-ui/ui/quickActions/handler.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,7 @@ private handleDocCommand(chatPrompt: ChatPrompt, tabID: string, taskName: string
344344
this.connector.startTestGen(testTabId, realPromptText)
345345
return
346346
}
347-
/**
348-
* right click -> generate test has no tab id
349-
* we have to manually create one if a testgen tab
350-
* wasn't previously created
351-
*/
352-
// if (!tabID) {
353-
// tabID = this.mynahUI?.updateStore('', {})
354-
// }
347+
355348
const affectedTabId: string | undefined = this.addTab(tabID)
356349

357350
// if there is no test tab, open a new one

0 commit comments

Comments
 (0)