@@ -2,6 +2,7 @@ package cc.unitmesh.devti.gui.chat.ui
2
2
3
3
import cc.unitmesh.devti.AutoDevBundle
4
4
import cc.unitmesh.devti.AutoDevIcons
5
+ import cc.unitmesh.devti.AutoDevNotifications
5
6
import cc.unitmesh.devti.agent.custom.model.CustomAgentConfig
6
7
import cc.unitmesh.devti.agent.custom.model.CustomAgentState
7
8
import cc.unitmesh.devti.completion.AutoDevInputLookupManagerListener
@@ -21,7 +22,6 @@ import com.intellij.openapi.Disposable
21
22
import com.intellij.openapi.actionSystem.Presentation
22
23
import com.intellij.openapi.actionSystem.impl.ActionButton
23
24
import com.intellij.openapi.application.ApplicationManager
24
- import com.intellij.openapi.application.invokeLater
25
25
import com.intellij.openapi.application.runInEdt
26
26
import com.intellij.openapi.diagnostic.logger
27
27
import com.intellij.openapi.editor.event.DocumentEvent
@@ -67,15 +67,17 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
67
67
private val documentListener: DocumentListener
68
68
private val sendButtonPresentation: Presentation
69
69
private val stopButtonPresentation: Presentation
70
+ private val enhanceButtonPresentation: Presentation
70
71
private val sendButton: ActionButton
71
72
private val stopButton: ActionButton
72
- private val buttonPanel = JPanel (CardLayout ())
73
+ private val enhanceButton: ActionButton
74
+ private var buttonPanel: JPanel = JPanel (CardLayout ())
73
75
private val inputPanel = BorderLayoutPanel ()
74
76
val focusableComponent: JComponent get() = input
75
77
76
78
private val relatedFileListViewModel = RelatedFileListViewModel (project)
77
79
private val elementsList = JBList (relatedFileListViewModel.getListModel())
78
-
80
+
79
81
private val workspaceFilePanel: WorkspaceFilePanel
80
82
81
83
private val defaultRag: CustomAgentConfig = CustomAgentConfig (" <Select Custom Agent>" , " Normal" )
@@ -114,12 +116,15 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
114
116
115
117
setupElementsList()
116
118
val sendButtonPresentation = Presentation (AutoDevBundle .message(" chat.panel.send" ))
117
- sendButtonPresentation.icon = AutoDevIcons .Send
119
+ sendButtonPresentation.icon = AutoDevIcons .SEND
118
120
this .sendButtonPresentation = sendButtonPresentation
119
121
120
- val stopButtonPresentation = Presentation (" Stop" )
121
- stopButtonPresentation.icon = AutoDevIcons .STOP
122
- this .stopButtonPresentation = stopButtonPresentation
122
+ this .stopButtonPresentation = Presentation (" Stop" ).apply {
123
+ icon = AutoDevIcons .STOP
124
+ }
125
+ this .enhanceButtonPresentation = Presentation (" Enhance" ).apply {
126
+ icon = AutoDevIcons .MAGIC
127
+ }
123
128
124
129
sendButton = ActionButton (
125
130
DumbAwareAction .create {
@@ -135,6 +140,13 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
135
140
this .stopButtonPresentation, " " , Dimension (20 , 20 )
136
141
)
137
142
143
+ enhanceButton = ActionButton (
144
+ DumbAwareAction .create {
145
+ AutoDevNotifications .notify(project, " Enhancing input text..." )
146
+ },
147
+ this .enhanceButtonPresentation, " " , Dimension (20 , 20 )
148
+ )
149
+
138
150
documentListener = object : DocumentListener {
139
151
override fun documentChanged (event : DocumentEvent ) {
140
152
val i = input.preferredSize?.height
@@ -171,16 +183,14 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
171
183
layoutPanel.addToLeft(customAgent)
172
184
}
173
185
174
-
175
- buttonPanel.add(sendButton, " Send" )
176
- buttonPanel.add(stopButton, " Stop" )
186
+ buttonPanel = createButtonPanel()
177
187
178
188
layoutPanel.addToCenter(horizontalGlue)
179
189
layoutPanel.addToRight(buttonPanel)
180
190
181
191
inputPanel.add(input, BorderLayout .CENTER )
182
192
inputPanel.addToBottom(layoutPanel)
183
-
193
+
184
194
inputPanel.addToTop(workspaceFilePanel)
185
195
186
196
val scrollPane = JBScrollPane (elementsList)
@@ -217,6 +227,21 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
217
227
}
218
228
}
219
229
230
+ private fun createButtonPanel (): JPanel {
231
+ val panel = JPanel (CardLayout ())
232
+
233
+ // Create a panel for the "Send" state that contains both enhance and send buttons
234
+ val sendPanel = JPanel (FlowLayout (FlowLayout .RIGHT , JBUI .scale(8 ), 0 ))
235
+ sendPanel.isOpaque = false
236
+ sendPanel.add(enhanceButton)
237
+ sendPanel.add(sendButton)
238
+
239
+ panel.add(sendPanel, " Send" )
240
+ panel.add(stopButton, " Stop" )
241
+
242
+ return panel
243
+ }
244
+
220
245
private fun setupEditorListener () {
221
246
project.messageBus.connect(disposable!! ).subscribe(
222
247
FileEditorManagerListener .FILE_EDITOR_MANAGER ,
@@ -262,7 +287,7 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
262
287
263
288
val wrapper = relatedFileListViewModel.getListModel().getElementAt(index)
264
289
val cellBounds = list.getCellBounds(index, index)
265
-
290
+
266
291
val actionType = relatedFileListViewModel.determineFileAction(wrapper, e.point, cellBounds)
267
292
val actionPerformed = relatedFileListViewModel.handleFileAction(wrapper, actionType) { vfile, relativePath ->
268
293
if (relativePath != null ) {
0 commit comments