Skip to content

Commit ca041d5

Browse files
committed
refactor(ui): clean up plan content and improve task panel layout #331
- Remove hardcoded plan content in `AutoDevPlanerToolWindowFactory`. - Set minimum size for plan sketch panel to improve UI responsiveness. - Refactor `TaskPanel` layout to use `BoxLayout` for better alignment. - Simplify task label HTML rendering and adjust background colors.
1 parent 0f978d0 commit ca041d5

File tree

3 files changed

+11
-29
lines changed

3 files changed

+11
-29
lines changed

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

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,7 @@ class AutoDevPlanerTooWindow(val project: Project) : SimpleToolWindowPanel(true,
5656
override fun getName(): @NlsActions.ActionText String? = "AutoDev Planer"
5757
var connection = ApplicationManager.getApplication().messageBus.connect(this)
5858

59-
val content = """1. 更新实体类 BlogPost
60-
- [✓] 添加 category 字段
61-
- [✓] 更新构造函数
62-
- [✓] 添加 getter 和 setter
63-
64-
2. 更新 DTO 类 CreateBlogRequest
65-
- [✓] 添加 category 字段
66-
67-
3. 更新 BlogService
68-
- [✓] 确保 createBlog 方法正确处理 category 字段
69-
70-
4. 更新 BlogRepository
71-
- [✓] 添加 findByCategory 方法
72-
73-
5. 更新 BlogController
74-
- [✓] 添加按 category 查询的 API 端点
75-
- [✓] 更新 Swagger 文档
76-
77-
6. 测试验证
78-
- [ ] 编写 Postman 测试用例
79-
- [ ] 创建带 category 参数的集成测试
80-
- [ ] 验证空分类场景处理
81-
"""
59+
val content = ""
8260
var planSketch: PlanSketch = PlanSketch(project, content, MarkdownPlanParser.parse(content).toMutableList(), true)
8361

8462
init {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import com.intellij.ui.components.JBPanel
1111
import com.intellij.util.ui.JBEmptyBorder
1212
import com.intellij.util.ui.JBUI
1313
import java.awt.BorderLayout
14+
import java.awt.Dimension
1415
import javax.swing.Box
1516
import javax.swing.BoxLayout
1617
import javax.swing.JComponent
@@ -97,6 +98,7 @@ class PlanSketch(
9798
planController.renderPlan()
9899
add(contentPanel, BorderLayout.CENTER)
99100

101+
minimumSize = Dimension(200, 0)
100102
background = JBUI.CurrentTheme.ToolWindow.background()
101103
}
102104

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.intellij.util.ui.JBUI
1313
import java.awt.Dimension
1414
import java.awt.FlowLayout
1515
import javax.swing.BorderFactory
16+
import javax.swing.BoxLayout
1617
import javax.swing.JButton
1718
import javax.swing.JComponent
1819
import javax.swing.JLabel
@@ -26,10 +27,11 @@ class TaskPanel(
2627
private val project: Project,
2728
private val task: AgentPlanStep,
2829
private val onStatusChange: () -> Unit
29-
) : JBPanel<JBPanel<*>>(FlowLayout(FlowLayout.LEFT, 2, 0)) {
30+
) : JBPanel<TaskPanel>() {
3031
private val taskLabel: JLabel
3132

3233
init {
34+
layout = BoxLayout(this, BoxLayout.X_AXIS)
3335
border = JBUI.Borders.empty(4, 16, 4, 0)
3436
background = JBUI.CurrentTheme.ToolWindow.background()
3537
taskLabel = createStyledTaskLabel()
@@ -67,9 +69,9 @@ class TaskPanel(
6769
private fun createExecuteButton(): JButton {
6870
return JButton(AllIcons.Actions.Execute).apply {
6971
border = BorderFactory.createEmptyBorder()
70-
isOpaque = true
7172
preferredSize = Dimension(20, 20)
7273
toolTipText = "Execute"
74+
background = JBUI.CurrentTheme.ToolWindow.background()
7375

7476
addActionListener {
7577
AutoDevToolWindowFactory.Companion.sendToSketchToolWindow(project, ChatActionType.SKETCH) { ui, _ ->
@@ -81,16 +83,16 @@ class TaskPanel(
8183

8284
private fun createStyledTaskLabel(): JLabel {
8385
val labelText = getLabelTextByStatus()
84-
return JLabel(labelText).apply {
86+
return JLabel("<html>$labelText</html>").apply {
8587
border = JBUI.Borders.emptyLeft(5)
8688
}
8789
}
8890

8991
private fun getLabelTextByStatus(): String {
9092
return when (task.status) {
91-
TaskStatus.COMPLETED -> "<html><strike>${task.step}</strike></html>"
92-
TaskStatus.FAILED -> "<html><span style='color:red'>${task.step}</span></html>"
93-
TaskStatus.IN_PROGRESS -> "<html><span style='color:blue;font-style:italic'>${task.step}</span></html>"
93+
TaskStatus.COMPLETED -> "<strike>${task.step}</strike>"
94+
TaskStatus.FAILED -> "<span style='color:red'>${task.step}</span>"
95+
TaskStatus.IN_PROGRESS -> "<span style='color:blue;font-style:italic'>${task.step}</span>"
9496
TaskStatus.TODO -> task.step
9597
}
9698
}

0 commit comments

Comments
 (0)