Skip to content

Commit 8fc0567

Browse files
committed
feat(devin): update disable /write in sketch and use patch only #352
- Change /write command to /patch for existing files in sketch templates - Update BuiltinCommand to set enableInSketch = false for /write command
1 parent 425167e commit 8fc0567

File tree

4 files changed

+36
-35
lines changed

4 files changed

+36
-35
lines changed

core/src/main/kotlin/cc/unitmesh/devti/devin/dataprovider/BuiltinCommand.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ enum class BuiltinCommand(
4747
"Write content to a file with markdown code block, /write:path/to/file:L1-L2",
4848
AllIcons.Actions.Edit,
4949
true,
50-
true
50+
true,
51+
enableInSketch = false
5152
),
5253
PATCH(
5354
"patch",

core/src/main/kotlin/cc/unitmesh/devti/gui/planner/LoadingPanel.kt

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package cc.unitmesh.devti.gui.planner
22

33
import com.intellij.ide.ui.LafManagerListener
44
import com.intellij.openapi.project.Project
5-
import com.intellij.util.ui.StartupUiUtil.isDarkTheme
5+
import com.intellij.util.ui.JBUI
66
import java.awt.*
77
import java.awt.event.ActionEvent
88
import java.awt.event.ActionListener
@@ -52,6 +52,8 @@ class LoadingPanel(val project: Project) : JPanel() {
5252
private val darkProgressBackground = Color(55, 65, 81)
5353

5454
init {
55+
val isDarkTheme = UIManager.getLookAndFeelDefaults().getBoolean("ui.theme.is.dark")
56+
5557
isDarkMode = isDarkTheme
5658
project.messageBus.connect().subscribe(
5759
LafManagerListener.TOPIC,
@@ -63,7 +65,7 @@ class LoadingPanel(val project: Project) : JPanel() {
6365
)
6466

6567
setLayout(BorderLayout())
66-
setBorder(EmptyBorder(20, 20, 20, 20))
68+
setBorder(JBUI.Borders.empty(20))
6769
setOpaque(false)
6870

6971
glassPanel = object : JPanel(BorderLayout()) {
@@ -75,33 +77,29 @@ class LoadingPanel(val project: Project) : JPanel() {
7577
val width = getWidth()
7678
val height = getHeight()
7779

78-
79-
// Create rounded rectangle for the panel
8080
val roundedRect: RoundRectangle2D =
8181
RoundRectangle2D.Float(0f, 0f, width.toFloat(), height.toFloat(), 15f, 15f)
82-
g2d.setClip(roundedRect)
82+
g2d.clip = roundedRect
8383

8484
val color1 = if (isDarkMode) Color(30, 40, 70, 200) else Color(240, 245, 255, 200)
8585
val color2 = if (isDarkMode) Color(40, 30, 70, 200) else Color(245, 240, 255, 200)
86-
val color3 = if (isDarkMode) Color(35, 35, 60, 200) else Color(250, 245, 255, 200)
8786

8887
val pos1 = (gradientPosition) % 1.0f
8988
val pos2 = (gradientPosition + 0.33f) % 1.0f
90-
val pos3 = (gradientPosition + 0.66f) % 1.0f
9189

9290
val gradient = GradientPaint(
9391
width * pos1, 0f, color1,
9492
width * pos2, height.toFloat(), color2
9593
)
9694

97-
g2d.setPaint(gradient)
95+
g2d.paint = gradient
9896
g2d.fill(roundedRect)
9997

100-
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f))
101-
g2d.setColor(Color.WHITE)
98+
g2d.composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f)
99+
g2d.color = Color.WHITE
102100
g2d.fillRect(0, 0, width, height / 2)
103101

104-
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity))
102+
g2d.composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity)
105103
g2d.dispose()
106104
}
107105
}
@@ -111,15 +109,15 @@ class LoadingPanel(val project: Project) : JPanel() {
111109

112110
contentPanel = JPanel(BorderLayout(10, 10))
113111
contentPanel.setOpaque(false)
114-
contentPanel.setBorder(EmptyBorder(15, 15, 15, 15))
112+
contentPanel.setBorder(JBUI.Borders.empty(12))
115113

116114
emojiLabel = JLabel()
117115
emojiLabel.setFont(Font("Segoe UI Emoji", Font.PLAIN, 24))
118116
emojiLabel.setHorizontalAlignment(SwingConstants.CENTER)
119-
emojiLabel.setPreferredSize(Dimension(40, 40))
117+
emojiLabel.preferredSize = Dimension(40, 40)
120118

121119
messagePane = JTextPane()
122-
messagePane.setEditable(false)
120+
messagePane.isEditable = false
123121
messagePane.setOpaque(false)
124122
messagePane.setFont(Font("Monospaced", Font.PLAIN, 14))
125123
messagePane.setBorder(null)
@@ -128,7 +126,7 @@ class LoadingPanel(val project: Project) : JPanel() {
128126
progressBar.setStringPainted(false)
129127
progressBar.setBorderPainted(false)
130128
progressBar.setOpaque(false)
131-
progressBar.setPreferredSize(Dimension(0, 5))
129+
progressBar.preferredSize = Dimension(0, 5)
132130
progressBar.setUI(object : BasicProgressBarUI() {
133131
override fun paintDeterminate(g: Graphics, c: JComponent) {
134132
val g2d = g.create() as Graphics2D
@@ -215,7 +213,7 @@ class LoadingPanel(val project: Project) : JPanel() {
215213
}
216214

217215
private fun updateTypingAnimation() {
218-
val message = loadingMessages.get(messageIndex)
216+
val message = loadingMessages[messageIndex]
219217
val textPart = message.substring(message.indexOf(' ') + 1)
220218

221219
if (charIndex < textPart.length) {
@@ -238,25 +236,25 @@ class LoadingPanel(val project: Project) : JPanel() {
238236
}
239237

240238
private fun updateMessageText() {
241-
val doc = messagePane.getStyledDocument()
239+
val doc = messagePane.styledDocument
242240
val style = messagePane.addStyle("MessageStyle", null)
243241
StyleConstants.setForeground(style, if (isDarkMode) darkForeground else lightForeground)
244242
StyleConstants.setFontFamily(style, "Monospaced")
245243
StyleConstants.setFontSize(style, 14)
246244

247245
try {
248-
doc.remove(0, doc.getLength())
246+
doc.remove(0, doc.length)
249247
doc.insertString(0, currentText, style)
250248

251249
StyleConstants.setForeground(style, progressColor)
252-
doc.insertString(doc.getLength(), "|", style)
250+
doc.insertString(doc.length, "|", style)
253251
} catch (e: BadLocationException) {
254252
e.printStackTrace()
255253
}
256254
}
257255

258256
private fun updateEmojiLabel() {
259-
val message = loadingMessages.get(messageIndex)
257+
val message = loadingMessages[messageIndex]
260258
val emoji = message.substring(0, message.indexOf(' '))
261259
emojiLabel.setText(emoji)
262260
}

core/src/main/resources/genius/en/code/sketch.vm

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ have created a routes.py and main.js file, and updated the main.html file.
129129
// then you can start coding with DevIn language. When you need to or patch, write execute the code, you should use the DevIn language
130130
// If you need to create a new file, you should use `/write` command, then write the code in the code block
131131
<devin>
132-
/write:src/main/route.py [注释:当确定文件不存在时,才能创建文件]
133-
```python
134-
// the route code
135-
// from flask import Flask
132+
/patch:src/main/route.py [注释:当确定文件不存在时,才能创建文件]
133+
```patch
134+
Index: src/main/route.py
135+
// the rest code
136136
```
137137
</devin>
138138
// patch to call tools for step 3 with DevIn language, should use `<devin />` tag with DevIn language
@@ -146,9 +146,10 @@ Index: src/main/index.html
146146
</devin>
147147
// step 4.1, call tools to create test code and run test code
148148
<devin>
149-
/write:src/test/test_routes.py
150-
```python
151-
// the test code
149+
/patch:src/test/test_routes.py
150+
```patch
151+
Index: src/test/test_routes.py
152+
// the rest code
152153
```
153154
</devin>
154155
// step 4.2, run test code

core/src/main/resources/genius/zh/code/sketch.vm

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ say 'I will edit your file'.
105105
# 第一步. 创建 routes.py
106106
我将创建了 routes.py 来定义 "/upload" 和 "/query" 端点。此外,我还添加了 "/" 作为 main.html 的端点。
107107
<devin>
108-
/write:src/main/route.py [注释:当确定文件不存在时,才能创建文件]
109-
```python
110-
// the route code
111-
// from flask import Flask
108+
/patch:src/main/route.py [注释:当确定文件不存在时,才能创建文件]
109+
```patch
110+
Index: src/main/route.py
111+
// the rest code
112112
```
113113
</devin>
114114
# 第二步. 创建 main.js
@@ -130,9 +130,10 @@ Index: src/main/index.html
130130
我将使用 Flask 的测试框架编写自动化测试用例,以确保应用程序的功能正常。
131131
// step 4.1, call tools to create test code and run test code
132132
<devin>
133-
/write:src/test/test_routes.py
134-
```python
135-
// the test code
133+
/patch:src/test/test_routes.py
134+
```patch
135+
Index: src/test/test_routes.py
136+
// the rest code
136137
```
137138
</devin>
138139
现在,你可以执行代码

0 commit comments

Comments
 (0)