Skip to content

Commit b07bc69

Browse files
committed
feat(core): add create issue functionality in AutoDev Planner #352
- Add CreateIssueAction to initiate issue creation process - Implement issue input panel in AutoDevPlannerToolWindowFactory - Update autodev-core.xml to include new CreateIssue action - Add new icons for edit task and input actions - Update messages properties for new create issue feature
1 parent 0ef94a6 commit b07bc69

File tree

10 files changed

+154
-8
lines changed

10 files changed

+154
-8
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,10 @@
425425
<group id="AutoDevPlanner.ToolWindow.TitleActions">
426426
<action id="ReviewPlan" icon="cc.unitmesh.devti.AutoDevIcons.REVIEWER"
427427
class="cc.unitmesh.devti.observer.plan.PlanReviewAction"/>
428-
<action id="EditPlan" icon="cc.unitmesh.devti.AutoDevIcons.EDIT"
428+
<action id="EditPlan" icon="cc.unitmesh.devti.AutoDevIcons.EDIT_TASK"
429429
class="cc.unitmesh.devti.observer.plan.EditPlanAction"/>
430+
<action id="CreateIssue" icon="cc.unitmesh.devti.AutoDevIcons.INPUT"
431+
class="cc.unitmesh.devti.observer.plan.CreateIssueAction"/>
430432
<separator/>
431433
</group>
432434
</actions>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,10 @@
428428
<group id="AutoDevPlanner.ToolWindow.TitleActions">
429429
<action id="ReviewPlan" icon="cc.unitmesh.devti.AutoDevIcons.REVIEWER"
430430
class="cc.unitmesh.devti.observer.plan.PlanReviewAction"/>
431-
<action id="EditPlan" icon="cc.unitmesh.devti.AutoDevIcons.EDIT"
431+
<action id="EditPlan" icon="cc.unitmesh.devti.AutoDevIcons.EDIT_TASK"
432432
class="cc.unitmesh.devti.observer.plan.EditPlanAction"/>
433+
<action id="CreateIssue" icon="cc.unitmesh.devti.AutoDevIcons.INPUT"
434+
class="cc.unitmesh.devti.observer.plan.CreateIssueAction"/>
433435
<separator/>
434436
</group>
435437
</actions>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ object AutoDevIcons {
7272
val PLANNER: Icon = IconLoader.getIcon("/icons/planner.svg", AutoDevIcons::class.java)
7373

7474
@JvmField
75-
val EDIT: Icon = IconLoader.getIcon("/icons/edit.svg", AutoDevIcons::class.java)
75+
val EDIT_TASK: Icon = IconLoader.getIcon("/icons/edit-task.svg", AutoDevIcons::class.java)
7676

7777
@JvmField
7878
val RULE: Icon = IconLoader.getIcon("/icons/rule.svg", AutoDevIcons::class.java)
@@ -82,4 +82,7 @@ object AutoDevIcons {
8282

8383
@JvmField
8484
val CHECK: Icon = IconLoader.getIcon("/icons/check.svg", AutoDevIcons::class.java)
85+
86+
@JvmField
87+
val INPUT: Icon = IconLoader.getIcon("/icons/input.svg", AutoDevIcons::class.java)
8588
}

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

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ import java.awt.BorderLayout
3333
import javax.swing.JPanel
3434
import javax.swing.JButton
3535
import javax.swing.Box
36+
import javax.swing.JTextArea
37+
import javax.swing.JLabel
38+
import java.awt.Dimension
3639
import java.util.concurrent.atomic.AtomicBoolean
3740

3841
class AutoDevPlannerToolWindowFactory : ToolWindowFactory, ToolWindowManagerListener, DumbAware {
@@ -75,16 +78,20 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
7578
private var markdownEditor: MarkdownLanguageField? = null
7679
private val contentPanel = JPanel(BorderLayout())
7780
private var isEditorMode = false
81+
private var isIssueInputMode = false
7882
private var currentCallback: ((String) -> Unit)? = null
83+
private var issueInputCallback: ((String) -> Unit)? = null
7984
private val planPanel: JPanel by lazy { createPlanPanel() }
85+
private val issueInputPanel: JPanel by lazy { createIssueInputPanel() }
86+
private var issueTextArea: JTextArea? = null
8087

8188
init {
8289
contentPanel.add(planPanel, BorderLayout.CENTER)
8390
add(contentPanel, BorderLayout.CENTER)
8491

8592
connection.subscribe(PlanUpdateListener.TOPIC, object : PlanUpdateListener {
8693
override fun onPlanUpdate(items: MutableList<AgentTaskEntry>) {
87-
if (!isEditorMode) {
94+
if (!isEditorMode && !isIssueInputMode) {
8895
runInEdt {
8996
planLangSketch.updatePlan(items)
9097
}
@@ -109,8 +116,61 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
109116
}
110117
}
111118

119+
private fun createIssueInputPanel(): JPanel {
120+
val panel = JPanel(BorderLayout())
121+
panel.border = JBUI.Borders.empty(10)
122+
panel.background = JBUI.CurrentTheme.ToolWindow.background()
123+
124+
val headerLabel = JLabel("Enter Issue Description").apply {
125+
font = font.deriveFont(font.size + 2f)
126+
border = JBUI.Borders.emptyBottom(10)
127+
}
128+
129+
issueTextArea = JTextArea().apply {
130+
lineWrap = true
131+
wrapStyleWord = true
132+
border = JBUI.Borders.empty(5)
133+
text = ""
134+
rows = 15
135+
}
136+
137+
val scrollPane = JBScrollPane(issueTextArea).apply {
138+
preferredSize = Dimension(400, 300)
139+
}
140+
141+
val buttonPanel = JPanel(BorderLayout())
142+
val buttonsBox = Box.createHorizontalBox().apply {
143+
add(JButton("Generate Tasks").apply {
144+
addActionListener {
145+
val issueText = issueTextArea?.text ?: ""
146+
if (issueText.isNotBlank()) {
147+
issueInputCallback?.invoke(issueText)
148+
switchToPlanView()
149+
}
150+
}
151+
})
152+
add(Box.createHorizontalStrut(10))
153+
add(JButton("Cancel").apply {
154+
addActionListener {
155+
switchToPlanView()
156+
}
157+
})
158+
}
159+
buttonPanel.add(buttonsBox, BorderLayout.EAST)
160+
buttonPanel.border = JBUI.Borders.emptyTop(10)
161+
162+
panel.add(headerLabel, BorderLayout.NORTH)
163+
panel.add(scrollPane, BorderLayout.CENTER)
164+
panel.add(buttonPanel, BorderLayout.SOUTH)
165+
166+
return panel
167+
}
168+
112169
private fun switchToEditorView() {
113170
if (isEditorMode) return
171+
if (isIssueInputMode) {
172+
isIssueInputMode = false
173+
}
114174

115175
if (markdownEditor == null) {
116176
markdownEditor = MarkdownLanguageField(project, content, "Edit your plan here...", "plan.md")
@@ -152,6 +212,22 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
152212

153213
isEditorMode = true
154214
}
215+
216+
private fun switchToIssueInputView() {
217+
if (isIssueInputMode) return
218+
if (isEditorMode) {
219+
isEditorMode = false
220+
}
221+
222+
contentPanel.removeAll()
223+
contentPanel.add(issueInputPanel, BorderLayout.CENTER)
224+
contentPanel.revalidate()
225+
contentPanel.repaint()
226+
227+
isIssueInputMode = true
228+
issueTextArea?.text = ""
229+
issueTextArea?.requestFocus()
230+
}
155231

156232
fun switchToPlanView(newContent: String? = null) {
157233
if (newContent != null && newContent != content) {
@@ -167,10 +243,12 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
167243
contentPanel.repaint()
168244

169245
isEditorMode = false
246+
isIssueInputMode = false
170247
}
171248

172249
override fun dispose() {
173250
markdownEditor = null
251+
issueTextArea = null
174252
}
175253

176254
companion object {
@@ -192,6 +270,21 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
192270
}
193271
}
194272
}
273+
274+
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
280+
281+
plannerWindow?.let {
282+
it.issueInputCallback = callback
283+
it.switchToIssueInputView()
284+
toolWindow.show()
285+
}
286+
}
287+
}
195288
}
196289
}
197290

@@ -229,4 +322,3 @@ private class MarkdownLanguageField(
229322
}
230323
}
231324
}
232-
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package cc.unitmesh.devti.observer.plan
2+
3+
import cc.unitmesh.devti.AutoDevBundle
4+
import cc.unitmesh.devti.gui.AutoDevPlannerToolWindow
5+
import com.intellij.openapi.actionSystem.ActionUpdateThread
6+
import com.intellij.openapi.actionSystem.AnAction
7+
import com.intellij.openapi.actionSystem.AnActionEvent
8+
9+
class CreateIssueAction : AnAction(AutoDevBundle.message("sketch.plan.create")) {
10+
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT
11+
12+
override fun actionPerformed(event: AnActionEvent) {
13+
val project = event.project ?: return
14+
AutoDevPlannerToolWindow.showIssueInput(project) { newPlan ->
15+
// todo
16+
}
17+
}
18+
}
Lines changed: 14 additions & 0 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 13 additions & 0 deletions
Loading

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,5 @@ sketch.terminal.show.hide=Show or hide the terminal
187187
chat.panel.clear.all=Clear all
188188
chat.panel.clear.all.tooltip=Clear all files
189189
chat.panel.select.files=Please double-click to select file to insert into input box
190-
sketch.plan.execute.tooltip=Execute task
190+
sketch.plan.execute.tooltip=Execute task
191+
sketch.plan.create=Create issue

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,4 @@ chat.panel.clear.all=Clear All
181181
chat.panel.clear.all.tooltip=清除所有文件
182182
chat.panel.select.files=请双击选择文件,以放到输入框内
183183
sketch.plan.execute.tooltip=Execute task
184+
sketch.plan.create=Create issue

0 commit comments

Comments
 (0)