From adedbec510f0d50ae49ce69b032ca7568b45b135 Mon Sep 17 00:00:00 2001 From: Rankin Zheng Date: Mon, 26 Aug 2024 18:31:03 +0800 Subject: [PATCH] feat(workflow): update custom workflows asynchronously Modify the workflow update mechanism to include asynchronous updates for custom workflows in addition to the standard workflows. This ensures that both default and custom workflows are updated efficiently, improving the overall functionality and user experience within the DevChat environment. BREAKING CHANGE: Custom workflow updates now occur asynchronously alongside standard workflow updates. This may affect downstream systems that rely on synchronous workflow updates. Systems should now handle the asynchronous nature of custom workflow updates. --- src/contributes/commands.ts | 3 +++ src/handler/handlerRegister.ts | 5 ++++- src/handler/workflowCommandHandler.ts | 10 ++++++++++ src/toolwrapper/devchatClient.ts | 13 +++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/contributes/commands.ts b/src/contributes/commands.ts index 46bb95f..83f5056 100644 --- a/src/contributes/commands.ts +++ b/src/contributes/commands.ts @@ -208,6 +208,7 @@ export function registerInstallCommandsCommand( if (!fs.existsSync(sysDirPath)) { // Directory does not exist, wait for updateWorkflows to finish await dcClient.updateWorkflows(); + await dcClient.updateCustomWorkflows(); sendCommandListByDevChatRun(); } else { // Directory exists, execute sendCommandListByDevChatRun immediately @@ -215,6 +216,8 @@ export function registerInstallCommandsCommand( // Then asynchronously execute updateWorkflows await dcClient.updateWorkflows(); + await dcClient.updateCustomWorkflows(); + await sendCommandListByDevChatRun(); } } diff --git a/src/handler/handlerRegister.ts b/src/handler/handlerRegister.ts index 12545cf..c7e3ac8 100644 --- a/src/handler/handlerRegister.ts +++ b/src/handler/handlerRegister.ts @@ -3,7 +3,7 @@ import { insertCodeBlockToFile } from './codeBlockHandler'; import { replaceCodeBlockToFile } from './codeBlockHandler'; import { doCommit } from './commitHandler'; import { getHistoryMessages } from './historyMessagesHandler'; -import { handleRegCommandList } from './workflowCommandHandler'; +import { handleRegCommandList,handleUpdateWorkflowList } from './workflowCommandHandler'; import { sendMessage, stopDevChat, regeneration, deleteChatMessage, userInput } from './sendMessage'; import { applyCodeWithDiff } from './diffHandler'; import { addConext } from './contextHandler'; @@ -37,6 +37,7 @@ messageHandler.registerHandler('historyMessages', getHistoryMessages); // Register the command list // Response: { command: 'regCommandList', result: } messageHandler.registerHandler('regCommandList', handleRegCommandList); +messageHandler.registerHandler('updateWorkflowList', handleUpdateWorkflowList); // Send a message, send the message entered by the user to AI // Response: // { command: 'receiveMessagePartial', text: , user: , date: } @@ -82,3 +83,5 @@ messageHandler.registerHandler('getIDEServicePort', getIDEServicePort); messageHandler.registerHandler('readServerConfigBase', readServerConfigBase); messageHandler.registerHandler('writeServerConfigBase', writeServerConfigBase); + + diff --git a/src/handler/workflowCommandHandler.ts b/src/handler/workflowCommandHandler.ts index c886116..b5b0792 100644 --- a/src/handler/workflowCommandHandler.ts +++ b/src/handler/workflowCommandHandler.ts @@ -58,3 +58,13 @@ export async function sendCommandListByDevChatRun() { await getWorkflowCommandList({}, existPannel!); } } + +export async function handleUpdateWorkflowList(){ + + const dcClient = new DevChatClient(); + + await dcClient.updateWorkflows(); + await dcClient.updateCustomWorkflows(); + + await sendCommandListByDevChatRun(); +} \ No newline at end of file diff --git a/src/toolwrapper/devchatClient.ts b/src/toolwrapper/devchatClient.ts index a599ccd..2b65fc3 100644 --- a/src/toolwrapper/devchatClient.ts +++ b/src/toolwrapper/devchatClient.ts @@ -229,6 +229,19 @@ export class DevChatClient { ); } + @timeThis + @catchAndReturn(undefined) + async updateCustomWorkflows(): Promise { + const response = await this._post("/workflows/custom_update"); + logger + .channel() + ?.trace( + `updateCustomWorkflows response data: \n${JSON.stringify( + response.data + )}` + ); + } + @timeThis async message( message: ChatRequest,