Skip to content

Commit cf0ec0c

Browse files
committed
refactor(devti): optimize chat panel update logic and enhance task step UI- Remove unnecessary invokeLater calls in AutoDevInlineChatPanel #344
- Replace JButton with ActionButton in TaskStepPanel for execute button - Add tooltip for execute button - Update messages properties for execute tooltip
1 parent 10fc9d1 commit cf0ec0c

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

core/src/main/kotlin/cc/unitmesh/devti/inline/AutoDevInlineChatPanel.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,12 @@ class AutoDevInlineChatPanel(val editor: Editor) : JPanel(GridBagLayout()), Edit
5656
editor = editor,
5757
onStart = { panelView.onStart() },
5858
onUpdate = { text ->
59-
invokeLater {
60-
panelView.onUpdate(text)
61-
panelView.resize()
62-
}
59+
panelView.onUpdate(text)
60+
panelView.resize()
6361
},
6462
onFinish = { text ->
65-
invokeLater {
66-
panelView.resize()
67-
panelView.onFinish(text)
68-
}
63+
panelView.resize()
64+
panelView.onFinish(text)
6965
},
7066
registerCancelHandler = { handler ->
7167
panelView.handleCancel = handler

core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/plan/TaskStepPanel.kt

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import cc.unitmesh.devti.gui.chat.message.ChatActionType
77
import cc.unitmesh.devti.observer.plan.AgentPlanStep
88
import cc.unitmesh.devti.observer.plan.TaskStatus
99
import com.intellij.ide.ui.UISettings
10+
import com.intellij.openapi.actionSystem.AnAction
11+
import com.intellij.openapi.actionSystem.AnActionEvent
12+
import com.intellij.openapi.actionSystem.Presentation
13+
import com.intellij.openapi.actionSystem.impl.ActionButton
1014
import com.intellij.openapi.editor.colors.EditorColorsManager
1115
import com.intellij.openapi.fileEditor.FileEditorManager
1216
import com.intellij.openapi.project.Project
@@ -86,7 +90,6 @@ class TaskStepPanel(
8690
font = Font(editorFontName, Font.PLAIN, editorFontSize)
8791
foreground = UIUtil.getLabelForeground()
8892

89-
// Handle links
9093
addMouseListener(object : MouseAdapter() {
9194
override fun mouseClicked(e: MouseEvent) {
9295
val offset = viewToModel2D(e.point)
@@ -132,19 +135,24 @@ class TaskStepPanel(
132135
}
133136
}
134137

135-
private fun createExecuteButton(): JButton {
136-
return JButton(AutoDevIcons.Run).apply {
137-
border = BorderFactory.createEmptyBorder()
138-
preferredSize = Dimension(20, 20)
139-
toolTipText = "Execute"
140-
background = JBUI.CurrentTheme.ToolWindow.background()
141-
142-
addActionListener {
138+
private fun createExecuteButton(): JComponent {
139+
val executeAction = object : AnAction(AutoDevIcons.Run) {
140+
override fun actionPerformed(e: AnActionEvent) {
143141
AutoDevToolWindowFactory.Companion.sendToSketchToolWindow(project, ChatActionType.SKETCH) { ui, _ ->
144142
ui.sendInput(AutoDevBundle.message("sketch.plan.finish.task") + task.step)
145143
}
146144
}
147145
}
146+
147+
val presentation = Presentation().apply {
148+
icon = AutoDevIcons.Run
149+
text = ""
150+
description = AutoDevBundle.message("sketch.plan.execute.tooltip", "Execute")
151+
}
152+
153+
return ActionButton(executeAction, presentation, "TaskStepPanelExecuteAction", Dimension(22, 22)).apply {
154+
background = JBUI.CurrentTheme.ToolWindow.background()
155+
}
148156
}
149157

150158
private fun updateTaskLabel() {
@@ -227,3 +235,4 @@ class TaskStepPanel(
227235
taskLabel.componentPopupMenu = taskPopupMenu
228236
}
229237
}
238+

core/src/main/resources/messages/AutoDevBundle_en.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,5 @@ sketch.terminal.show.hide=Show or hide the terminal
186186

187187
chat.panel.clear.all=Clear all
188188
chat.panel.clear.all.tooltip=Clear all files
189-
chat.panel.select.files=Please double-click to select file to insert into input box
189+
chat.panel.select.files=Please double-click to select file to insert into input box
190+
sketch.plan.execute.tooltip=Execute task

core/src/main/resources/messages/AutoDevBundle_zh.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,4 @@ chat.panel.stop=Stop
182182
chat.panel.clear.all=Clear All
183183
chat.panel.clear.all.tooltip=清除所有文件
184184
chat.panel.select.files=请双击选择文件,以放到输入框内
185+
sketch.plan.execute.tooltip=Execute task

0 commit comments

Comments
 (0)