Skip to content

Commit c4a9257

Browse files
committed
feat: Update workflow installation and log event handling
- Enhance workflow installation logic with version checks - Modify copyResourceDirToPath to support overwriting - Refine log event request handling in Agent class
1 parent 1c49b33 commit c4a9257

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/main/kotlin/ai/devchat/plugin/DevChatToolWindowFactory.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,12 @@ private suspend fun setupPython(envManager: PythonEnvManager, devChatService: De
209209
private suspend fun installWorkflows() {
210210
Log.info("Start checking and copying workflows files")
211211
val workflowMericoDir = File(PathUtils.workflowMericoPath)
212+
var update_public_workflows = CONFIG["update_public_workflow"]
213+
val overwrite = devChatVersion != DevChatState.instance.lastVersion
212214

213-
if (!workflowMericoDir.exists() || !workflowMericoDir.isDirectory || workflowMericoDir.listFiles()?.isEmpty() == true) {
215+
if ((overwrite && update_public_workflows == false) || !workflowMericoDir.exists() || !workflowMericoDir.isDirectory || workflowMericoDir.listFiles()?.isEmpty() == true) {
214216
Log.info("Workflow Merico directory is missing or empty. Creating and populating it.")
215-
PathUtils.copyResourceDirToPath("/workflows", PathUtils.workflowPath)
217+
PathUtils.copyResourceDirToPath("/workflows", PathUtils.workflowPath, true)
216218
} else {
217219
Log.info("Workflow Merico directory exists and is not empty. Skipping copy.")
218220
}

src/main/kotlin/ai/devchat/plugin/completion/agent/Agent.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Agent(val scope: CoroutineScope) {
8080
@SerializedName("llm_time") val llmRequestElapse: Long,
8181
@SerializedName("model") val model: String? = null,
8282
@SerializedName("cache_hit") val cacheHit: Boolean = false,
83-
@SerializedName("is_manual_trigger") var isManualTrigger: Boolean = false
83+
@SerializedName("is_manual_trigger") val isManualTrigger: Boolean = false,
8484
) {
8585
enum class EventType {
8686
@SerializedName("view") VIEW,
@@ -340,8 +340,11 @@ private fun requestDevChatAPI(prompt: String): Flow<CodeCompletionChunk> = flow
340340
"command" to "logEvent",
341341
"id" to logEventRequest.completionId,
342342
"language" to logEventRequest.language,
343-
"name" to logEventRequest.type,
344-
"value" to logEventRequest
343+
"name" to when(logEventRequest.type) {
344+
LogEventRequest.EventType.VIEW -> "view"
345+
LogEventRequest.EventType.SELECT -> "select"
346+
},
347+
"value" to gson.toJson(logEventRequest)
345348
)
346349

347350
// 使用 Browser 类的 sendToWebView 方法发送消息

0 commit comments

Comments
 (0)