Skip to content

Commit 6d20c1a

Browse files
committed
feat(dev-planner): implement issue input functionality and enhance tool window logic #352
- Add conditional rendering of issue input panel based on content - Refactor issue input callback and tool window management - Implement basic functionality for creating issues and sending to sketch tool window - Improve code structure and readability in multiple files
1 parent b07bc69 commit 6d20c1a

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

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

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
8686
private var issueTextArea: JTextArea? = null
8787

8888
init {
89-
contentPanel.add(planPanel, BorderLayout.CENTER)
89+
// Check if there's no plan content and conditionally show the appropriate panel
90+
if (content.isBlank()) {
91+
isIssueInputMode = true
92+
contentPanel.add(issueInputPanel, BorderLayout.CENTER)
93+
} else {
94+
contentPanel.add(planPanel, BorderLayout.CENTER)
95+
}
96+
9097
add(contentPanel, BorderLayout.CENTER)
9198

9299
connection.subscribe(PlanUpdateListener.TOPIC, object : PlanUpdateListener {
@@ -272,17 +279,16 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
272279
}
273280

274281
fun showIssueInput(project: Project, callback: (String) -> Unit) {
275-
val toolWindow =
276-
ToolWindowManager.getInstance(project).getToolWindow(AutoDevPlannerToolWindowFactory.PlANNER_ID)
277-
if (toolWindow != null) {
278-
val content = toolWindow.contentManager.getContent(0)
279-
val plannerWindow = content?.component as? AutoDevPlannerToolWindow
282+
val toolWindow = ToolWindowManager.getInstance(project).getToolWindow(AutoDevPlannerToolWindowFactory.PlANNER_ID)
283+
if (toolWindow == null) return
280284

281-
plannerWindow?.let {
282-
it.issueInputCallback = callback
283-
it.switchToIssueInputView()
284-
toolWindow.show()
285-
}
285+
val content = toolWindow.contentManager.getContent(0)
286+
val plannerWindow = content?.component as? AutoDevPlannerToolWindow
287+
288+
plannerWindow?.let {
289+
it.issueInputCallback = callback
290+
it.switchToIssueInputView()
291+
toolWindow.show()
286292
}
287293
}
288294
}
@@ -322,3 +328,4 @@ private class MarkdownLanguageField(
322328
}
323329
}
324330
}
331+

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ class AutoDevToolWindowFactory : ToolWindowFactory, DumbAware {
138138
runnable: (SketchToolWindow, ChatCodingService) -> Unit,
139139
) {
140140
val chatCodingService = ChatCodingService(actionType, project)
141-
142141
val toolWindowManager = ToolWindowManager.getInstance(project).getToolWindow(AutoDevToolUtil.ID) ?: run {
143142
logger<ChatCodingService>().warn("Tool window not found")
144143
return

core/src/main/kotlin/cc/unitmesh/devti/observer/plan/CreateIssueAction.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package cc.unitmesh.devti.observer.plan
22

33
import cc.unitmesh.devti.AutoDevBundle
44
import cc.unitmesh.devti.gui.AutoDevPlannerToolWindow
5+
import cc.unitmesh.devti.gui.AutoDevToolWindowFactory
6+
import cc.unitmesh.devti.gui.chat.message.ChatActionType
57
import com.intellij.openapi.actionSystem.ActionUpdateThread
68
import com.intellij.openapi.actionSystem.AnAction
79
import com.intellij.openapi.actionSystem.AnActionEvent
@@ -12,7 +14,9 @@ class CreateIssueAction : AnAction(AutoDevBundle.message("sketch.plan.create"))
1214
override fun actionPerformed(event: AnActionEvent) {
1315
val project = event.project ?: return
1416
AutoDevPlannerToolWindow.showIssueInput(project) { newPlan ->
15-
// todo
17+
AutoDevToolWindowFactory.Companion.sendToSketchToolWindow(project, ChatActionType.SKETCH) { ui, _ ->
18+
ui.sendInput(newPlan)
19+
}
1620
}
1721
}
1822
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ class TaskStepPanel(
282282
updateStatusLabel()
283283
onStatusChange()
284284

285-
// Send to AI for execution
286285
AutoDevToolWindowFactory.Companion.sendToSketchToolWindow(project, ChatActionType.SKETCH) { ui, _ ->
287286
ui.sendInput(AutoDevBundle.message("sketch.plan.finish.task") + task.step)
288287
}

0 commit comments

Comments
 (0)