Skip to content

Commit 4c72487

Browse files
committed
refactor(devti): enhance UI visuals and consistency #352
- Update colors and icons for improved visual consistency - Refactor UI components to use new color constants- Adjust layout and spacing for better readability - Replace text labels with icons for Execute and Retry actions - Add new check icon for completed tasks
1 parent 15a4970 commit 4c72487

File tree

6 files changed

+81
-64
lines changed

6 files changed

+81
-64
lines changed

core/src/main/kotlin/cc/unitmesh/devti/AutoDevIcons.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ object AutoDevIcons {
3636
val Checked: Icon = IconLoader.getIcon("/icons/checked.svg", AutoDevIcons::class.java)
3737

3838
@JvmField
39-
val Repair: Icon = IconLoader.getIcon("/icons/repair.svg", AutoDevIcons::class.java)
39+
val REPAIR: Icon = IconLoader.getIcon("/icons/repair.svg", AutoDevIcons::class.java)
4040

4141
@JvmField
4242
val Build: Icon = IconLoader.getIcon("/icons/build.svg", AutoDevIcons::class.java)
@@ -79,4 +79,7 @@ object AutoDevIcons {
7979

8080
@JvmField
8181
val MCP: Icon = IconLoader.getIcon("/icons/mcp.svg", AutoDevIcons::class.java)
82+
83+
@JvmField
84+
val CHECK: Icon = IconLoader.getIcon("/icons/check.svg", AutoDevIcons::class.java)
8285
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package cc.unitmesh.devti.sketch.ui
2+
3+
import com.intellij.ui.JBColor
4+
5+
/**
6+
* Color constants used throughout the AutoDev UI
7+
*/
8+
object AutoDevColors {
9+
// Status colors
10+
val COMPLETED_STATUS = JBColor(0x59A869, 0x59A869) // Green
11+
val FAILED_STATUS = JBColor(0xD94F4F, 0xD94F4F) // Red
12+
val IN_PROGRESS_STATUS = JBColor(0x3592C4, 0x3592C4) // Blue
13+
val TODO_STATUS = JBColor(0x808080, 0x808080) // Gray
14+
15+
// Text colors
16+
val COMPLETED_TEXT = JBColor(0x808080, 0x999999)
17+
val FAILED_TEXT = JBColor(0xD94F4F, 0xFF6B68)
18+
val IN_PROGRESS_TEXT = JBColor(0x3592C4, 0x589DF6)
19+
20+
// UI elements
21+
val SEPARATOR_BORDER = JBColor(0xE5E5E5, 0x323232)
22+
val LINK_COLOR = JBColor(0x3366CC, 0x589DF6)
23+
}

core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/patch/SingleFileDiffSketch.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import cc.unitmesh.devti.sketch.AutoSketchMode
77
import cc.unitmesh.devti.sketch.lint.SketchCodeInspection
88
import cc.unitmesh.devti.sketch.ui.LangSketch
99
import cc.unitmesh.devti.template.context.TemplateContext
10-
import cc.unitmesh.devti.util.AutoDevAppScope
11-
import cc.unitmesh.devti.util.AutoDevCoroutineScope
1210
import com.intellij.diff.editor.DiffVirtualFileBase
1311
import com.intellij.lang.annotation.HighlightSeverity
1412
import com.intellij.openapi.application.*
@@ -28,14 +26,12 @@ import com.intellij.openapi.vfs.VfsUtilCore
2826
import com.intellij.openapi.vfs.VirtualFile
2927
import com.intellij.psi.PsiManager
3028
import com.intellij.testFramework.LightVirtualFile
31-
import com.intellij.ui.DarculaColors
3229
import com.intellij.ui.JBColor
3330
import com.intellij.ui.components.JBLabel
3431
import com.intellij.ui.components.panels.HorizontalLayout
3532
import com.intellij.ui.components.panels.VerticalLayout
3633
import com.intellij.util.LocalTimeCounter
3734
import com.intellij.util.concurrency.annotations.RequiresWriteLock
38-
import kotlinx.coroutines.launch
3935
import java.awt.BorderLayout
4036
import java.awt.event.MouseAdapter
4137
import java.awt.event.MouseEvent
@@ -214,7 +210,7 @@ class SingleFileDiffSketch(
214210
icon = if (isAutoRepair && isFailedPatch) {
215211
AutoDevIcons.InProgress
216212
} else {
217-
AutoDevIcons.Repair
213+
AutoDevIcons.REPAIR
218214
}
219215

220216
toolTipText = AutoDevBundle.message("sketch.patch.action.repairDiff.tooltip")

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

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,16 @@ import cc.unitmesh.devti.gui.AutoDevToolWindowFactory
66
import cc.unitmesh.devti.gui.chat.message.ChatActionType
77
import cc.unitmesh.devti.observer.plan.AgentTaskEntry
88
import cc.unitmesh.devti.observer.plan.TaskStatus
9+
import cc.unitmesh.devti.sketch.ui.AutoDevColors
910
import com.intellij.openapi.project.Project
1011
import com.intellij.ui.JBColor
1112
import com.intellij.ui.components.JBPanel
1213
import com.intellij.ui.components.JBScrollPane
13-
import com.intellij.util.ui.AnimatedIcon
1414
import com.intellij.util.ui.JBUI
15-
import com.intellij.util.ui.UIUtil
1615
import java.awt.BorderLayout
1716
import java.awt.Dimension
1817
import java.awt.FlowLayout
1918
import java.awt.Font
20-
import java.awt.event.ActionEvent
21-
import java.awt.event.ComponentAdapter
22-
import java.awt.event.ComponentEvent
2319
import javax.swing.*
2420
import javax.swing.border.CompoundBorder
2521

@@ -37,7 +33,6 @@ class TaskSectionPanel(
3733
private var isExpanded = true
3834
private var expandButton: JButton? = null
3935
private var statusLabel: JLabel? = null
40-
private var progressLabel: JLabel? = null
4136
private val scrollPane: JBScrollPane
4237
private val MAX_TITLE_LENGTH = 50
4338

@@ -54,7 +49,7 @@ class TaskSectionPanel(
5449

5550
stepsPanel.layout = BoxLayout(stepsPanel, BoxLayout.Y_AXIS)
5651
stepsPanel.background = JBUI.CurrentTheme.ToolWindow.background()
57-
stepsPanel.border = JBUI.Borders.emptyLeft(24)
52+
stepsPanel.border = JBUI.Borders.emptyLeft(4)
5853

5954
refreshStepsPanel()
6055

@@ -67,8 +62,6 @@ class TaskSectionPanel(
6762
}
6863

6964
add(scrollPane, BorderLayout.CENTER)
70-
71-
// Initially show or hide based on state
7265
toggleStepsVisibility(isExpanded)
7366
}
7467

@@ -78,15 +71,13 @@ class TaskSectionPanel(
7871
border = JBUI.Borders.empty(2)
7972
}
8073

81-
// Left side with expand button and title
8274
val leftPanel = JPanel(FlowLayout(FlowLayout.LEFT, 5, 0)).apply {
8375
isOpaque = false
8476
}
8577

86-
// Expand/collapse button
8778
expandButton = JButton(if (isExpanded) "" else "").apply {
88-
preferredSize = Dimension(20, 20) // Slightly smaller button
89-
margin = JBUI.insets(0)
79+
preferredSize = Dimension(20, 20)
80+
margin = JBUI.emptyInsets()
9081
isBorderPainted = false
9182
isContentAreaFilled = false
9283
toolTipText = if (isExpanded) "Collapse section" else "Expand section"
@@ -119,40 +110,40 @@ class TaskSectionPanel(
119110

120111
val titleLabel = JLabel(displayTitle).apply {
121112
font = font.deriveFont(Font.BOLD)
122-
toolTipText = fullTitle // Show full title on hover
113+
toolTipText = fullTitle
123114
}
124115
leftPanel.add(titleLabel)
125116

126117
val rightPanel = JPanel(FlowLayout(FlowLayout.RIGHT, 5, 0)).apply {
127118
isOpaque = false
128119
}
129120

130-
val completedSteps = planItem.steps.count { it.completed }
131-
val totalSteps = planItem.steps.size
132-
val progressPercentage = if (totalSteps > 0) (completedSteps * 100) / totalSteps else 0
133-
134-
progressLabel = JLabel("$progressPercentage% complete").apply {
135-
foreground = JBColor.GRAY
136-
font = font.deriveFont(Font.PLAIN, 10f)
137-
}
138-
rightPanel.add(progressLabel)
139-
140121
statusLabel = JLabel(getStatusText(planItem.status)).apply {
141122
foreground = getStatusColor(planItem.status)
142123
font = font.deriveFont(Font.BOLD, 11f)
143-
border = JBUI.Borders.empty(2, 5)
124+
border = JBUI.Borders.empty(2)
125+
preferredSize = Dimension(80, 16)
144126
}
127+
145128
rightPanel.add(statusLabel)
146129

147130
if (planItem.status == TaskStatus.TODO || planItem.status == TaskStatus.FAILED) {
148-
val executeButton = JButton("Execute").apply {
131+
val executeButton = JButton(AutoDevIcons.Run).apply {
132+
margin = JBUI.emptyInsets()
133+
isBorderPainted = false
134+
isContentAreaFilled = false
135+
preferredSize = Dimension(20, 20)
149136
addActionListener { executeSection() }
150137
}
151138
rightPanel.add(executeButton)
152139
}
153140

154141
if (planItem.status == TaskStatus.FAILED) {
155-
val retryButton = JButton("Retry").apply {
142+
val retryButton = JButton(AutoDevIcons.REPAIR).apply {
143+
margin = JBUI.emptyInsets()
144+
isBorderPainted = false
145+
isContentAreaFilled = false
146+
preferredSize = Dimension(20, 20)
156147
addActionListener { executeSection() }
157148
}
158149
rightPanel.add(retryButton)
@@ -207,12 +198,6 @@ class TaskSectionPanel(
207198
}
208199

209200
private fun updateProgressAndStatus() {
210-
val completedSteps = planItem.steps.count { it.completed }
211-
val totalSteps = planItem.steps.size
212-
val progressPercentage = if (totalSteps > 0) (completedSteps * 100) / totalSteps else 0
213-
214-
progressLabel?.text = "$progressPercentage% complete"
215-
216201
statusLabel?.text = getStatusText(planItem.status)
217202
statusLabel?.foreground = getStatusColor(planItem.status)
218203

@@ -235,10 +220,10 @@ class TaskSectionPanel(
235220

236221
private fun getStatusColor(status: TaskStatus): JBColor {
237222
return when (status) {
238-
TaskStatus.COMPLETED -> JBColor(0x59A869, 0x59A869) // Green
239-
TaskStatus.FAILED -> JBColor(0xD94F4F, 0xD94F4F) // Red
240-
TaskStatus.IN_PROGRESS -> JBColor(0x3592C4, 0x3592C4) // Blue
241-
TaskStatus.TODO -> JBColor(0x808080, 0x808080) // Gray
223+
TaskStatus.COMPLETED -> AutoDevColors.COMPLETED_STATUS
224+
TaskStatus.FAILED -> AutoDevColors.FAILED_STATUS
225+
TaskStatus.IN_PROGRESS -> AutoDevColors.IN_PROGRESS_STATUS
226+
TaskStatus.TODO -> AutoDevColors.TODO_STATUS
242227
}
243228
}
244229
}

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

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import cc.unitmesh.devti.gui.AutoDevToolWindowFactory
66
import cc.unitmesh.devti.gui.chat.message.ChatActionType
77
import cc.unitmesh.devti.observer.plan.AgentPlanStep
88
import cc.unitmesh.devti.observer.plan.TaskStatus
9+
import cc.unitmesh.devti.sketch.ui.AutoDevColors
910
import com.intellij.openapi.editor.colors.EditorColorsManager
1011
import com.intellij.openapi.fileEditor.FileEditorManager
1112
import com.intellij.openapi.project.Project
@@ -45,20 +46,15 @@ class TaskStepPanel(
4546
init {
4647
layout = BorderLayout()
4748
background = JBUI.CurrentTheme.ToolWindow.background()
48-
border = CompoundBorder(
49-
BorderFactory.createMatteBorder(0, 0, 1, 0, JBColor(0xE5E5E5, 0x323232)),
50-
JBUI.Borders.empty(3, 2) // Reduced padding for more compact view
51-
)
49+
border = JBUI.Borders.empty(3, 2)
5250

53-
// Left panel for status icon with reduced spacing
5451
val leftPanel = JPanel(FlowLayout(FlowLayout.LEFT, 2, 0)).apply {
5552
isOpaque = false
5653
}
5754

5855
val statusIcon = createStatusIcon()
5956
leftPanel.add(statusIcon)
6057

61-
// Center panel for task description with links
6258
taskLabel = createTaskTextPane()
6359
doc = taskLabel.styledDocument
6460
updateTaskLabel()
@@ -105,26 +101,30 @@ class TaskStepPanel(
105101
add(rightPanel, BorderLayout.EAST)
106102

107103
setupContextMenu()
108-
109-
// Set preferred size for compact view
110104
preferredSize = Dimension(preferredSize.width, Math.min(preferredSize.height, 28))
111105
}
112106

113107
private fun createStatusIcon(): JComponent {
114108
return when (task.status) {
115109
TaskStatus.COMPLETED -> JLabel(AutoDevIcons.Checked).apply {
116-
preferredSize = Dimension(16, 16)
110+
preferredSize = Dimension(20, 16)
111+
border = JBUI.Borders.empty()
117112
}
118113

119114
TaskStatus.FAILED -> JLabel(AutoDevIcons.Error).apply {
120-
preferredSize = Dimension(16, 16)
115+
preferredSize = Dimension(20, 16)
116+
border = JBUI.Borders.empty()
121117
}
122118

123119
TaskStatus.IN_PROGRESS -> JLabel(AutoDevIcons.Build).apply {
124-
preferredSize = Dimension(16, 16)
120+
preferredSize = Dimension(20, 16)
121+
border = JBUI.Borders.empty()
125122
}
126123

127124
TaskStatus.TODO -> JCheckBox().apply {
125+
border = JBUI.Borders.empty()
126+
preferredSize = Dimension(20, 16)
127+
128128
isSelected = task.completed
129129
addActionListener {
130130
task.completed = isSelected
@@ -133,10 +133,9 @@ class TaskStepPanel(
133133
updateStatusLabel()
134134
onStatusChange()
135135
}
136+
136137
isBorderPainted = false
137138
isContentAreaFilled = false
138-
background = JBUI.CurrentTheme.ToolWindow.background()
139-
preferredSize = Dimension(16, 16)
140139
}
141140
}
142141
}
@@ -207,7 +206,7 @@ class TaskStepPanel(
207206
currentPos += beforeLink.length
208207

209208
val linkStyle = SimpleAttributeSet().apply {
210-
StyleConstants.setForeground(this, JBColor(0x3366CC, 0x589DF6))
209+
StyleConstants.setForeground(this, AutoDevColors.LINK_COLOR)
211210
StyleConstants.setUnderline(this, true)
212211
}
213212

@@ -233,15 +232,15 @@ class TaskStepPanel(
233232
when (status) {
234233
TaskStatus.COMPLETED -> {
235234
StyleConstants.setStrikeThrough(style, true)
236-
StyleConstants.setForeground(style, JBColor(0x808080, 0x999999))
235+
StyleConstants.setForeground(style, AutoDevColors.COMPLETED_TEXT)
237236
}
238237

239238
TaskStatus.FAILED -> {
240-
StyleConstants.setForeground(style, JBColor(0xD94F4F, 0xFF6B68))
239+
StyleConstants.setForeground(style, AutoDevColors.FAILED_TEXT)
241240
}
242241

243242
TaskStatus.IN_PROGRESS -> {
244-
StyleConstants.setForeground(style, JBColor(0x3592C4, 0x589DF6))
243+
StyleConstants.setForeground(style, AutoDevColors.IN_PROGRESS_TEXT)
245244
StyleConstants.setItalic(style, true)
246245
}
247246

@@ -356,10 +355,10 @@ class TaskStepPanel(
356355

357356
private fun getStatusColor(status: TaskStatus): JBColor {
358357
return when (status) {
359-
TaskStatus.COMPLETED -> JBColor(0x59A869, 0x59A869) // Green
360-
TaskStatus.FAILED -> JBColor(0xD94F4F, 0xD94F4F) // Red
361-
TaskStatus.IN_PROGRESS -> JBColor(0x3592C4, 0x3592C4) // Blue
362-
TaskStatus.TODO -> JBColor(0x808080, 0x808080) // Gray
358+
TaskStatus.COMPLETED -> AutoDevColors.COMPLETED_STATUS
359+
TaskStatus.FAILED -> AutoDevColors.FAILED_STATUS
360+
TaskStatus.IN_PROGRESS -> AutoDevColors.IN_PROGRESS_STATUS
361+
TaskStatus.TODO -> AutoDevColors.TODO_STATUS
363362
}
364363
}
365364
}
Lines changed: 11 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)