Skip to content

Commit 92c0368

Browse files
committed
fix(planner): correct typo in AutoDevPlannerToolWindowFactory
#331 - Rename `AutoDevPlanerToolWindowFactory` to `AutoDevPlannerToolWindowFactory` to fix typo. - Update references in XML and Kotlin files. - Refactor plan content and UI layout in PlanSketch and SectionPanel.
1 parent 185f9c6 commit 92c0368

File tree

6 files changed

+61
-55
lines changed

6 files changed

+61
-55
lines changed

core/src/223/main/resources/META-INF/autodev-core.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
order="after Structure"
6060
icon="cc.unitmesh.devti.AutoDevIcons.AI_COPILOT"
6161
secondary="true"
62-
factoryClass="cc.unitmesh.devti.gui.AutoDevPlanerToolWindowFactory"/>
62+
factoryClass="cc.unitmesh.devti.gui.AutoDevPlannerToolWindowFactory"/>
6363

6464
<notificationGroup id="AutoDev.notify" displayType="STICKY_BALLOON" bundle="messages.AutoDevBundle"
6565
key="name"/>

core/src/233/main/resources/META-INF/autodev-core.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
order="after Structure"
5959
icon="cc.unitmesh.devti.AutoDevIcons.AI_COPILOT"
6060
secondary="true"
61-
factoryClass="cc.unitmesh.devti.gui.AutoDevPlanerToolWindowFactory"/>
61+
factoryClass="cc.unitmesh.devti.gui.AutoDevPlannerToolWindowFactory"/>
6262

6363
<notificationGroup id="AutoDev.notify" displayType="STICKY_BALLOON" bundle="messages.AutoDevBundle"
6464
key="name"/>

core/src/main/kotlin/cc/unitmesh/devti/gui/AutoDevPlanerToolWindowFactory.kt renamed to core/src/main/kotlin/cc/unitmesh/devti/gui/AutoDevPlannerToolWindowFactory.kt

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import com.intellij.util.ui.UIUtil
2323
import java.awt.BorderLayout
2424
import java.util.concurrent.atomic.AtomicBoolean
2525

