Agent Zero AI framework
add extension points for chat, sidebar, and modal shell
Alessandrod65fada385f9
diff --git a/plugins/README.md b/plugins/README.mdindex 4bac307e3..6404c5e9c 100644--- a/plugins/README.md+++ b/plugins/README.md@@ -35,6 +35,53 @@ Core UI defines insertion points like:<x-extension id="sidebar-quick-actions-main-start"></x-extension>```+Current sidebar surfaces:++- `sidebar-start`+- `sidebar-end`+- `sidebar-top-wrapper-start`+- `sidebar-top-wrapper-end`+- `sidebar-quick-actions-main-start`+- `sidebar-quick-actions-main-end`+- `sidebar-quick-actions-dropdown-start`+- `sidebar-quick-actions-dropdown-end`+- `sidebar-chats-list-start`+- `sidebar-chats-list-end`+- `sidebar-tasks-list-start`+- `sidebar-tasks-list-end`+- `sidebar-bottom-wrapper-start`+- `sidebar-bottom-wrapper-end`++Current input surfaces:++- `chat-input-start`+- `chat-input-end`+- `chat-input-progress-start`+- `chat-input-progress-end`+- `chat-input-box-start`+- `chat-input-box-end`+- `chat-input-bottom-actions-start`+- `chat-input-bottom-actions-end`++Current chat surfaces:++- `chat-top-start`+- `chat-top-end`++Current welcome surfaces:++- `welcome-screen-start`+- `welcome-screen-end`++Current modal surfaces:++- `modal-shell-start`+- `modal-shell-end`++Placement pattern:+- keep wrapper-level anchors in parent composition files+- keep section anchors in their owning component files, inside local `x-data` scope+Resolution flow:1. `webui/js/extensions.js` finds `x-extension` nodes.@@ -72,6 +119,10 @@ Runtime code calls:`callJsExtensions("<extension_point>", ...args)`+JS hook convention:+- pass one mutable context object when extensions are expected to influence behavior+- that object is passed by reference, so mutations are visible to subsequent hooks in the same flow+Example:`set_messages_before_loop` and `set_messages_after_loop` in `webui/js/messages.js`.@@ -86,6 +137,12 @@ Example:- `x-move-before`- `x-move-after`+Placement behavior:+- `x-move-to-start`, `x-move-to-end`, and `x-move-to` resolve a parent selector and insert the extension element as that parent's child.+- `x-move-before` and `x-move-after` resolve a reference selector and insert the extension element as a sibling in the reference element's parent.+- This structural difference can produce different visual results when parent and sibling styling differ (for example dropdown spacing/padding).+- Example anchor selector for placing after the first dropdown item: `x-move-after=".quick-actions-dropdown .dropdown-header + .dropdown-item"`.+## Plugin Author Flow1. Pick an existing core breakpoint ID (`<x-extension id="...">`).diff --git a/plugins/tests/test_webui_extension_surfaces.py b/plugins/tests/test_webui_extension_surfaces.pynew file mode 100644index 000000000..186de038d--- /dev/null+++ b/plugins/tests/test_webui_extension_surfaces.py@@ -0,0 +1,118 @@+from __future__ import annotations++import sys+import tempfile+import threading+from contextlib import contextmanager+from pathlib import Path+from typing import Iterator++import pytest+from flask import Flask++PROJECT_ROOT = Path(__file__).resolve().parents[2]+if str(PROJECT_ROOT) not in sys.path:+ sys.path.insert(0, str(PROJECT_ROOT))++from python.api.load_webui_extensions import LoadWebuiExtensions+++SURFACE_SCENARIOS: list[tuple[str, str]] = [+ ("sidebar-start", "webui/components/sidebar/left-sidebar.html"),+ ("sidebar-end", "webui/components/sidebar/left-sidebar.html"),+ ("sidebar-top-wrapper-start", "webui/components/sidebar/top-section/sidebar-top.html"),+ ("sidebar-top-wrapper-end", "webui/components/sidebar/top-section/sidebar-top.html"),+ ("sidebar-quick-actions-main-start", "webui/components/sidebar/top-section/quick-actions.html"),+ ("sidebar-quick-actions-main-end", "webui/components/sidebar/top-section/quick-actions.html"),+ ("sidebar-quick-actions-dropdown-start", "webui/components/sidebar/top-section/quick-actions.html"),+ ("sidebar-quick-actions-dropdown-end", "webui/components/sidebar/top-section/quick-actions.html"),+ ("sidebar-chats-list-start", "webui/components/sidebar/chats/chats-list.html"),+ ("sidebar-chats-list-end", "webui/components/sidebar/chats/chats-list.html"),+ ("sidebar-tasks-list-start", "webui/components/sidebar/tasks/tasks-list.html"),+ ("sidebar-tasks-list-end", "webui/components/sidebar/tasks/tasks-list.html"),+ ("sidebar-bottom-wrapper-start", "webui/components/sidebar/bottom/sidebar-bottom.html"),+ ("sidebar-bottom-wrapper-end", "webui/components/sidebar/bottom/sidebar-bottom.html"),+ ("chat-input-start", "webui/components/chat/input/chat-bar.html"),+ ("chat-input-end", "webui/components/chat/input/chat-bar.html"),+ ("chat-input-progress-start", "webui/components/chat/input/progress.html"),+ ("chat-input-progress-end", "webui/components/chat/input/progress.html"),+ ("chat-input-box-start", "webui/components/chat/input/chat-bar-input.html"),+ ("chat-input-box-end", "webui/components/chat/input/chat-bar-input.html"),+ ("chat-input-bottom-actions-start", "webui/components/chat/input/bottom-actions.html"),+ ("chat-input-bottom-actions-end", "webui/components/chat/input/bottom-actions.html"),+ ("chat-top-start", "webui/components/chat/top-section/chat-top.html"),+ ("chat-top-end", "webui/components/chat/top-section/chat-top.html"),+ ("welcome-screen-start", "webui/components/welcome/welcome-screen.html"),+ ("welcome-screen-end", "webui/components/welcome/welcome-screen.html"),+ ("modal-shell-start", "webui/js/modals.js"),+ ("modal-shell-end", "webui/js/modals.js"),+]+++def _new_handler() -> LoadWebuiExtensions:+ app = Flask("test_webui_extension_surfaces")+ app.secret_key = "test-secret"+ return LoadWebuiExtensions(app, threading.RLock())+++def _assert_surface_anchor_in_template(surface: str, template_rel_path: str) -> None:+ template_path = PROJECT_ROOT / template_rel_path+ template_html = template_path.read_text(encoding="utf-8")+ assert f'<x-extension id="{surface}"></x-extension>' in template_html+++@contextmanager+def _temporary_probe_plugin(surface: str) -> Iterator[tuple[str, str]]:+ plugins_root = PROJECT_ROOT / "plugins"+ with tempfile.TemporaryDirectory(+ prefix="tmp_surface_probe_",+ dir=plugins_root,+ ) as temp_plugin_dir:+ plugin_id = Path(temp_plugin_dir).name+ probe_file = (+ Path(temp_plugin_dir)+ / "extensions"+ / "webui"+ / surface+ / "surface-probe.html"+ )+ probe_file.parent.mkdir(parents=True, exist_ok=True)+ probe_file.write_text(+ (+ "<div x-data "+ f'data-surface-probe="{surface}" '+ f'data-plugin-id="{plugin_id}"></div>'+ ),+ encoding="utf-8",+ )+ yield plugin_id, probe_file.name+++ ("surface", "template_rel_path"),+ SURFACE_SCENARIOS,+ ids=[scenario[0] for scenario in SURFACE_SCENARIOS],+)+async def test_webui_surface_extension_point_end_to_end(+ surface: str,+ template_rel_path: str,+) -> None:+ _assert_surface_anchor_in_template(surface, template_rel_path)++ with _temporary_probe_plugin(surface) as (plugin_id, probe_file_name):+ payload = await _new_handler().process(+ {"extension_point": surface, "filters": ["*.html"]},+ None,+ )+ assert isinstance(payload, dict)+ extensions = payload.get("extensions", [])+ expected_suffix = (+ f"{plugin_id}/extensions/webui/{surface}/{probe_file_name}"+ )++ assert any(+ extension.get("plugin_id") == plugin_id+ and str(extension.get("path", "")).replace("\\", "/").endswith(expected_suffix)+ for extension in extensions+ )diff --git a/webui/components/chat/input/bottom-actions.html b/webui/components/chat/input/bottom-actions.htmlindex 1353fbbd2..22cc32251 100644--- a/webui/components/chat/input/bottom-actions.html+++ b/webui/components/chat/input/bottom-actions.html@@ -10,6 +10,7 @@<body><div x-data><template x-if="$store.chatInput">+ <x-extension id="chat-input-bottom-actions-start"></x-extension><div class="text-buttons-row"><button class="text-button" @click="$store.chatInput.pauseAgent(!$store.chatInput.paused)"><template x-if="!$store.chatInput.paused">@@ -74,6 +75,7 @@<p>Nudge</p></button></div>+ <x-extension id="chat-input-bottom-actions-end"></x-extension></template></div>diff --git a/webui/components/chat/input/chat-bar-input.html b/webui/components/chat/input/chat-bar-input.htmlindex 3fd7506ad..2e93553ea 100644--- a/webui/components/chat/input/chat-bar-input.html+++ b/webui/components/chat/input/chat-bar-input.html@@ -9,7 +9,9 @@</script></head><body>- <div class="input-row">+ <div x-data>+ <x-extension id="chat-input-box-start"></x-extension>+ <div class="input-row"><!-- Attachment icon with tooltip --><div class="attachment-wrapper"><label for="file-input" class="attachment-icon" title="Add attachments to the message" data-bs-placement="top" data-bs-trigger="hover">@@ -50,10 +52,12 @@</svg></button></div>- </div>+ </div>- <!-- Full Screen Input Modal -->- <x-component path="modals/full-screen-input/full-screen-input.html"></x-component>+ <!-- Full Screen Input Modal -->+ <x-component path="modals/full-screen-input/full-screen-input.html"></x-component>+ <x-extension id="chat-input-box-end"></x-extension>+ </div><style>diff --git a/webui/components/chat/input/chat-bar.html b/webui/components/chat/input/chat-bar.htmlindex addcb19d5..c8d158656 100644--- a/webui/components/chat/input/chat-bar.html+++ b/webui/components/chat/input/chat-bar.html@@ -7,6 +7,7 @@</head><body><div id="input-section" x-data>+ <x-extension id="chat-input-start"></x-extension><template x-if="$store.chatInput"><div style="width: 100%; display: contents;"><!-- Message Queue section -->@@ -21,6 +22,7 @@<x-component path="chat/input/bottom-actions.html"></x-component></div></template>+ <x-extension id="chat-input-end"></x-extension></div>diff --git a/webui/components/chat/input/progress.html b/webui/components/chat/input/progress.htmlindex 81d94ad95..52f04a2ac 100644--- a/webui/components/chat/input/progress.html+++ b/webui/components/chat/input/progress.html@@ -6,7 +6,8 @@</script></head><body>- <div id="progress-bar-box">+ <div id="progress-bar-box" x-data>+ <x-extension id="chat-input-progress-start"></x-extension><h4 id="progress-bar-h"><span id="progress-bar-i">|></span><span id="progress-bar"></span></h4>@@ -31,6 +32,7 @@</button></div></div>+ <x-extension id="chat-input-progress-end"></x-extension></div>diff --git a/webui/components/chat/top-section/chat-top.html b/webui/components/chat/top-section/chat-top.htmlindex 32a4c9edb..c23cc76ea 100644--- a/webui/components/chat/top-section/chat-top.html+++ b/webui/components/chat/top-section/chat-top.html@@ -14,6 +14,7 @@<!-- This construct of x-data + x-if is used to ensure the component is only rendered when the store is available --><div x-data><template x-if="$store.chatTop">+ <x-extension id="chat-top-start"></x-extension><!-- Time and Date --><div id="time-date-container">@@ -24,6 +25,7 @@<!-- Project Selector --><x-component path="projects/project-selector.html"></x-component></div>+ <x-extension id="chat-top-end"></x-extension></template></div>diff --git a/webui/components/sidebar/bottom/sidebar-bottom.html b/webui/components/sidebar/bottom/sidebar-bottom.htmlindex 07ff59b58..800c701cd 100644--- a/webui/components/sidebar/bottom/sidebar-bottom.html+++ b/webui/components/sidebar/bottom/sidebar-bottom.html@@ -8,6 +8,7 @@<div x-data><template x-if="$store.sidebarBottom"><div class="sidebar-bottom-wrapper">+ <x-extension id="sidebar-bottom-wrapper-start"></x-extension><!-- Preferences Panel --><x-component path="sidebar/bottom/preferences/preferences-panel.html"></x-component>@@ -15,6 +16,7 @@<div class="version-info"><span id="a0version" x-text="$store.sidebarBottom.versionLabel"></span></div>+ <x-extension id="sidebar-bottom-wrapper-end"></x-extension></div></template></div>diff --git a/webui/components/sidebar/chats/chats-list.html b/webui/components/sidebar/chats/chats-list.htmlindex ba071fd00..a2123d783 100644--- a/webui/components/sidebar/chats/chats-list.html+++ b/webui/components/sidebar/chats/chats-list.html@@ -10,6 +10,7 @@<div x-data><template x-if="$store.chats"><div class="chats-list-container" x-data>+ <x-extension id="sidebar-chats-list-start"></x-extension><div class="section-header-row"><h3 class="section-header">Chats</h3><!-- New Chat Button -->@@ -41,6 +42,7 @@<div class="empty-list-message" x-show="$store.chats.contexts.length === 0"><p><i>No chats to list.</i></p></div>+ <x-extension id="sidebar-chats-list-end"></x-extension></div></template></div>diff --git a/webui/components/sidebar/left-sidebar.html b/webui/components/sidebar/left-sidebar.htmlindex e3d6ca8ad..34f0c7443 100644--- a/webui/components/sidebar/left-sidebar.html+++ b/webui/components/sidebar/left-sidebar.html@@ -11,6 +11,7 @@<div x-data><template x-if="$store.sidebar"><div id="left-panel" class="panel" x-data :class="{'hidden': !$store.sidebar.isOpen}">+ <x-extension id="sidebar-start"></x-extension><!--Sidebar upper elements--><div class="left-panel-top no-scrollbar"><!-- Top Section: Header Icons + Quick Actions -->@@ -29,6 +30,7 @@<div class="left-panel-bottom"><x-component path="sidebar/bottom/sidebar-bottom.html"></x-component></div>+ <x-extension id="sidebar-end"></x-extension></div></template></div>diff --git a/webui/components/sidebar/tasks/tasks-list.html b/webui/components/sidebar/tasks/tasks-list.htmlindex fc00c8000..2dc6c0833 100644--- a/webui/components/sidebar/tasks/tasks-list.html+++ b/webui/components/sidebar/tasks/tasks-list.html@@ -8,6 +8,7 @@<div class="tasks-list-root"><template x-if="$store.tasks"><div x-data class="tasks-list-inner">+ <x-extension id="sidebar-tasks-list-start"></x-extension><h3 class="section-header section-header-collapsible"data-bs-toggle="collapse"@click="$store.sidebar.toggleSection('tasks')"@@ -64,6 +65,7 @@</div></div></div>+ <x-extension id="sidebar-tasks-list-end"></x-extension></div></template></div>diff --git a/webui/components/sidebar/top-section/sidebar-top.html b/webui/components/sidebar/top-section/sidebar-top.htmlindex 5ba8b3180..6d3dcb493 100644--- a/webui/components/sidebar/top-section/sidebar-top.html+++ b/webui/components/sidebar/top-section/sidebar-top.html@@ -8,11 +8,13 @@<div x-data><template x-if="$store.sidebar"><div class="sidebar-top-wrapper">+ <x-extension id="sidebar-top-wrapper-start"></x-extension><!-- Header Icons (Toggle + Logo) --><x-component path="sidebar/top-section/header-icons.html"></x-component><!-- Quick Actions Buttons --><x-component path="sidebar/top-section/quick-actions.html"></x-component>+ <x-extension id="sidebar-top-wrapper-end"></x-extension></div></template></div>diff --git a/webui/components/welcome/welcome-screen.html b/webui/components/welcome/welcome-screen.htmlindex 74127b287..10b6bfb61 100644--- a/webui/components/welcome/welcome-screen.html+++ b/webui/components/welcome/welcome-screen.html@@ -9,6 +9,7 @@<body><div x-data ><template x-if="$store.welcomeStore && $store.welcomeStore.isVisible">+ <x-extension id="welcome-screen-start"></x-extension><div x-create="$store.welcomeStore.onCreate()" class="welcome-container"><div class="welcome-content"><!-- Action Cards -->@@ -96,6 +97,7 @@</div></div></div>+ <x-extension id="welcome-screen-end"></x-extension></template></div>diff --git a/webui/js/modals.js b/webui/js/modals.jsindex 6d96d8d98..ba13dd1de 100644--- a/webui/js/modals.js+++ b/webui/js/modals.js@@ -63,7 +63,8 @@ function createModalElement(path) {// Create modal structurenewModal.innerHTML = `- <div class="modal-inner">+ <div class="modal-inner" x-data>+ <x-extension id="modal-shell-start"></x-extension><div class="modal-header"><h2 class="modal-title"></h2><button class="modal-close">×</button>@@ -72,6 +73,7 @@ function createModalElement(path) {<div class="modal-bd"></div></div><div class="modal-footer-slot" style="display: none;"></div>+ <x-extension id="modal-shell-end"></x-extension></div>`;