@@ -9,6 +9,7 @@ import cc.unitmesh.devti.language.psi.DevInVisitor
9
9
import cc.unitmesh.devti.provider.ContextPrompter
10
10
import cc.unitmesh.devti.util.parser.Code
11
11
import com.intellij.execution.process.ProcessEvent
12
+ import com.intellij.openapi.application.runInEdt
12
13
import com.intellij.openapi.application.runReadAction
13
14
import com.intellij.openapi.components.Service
14
15
import com.intellij.openapi.components.service
@@ -58,7 +59,9 @@ class DevInsProcessProcessor(val project: Project) {
58
59
val code = Code .parse(conversationService.getLlmResponse(scriptPath))
59
60
val isDevInCode = code.language == DevInLanguage .INSTANCE
60
61
if (isDevInCode) {
61
- executeTask(DevInFile .fromString(project, code.text))
62
+ runInEdt {
63
+ executeTask(DevInFile .fromString(project, code.text))
64
+ }
62
65
}
63
66
64
67
when {
@@ -88,11 +91,13 @@ class DevInsProcessProcessor(val project: Project) {
88
91
val compiledResult = DevInsCompiler (project, newScript).compile()
89
92
val prompt = compiledResult.output
90
93
91
- sendToChatWindow(project, ChatActionType .CHAT ) { panel, service ->
92
- service.handlePromptAndResponse(panel, object : ContextPrompter () {
93
- override fun displayPrompt (): String = prompt
94
- override fun requestPrompt (): String = prompt
95
- }, null , true )
94
+ if (compiledResult.hasError) {
95
+ sendToChatWindow(project, ChatActionType .CHAT ) { panel, service ->
96
+ service.handlePromptAndResponse(panel, object : ContextPrompter () {
97
+ override fun displayPrompt (): String = prompt
98
+ override fun requestPrompt (): String = prompt
99
+ }, null , true )
100
+ }
96
101
}
97
102
}
98
103
0 commit comments