Agent Zero AI framework
Fix branch button only appearing on the first code block/table within a message.
keyboardstaff1d837cc41fce
diff --git a/plugins/chat_branching/extensions/webui/set_messages_after_loop/inject-branch-buttons.js b/plugins/chat_branching/extensions/webui/set_messages_after_loop/inject-branch-buttons.jsindex 892a920af..a0c2a3123 100644--- a/plugins/chat_branching/extensions/webui/set_messages_after_loop/inject-branch-buttons.js+++ b/plugins/chat_branching/extensions/webui/set_messages_after_loop/inject-branch-buttons.js@@ -11,22 +11,22 @@ export default async function injectBranchButtons(context) {for (const { args, result } of context.results) {if (!result?.element || args.no == null) continue;- const bar = result.element.querySelector(".step-action-buttons");- if (!bar || bar.querySelector(".action-fork_right")) continue;-const logNo = args.no;- bar.appendChild(- createActionButton("fork_right", "Branch chat", async () => {- const ctxid = globalThis.getContext?.();- if (!ctxid) throw new Error("No active chat");+ for (const bar of result.element.querySelectorAll(".step-action-buttons")) {+ if (bar.querySelector(".action-fork_right")) continue;+ bar.appendChild(+ createActionButton("fork_right", "Branch chat", async () => {+ const ctxid = globalThis.getContext?.();+ if (!ctxid) throw new Error("No active chat");- const res = await callJsonApi("/plugins/chat_branching/branch_chat", {- context: ctxid,- log_no: logNo,- });- if (!res?.ok) throw new Error(res?.message || "Branch failed");- chatsStore.selectChat(res.ctxid);- }),- );+ const res = await callJsonApi("/plugins/chat_branching/branch_chat", {+ context: ctxid,+ log_no: logNo,+ });+ if (!res?.ok) throw new Error(res?.message || "Branch failed");+ chatsStore.selectChat(res.ctxid);+ }),+ );+ }}}\ No newline at end of file