Skip to content

Commit dba54c2

Browse files
committed
fixes
1 parent 377385a commit dba54c2

File tree

10 files changed

+39
-39
lines changed

10 files changed

+39
-39
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
<actions>
3131
<action id="aws.toolkit.open.q.window" class="software.aws.toolkits.jetbrains.services.amazonq.QRefreshPanelAction"/>
3232
<action id="aws.toolkit.jetbrains.core.services.cwc.inline.openChat" class="software.aws.toolkits.jetbrains.services.cwc.inline.OpenChatInputAction">
33-
<keyboard-shortcut first-keystroke="meta I" keymap="$default"/>
34-
<keyboard-shortcut first-keystroke="control I" keymap="$default"/>
33+
<keyboard-shortcut keymap="Mac OS X" first-keystroke="meta I"/>
34+
<keyboard-shortcut keymap="Mac OS X 10.5+" first-keystroke="meta I"/>
35+
<keyboard-shortcut keymap="$default" first-keystroke="control I"/>
3536
</action>
3637
<group id="aws.q.toolwindow.titleBar" popup="false" compact="true">
3738
<reference id="aws.toolkit.open.q.window"/>

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/inline/InlineChatController.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,13 @@ class InlineChatController(
243243

244244
private fun highlightCodeWithBackgroundColor(editor: Editor, startOffset: Int, endOffset: Int, isGreen: Boolean) {
245245
val greenBackgroundAttributes = TextAttributes().apply {
246-
backgroundColor = JBColor(0xAADEAA, 0x447152)
247-
effectColor = JBColor(0xAADEAA, 0x447152)
246+
backgroundColor = JBColor(0xAADEAA, 0x294436)
247+
effectColor = JBColor(0xAADEAA, 0x294436)
248248
}
249249

250250
val redBackgroundAttributes = TextAttributes().apply {
251-
backgroundColor = JBColor(0xFFC8BD, 0x8F5247)
252-
effectColor = JBColor(0xFFC8BD, 0x8F5247)
251+
backgroundColor = JBColor(0xFFC8BD, 0x45302B)
252+
effectColor = JBColor(0xFFC8BD, 0x45302B)
253253
}
254254
val attributes = if (isGreen) greenBackgroundAttributes else redBackgroundAttributes
255255
rangeHighlighter = editor.markupModel.addRangeHighlighter(
@@ -395,6 +395,7 @@ class InlineChatController(
395395

396396
private fun finalComputation(selectedCode: String, finalMessage: String?) {
397397
if (finalMessage == null) {
398+
canPopupAbort.set(true)
398399
throw Exception("No suggestions from Q; please try a different instruction.")
399400
}
400401
var numSuggestionAddChars = 0
@@ -437,6 +438,7 @@ class InlineChatController(
437438
metrics?.numSuggestionDelChars = numSuggestionDelChars
438439
metrics?.numSuggestionDelLines = numSuggestionDelLines
439440
if (isAllEqual) {
441+
canPopupAbort.set(true)
440442
throw Exception("No suggestions from Q; please try a different instruction.")
441443
}
442444
}
@@ -650,6 +652,8 @@ class InlineChatController(
650652
processNewCode(editor, selectedLineStart, unescape(event.message), prevMessage)
651653
}
652654
} catch (e: Exception) {
655+
canPopupAbort.set(true)
656+
undoChanges()
653657
logger.warn { "error streaming chat message to editor: ${e.stackTraceToString()}" }
654658
errorMessage = "Error processing request; please try again."
655659
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/inline/InlineChatPopupFactory.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ class InlineChatPopupFactory(
5454
}
5555

5656
val submitListener: () -> Unit = {
57-
submitButton.isEnabled = false
58-
cancelButton.isEnabled = false
59-
textField.isEnabled = false
6057
val prompt = textField.text
6158
if (prompt.isNotBlank()) {
59+
submitButton.isEnabled = false
60+
cancelButton.isEnabled = false
61+
textField.isEnabled = false
6262
setLabel(message("amazonqInlineChat.popup.generating"))
6363
revalidate()
6464

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/inline/InlineChatPopupPanel.kt

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ import java.awt.BorderLayout
2020
import java.awt.Dimension
2121
import java.awt.Font
2222
import javax.swing.BorderFactory
23-
import javax.swing.Icon
2423
import javax.swing.JButton
2524
import javax.swing.JLabel
2625
import javax.swing.JPanel
2726
import javax.swing.JTextField
2827
import javax.swing.SwingConstants
28+
import javax.swing.event.DocumentEvent
29+
import javax.swing.event.DocumentListener
2930

3031
class InlineChatPopupPanel(private val parentDisposable: Disposable) : JPanel() {
3132
private var submitClickListener: (() -> Unit)? = null
@@ -37,11 +38,23 @@ class InlineChatPopupPanel(private val parentDisposable: Disposable) : JPanel()
3738
private val popupInputHeight = 40
3839
private val popupInputWidth = 500
3940

40-
val textField = createTextField()
41+
val textField = createTextField().apply {
42+
document.addDocumentListener(object : DocumentListener {
43+
fun updateButtonState() {
44+
submitButton.isEnabled = text.isNotEmpty()
45+
}
46+
47+
override fun insertUpdate(e: DocumentEvent) = updateButtonState()
48+
override fun removeUpdate(e: DocumentEvent) = updateButtonState()
49+
override fun changedUpdate(e: DocumentEvent) = updateButtonState()
50+
})
51+
}
4152

42-
val submitButton = createButtonWithIcon(AwsIcons.Resources.InlineChat.CONFIRM, message("amazonqInlineChat.popup.confirm"))
53+
val submitButton = createButton(message("amazonqInlineChat.popup.confirm")).apply {
54+
isEnabled = false
55+
}
4356

44-
val cancelButton = createButtonWithIcon(AwsIcons.Resources.InlineChat.REJECT, message("amazonqInlineChat.popup.cancel")).apply {
57+
val cancelButton = createButton(message("amazonqInlineChat.popup.cancel")).apply {
4558
addActionListener {
4659
if (!Disposer.isDisposed(parentDisposable)) {
4760
Disposer.dispose(parentDisposable)
@@ -55,8 +68,8 @@ class InlineChatPopupPanel(private val parentDisposable: Disposable) : JPanel()
5568
add(cancelButton, BorderLayout.EAST)
5669
}
5770

58-
private val acceptButton = createButtonWithIcon(AwsIcons.Resources.InlineChat.CONFIRM, message("amazonqInlineChat.popup.accept"))
59-
private val rejectButton = createButtonWithIcon(AwsIcons.Resources.InlineChat.REJECT, message("amazonqInlineChat.popup.reject"))
71+
private val acceptButton = createButton(message("amazonqInlineChat.popup.accept"))
72+
private val rejectButton = createButton(message("amazonqInlineChat.popup.reject"))
6073
private val textLabel = JLabel(message("amazonqInlineChat.popup.editCode"), AwsIcons.Logos.AWS_Q_GREY, SwingConstants.RIGHT).apply {
6174
font = font.deriveFont(popupButtonFontSize)
6275
}
@@ -86,10 +99,8 @@ class InlineChatPopupPanel(private val parentDisposable: Disposable) : JPanel()
8699
font = Font(editorColorsScheme.editorFontName, Font.PLAIN, editorColorsScheme.editorFontSize)
87100
}
88101

89-
private fun createButtonWithIcon(icon: Icon, text: String): JButton = JButton(text).apply {
90-
horizontalTextPosition = SwingConstants.LEFT
102+
private fun createButton(text: String): JButton = JButton(text).apply {
91103
preferredSize = Dimension(popupButtonWidth, popupButtonHeight)
92-
setIcon(icon)
93104
isOpaque = false
94105
isContentAreaFilled = false
95106
isBorderPainted = false

plugins/amazonq/chat/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonq/TelemetryHelperTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class TelemetryHelperTest {
180180
sessionStorage = mock {
181181
on { this.getSession(eq(tabId)) } doReturn ChatSessionInfo(session = mockSession, scope = mock(), history = mutableListOf())
182182
}
183-
sut = TelemetryHelper(appInitContext, sessionStorage)
183+
sut = TelemetryHelper(appInitContext.project, sessionStorage)
184184

185185
// set up client
186186
mockClientManager.create<SsoOidcClient>()
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
action.q.hello.description=Hello description
2-
amazonqInlineChat.gutter.tooltip = Amazon Q
32
amazonqInlineChat.hint.edit = Edit
4-
amazonqInlineChat.hint.windows.shortCut = (Ctrl + I)
5-
amazonqInlineChat.popup.accept=Accept
6-
amazonqInlineChat.popup.cancel=Cancel
7-
amazonqInlineChat.popup.confirm=Confirm
3+
amazonqInlineChat.popup.accept=Accept \u23CE
4+
amazonqInlineChat.popup.cancel=Cancel \u238B
5+
amazonqInlineChat.popup.confirm=Confirm \u23CE
86
amazonqInlineChat.popup.editCode = Edit Code
97
amazonqInlineChat.popup.generating = Generating...
10-
amazonqInlineChat.popup.reject=Reject
8+
amazonqInlineChat.popup.reject=Reject \u238B
119
amazonqInlineChat.popup.title=Enter Instructions for Q
1210
amazonq.refresh.panel=Refresh Chat Session
1311
q.hello=Hello

plugins/core/jetbrains-community/resources/icons/resources/inlinechat/amazonq_inline_chat_cancel_icon.svg

Lines changed: 0 additions & 3 deletions
This file was deleted.

plugins/core/jetbrains-community/resources/icons/resources/inlinechat/amazonq_inline_chat_confirm_icon.svg

Lines changed: 0 additions & 3 deletions
This file was deleted.

plugins/core/jetbrains-community/resources/icons/resources/inlinechat/amazonq_inline_chat_reject.svg

Lines changed: 0 additions & 4 deletions
This file was deleted.

plugins/core/jetbrains-community/src/icons/AwsIcons.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ object AwsIcons {
127127
}
128128

129129
object InlineChat {
130-
@JvmField val CONFIRM = load("/icons/resources/inlinechat/amazonq_inline_chat_confirm_icon.svg")
131-
132-
@JvmField val REJECT = load("/icons/resources/inlinechat/amazonq_inline_chat_reject.svg")
133-
134130
@JvmField val AWS_Q_INLINECHAT_SHORTCUT = load("/icons/resources/inlinechat/amazonq_inline_chat_shortcut.svg")
135131
}
136132
}

0 commit comments

Comments
 (0)