mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-07-10 01:18:29 +00:00
Fix branch button only appearing on the first code block/table within a message.
This commit is contained in:
parent
1779277187
commit
1d837cc41f
1 changed files with 15 additions and 15 deletions
|
|
@ -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);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue