Skip to content

Commit b01283e

Browse files
authored
feat(amazonq): Introduce auto trigger changes officially (#5080)
1. Auto-trigger now triggers much more frequently and suggestions will consistently show whenever user stops typing. The key shortcuts for Q inline suggestions are now configurable from the keymap settings. Default key shortcut for force accept is option + tab or option + enter and default for navigation keys has now changed from <- (navigating to prev) and -> (navigating to next) arrow keys to option + [ and option + ] , respectively. 2. Amazon Q suggestions can now co-exist with JetBrains code completions (IntelliSense). When both suggestions appear on the screen, tab accepts JetBrains suggestions first. Users will also have other key shortcuts to force accept the other Q suggestion (option + tab or option + enter) 3. The Amazon Q suggestion popup is now hidden by default and only appears above the current editing line when the user hovers over the suggestion preview text. IntelliSense popup (if it's showing) will also appear to be more transparent when user hovers over the suggestion preview.
1 parent 33080ef commit b01283e

File tree

69 files changed

+1208
-4594
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1208
-4594
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "Inline Auto trigger will now happen more consistently and will not conflict with JetBrains code completion."
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "The key shortcuts for Q inline suggestions are now configurable from keymap settings. Default key shortcuts for navigating through suggestions are changed from left/right arrow keys to option(alt) + [ and option(alt) + ], respectively."
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "The Q suggestion inline popup will now hide by default and will show when the user hovers over the suggestion text, the IDE code suggestion popup will also appear to be more transparent to unblock seeing the multi-line suggestions."
4+
}

plugins/amazonq/codewhisperer/jetbrains-community/resources/META-INF/plugin-codewhisperer.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@
55
<applicationListeners>
66
<listener class="software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererUIChangeListener"
77
topic="software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererPopupStateChangeListener"/>
8-
<listener class="software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererUIChangeListenerNew"
9-
topic="software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererPopupStateChangeListener"/>
108
<listener class="software.aws.toolkits.jetbrains.services.codewhisperer.toolwindow.CodeWhispererCodeReferenceActionListener"
119
topic="software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererUserActionListener"/>
12-
<listener class="software.aws.toolkits.jetbrains.services.codewhisperer.toolwindow.CodeWhispererCodeReferenceActionListenerNew"
13-
topic="software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererUserActionListener"/>
1410
</applicationListeners>
1511

1612
<projectListeners>

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/CodeWhispererAcceptAction.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ import com.intellij.openapi.actionSystem.CommonDataKeys
1010
import com.intellij.openapi.application.ApplicationManager
1111
import com.intellij.openapi.project.DumbAware
1212
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererPopupManager
13-
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatusNew
14-
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererServiceNew
13+
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatus
14+
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererService
1515
import software.aws.toolkits.resources.message
1616

1717
open class CodeWhispererAcceptAction(title: String = message("codewhisperer.inline.accept")) : AnAction(title), DumbAware {
1818
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT
1919

2020
override fun update(e: AnActionEvent) {
2121
e.presentation.isEnabled = e.project != null && e.getData(CommonDataKeys.EDITOR) != null &&
22-
CodeWhispererInvocationStatusNew.getInstance().isDisplaySessionActive()
22+
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()
2323
}
2424

2525
override fun actionPerformed(e: AnActionEvent) {
26-
val sessionContext = e.project?.getUserData(CodeWhispererServiceNew.KEY_SESSION_CONTEXT) ?: return
27-
if (!CodeWhispererInvocationStatusNew.getInstance().isDisplaySessionActive()) return
26+
val sessionContext = e.project?.getUserData(CodeWhispererService.KEY_SESSION_CONTEXT) ?: return
27+
if (!CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()) return
2828
ApplicationManager.getApplication().messageBus.syncPublisher(
2929
CodeWhispererPopupManager.CODEWHISPERER_USER_ACTION_PERFORMED
3030
).beforeAccept(sessionContext)

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/CodeWhispererActionPromoter.kt

Lines changed: 20 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,77 +7,45 @@ import com.intellij.codeInsight.lookup.impl.actions.ChooseItemAction
77
import com.intellij.openapi.actionSystem.ActionPromoter
88
import com.intellij.openapi.actionSystem.AnAction
99
import com.intellij.openapi.actionSystem.DataContext
10-
import com.intellij.openapi.editor.actionSystem.EditorAction
11-
import software.aws.toolkits.jetbrains.services.amazonq.CodeWhispererFeatureConfigService
12-
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.handlers.CodeWhispererPopupLeftArrowHandler
13-
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.handlers.CodeWhispererPopupRightArrowHandler
14-
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.handlers.CodeWhispererPopupTabHandler
15-
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatusNew
10+
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatus
1611

1712
class CodeWhispererActionPromoter : ActionPromoter {
1813
override fun promote(actions: MutableList<out AnAction>, context: DataContext): MutableList<AnAction> {
19-
if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
20-
val results = actions.toMutableList()
21-
if (!CodeWhispererInvocationStatusNew.getInstance().isDisplaySessionActive()) return results
22-
23-
results.sortWith { a, b ->
24-
if (isCodeWhispererForceAction(a)) {
25-
return@sortWith -1
26-
} else if (isCodeWhispererForceAction(b)) {
27-
return@sortWith 1
28-
}
29-
30-
if (a is ChooseItemAction) {
31-
return@sortWith -1
32-
} else if (b is ChooseItemAction) {
33-
return@sortWith 1
34-
}
14+
val results = actions.toMutableList()
15+
if (!CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()) return results
3516

36-
if (isCodeWhispererAcceptAction(a)) {
37-
return@sortWith -1
38-
} else if (isCodeWhispererAcceptAction(b)) {
39-
return@sortWith 1
40-
}
17+
results.sortWith { a, b ->
18+
if (isCodeWhispererForceAction(a)) {
19+
return@sortWith -1
20+
} else if (isCodeWhispererForceAction(b)) {
21+
return@sortWith 1
22+
}
4123

42-
0
24+
if (a is ChooseItemAction) {
25+
return@sortWith -1
26+
} else if (b is ChooseItemAction) {
27+
return@sortWith 1
4328
}
44-
return results
45-
}
46-
val results = actions.toMutableList()
47-
results.sortWith { a, b ->
48-
if (isCodeWhispererPopupAction(a)) {
29+
30+
if (isCodeWhispererAcceptAction(a)) {
4931
return@sortWith -1
50-
} else if (isCodeWhispererPopupAction(b)) {
32+
} else if (isCodeWhispererAcceptAction(b)) {
5133
return@sortWith 1
52-
} else {
53-
0
5434
}
35+
36+
0
5537
}
5638
return results
5739
}
5840

5941
private fun isCodeWhispererAcceptAction(action: AnAction): Boolean =
60-
if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
61-
action is CodeWhispererAcceptAction
62-
} else {
63-
action is EditorAction && action.handler is CodeWhispererPopupTabHandler
64-
}
42+
action is CodeWhispererAcceptAction
6543

6644
private fun isCodeWhispererForceAcceptAction(action: AnAction): Boolean =
6745
action is CodeWhispererForceAcceptAction
6846

6947
private fun isCodeWhispererNavigateAction(action: AnAction): Boolean =
70-
if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
71-
action is CodeWhispererNavigateNextAction || action is CodeWhispererNavigatePrevAction
72-
} else {
73-
action is EditorAction && (
74-
action.handler is CodeWhispererPopupRightArrowHandler ||
75-
action.handler is CodeWhispererPopupLeftArrowHandler
76-
)
77-
}
78-
79-
private fun isCodeWhispererPopupAction(action: AnAction): Boolean =
80-
isCodeWhispererAcceptAction(action) || isCodeWhispererNavigateAction(action)
48+
action is CodeWhispererNavigateNextAction || action is CodeWhispererNavigatePrevAction
8149

8250
private fun isCodeWhispererForceAction(action: AnAction): Boolean =
8351
isCodeWhispererForceAcceptAction(action) || isCodeWhispererNavigateAction(action)

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/CodeWhispererNavigateNextAction.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import com.intellij.openapi.actionSystem.CommonDataKeys
1010
import com.intellij.openapi.application.ApplicationManager
1111
import com.intellij.openapi.project.DumbAware
1212
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererPopupManager
13-
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatusNew
14-
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererServiceNew
13+
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatus
14+
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererService
1515
import software.aws.toolkits.resources.message
1616

1717
class CodeWhispererNavigateNextAction : AnAction(message("codewhisperer.inline.navigate.next")), DumbAware {
@@ -20,12 +20,12 @@ class CodeWhispererNavigateNextAction : AnAction(message("codewhisperer.inline.n
2020
override fun update(e: AnActionEvent) {
2121
e.presentation.isEnabled = e.project != null &&
2222
e.getData(CommonDataKeys.EDITOR) != null &&
23-
CodeWhispererInvocationStatusNew.getInstance().isDisplaySessionActive()
23+
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()
2424
}
2525

2626
override fun actionPerformed(e: AnActionEvent) {
27-
val sessionContext = e.project?.getUserData(CodeWhispererServiceNew.KEY_SESSION_CONTEXT) ?: return
28-
if (!CodeWhispererInvocationStatusNew.getInstance().isDisplaySessionActive()) return
27+
val sessionContext = e.project?.getUserData(CodeWhispererService.KEY_SESSION_CONTEXT) ?: return
28+
if (!CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()) return
2929
ApplicationManager.getApplication().messageBus.syncPublisher(
3030
CodeWhispererPopupManager.CODEWHISPERER_USER_ACTION_PERFORMED
3131
).navigateNext(sessionContext)

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/CodeWhispererNavigatePrevAction.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import com.intellij.openapi.actionSystem.CommonDataKeys
1010
import com.intellij.openapi.application.ApplicationManager
1111
import com.intellij.openapi.project.DumbAware
1212
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererPopupManager
13-
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatusNew
14-
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererServiceNew
13+
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatus
14+
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererService
1515
import software.aws.toolkits.resources.message
1616

1717
class CodeWhispererNavigatePrevAction : AnAction(message("codewhisperer.inline.navigate.previous")), DumbAware {
@@ -20,12 +20,12 @@ class CodeWhispererNavigatePrevAction : AnAction(message("codewhisperer.inline.n
2020
override fun update(e: AnActionEvent) {
2121
e.presentation.isEnabled = e.project != null &&
2222
e.getData(CommonDataKeys.EDITOR) != null &&
23-
CodeWhispererInvocationStatusNew.getInstance().isDisplaySessionActive()
23+
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()
2424
}
2525

2626
override fun actionPerformed(e: AnActionEvent) {
27-
val sessionContext = e.project?.getUserData(CodeWhispererServiceNew.KEY_SESSION_CONTEXT) ?: return
28-
if (!CodeWhispererInvocationStatusNew.getInstance().isDisplaySessionActive()) return
27+
val sessionContext = e.project?.getUserData(CodeWhispererService.KEY_SESSION_CONTEXT) ?: return
28+
if (!CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()) return
2929
ApplicationManager.getApplication().messageBus.syncPublisher(
3030
CodeWhispererPopupManager.CODEWHISPERER_USER_ACTION_PERFORMED
3131
).navigatePrevious(sessionContext)

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/CodeWhispererRecommendationAction.kt

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ import com.intellij.openapi.actionSystem.CommonDataKeys
1010
import com.intellij.openapi.project.DumbAware
1111
import com.intellij.openapi.util.Key
1212
import kotlinx.coroutines.Job
13-
import software.aws.toolkits.jetbrains.services.amazonq.CodeWhispererFeatureConfigService
1413
import software.aws.toolkits.jetbrains.services.codewhisperer.model.LatencyContext
1514
import software.aws.toolkits.jetbrains.services.codewhisperer.model.TriggerTypeInfo
1615
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererAutomatedTriggerType
1716
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererService
18-
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererServiceNew
1917
import software.aws.toolkits.resources.message
2018
import software.aws.toolkits.telemetry.CodewhispererTriggerType
2119
import java.util.concurrent.atomic.AtomicReference
@@ -32,23 +30,12 @@ class CodeWhispererRecommendationAction : AnAction(message("codewhisperer.trigge
3230
latencyContext.codewhispererPreprocessingStart = System.nanoTime()
3331
latencyContext.codewhispererEndToEndStart = System.nanoTime()
3432
val editor = e.getRequiredData(CommonDataKeys.EDITOR)
35-
if (!(
36-
if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
37-
CodeWhispererServiceNew.getInstance().canDoInvocation(editor, CodewhispererTriggerType.OnDemand)
38-
} else {
39-
CodeWhispererService.getInstance().canDoInvocation(editor, CodewhispererTriggerType.OnDemand)
40-
}
41-
)
42-
) {
33+
if (!CodeWhispererService.getInstance().canDoInvocation(editor, CodewhispererTriggerType.OnDemand)) {
4334
return
4435
}
4536

4637
val triggerType = TriggerTypeInfo(CodewhispererTriggerType.OnDemand, CodeWhispererAutomatedTriggerType.Unknown())
47-
val job = if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
48-
CodeWhispererServiceNew.getInstance().showRecommendationsInPopup(editor, triggerType, latencyContext)
49-
} else {
50-
CodeWhispererService.getInstance().showRecommendationsInPopup(editor, triggerType, latencyContext)
51-
}
38+
val job = CodeWhispererService.getInstance().showRecommendationsInPopup(editor, triggerType, latencyContext)
5239

5340
e.getData(CommonDataKeys.EDITOR)?.getUserData(ACTION_JOB_KEY)?.set(job)
5441
}

0 commit comments

Comments
 (0)