@@ -20,7 +20,6 @@ import com.intellij.openapi.project.Project
20
20
import com.intellij.openapi.wm.ToolWindowManager
21
21
import com.intellij.ui.components.JBCheckBox
22
22
import com.intellij.ui.components.JBPanel
23
- import com.intellij.ui.components.JBScrollPane
24
23
import com.intellij.ui.components.panels.Wrapper
25
24
import com.intellij.util.ui.JBEmptyBorder
26
25
import com.intellij.util.ui.JBUI
@@ -49,12 +48,12 @@ class PlanSketch(
49
48
private val project : Project ,
50
49
private var content : String ,
51
50
private var agentTaskItems : MutableList <AgentTaskEntry >,
52
- private val isInPopup : Boolean = false
51
+ private val isInToolwindow : Boolean = false
53
52
) : JBPanel<PlanSketch>(BorderLayout ()), ExtensionLangSketch {
54
53
private val panel = JBPanel <PlanSketch >(BorderLayout ())
55
54
private val contentPanel = JBPanel <PlanSketch >().apply {
56
55
layout = BoxLayout (this , BoxLayout .Y_AXIS )
57
- border = JBEmptyBorder (JBUI .insets(8 ))
56
+ border = JBEmptyBorder (JBUI .insets(4 ))
58
57
}
59
58
60
59
private val actionGroup = DefaultActionGroup (createToolbar(project))
@@ -86,7 +85,7 @@ class PlanSketch(
86
85
}
87
86
88
87
private val toolbarPanel = JPanel (BorderLayout ()).apply {
89
- if (! isInPopup ) {
88
+ if (! isInToolwindow ) {
90
89
add(titleLabel, BorderLayout .WEST )
91
90
add(toolbar.component, BorderLayout .EAST )
92
91
}
@@ -99,35 +98,21 @@ class PlanSketch(
99
98
init {
100
99
createPlanUI()
101
100
102
- val scrollPane = JBScrollPane (contentPanel)
103
- panel.add(scrollPane, BorderLayout .CENTER )
104
101
panel.add(toolbarWrapper, BorderLayout .NORTH )
105
102
106
- add(panel, BorderLayout .CENTER )
103
+ if (isInToolwindow) {
104
+ border = JBUI .Borders .empty(8 )
105
+ }
106
+
107
+ add(contentPanel, BorderLayout .CENTER )
107
108
}
108
109
109
110
private fun createPlanUI () {
110
111
agentTaskItems.forEachIndexed { index, planItem ->
111
- val titlePanel = JBPanel <JBPanel <* >>(FlowLayout (FlowLayout .LEFT )).apply {
112
- border = JBUI .Borders .empty()
113
- }
114
-
115
- val executeTaskButton = JButton (AllIcons .Actions .Execute ).apply {
116
- border = BorderFactory .createEmptyBorder()
117
- isOpaque = true
118
- preferredSize = Dimension (24 , 24 )
119
- toolTipText = " Execute Task"
120
-
121
- addActionListener {
122
- AutoDevToolWindowFactory .sendToSketchToolWindow(project, ChatActionType .SKETCH ) { ui, _ ->
123
- val allSteps = planItem.steps.joinToString(" \n " ) { it.step }
124
- ui.sendInput(AutoDevBundle .message(" sketch.plan.finish.task" ) + allSteps)
125
- }
126
- }
112
+ val titlePanel = JBPanel <JBPanel <* >>(FlowLayout (FlowLayout .LEFT , 2 , 0 )).apply {
113
+ border = JBUI .Borders .empty(2 )
127
114
}
128
115
129
- titlePanel.add(executeTaskButton)
130
-
131
116
// Check if all tasks in the section are completed
132
117
updateSectionCompletionStatus(planItem)
133
118
@@ -146,19 +131,35 @@ class PlanSketch(
146
131
}
147
132
148
133
val sectionLabel = JLabel (titleText)
149
- sectionLabel.border = JBUI .Borders .empty()
134
+ sectionLabel.border = JBUI .Borders .emptyLeft(2 )
135
+
136
+ if (planItem.status == TaskStatus .TODO && planItem.completed == false ) {
137
+ val executeTaskButton = JButton (AllIcons .Actions .Execute ).apply {
138
+ border = BorderFactory .createEmptyBorder()
139
+ isOpaque = true
140
+ preferredSize = Dimension (20 , 20 )
141
+ toolTipText = " Execute Task"
142
+
143
+ addActionListener {
144
+ AutoDevToolWindowFactory .sendToSketchToolWindow(project, ChatActionType .SKETCH ) { ui, _ ->
145
+ val allSteps = planItem.steps.joinToString(" \n " ) { it.step }
146
+ ui.sendInput(AutoDevBundle .message(" sketch.plan.finish.task" ) + allSteps)
147
+ }
148
+ }
149
+ }
150
+ titlePanel.add(executeTaskButton)
151
+ }
152
+
150
153
titlePanel.add(sectionLabel)
151
154
contentPanel.add(titlePanel)
152
155
153
156
planItem.steps.forEachIndexed { taskIndex, task ->
154
- val taskPanel = JBPanel <JBPanel <* >>(FlowLayout (FlowLayout .LEFT )).apply {
155
- border = JBUI .Borders .empty()
157
+ val taskPanel = JBPanel <JBPanel <* >>(FlowLayout (FlowLayout .LEFT , 2 , 0 )).apply {
158
+ border = JBUI .Borders .empty(1 , 16 , 1 , 0 )
156
159
}
157
160
158
- // First create task label with appropriate styling based on status
159
161
val taskLabel = createStyledTaskLabel(task)
160
162
161
- // Create a custom status indicator based on task status
162
163
val statusIcon = when (task.status) {
163
164
TaskStatus .COMPLETED -> JLabel (AllIcons .Actions .Checked )
164
165
TaskStatus .FAILED -> JLabel (AllIcons .General .Error )
@@ -193,7 +194,7 @@ class PlanSketch(
193
194
val executeButton = JButton (AllIcons .Actions .Execute ).apply {
194
195
border = BorderFactory .createEmptyBorder()
195
196
isOpaque = true
196
- preferredSize = Dimension (24 , 24 )
197
+ preferredSize = Dimension (20 , 20 )
197
198
toolTipText = " Execute"
198
199
199
200
addActionListener {
@@ -318,7 +319,7 @@ class PlanSketch(
318
319
}
319
320
320
321
override fun onComplete (context : String ) {
321
- if (! isInPopup ) {
322
+ if (! isInToolwindow ) {
322
323
val agentPlans = MarkdownPlanParser .parse(content).toMutableList()
323
324
updatePlan(agentPlans)
324
325
project.getService(AgentStateService ::class .java).updatePlan(agentPlans)
0 commit comments