Refactor code diff apply message flow

This commit is contained in:
Luo Tim 2024-06-07 16:36:00 +08:00
parent 2c01f5c5ba
commit 85c9860719
3 changed files with 12 additions and 5 deletions

View File

@ -9,11 +9,7 @@ class APIUtil {
constructor() {
window.onCodeDiffApply = () => {
const e = 'code_diff_apply'
this.createEvent({name: e, value: e})
};
console.log("Registered onCodeDiffApply");
console.log("APIUtil ready");
}
public static getInstance(): APIUtil {

View File

@ -329,6 +329,9 @@ class IdeaBridge {
case "updateSetting/response":
this.resviceUpdateSetting(res);
break;
case "codeDiffApply/response":
this.resviceCodeDiffApply(res);
break;
case "sendUserMessage/response":
this.resviceSendUserMessage(res);
break;
@ -377,6 +380,10 @@ class IdeaBridge {
this.executeHandlers("updateSetting", res.payload);
}
resviceCodeDiffApply(res) {
this.executeHandlers("codeDiffApply", res.payload);
}
resviceSendUserMessage(res) {
this.executeHandlers("chatWithDevChat", {
command: "chatWithDevChat",

View File

@ -174,6 +174,10 @@ export const ChatStore = types
self.currentMessage = "";
const config = getParent<RootInstance>(self).config
const chatModel = config.getDefaultModel();
messageUtil.registerHandler("codeDiffApply", (_: any) => {
const e = 'code_diff_apply'
APIUtil.createEvent({name: e, value: e})
})
messageUtil.sendMessage({
command: "sendMessage",
text: text,