Skip to content

Commit 9985510

Browse files
committed
refactor(devti): optimize UI components and improve functionality
- Remove unnecessary border layouts and wrapper panels - Enhance diff panel creation with file existence checks- Adjust markdown preview styling and add HTML conversion - Improve SQL execution error handling and timeout settings - Update terminal sketch provider to correctly handle terminal commands
1 parent c492fc9 commit 9985510

File tree

10 files changed

+30
-14
lines changed

10 files changed

+30
-14
lines changed

core/src/main/kotlin/cc/unitmesh/devti/sketch/SketchToolWindow.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import cc.unitmesh.devti.sketch.ui.MarkdownPreviewHighlightSketch
1919
import cc.unitmesh.devti.sketch.ui.code.CodeHighlightSketch
2020
import cc.unitmesh.devti.util.AutoDevCoroutineScope
2121
import cc.unitmesh.devti.util.parser.CodeFence
22+
import cc.unitmesh.devti.util.parser.convertMarkdownToHtml
2223
import com.intellij.openapi.Disposable
2324
import com.intellij.openapi.actionSystem.ActionPlaces
2425
import com.intellij.openapi.actionSystem.ActionToolbar

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.intellij.ide.BrowserUtil
77
import com.intellij.lang.Language
88
import com.intellij.openapi.project.Project
99
import com.intellij.ui.dsl.builder.panel
10+
import com.intellij.util.ui.JBUI
1011
import java.awt.event.MouseAdapter
1112
import java.awt.event.MouseEvent
1213
import javax.swing.JComponent
@@ -39,7 +40,7 @@ class MarkdownPreviewHighlightSketch(val project: Project, val text: String) : E
3940
cell(editorPane).fullWidth()
4041
}.resizableRow()
4142
}.apply {
42-
border = javax.swing.BorderFactory.createEmptyBorder(8, 8, 8, 8)
43+
border = JBUI.Borders.empty(0, 8)
4344
}
4445

4546
override fun updateViewText(text: String, complete: Boolean) {
@@ -53,6 +54,10 @@ class MarkdownPreviewHighlightSketch(val project: Project, val text: String) : E
5354
return previewPanel
5455
}
5556

57+
override fun onComplete(code: String) {
58+
println(convertMarkdownToHtml(code))
59+
}
60+
5661
override fun updateLanguage(language: Language?, originLanguage: String?) {}
5762

5863
override fun dispose() {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import com.intellij.openapi.project.Project
44

55
class MarkdownPreviewSketchProvider : LanguageSketchProvider {
66
override fun isSupported(lang: String): Boolean {
7-
return lang.lowercase() == "markdown"
7+
// return lang.lowercase() == "markdown"
8+
return false
89
}
910

1011
override fun create(project: Project, content: String): ExtensionLangSketch = MarkdownPreviewHighlightSketch(project, content)

core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/code/CodeHighlightSketch.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ private fun CodeHighlightSketch.processWriteCommand(currentText: String, fileNam
333333
panel.layout = BoxLayout(panel, BoxLayout.X_AXIS)
334334
panel.add(button)
335335

336-
add(panel, BorderLayout.SOUTH)
336+
add(panel)
337337
}
338338

339339
@RequiresReadLock

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,18 @@ class DiffLangSketch(private val myProject: Project, private var patchContent: S
100100
private fun createDiffPanel(patch: TextFilePatch): SingleFileDiffSketch? {
101101
return when {
102102
patch.beforeFileName != null -> {
103-
val originFile = LightVirtualFile(patch.beforeFileName!!, patch.singleHunkPatchText)
103+
val originFile = myProject.findFile(patch.beforeFileName!!) ?: LightVirtualFile(
104+
patch.beforeFileName!!,
105+
patch.singleHunkPatchText
106+
)
104107
createSingleFileDiffSketch(originFile, patch)
105108
}
106109

107110
patch.afterFileName != null -> {
108-
val virtualFile = LightVirtualFile(patch.afterFileName!!, patch.singleHunkPatchText)
111+
val virtualFile = myProject.findFile(patch.afterFileName!!) ?: LightVirtualFile(
112+
patch.afterFileName!!,
113+
patch.singleHunkPatchText
114+
)
109115
createSingleFileDiffSketch(virtualFile, patch)
110116
}
111117

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,11 @@ class SingleFileDiffSketch(
219219
override fun updateLanguage(language: Language?, originLanguage: String?) {}
220220

221221
override fun onComplete(code: String) {
222-
lintCheckForNewCode(currentFile)
223222
if (isAutoRepair && appliedPatch?.status != ApplyPatchStatus.SUCCESS) {
224223
executeAutoRepair()
225224
}
225+
226+
// lintCheckForNewCode(currentFile)
226227
}
227228

228229
fun lintCheckForNewCode(currentFile: VirtualFile) {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,13 @@ class PlanLangSketch(
101101
viewport.view = contentPanel
102102
}
103103

104-
// Use a wrapper panel to ensure proper scroll behavior
105104
val wrapperPanel = JPanel(BorderLayout())
106105
wrapperPanel.add(scrollPane, BorderLayout.CENTER)
107106
wrapperPanel.background = JBUI.CurrentTheme.ToolWindow.background()
108107

109108
add(wrapperPanel, BorderLayout.CENTER)
110109

111110
minimumSize = Dimension(200, 0)
112-
background = JBUI.CurrentTheme.ToolWindow.background()
113111
}
114112

115113
override fun getExtensionName(): String = "ThoughtPlan"

core/src/main/resources/icons/planner.svg

Lines changed: 1 addition & 1 deletion
Loading

exts/ext-database/src/241/main/kotlin/cc/unitmesh/database/util/SQLExecutor.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ object SQLExecutor {
5858
result = executeSql(project, dataSource, sql) ?: "Error"
5959
}
6060

61+
if (result.trim().isEmpty()) {
62+
result = "ShireError[Database]: No result for $sql"
63+
}
64+
6165
return result
6266
} else {
6367
try {
@@ -147,7 +151,7 @@ object SQLExecutor {
147151
object : com.intellij.database.datagrid.DataRequest.QueryRequest(session, query,
148152
newConstraints(dataSource.dbms), null) {}
149153
messageBus.dataProducer.processRequest(request)
150-
return future.get(5, java.util.concurrent.TimeUnit.SECONDS)
154+
return future.get(30, java.util.concurrent.TimeUnit.SECONDS)
151155
}
152156

153157
private fun createConsole(project: Project, file: LightVirtualFile): JdbcConsole? {

exts/ext-terminal/src/main/kotlin/cc/unitmesh/terminal/sketch/TerminalSketchProvider.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,14 @@ class TerminalSketchProvider : LanguageSketchProvider {
177177
}
178178

179179
override fun onComplete(code: String) {
180-
ApplicationManager.getApplication().invokeLater {
181-
terminalWidget!!.terminalStarter?.sendString(content, false)
182-
}
180+
titleLabel.text = "Terminal - ($content)"
183181
}
184182

185183
override fun onDoneStream(allText: String) {
186184
if (content.lines().size > 1) return
187-
titleLabel.text = "Terminal - ($content)"
185+
ApplicationManager.getApplication().invokeLater {
186+
terminalWidget!!.terminalStarter?.sendString(content, false)
187+
}
188188
}
189189

190190
override fun getComponent(): JComponent = mainPanel!!

0 commit comments

Comments
 (0)