Skip to content

Commit 59b5353

Browse files
committed
feat(sketch): add rerun functionality for failed tasks #352
- Add rerun button for failed tasks in TaskStepPanel - Implement executeTask function with isRerun parameter - Update UI to show appropriate message for rerun tasks - Add new icon for rerun action - Update localization files for new rerun message
1 parent bb8da4c commit 59b5353

File tree

5 files changed

+46
-20
lines changed

5 files changed

+46
-20
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,7 @@ object AutoDevIcons {
9797

9898
@JvmField
9999
val GIT_MOVE: Icon = IconLoader.getIcon("/icons/git-move.svg", AutoDevIcons::class.java)
100+
101+
@JvmField
102+
val RERUN: Icon = IconLoader.getIcon("/icons/rerun.svg", AutoDevIcons::class.java)
100103
}

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

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,19 @@ class TaskStepPanel(
276276
taskLabel.componentPopupMenu = taskPopupMenu
277277
}
278278

279-
private fun executeTask() {
279+
private fun executeTask(isRerun: Boolean = false) {
280280
task.updateStatus(TaskStatus.IN_PROGRESS)
281281
updateTaskLabel()
282282
updateStatusLabel()
283283
onStatusChange()
284284

285+
val message = if (isRerun) {
286+
AutoDevBundle.message("sketch.plan.rerun.task")
287+
} else {
288+
AutoDevBundle.message("sketch.plan.finish.task")
289+
}
285290
AutoDevToolWindowFactory.Companion.sendToSketchToolWindow(project, ChatActionType.SKETCH) { ui, _ ->
286-
ui.sendInput(AutoDevBundle.message("sketch.plan.finish.task") + task.step)
291+
ui.sendInput(message + task.step)
287292
}
288293

289294
refreshPanel()
@@ -312,25 +317,30 @@ class TaskStepPanel(
312317
isOpaque = false
313318
add(statusLabel)
314319

315-
if (task.status == TaskStatus.TODO || task.status == TaskStatus.FAILED) {
316-
val executeButton = JButton(AutoDevIcons.RUN).apply {
317-
preferredSize = Dimension(24, 24)
318-
margin = JBUI.insets(0)
319-
isBorderPainted = false
320-
isContentAreaFilled = false
321-
toolTipText = "Execute this step"
322-
addActionListener { executeTask() }
320+
when (task.status) {
321+
TaskStatus.TODO -> {
322+
val executeButton = JButton(AutoDevIcons.RUN).apply {
323+
preferredSize = Dimension(24, 24)
324+
margin = JBUI.emptyInsets()
325+
isBorderPainted = false
326+
isContentAreaFilled = false
327+
toolTipText = "Execute this step"
328+
addActionListener { executeTask() }
329+
}
330+
add(executeButton)
323331
}
324-
add(executeButton)
325-
}
326-
327-
if (task.status == TaskStatus.FAILED) {
328-
val retryButton = JButton("Retry").apply {
329-
margin = JBUI.insets(0, 3)
330-
font = font.deriveFont(Font.PLAIN, 10f)
331-
addActionListener { executeTask() }
332+
TaskStatus.FAILED -> {
333+
val retryButton = JButton(AutoDevIcons.RERUN).apply {
334+
preferredSize = Dimension(24, 24)
335+
margin = JBUI.emptyInsets()
336+
isBorderPainted = false
337+
isContentAreaFilled = false
338+
toolTipText = "Rerun"
339+
addActionListener { executeTask(isRerun = true) }
340+
}
341+
add(retryButton)
332342
}
333-
add(retryButton)
343+
else -> {}
334344
}
335345
}
336346

Lines changed: 12 additions & 0 deletions
Loading

core/src/main/resources/messages/AutoDevBundle_en.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,4 @@ planner.action.accept.changes=Accept
203203
planner.error.no.file=No {0} file
204204
planner.error.no.after.file=No after file
205205
planner.error.create.file=Create file error {0}
206+
sketch.plan.rerun.task=Help me fix this failed task:

core/src/main/resources/messages/AutoDevBundle_zh.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,4 @@ planner.action.accept.changes=Accept
196196
planner.error.no.file=没有文件 {0}
197197
planner.error.no.after.file=No after file
198198
planner.error.create.file=Create file error {0}
199-
199+
sketch.plan.rerun.task=Help me fix this failed task:

0 commit comments

Comments
 (0)