agent-zero/plugins/_chat_branching
frdel e138e33ca9 Add file-level DOX docs & update AGENTS indexes
Add comprehensive file-level DOX documentation across the repo and update directory AGENTS.md indexes. Many new `*.py.dox.md` files were added under api, helpers, tools, plugins, extensions, webui, and other dirs to document endpoint purpose, ownership, runtime contracts, work guidance, and verification. Several AGENTS.md files were created or updated (agents profiles, api, docker, extensions, helpers, plugins, skills, webui components, etc.) to list child DOX files and clarify documentation/work guidance. Also add example and bundled profile DOX files (agent0, default, developer, hacker, researcher) and minor updates to helpers/dirty_json.py and its tests. These changes improve on-disk documentation coverage and establish the convention that each direct runtime file should have a matching `*.dox.md` describing its contracts and verification steps.
2026-06-08 12:41:53 +02:00
..
api Refactor: use user locale for time displays 2026-05-21 15:26:00 +02:00
extensions/webui/set_messages_after_loop refactor(chat_branching): ID-based log ↔ history linking for precise branch trimming 2026-03-24 03:04:09 -07:00
webui generated logos for builtin plugins 2026-03-19 17:35:03 +01:00
AGENTS.md Add file-level DOX docs & update AGENTS indexes 2026-06-08 12:41:53 +02:00
plugin.yaml refactor - plugin names and builtin plugins 2026-03-10 22:20:53 +01:00
README.md refactor(chat_branching): ID-based log ↔ history linking for precise branch trimming 2026-03-24 03:04:09 -07:00

Chat Branching

Create a new chat from any existing point in a conversation.

What It Does

Adds a Branch button to every chat message. Clicking it clones the current chat up to that message, creating a new conversation you can continue independently.

How It Works

  1. ID-based log ↔ history linking Every LogItem and history.Message share a UUID generated at creation time. The branch button is only shown on messages that carry this ID.

  2. Clone & trim

    • Serializes the source context → deserializes into a new context with a fresh ID.
    • Walks log entries: keeps everything up to the selected log_no, discards the rest.
    • Collects the IDs of kept entries and uses them to trim history.messages so log and history stay consistent.
  3. Persist & refresh

    • Saves the branched chat immediately.
    • Marks UI state dirty so all connected tabs see the new branch.

Entry Points

Path Purpose
api/branch_chat.py API endpoint — clone, trim, persist
extensions/webui/set_messages_after_loop/inject-branch-buttons.js Injects the Branch button into each message DOM element

Plugin Metadata

  • Name: _chat_branching
  • Title: Chat Branching
  • Description: Branch a chat from any message, creating a new chat with history up to that point.