Skip to content

Commit adedbec

Browse files
author
Rankin Zheng
committed
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.
1 parent 6a8393e commit adedbec

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

src/contributes/commands.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,16 @@ export function registerInstallCommandsCommand(
208208
if (!fs.existsSync(sysDirPath)) {
209209
// Directory does not exist, wait for updateWorkflows to finish
210210
await dcClient.updateWorkflows();
211+
await dcClient.updateCustomWorkflows();
211212
sendCommandListByDevChatRun();
212213
} else {
213214
// Directory exists, execute sendCommandListByDevChatRun immediately
214215
await sendCommandListByDevChatRun();
215216

216217
// Then asynchronously execute updateWorkflows
217218
await dcClient.updateWorkflows();
219+
await dcClient.updateCustomWorkflows();
220+
218221
await sendCommandListByDevChatRun();
219222
}
220223
}

src/handler/handlerRegister.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { insertCodeBlockToFile } from './codeBlockHandler';
33
import { replaceCodeBlockToFile } from './codeBlockHandler';
44
import { doCommit } from './commitHandler';
55
import { getHistoryMessages } from './historyMessagesHandler';
6-
import { handleRegCommandList } from './workflowCommandHandler';
6+
import { handleRegCommandList,handleUpdateWorkflowList } from './workflowCommandHandler';
77
import { sendMessage, stopDevChat, regeneration, deleteChatMessage, userInput } from './sendMessage';
88
import { applyCodeWithDiff } from './diffHandler';
99
import { addConext } from './contextHandler';
@@ -37,6 +37,7 @@ messageHandler.registerHandler('historyMessages', getHistoryMessages);
3737
// Register the command list
3838
// Response: { command: 'regCommandList', result: <command list> }
3939
messageHandler.registerHandler('regCommandList', handleRegCommandList);
40+
messageHandler.registerHandler('updateWorkflowList', handleUpdateWorkflowList);
4041
// Send a message, send the message entered by the user to AI
4142
// Response:
4243
// { command: 'receiveMessagePartial', text: <response message text>, user: <user>, date: <date> }
@@ -82,3 +83,5 @@ messageHandler.registerHandler('getIDEServicePort', getIDEServicePort);
8283

8384
messageHandler.registerHandler('readServerConfigBase', readServerConfigBase);
8485
messageHandler.registerHandler('writeServerConfigBase', writeServerConfigBase);
86+
87+

src/handler/workflowCommandHandler.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,13 @@ export async function sendCommandListByDevChatRun() {
5858
await getWorkflowCommandList({}, existPannel!);
5959
}
6060
}
61+
62+
export async function handleUpdateWorkflowList(){
63+
64+
const dcClient = new DevChatClient();
65+
66+
await dcClient.updateWorkflows();
67+
await dcClient.updateCustomWorkflows();
68+
69+
await sendCommandListByDevChatRun();
70+
}

src/toolwrapper/devchatClient.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,19 @@ export class DevChatClient {
229229
);
230230
}
231231

232+
@timeThis
233+
@catchAndReturn(undefined)
234+
async updateCustomWorkflows(): Promise<void> {
235+
const response = await this._post("/workflows/custom_update");
236+
logger
237+
.channel()
238+
?.trace(
239+
`updateCustomWorkflows response data: \n${JSON.stringify(
240+
response.data
241+
)}`
242+
);
243+
}
244+
232245
@timeThis
233246
async message(
234247
message: ChatRequest,

0 commit comments

Comments
 (0)