Skip to content

Commit b7d6b2a

Browse files
committed
fix(ui): change error notification to warning for empty patches
Update the notification type from error to warning when no valid patches are found. This provides a less severe user feedback for non-critical issues.
1 parent 8199655 commit b7d6b2a

File tree

4 files changed

+104
-47
lines changed

4 files changed

+104
-47
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class DiffLangSketch(private val myProject: Project, private var patchContent: S
6060
ApplicationManager.getApplication().invokeLater {
6161
if (filePatches.isEmpty()) {
6262
val msg = "PatchProcessor: no valid patches found, please check the patch content"
63-
AutoDevNotifications.error(myProject, msg)
63+
AutoDevNotifications.warn(myProject, msg)
6464

6565
val repairButton = JButton("Repair").apply {
6666
icon = AllIcons.Actions.IntentionBulb
@@ -82,7 +82,8 @@ class DiffLangSketch(private val myProject: Project, private var patchContent: S
8282

8383
mainPanel.add(actionPanel)
8484

85-
return@invokeLater }
85+
return@invokeLater
86+
}
8687

8788
filePatches.forEachIndexed { _, patch ->
8889
val diffPanel = when {

docs/development/agentic-testcase.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
layout: default
3+
title: Agentic Testcase
4+
nav_order: 998
5+
parent: Development
6+
---
7+
8+
## AutoDev Sketch
9+
10+
### Alpha 1
11+
12+
- git 如何 merge branch。
13+
- 添加删除博客
14+
```devin
15+
/file:src/main/java/cc/unitmesh/untitled/demo/controller/BlogController.java
16+
/file:src/main/java/cc/unitmesh/untitled/demo/service/BlogService.java
17+
/file:src/main/java/cc/unitmesh/untitled/demo/repository/BlogRepository.java
18+
```
19+
- 添加根据作者删除博客
20+
- 给 Blogpost 添加 category 的功能,并支持按 category 获取所有的 blog
21+
```devin
22+
/file:src/main/java/cc/unitmesh/untitled/demo/controller/BlogController.java
23+
/file:src/main/java/cc/unitmesh/untitled/demo/service/BlogService.java
24+
/file:src/main/java/cc/unitmesh/untitled/demo/repository/BlogRepository.java
25+
```
26+
- 采用 DDD,生成对应的 ApplicationService 和 DomainService
27+
```devin
28+
/file:src/main/java/cc/unitmesh/untitled/demo/service/BlogService.java
29+
/file:src/main/java/cc/unitmesh/untitled/demo/repository/BlogRepository.java
30+
```
31+
32+
### Alpha 2
33+
34+
- 采用 DDD + 充血模型,重构 Blog 功能
35+
- Gradle 启动Spring boot 应用的 bash 代码
36+
- 获取最近两周的代码提交,生成发布日志
37+
- 针对代码变更,生成测试
38+
39+
### Multiple-Language
40+
41+
- 使用 patch 的方式添加 vue router
42+
- 使用 patch 的方式添加 Element UI
43+
- 生成 OpenAPI Yaml 示例,使用 markdown yaml 返回
44+
- 编写 go hello world,使用 markdown go 语言返回(不使用 write 等 DevIns 指令)
45+
- 我在为当前项目创建 OpenAPI 3.0 spec,编写一个基本的 swagger yaml 骨架,方便我学习。只返回 swagger yaml,不使用 devins
46+
- 根据如下 Vue 数据结构,设计重构策略:
47+
```devin
48+
/structure:src/components/Custom/DataSelect.vue
49+
```
50+
- 结合行号,使用 file 指令选择合适的“代码段”来查看代码。由于代码太长,你只能选择一小段。
51+
- 我只想要一个生成 Vite + Jest 的 package.json 示例,再添加 axios、jszip的依赖。
52+
53+
## AutoDev Bridge
54+
55+
### 切换数据库到 MongoDB
56+
57+
### Vue2 迁移到 Vue 3
58+
59+
### Spring Boot to micronaut migration
60+
61+
Spring Boot to micronaut migration
62+
```devin
63+
/dependencies
64+
/scc
65+
/containerView
66+
/dir:src
67+
/ripgrepSearch:JdbcTemplate
68+
/database:schema
69+
```
70+
71+
### 使用 Node.js 重写当前项目
72+
73+
如下是当前项目的 APIs
74+
```devin
75+
/webApiView
76+
```

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/DirInsCommand.kt

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,12 @@ import cc.unitmesh.devti.devin.InsCommand
44
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand
55
import cc.unitmesh.devti.language.utils.lookupFile
66
import com.intellij.openapi.application.runReadAction
7-
import com.intellij.openapi.progress.ProgressIndicator
8-
import com.intellij.openapi.progress.ProgressManager
9-
import com.intellij.openapi.progress.Task
10-
import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator
117
import com.intellij.openapi.project.Project
12-
import com.intellij.openapi.roots.ProjectFileIndex
138
import com.intellij.openapi.util.text.StringUtilRt
149
import com.intellij.openapi.vcs.FileStatus
1510
import com.intellij.openapi.vcs.FileStatusManager
16-
import com.intellij.openapi.vfs.VirtualFile
1711
import com.intellij.psi.PsiDirectory
1812
import com.intellij.psi.PsiManager
19-
import java.util.concurrent.CompletableFuture
20-
import java.util.regex.Pattern
2113

2214

2315
/**
@@ -47,50 +39,25 @@ import java.util.regex.Pattern
4739
*/
4840
class DirInsCommand(private val myProject: Project, private val dir: String) : InsCommand {
4941
override val commandName: BuiltinCommand = BuiltinCommand.DIR
50-
private val HASH_FILE_PATTERN: Pattern = Pattern.compile(
51-
"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(?:\\.json|@[0-9a-f]+\\.json)$",
52-
Pattern.CASE_INSENSITIVE
53-
)
54-
55-
fun isHashJson(file: VirtualFile?): Boolean {
56-
return file != null && HASH_FILE_PATTERN.matcher(file.name).matches()
57-
}
42+
private val defaultMaxDepth = 2
5843

5944
private val output = StringBuilder()
60-
private val maxLength = 2
6145

6246
override suspend fun execute(): String? {
6347
val virtualFile = myProject.lookupFile(dir) ?: return "File not found: $dir"
64-
val future = CompletableFuture<String>()
65-
val task = object : Task.Backgroundable(myProject, "Processing context", false) {
66-
override fun run(indicator: ProgressIndicator) {
67-
val psiDirectory = runReadAction {
68-
PsiManager.getInstance(myProject!!).findDirectory(virtualFile)
69-
}
70-
71-
if (psiDirectory == null) {
72-
future.complete("Directory not found: $dir")
73-
return
74-
}
75-
76-
output.appendLine("$dir/")
77-
runReadAction { listDirectory(myProject!!, psiDirectory, 1) }
78-
future.complete(
79-
"Here is the directory tree (depth = 2) for $dir:\n$output"
80-
)
81-
}
82-
}
48+
val psiDirectory = PsiManager.getInstance(myProject).findDirectory(virtualFile) ?: return null
8349

84-
ProgressManager.getInstance()
85-
.runProcessWithProgressAsynchronously(task, BackgroundableProcessIndicator(task))
50+
output.appendLine("$dir/")
51+
runReadAction { listDirectory(myProject, psiDirectory, 1) }
8652

87-
return future.get()
53+
return output.toString()
8854
}
8955

9056
private fun listDirectory(project: Project, directory: PsiDirectory, depth: Int) {
91-
if (depth > maxLength || isExclude(project, directory)) return
57+
if(isExclude(project, directory)) return
58+
if (depth > defaultMaxDepth && !shouldContinueForPath(directory)) return
9259

93-
val files = directory.files.filter { !it.fileType.isBinary && !isHashJson(it.virtualFile) }
60+
val files = directory.files
9461
val subdirectories = directory.subdirectories
9562

9663
val items = files.map { it.name to StringUtilRt.formatFileSize(it.virtualFile.length) } +
@@ -103,11 +70,24 @@ class DirInsCommand(private val myProject: Project, private val dir: String) : I
10370
}
10471
}
10572

73+
/// todo: replace to intellij source content dir
74+
private fun shouldContinueForPath(directory: PsiDirectory): Boolean {
75+
// 如果是 src 目录,检查是否是单路径结构
76+
if (directory.name == "src" || directory.parent?.name == "src") {
77+
val subdirs = directory.subdirectories
78+
// 对于只有一个子目录的情况,继续遍历
79+
return subdirs.size == 1
80+
}
81+
return false
82+
}
83+
10684
private fun isExclude(project: Project, directory: PsiDirectory): Boolean {
107-
if (directory.name == ".idea") return true
85+
if (directory.name == ".idea" ||
86+
directory.name == "build" ||
87+
directory.name == "target" ||
88+
directory.name == "node_modules") return true
10889

10990
val status = FileStatusManager.getInstance(project).getStatus(directory.virtualFile)
11091
return status == FileStatus.IGNORED
11192
}
11293
}
113-
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
List the contents of a directory up to a depth of 2 (the default depth)
1+
列出目录内容,默认深度为2,支持智能深度处理(单路径结构自动深入遍历,适合Java等层级深的结构,自动排除二进制文件、.idea目录和被版本控制系统忽略的文件)。
22
/dir:.
3-
If navigating deeper, list contents up to a depth of 2 for each selected directory:
3+
列出特定目录:
44
/dir:src/components

0 commit comments

Comments
 (0)