26-
class AutoDevPlanerToolWindowFactory : ToolWindowFactory, ToolWindowManagerListener, DumbAware {
26+
class AutoDevPlannerToolWindowFactory : ToolWindowFactory, ToolWindowManagerListener, DumbAware {
2727
private val orientation = AtomicBoolean(true)
2828

2929
override fun createToolWindowContent(
@@ -58,7 +58,31 @@ class AutoDevPlanerTooWindow(val project: Project) : SimpleToolWindowPanel(true,
5858
override fun getName(): @NlsActions.ActionText String? = "AutoDev Planer"
5959
var connection = ApplicationManager.getApplication().messageBus.connect(this)
6060

61-
val content = ""
61+
val content = """1. 分析当前Blog功能结构(✓)
62+
- 当前Blog功能分散在entity(BlogPost)、service、controller层,采用贫血模型
63+
- domain.Blog类存在但未充分使用,需要明确领域模型边界
64+
65+
2. 建立领域模型(*)
66+
a. 定义Blog聚合根(进行中)
67+
b. 创建Value Object(标题、内容等)
68+
c. 定义领域服务接口
69+
d. 实现业务规则(如发布校验、状态转换)
70+
71+
3. 重构数据持久层
72+
- 将BlogRepository改为面向领域模型
73+
- 移除BlogPost实体与数据库的直接映射
74+
75+
4. 调整应用层
76+
- 重写BlogService使用领域模型
77+
- 修改BlogController适配DTO转换
78+
79+
5. 业务逻辑迁移
80+
- 将Service中的CRUD逻辑转移到Blog领域对象
81+
- 实现领域事件机制(如博客发布事件)
82+
83+
6. 验证测试
84+
- 修改现有测试用例
85+
- 添加领域模型单元测试"""
6286
var planSketch: PlanSketch = PlanSketch(project, content, MarkdownPlanParser.parse(content).toMutableList(), true)
6387

6488
init {
Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// filepath: /Volumes/source/ai/autocrud/core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/plan/PlanSketch.kt
21
package cc.unitmesh.devti.sketch.ui.plan
32

43
import cc.unitmesh.devti.observer.agent.AgentStateService
@@ -10,7 +9,7 @@ import com.intellij.lang.Language
109
import com.intellij.openapi.project.Project
1110
import com.intellij.ui.components.JBPanel
1211
import com.intellij.ui.components.JBScrollPane
13-
import com.intellij.util.ui.JBEmptyBorder
12+
import com.intellij.ui.components.panels.VerticalLayout
1413
import com.intellij.util.ui.JBUI
1514
import java.awt.BorderLayout
1615
import java.awt.Dimension
@@ -24,43 +23,39 @@ import javax.swing.ScrollPaneConstants
2423
* Controller class for managing the plan data and UI updates
2524
*/
2625
class PlanController(
27-
private val project: Project,
26+
private val project: Project,
2827
private val contentPanel: JPanel,
2928
private var agentTaskItems: MutableList<AgentTaskEntry>
3029
) {
3130
fun renderPlan() {
3231
contentPanel.removeAll()
33-
3432
agentTaskItems.forEachIndexed { index, planItem ->
3533
val sectionPanel = SectionPanel(project, index, planItem) {
3634
contentPanel.revalidate()
3735
contentPanel.repaint()
3836
}
39-
37+
4038
contentPanel.add(sectionPanel)
4139
}
42-
43-
// Add a vertical glue to push content up when there's extra space
44-
contentPanel.add(Box.createVerticalGlue())
45-
40+
4641
contentPanel.revalidate()
4742
contentPanel.repaint()
4843
}
49-
44+
5045
fun updatePlan(newPlanItems: List<AgentTaskEntry>) {
5146
if (newPlanItems.isEmpty()) {
5247
return
5348
}
54-
49+
5550
val taskStateMap = mutableMapOf<String, Pair<Boolean, TaskStatus>>()
5651
agentTaskItems.forEach { planItem ->
5752
planItem.steps.forEach { task ->
5853
taskStateMap[task.step] = Pair(task.completed, task.status)
5954
}
6055
}
61-
56+
6257
agentTaskItems.clear()
63-
58+
6459
newPlanItems.forEach { newItem ->
6560
agentTaskItems.add(newItem)
6661
newItem.steps.forEach { task ->
@@ -70,10 +65,10 @@ class PlanController(
7065
}
7166
}
7267
}
73-
68+
7469
renderPlan()
7570
}
76-
71+
7772
fun savePlanToService() {
7873
project.getService(AgentStateService::class.java).updatePlan(agentTaskItems)
7974
}
@@ -88,30 +83,24 @@ class PlanSketch(
8883
private var agentTaskItems: MutableList<AgentTaskEntry>,
8984
private val isInToolwindow: Boolean = false
9085
) : JBPanel<PlanSketch>(BorderLayout(JBUI.scale(8), 0)), ExtensionLangSketch {
91-
private val contentPanel = JPanel().apply {
92-
layout = BoxLayout(this, BoxLayout.Y_AXIS)
93-
// Ensure content panel takes maximum width but doesn't force height
94-
maximumSize = Dimension(Int.MAX_VALUE, Int.MAX_VALUE)
95-
alignmentX = LEFT_ALIGNMENT
96-
}
97-
86+
private val contentPanel = JPanel(VerticalLayout(JBUI.scale(0)))
87+
val scrollPane: JBScrollPane
9888
private val toolbarFactory = PlanToolbarFactory(project)
9989
private val planController = PlanController(project, contentPanel, agentTaskItems)
100-
90+
10191
init {
10292
if (!isInToolwindow) {
10393
add(toolbarFactory.createToolbar(this), BorderLayout.NORTH)
10494
border = JBUI.Borders.empty(8)
10595
}
106-
96+
10797
planController.renderPlan()
108-
109-
val scrollPane = JBScrollPane(contentPanel).apply {
98+
99+
scrollPane = JBScrollPane(contentPanel).apply {
110100
verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
111101
horizontalScrollBarPolicy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
112-
border = null
113-
114-
// Make sure viewport tracks width but not height
102+
border = JBUI.Borders.empty()
103+
115104
viewport.isOpaque = false
116105
viewport.view = contentPanel
117106
}
@@ -128,30 +117,31 @@ class PlanSketch(
128117
}
129118

130119
override fun getExtensionName(): String = "ThoughtPlan"
131-
120+
132121
override fun getViewText(): String = content
133-
122+
134123
override fun updateViewText(text: String, complete: Boolean) {
135124
this.content = text
136125
val agentPlans = MarkdownPlanParser.parse(text)
137126
planController.updatePlan(agentPlans)
138127
}
139-
128+
140129
override fun onComplete(context: String) {
141130
if (!isInToolwindow) {
142131
val agentPlans = MarkdownPlanParser.parse(content).toMutableList()
143132
planController.updatePlan(agentPlans)
144133
planController.savePlanToService()
145134
}
146135
}
147-
136+
148137
fun updatePlan(newPlanItems: List<AgentTaskEntry>) {
149138
planController.updatePlan(newPlanItems)
150139
}
151-
140+
152141
override fun getComponent(): JComponent = this
153-
142+
154143
override fun updateLanguage(language: Language?, originLanguage: String?) {}
155-
144+
156145
override fun dispose() {}
157146
}
147+

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package cc.unitmesh.devti.sketch.ui.plan
22

3-
import cc.unitmesh.devti.gui.AutoDevPlanerToolWindowFactory
3+
import cc.unitmesh.devti.gui.AutoDevPlannerToolWindowFactory
44
import com.intellij.icons.AllIcons
55
import com.intellij.openapi.actionSystem.ActionManager
66
import com.intellij.openapi.actionSystem.AnAction
@@ -49,7 +49,7 @@ class PlanToolbarFactory(private val project: Project) {
4949

5050
override fun actionPerformed(e: AnActionEvent) {
5151
val toolWindow =
52-
ToolWindowManager.Companion.getInstance(project).getToolWindow(AutoDevPlanerToolWindowFactory.Companion.PlANNER_ID)
52+
ToolWindowManager.Companion.getInstance(project).getToolWindow(AutoDevPlannerToolWindowFactory.Companion.PlANNER_ID)
5353
?: return
5454

5555
toolWindow.activate {

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// filepath: /Volumes/source/ai/autocrud/core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/plan/SectionPanel.kt
21
package cc.unitmesh.devti.sketch.ui.plan
32

43
import cc.unitmesh.devti.AutoDevBundle
@@ -28,14 +27,11 @@ class SectionPanel(
2827
private val planItem: AgentTaskEntry,
2928
private val onStatusChange: () -> Unit
3029
) : JBPanel<JBPanel<*>>(BorderLayout()) {
31-
3230
init {
3331
layout = BoxLayout(this, BoxLayout.Y_AXIS)
3432
background = JBUI.CurrentTheme.ToolWindow.background()
35-
36-
alignmentX = LEFT_ALIGNMENT
37-
maximumSize = Dimension(Int.MAX_VALUE, Int.MAX_VALUE)
38-
33+
border = JBUI.Borders.empty(2, 0)
34+
3935
val titlePanel = createSectionTitlePanel()
4036
add(titlePanel)
4137

@@ -45,11 +41,8 @@ class SectionPanel(
4541
onStatusChange()
4642
}
4743

48-
taskPanel.alignmentX = LEFT_ALIGNMENT
4944
add(taskPanel)
5045
}
51-
52-
revalidate()
5346
}
5447

5548
private fun createSectionTitlePanel(): JPanel {
@@ -85,15 +78,14 @@ class SectionPanel(
8578
private fun createExecuteSectionButton(): JButton {
8679
return JButton(AllIcons.Actions.Execute).apply {
8780
border = BorderFactory.createEmptyBorder()
88-
8981
preferredSize = Dimension(20, 20)
9082
toolTipText = "Execute Task"
9183
background = JBUI.CurrentTheme.ToolWindow.background()
9284

9385
addActionListener {
9486
AutoDevToolWindowFactory.Companion.sendToSketchToolWindow(project, ChatActionType.SKETCH) { ui, _ ->
95-
val allSteps = planItem.steps.joinToString("\n") { it.step }
96-
ui.sendInput(AutoDevBundle.message("sketch.plan.finish.task") + allSteps)
87+
val content = planItem.title + "\n" + planItem.steps.joinToString("\n") { " - " + it.step }
88+
ui.sendInput(AutoDevBundle.message("sketch.plan.finish.task") + content)
9789
}
9890
}
9991
}
@@ -102,4 +94,4 @@ class SectionPanel(
10294
fun updateSectionStatus() {
10395
planItem.updateCompletionStatus()
10496
}
105-
}
97+
}

0 commit comments

Comments
 (0)