Agent Zero AI framework
Import chats store via ES module instead
keyboardstaff177927718702
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 80568b613..892a920af 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@@ -1,11 +1,9 @@// Chat Branching Plugin — injects a "branch" button into every message's action bar.-// Runs as a set_messages_after_loop JS extension.-//-// Uses the unified handler output: context.results is an array of-// { args: { no, id, type, … }, result: { element, … } } from each setMessage() call.+// Uses the unified handler output: context.results[] = { args: { no, … }, result: { element, … } }import { createActionButton } from "/components/messages/action-buttons/simple-action-buttons.js";import { callJsonApi } from "/js/api.js";+import { store as chatsStore } from "/components/sidebar/chats/chats-store.js";export default async function injectBranchButtons(context) {if (!context?.results?.length) return;@@ -17,24 +15,18 @@ export default async function injectBranchButtons(context) {if (!bar || bar.querySelector(".action-fork_right")) continue;const logNo = args.no;- const btn = 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");-- // Select the newly created branch chat- const chatsStore = Alpine.store("chats");- if (chatsStore) {+ 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);- }- });-- if (btn) bar.appendChild(btn);+ }),+ );}}\ No newline at end of file