@@ -4,9 +4,9 @@ import cc.unitmesh.devti.AutoDevBundle
4
4
import cc.unitmesh.devti.gui.AutoDevToolWindowFactory
5
5
import cc.unitmesh.devti.gui.chat.message.ChatActionType
6
6
import cc.unitmesh.devti.observer.agent.AgentStateService
7
- import cc.unitmesh.devti.observer.agent.PlanList
8
- import cc.unitmesh.devti.observer.agent .PlanTask
9
- import cc.unitmesh.devti.observer.agent .TaskStatus
7
+ import cc.unitmesh.devti.observer.plan.AgentPlan
8
+ import cc.unitmesh.devti.observer.plan .PlanTask
9
+ import cc.unitmesh.devti.observer.plan .TaskStatus
10
10
import cc.unitmesh.devti.observer.plan.PlanBoard
11
11
import cc.unitmesh.devti.sketch.ui.code.CodeHighlightSketch
12
12
import cc.unitmesh.devti.sketch.ui.plan.MarkdownPlanParser
@@ -47,7 +47,7 @@ class ThoughtPlanSketchProvider : LanguageSketchProvider {
47
47
class PlanSketch (
48
48
private val project : Project ,
49
49
private var content : String ,
50
- private val planLists : MutableList <PlanList >,
50
+ private val agentPlans : MutableList <AgentPlan >,
51
51
private val isInPopup : Boolean = false
52
52
) : JBPanel<PlanSketch>(BorderLayout ()), ExtensionLangSketch {
53
53
private val panel = JBPanel <PlanSketch >(BorderLayout ())
@@ -91,7 +91,7 @@ class PlanSketch(
91
91
override fun displayTextInToolbar (): Boolean = true
92
92
93
93
override fun actionPerformed (e : AnActionEvent ) {
94
- project.getService(AgentStateService ::class .java).updatePlan(planLists )
94
+ project.getService(AgentStateService ::class .java).updatePlan(agentPlans )
95
95
project.getService(PlanBoard ::class .java).updateShow()
96
96
}
97
97
}
@@ -101,7 +101,7 @@ class PlanSketch(
101
101
102
102
103
103
private fun createPlanUI () {
104
- planLists .forEachIndexed { index, planItem ->
104
+ agentPlans .forEachIndexed { index, planItem ->
105
105
val titlePanel = JBPanel <JBPanel <* >>(FlowLayout (FlowLayout .LEFT )).apply {
106
106
border = JBUI .Borders .empty()
107
107
}
@@ -128,7 +128,7 @@ class PlanSketch(
128
128
titlePanel.add(sectionLabel)
129
129
contentPanel.add(titlePanel)
130
130
131
- planItem.planTasks .forEachIndexed { taskIndex, task ->
131
+ planItem.tasks .forEachIndexed { taskIndex, task ->
132
132
val taskPanel = JBPanel <JBPanel <* >>(FlowLayout (FlowLayout .LEFT )).apply {
133
133
border = JBUI .Borders .empty()
134
134
}
@@ -152,7 +152,7 @@ class PlanSketch(
152
152
}
153
153
154
154
// Update section status when task status changes
155
- val currentSection = planLists .find { it.planTasks .contains(task) }
155
+ val currentSection = agentPlans .find { it.tasks .contains(task) }
156
156
currentSection?.let { updateSectionCompletionStatus(it) }
157
157
158
158
updateTaskLabel(taskLabel, task)
@@ -175,7 +175,7 @@ class PlanSketch(
175
175
176
176
addActionListener {
177
177
AutoDevToolWindowFactory .sendToSketchToolWindow(project, ChatActionType .SKETCH ) { ui, _ ->
178
- ui.sendInput(AutoDevBundle .message(" sketch.plan.finish.task" ) + task.description )
178
+ ui.sendInput(AutoDevBundle .message(" sketch.plan.finish.task" ) + task.step )
179
179
}
180
180
}
181
181
}
@@ -197,7 +197,7 @@ class PlanSketch(
197
197
updateTaskLabel(taskLabel, task)
198
198
199
199
// Update section status after changing task status
200
- val currentSection = planLists .find { it.planTasks .contains(task) }
200
+ val currentSection = agentPlans .find { it.tasks .contains(task) }
201
201
currentSection?.let { updateSectionCompletionStatus(it) }
202
202
203
203
contentPanel.revalidate()
@@ -208,7 +208,7 @@ class PlanSketch(
208
208
task.updateStatus(TaskStatus .IN_PROGRESS )
209
209
updateTaskLabel(taskLabel, task)
210
210
211
- val currentSection = planLists .find { it.planTasks .contains(task) }
211
+ val currentSection = agentPlans .find { it.tasks .contains(task) }
212
212
currentSection?.let { updateSectionCompletionStatus(it) }
213
213
214
214
contentPanel.revalidate()
@@ -219,7 +219,7 @@ class PlanSketch(
219
219
task.updateStatus(TaskStatus .FAILED )
220
220
updateTaskLabel(taskLabel, task)
221
221
222
- val currentSection = planLists .find { it.planTasks .contains(task) }
222
+ val currentSection = agentPlans .find { it.tasks .contains(task) }
223
223
currentSection?.let { updateSectionCompletionStatus(it) }
224
224
225
225
contentPanel.revalidate()
@@ -230,7 +230,7 @@ class PlanSketch(
230
230
task.updateStatus(TaskStatus .TODO )
231
231
updateTaskLabel(taskLabel, task)
232
232
233
- val currentSection = planLists .find { it.planTasks .contains(task) }
233
+ val currentSection = agentPlans .find { it.tasks .contains(task) }
234
234
currentSection?.let { updateSectionCompletionStatus(it) }
235
235
236
236
contentPanel.revalidate()
@@ -247,7 +247,7 @@ class PlanSketch(
247
247
contentPanel.add(taskPanel)
248
248
}
249
249
250
- if (index < planLists .size - 1 ) {
250
+ if (index < agentPlans .size - 1 ) {
251
251
contentPanel.add(Box .createVerticalStrut(8 ))
252
252
}
253
253
}
@@ -256,10 +256,10 @@ class PlanSketch(
256
256
// Helper method to create a styled task label based on status
257
257
private fun createStyledTaskLabel (task : PlanTask ): JLabel {
258
258
val labelText = when (task.status) {
259
- TaskStatus .COMPLETED -> " <html><strike>${task.description } </strike></html>"
260
- TaskStatus .FAILED -> " <html><span style='color:red'>${task.description } </span></html>"
261
- TaskStatus .IN_PROGRESS -> " <html><span style='color:blue;font-style:italic'>${task.description } </span></html>"
262
- TaskStatus .TODO -> task.description
259
+ TaskStatus .COMPLETED -> " <html><strike>${task.step } </strike></html>"
260
+ TaskStatus .FAILED -> " <html><span style='color:red'>${task.step } </span></html>"
261
+ TaskStatus .IN_PROGRESS -> " <html><span style='color:blue;font-style:italic'>${task.step } </span></html>"
262
+ TaskStatus .TODO -> task.step
263
263
}
264
264
265
265
return JLabel (labelText).apply {
@@ -270,15 +270,15 @@ class PlanSketch(
270
270
// Helper method to update the task label based on current status
271
271
private fun updateTaskLabel (label : JLabel , task : PlanTask ) {
272
272
label.text = when (task.status) {
273
- TaskStatus .COMPLETED -> " <html><strike>${task.description } </strike></html>"
274
- TaskStatus .FAILED -> " <html><span style='color:red'>${task.description } </span></html>"
275
- TaskStatus .IN_PROGRESS -> " <html><span style='color:blue;font-style:italic'>${task.description } </span></html>"
276
- TaskStatus .TODO -> task.description
273
+ TaskStatus .COMPLETED -> " <html><strike>${task.step } </strike></html>"
274
+ TaskStatus .FAILED -> " <html><span style='color:red'>${task.step } </span></html>"
275
+ TaskStatus .IN_PROGRESS -> " <html><span style='color:blue;font-style:italic'>${task.step } </span></html>"
276
+ TaskStatus .TODO -> task.step
277
277
}
278
278
}
279
279
280
280
// Helper method to update section completion status based on tasks
281
- private fun updateSectionCompletionStatus (planItem : PlanList ) {
281
+ private fun updateSectionCompletionStatus (planItem : AgentPlan ) {
282
282
// Use the new method instead of reflection
283
283
planItem.updateCompletionStatus()
284
284
@@ -300,26 +300,26 @@ class PlanSketch(
300
300
updatePlan(MarkdownPlanParser .parse(text))
301
301
}
302
302
303
- fun updatePlan (newPlanItems : List <PlanList >) {
303
+ fun updatePlan (newPlanItems : List <AgentPlan >) {
304
304
if (newPlanItems.isNotEmpty()) {
305
305
// Save current states of all tasks
306
306
val taskStateMap = mutableMapOf<String , Pair <Boolean , TaskStatus >>()
307
307
308
- planLists .forEach { planItem ->
309
- planItem.planTasks .forEach { task ->
310
- taskStateMap[task.description ] = Pair (task.completed, task.status)
308
+ agentPlans .forEach { planItem ->
309
+ planItem.tasks .forEach { task ->
310
+ taskStateMap[task.step ] = Pair (task.completed, task.status)
311
311
}
312
312
}
313
313
314
314
contentPanel.removeAll()
315
- planLists .clear()
315
+ agentPlans .clear()
316
316
317
317
newPlanItems.forEach { newItem ->
318
- planLists .add(newItem)
318
+ agentPlans .add(newItem)
319
319
320
- newItem.planTasks .forEach { task ->
320
+ newItem.tasks .forEach { task ->
321
321
// Restore saved states if available
322
- taskStateMap[task.description ]?.let { (completed, status) ->
322
+ taskStateMap[task.step ]?.let { (completed, status) ->
323
323
task.completed = completed
324
324
task.status = status
325
325
}
@@ -338,7 +338,7 @@ class PlanSketch(
338
338
override fun onDoneStream (allText : String ) {
339
339
if (! isInPopup) {
340
340
updatePlan(this .content)
341
- project.getService(AgentStateService ::class .java).updatePlan(planLists )
341
+ project.getService(AgentStateService ::class .java).updatePlan(agentPlans )
342
342
}
343
343
}
344
344
0 commit comments