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.
This commit is contained in:
Rankin Zheng 2024-08-26 18:31:03 +08:00
parent 6a8393ed9d
commit adedbec510
4 changed files with 30 additions and 1 deletions

View File

@ -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();
}
}

View File

@ -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: <command list> }
messageHandler.registerHandler('regCommandList', handleRegCommandList);
messageHandler.registerHandler('updateWorkflowList', handleUpdateWorkflowList);
// Send a message, send the message entered by the user to AI
// Response:
// { command: 'receiveMessagePartial', text: <response message text>, user: <user>, date: <date> }
@ -82,3 +83,5 @@ messageHandler.registerHandler('getIDEServicePort', getIDEServicePort);
messageHandler.registerHandler('readServerConfigBase', readServerConfigBase);
messageHandler.registerHandler('writeServerConfigBase', writeServerConfigBase);

View File

@ -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();
}

View File

@ -229,6 +229,19 @@ export class DevChatClient {
);
}
@timeThis
@catchAndReturn(undefined)
async updateCustomWorkflows(): Promise<void> {
const response = await this._post("/workflows/custom_update");
logger
.channel()
?.trace(
`updateCustomWorkflows response data: \n${JSON.stringify(
response.data
)}`
);
}
@timeThis
async message(
message: ChatRequest,