Agent Zero AI framework
refactor(sidebar): share rows across plugin list views
Alessandro7ac2c8daa5f6
diff --git a/tests/test_parallel_tool.py b/tests/test_parallel_tool.pyindex ba4d15192..728ac54db 100644--- a/tests/test_parallel_tool.py+++ b/tests/test_parallel_tool.py@@ -1177,6 +1177,8 @@ def test_chats_sidebar_projects_parallel_children_as_indented_accordion() -> Nonencoding="utf-8")+ html += (PROJECT_ROOT / "webui/components/sidebar/chats/chat-tree.html").read_text(encoding="utf-8")+assert "parent_context_id" in storeassert "this.expandedParents[selectedId] === undefined" in storeassert "...this.expandedParents," in storediff --git a/tests/test_sidebar_row_actions.py b/tests/test_sidebar_row_actions.pyindex 9c644a7f1..c61b11119 100644--- a/tests/test_sidebar_row_actions.py+++ b/tests/test_sidebar_row_actions.py@@ -6,7 +6,7 @@ PROJECT_ROOT = Path(__file__).resolve().parents[1]def test_chat_rows_have_hover_scoped_overflow_actions() -> None:html = (- PROJECT_ROOT / "webui/components/sidebar/chats/chats-list.html"+ PROJECT_ROOT / "webui/components/sidebar/chats/chat-tree.html").read_text(encoding="utf-8")assert html.count('aria-label="More chat actions"') == 2@@ -17,7 +17,7 @@ def test_chat_rows_have_hover_scoped_overflow_actions() -> None:def test_task_rows_have_overflow_actions_after_standard_buttons() -> None:html = (- PROJECT_ROOT / "webui/components/sidebar/tasks/tasks-list.html"+ PROJECT_ROOT / "webui/components/sidebar/tasks/task-row.html").read_text(encoding="utf-8")delete_button = html.index('title="Delete task"')diff --git a/tests/test_webui_extension_surfaces.py b/tests/test_webui_extension_surfaces.pyindex 15002b6c7..549638334 100644--- a/tests/test_webui_extension_surfaces.py+++ b/tests/test_webui_extension_surfaces.py@@ -38,8 +38,10 @@ SURFACE_SCENARIOS: list[tuple[str, str]] = [("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-view", "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-view", "webui/components/sidebar/tasks/tasks-list.html"),("sidebar-tasks-list-end", "webui/components/sidebar/tasks/tasks-list.html"),("sidebar-row-actions-menu", "webui/components/sidebar/left-sidebar.html"),("sidebar-bottom-wrapper-start", "webui/components/sidebar/bottom/sidebar-bottom.html"),@@ -90,7 +92,7 @@ def anyio_backend():def _assert_surface_anchor_in_template(surface: str, template_rel_path: str) -> None:template_path = PROJECT_ROOT / template_rel_pathtemplate_html = template_path.read_text(encoding="utf-8")- assert f'<x-extension id="{surface}"></x-extension>' in template_html+ assert f'<x-extension id="{surface}"' in template_html@contextmanagerdiff --git a/webui/components/sidebar/AGENTS.md b/webui/components/sidebar/AGENTS.mdindex 71bbcd9ec..c20353640 100644--- a/webui/components/sidebar/AGENTS.md+++ b/webui/components/sidebar/AGENTS.md@@ -8,8 +8,8 @@- `left-sidebar.html` and `sidebar-store.js` own sidebar shell and shared state.- `top-section/` owns header and quick actions.-- `chats/` owns chat list UI and state.-- `tasks/` owns task list UI and state.+- `chats/` owns chat list UI and state; `chat-tree.html` is the shared parent/parallel-child row.+- `tasks/` owns task list UI and state; `task-row.html` is the shared scheduler row.- `bottom/` owns lower sidebar controls and preferences panel.## Local Contracts@@ -28,6 +28,7 @@- `chats.saveChat(ctxid)` exports an explicit context without changing selection; omitted IDs retain current-chat behavior.- Cancelling the Load Chat file chooser resolves without calling `chat_load` or showing a success/error notification.- `sidebar-row-actions-menu` owns plugin-contributed row-menu actions; list-order plugins register stable sort and divider callbacks through the sidebar store instead of patching chat/task stores or injecting row DOM.+- `sidebar-chats-list-view` and `sidebar-tasks-list-view` host plugin list presentations. A row-list extension may expose `hasView()` to hide the default list; both presentations reuse the core row components and their inherited `context`/`task` scopes.- `chats.newChat(projectName)` passes an explicit project choice to `chat_create`; omitted project names retain inheritance behavior, and an empty name explicitly creates a chat without a project.- Bottom version information shows its commit timestamp in UTC without a timezone suffix and remains on one line.- Avoid text or controls overflowing fixed sidebar widths.diff --git a/webui/components/sidebar/chats/chat-tree.html b/webui/components/sidebar/chats/chat-tree.htmlnew file mode 100644index 000000000..bdb26f4ea--- /dev/null+++ b/webui/components/sidebar/chats/chat-tree.html@@ -0,0 +1,59 @@+<html>+<head></head>+<body>+ <div x-data class="sidebar-row-content">+ <div :class="{'chat-container': true, 'chat-has-children': $store.chats.hasChildren(context.id), 'chat-selected': context.id === $store.chats.selected}"+ @click="$store.chats.selectChat(context.id)">+ <button class="chat-expand-btn"+ x-show="$store.chats.hasChildren(context.id)"+ :class="{ 'is-visible': $store.chats.hasChildren(context.id), 'is-expanded': $store.chats.isExpanded(context.id) }"+ :aria-expanded="$store.chats.isExpanded(context.id)"+ :aria-label="$store.chats.isExpanded(context.id) ? 'Collapse chat children' : 'Expand chat children'"+ @click.stop="$store.chats.toggleChildren(context.id)">+ <x-icon+ :name="$store.chats.isExpanded(context.id) ? 'keyboard_arrow_up' : 'keyboard_arrow_down'"></x-icon>+ </button>+ <div class="chat-list-button">+ <span :class="{'project-color-ball': true, 'heartbeat': context.running}"+ :style="context.project?.color ? { backgroundColor: context.project.color } : { border: '1px solid var(--color-border)' }"></span>+ <span class="chat-name"+ x-text="$store.chats.displayName(context)"></span>+ </div>+ <button class="btn-icon-action chat-list-action-btn" title="Close chat" @click.stop="$confirmClick($event, () => $store.chats.killChat(context.id))">+ <x-icon name="close"></x-icon>+ </button>+ <button type="button" class="btn-icon-action chat-list-action-btn" title="More chat actions"+ aria-label="More chat actions" aria-haspopup="menu"+ :aria-expanded="($store.sidebar.rowMenuOpenId === `chat:${context.id}`).toString()"+ @click.stop="$store.sidebar.rowMenuToggle(`chat:${context.id}`, 'chat', $event.currentTarget)">+ <x-icon name="more_vert"></x-icon>+ </button>+ </div>+ <ul class="chat-child-list" x-show="$store.chats.isExpanded(context.id) && $store.chats.hasChildren(context.id)">+ <template x-for="(child, childIndex) in $store.chats.childContexts(context.id)" :key="child.id">+ <li :class="{ 'sidebar-list-divider': $store.sidebar.hasRowDividerBefore('chat', child, childIndex, $store.chats.childContexts(context.id)) }">+ <div :class="{'chat-container': true, 'chat-child-container': true, 'chat-selected': child.id === $store.chats.selected}"+ @click="$store.chats.selectChat(child.id)">+ <div class="chat-child-indent"></div>+ <div class="chat-list-button">+ <span :class="{'project-color-ball': true, 'heartbeat': child.running}"+ :style="child.project?.color ? { backgroundColor: child.project.color } : { border: '1px solid var(--color-border)' }"></span>+ <span class="chat-name"+ x-text="$store.chats.displayName(child)"></span>+ </div>+ <button class="btn-icon-action chat-list-action-btn" title="Close chat" @click.stop="$confirmClick($event, () => $store.chats.killChat(child.id))">+ <x-icon name="close"></x-icon>+ </button>+ <button type="button" class="btn-icon-action chat-list-action-btn" title="More chat actions"+ aria-label="More chat actions" aria-haspopup="menu"+ :aria-expanded="($store.sidebar.rowMenuOpenId === `chat:${child.id}`).toString()"+ @click.stop="$store.sidebar.rowMenuToggle(`chat:${child.id}`, 'chat', $event.currentTarget)">+ <x-icon name="more_vert"></x-icon>+ </button>+ </div>+ </li>+ </template>+ </ul>+ </div>+</body>+</html>diff --git a/webui/components/sidebar/chats/chats-list.html b/webui/components/sidebar/chats/chats-list.htmlindex 6caeb4008..315c025b1 100644--- a/webui/components/sidebar/chats/chats-list.html+++ b/webui/components/sidebar/chats/chats-list.html@@ -20,70 +20,22 @@<x-extension id="chats-header-controls"></x-extension></div>--- <ul class="config-list chats-config-list no-scrollbar" x-show="$store.chats.topLevelContexts().length > 0">- <template x-for="(context, contextIndex) in $store.chats.topLevelContexts()" :key="context.id">- <li class="chat-tree-item"- :class="{ 'sidebar-list-divider': $store.sidebar.hasRowDividerBefore('chat', context, contextIndex, $store.chats.topLevelContexts()) }">- <div :class="{'chat-container': true, 'chat-has-children': $store.chats.hasChildren(context.id), 'chat-selected': context.id === $store.chats.selected}"- @click="$store.chats.selectChat(context.id)">- <button class="chat-expand-btn"- x-show="$store.chats.hasChildren(context.id)"- :class="{ 'is-visible': $store.chats.hasChildren(context.id), 'is-expanded': $store.chats.isExpanded(context.id) }"- :aria-expanded="$store.chats.isExpanded(context.id)"- :aria-label="$store.chats.isExpanded(context.id) ? 'Collapse chat children' : 'Expand chat children'"- @click.stop="$store.chats.toggleChildren(context.id)">- <x-icon- :name="$store.chats.isExpanded(context.id) ? 'keyboard_arrow_up' : 'keyboard_arrow_down'"></x-icon>- </button>- <div class="chat-list-button">- <span :class="{'project-color-ball': true, 'heartbeat': context.running}"- :style="context.project?.color ? { backgroundColor: context.project.color } : { border: '1px solid var(--color-border)' }"></span>- <span class="chat-name"- x-text="$store.chats.displayName(context)"></span>- </div>- <button class="btn-icon-action chat-list-action-btn" title="Close chat" @click.stop="$confirmClick($event, () => $store.chats.killChat(context.id))">- <x-icon name="close"></x-icon>- </button>- <button type="button" class="btn-icon-action chat-list-action-btn" title="More chat actions"- aria-label="More chat actions" aria-haspopup="menu"- :aria-expanded="($store.sidebar.rowMenuOpenId === `chat:${context.id}`).toString()"- @click.stop="$store.sidebar.rowMenuToggle(`chat:${context.id}`, 'chat', $event.currentTarget)">- <x-icon name="more_vert"></x-icon>- </button>- </div>- <ul class="chat-child-list" x-show="$store.chats.isExpanded(context.id) && $store.chats.hasChildren(context.id)">- <template x-for="(child, childIndex) in $store.chats.childContexts(context.id)" :key="child.id">- <li :class="{ 'sidebar-list-divider': $store.sidebar.hasRowDividerBefore('chat', child, childIndex, $store.chats.childContexts(context.id)) }">- <div :class="{'chat-container': true, 'chat-child-container': true, 'chat-selected': child.id === $store.chats.selected}"- @click="$store.chats.selectChat(child.id)">- <div class="chat-child-indent"></div>- <div class="chat-list-button">- <span :class="{'project-color-ball': true, 'heartbeat': child.running}"- :style="child.project?.color ? { backgroundColor: child.project.color } : { border: '1px solid var(--color-border)' }"></span>- <span class="chat-name"- x-text="$store.chats.displayName(child)"></span>- </div>- <button class="btn-icon-action chat-list-action-btn" title="Close chat" @click.stop="$confirmClick($event, () => $store.chats.killChat(child.id))">- <x-icon name="close"></x-icon>- </button>- <button type="button" class="btn-icon-action chat-list-action-btn" title="More chat actions"- aria-label="More chat actions" aria-haspopup="menu"- :aria-expanded="($store.sidebar.rowMenuOpenId === `chat:${child.id}`).toString()"- @click.stop="$store.sidebar.rowMenuToggle(`chat:${child.id}`, 'chat', $event.currentTarget)">- <x-icon name="more_vert"></x-icon>- </button>- </div>- </li>- </template>- </ul>- </li>- </template>- </ul>- <div class="empty-list-message" x-show="$store.chats.topLevelContexts().length === 0">- <p><i>No chats to list.</i></p>- </div>+ <x-extension id="sidebar-chats-list-view" class="sidebar-list-view"></x-extension>+ <template x-if="!$store.sidebar.hasListView('chat')">+ <div class="sidebar-default-list">+ <ul class="config-list chats-config-list no-scrollbar" x-show="$store.chats.topLevelContexts().length > 0">+ <template x-for="(context, contextIndex) in $store.chats.topLevelContexts()" :key="context.id">+ <li class="chat-tree-item"+ :class="{ 'sidebar-list-divider': $store.sidebar.hasRowDividerBefore('chat', context, contextIndex, $store.chats.topLevelContexts()) }">+ <x-component path="sidebar/chats/chat-tree.html"></x-component>+ </li>+ </template>+ </ul>+ <div class="empty-list-message" x-show="$store.chats.topLevelContexts().length === 0">+ <p><i>No chats to list.</i></p>+ </div>+ </div>+ </template><x-extension id="sidebar-chats-list-end"></x-extension></div></template>@@ -103,6 +55,7 @@.chats-list-container .section-header {margin: 0;+ margin-right: auto;}/* Chats list container and items */diff --git a/webui/components/sidebar/left-sidebar.html b/webui/components/sidebar/left-sidebar.htmlindex 5319aed44..09956281e 100644--- a/webui/components/sidebar/left-sidebar.html+++ b/webui/components/sidebar/left-sidebar.html@@ -46,6 +46,15 @@</div><style>+ .sidebar-default-list,+ .sidebar-list-view,+ .sidebar-list-view > x-component,+ .sidebar-row-content,+ .chat-tree-item > x-component,+ .task-list-item > x-component {+ display: contents;+ }+/* Left Panel styles from index.css */#left-panel {background-color: var(--color-panel);diff --git a/webui/components/sidebar/sidebar-store.js b/webui/components/sidebar/sidebar-store.jsindex 18b815175..e2fc1b914 100644--- a/webui/components/sidebar/sidebar-store.js+++ b/webui/components/sidebar/sidebar-store.js@@ -146,6 +146,12 @@ const model = {};},+ hasListView(kind) {+ return Object.values(this.rowListExtensions[kind] || {}).some(+ (extension) => extension.hasView?.(),+ );+ },+sortRows(kind, rows) {return Object.values(this.rowListExtensions[kind] || {}).reduce((result, extension) => extension.sort?.(result) || result,diff --git a/webui/components/sidebar/tasks/task-row.html b/webui/components/sidebar/tasks/task-row.htmlnew file mode 100644index 000000000..5173501a4--- /dev/null+++ b/webui/components/sidebar/tasks/task-row.html@@ -0,0 +1,44 @@+<html>+<head></head>+<body>+ <div x-data class="sidebar-row-content">+ <div class="task-container" :class="{'task-selected': task.id === $store.tasks.selected}">+ <div class="chat-list-button" @click="$store.tasks.selectTask(task.id)">+ <div class="task-container-vertical">+ <div class="task-title-line">+ <span :class="{'project-color-ball': true, 'heartbeat': task.running}" :style="task.project?.color ? { backgroundColor: task.project.color } : { border: '1px solid var(--color-border)' }"></span>+ <span class="task-name"+ x-text="(task.task_name || `Task #${task.no}`)"+ :data-task-id="task.id"></span>+ </div>+ <div class="task-info-line">+ <span class="scheduler-status-badge scheduler-status-badge-small"+ :class="task.state ? `scheduler-status-${task.state}` : 'scheduler-status-idle'"+ x-text="task.state || 'idle'"></span>+ <div class="task-actions">+ <button class="btn-icon-action"+ @click.stop="$store.tasks.openDetail(task.id)"+ title="View task details">+ <x-icon name="info"></x-icon>+ </button>+ <button class="btn-icon-action" title="Clear task chat"+ @click.stop="$confirmClick($event, () => $store.tasks.reset(task.id))">+ <x-icon name="delete_sweep"></x-icon>+ </button>+ <button class="btn-icon-action" title="Delete task" @click.stop="$confirmClick($event, () => $store.tasks.deleteTask(task.id))">+ <x-icon name="close"></x-icon>+ </button>+ <button type="button" class="btn-icon-action" title="More task actions"+ aria-label="More task actions" aria-haspopup="menu"+ :aria-expanded="($store.sidebar.rowMenuOpenId === `task:${task.id}`).toString()"+ @click.stop="$store.sidebar.rowMenuToggle(`task:${task.id}`, 'task', $event.currentTarget)">+ <x-icon name="more_vert"></x-icon>+ </button>+ </div>+ </div>+ </div>+ </div>+ </div>+ </div>+</body>+</html>diff --git a/webui/components/sidebar/tasks/tasks-list.html b/webui/components/sidebar/tasks/tasks-list.htmlindex 3a0c77edf..fca7e2005 100644--- a/webui/components/sidebar/tasks/tasks-list.html+++ b/webui/components/sidebar/tasks/tasks-list.html@@ -22,53 +22,22 @@x-effect="(() => { const c = bootstrap.Collapse.getOrCreateInstance($el, { toggle: false }); $store.sidebar.isSectionOpen('tasks') ? c.show() : c.hide(); })()"><div class="tasks-list-body"><div class="tasks-list-container" x-data>- <ul class="config-list tasks-config-list no-scrollbar" x-show="$store.tasks.visibleTasks().length > 0">- <template x-for="(task, taskIndex) in $store.tasks.visibleTasks()" :key="task.id">- <li class="task-list-item"- :class="{ 'sidebar-list-divider': $store.sidebar.hasRowDividerBefore('task', task, taskIndex, $store.tasks.visibleTasks()) }">- <div class="task-container" :class="{'task-selected': task.id === $store.tasks.selected}">- <div class="chat-list-button" @click="$store.tasks.selectTask(task.id)">- <div class="task-container-vertical">- <div class="task-title-line">- <span :class="{'project-color-ball': true, 'heartbeat': task.running}" :style="task.project?.color ? { backgroundColor: task.project.color } : { border: '1px solid var(--color-border)' }"></span>- <span class="task-name"- x-text="(task.task_name || `Task #${task.no}`)"- :data-task-id="task.id"></span>- </div>- <div class="task-info-line">- <span class="scheduler-status-badge scheduler-status-badge-small"- :class="task.state ? `scheduler-status-${task.state}` : 'scheduler-status-idle'"- x-text="task.state || 'idle'"></span>- <div class="task-actions">- <button class="btn-icon-action"- @click.stop="$store.tasks.openDetail(task.id)"- title="View task details">- <x-icon name="info"></x-icon>- </button>- <button class="btn-icon-action" title="Clear task chat"- @click.stop="$confirmClick($event, () => $store.tasks.reset(task.id))">- <x-icon name="delete_sweep"></x-icon>- </button>- <button class="btn-icon-action" title="Delete task" @click.stop="$confirmClick($event, () => $store.tasks.deleteTask(task.id))">- <x-icon name="close"></x-icon>- </button>- <button type="button" class="btn-icon-action" title="More task actions"- aria-label="More task actions" aria-haspopup="menu"- :aria-expanded="($store.sidebar.rowMenuOpenId === `task:${task.id}`).toString()"- @click.stop="$store.sidebar.rowMenuToggle(`task:${task.id}`, 'task', $event.currentTarget)">- <x-icon name="more_vert"></x-icon>- </button>- </div>- </div>- </div>- </div>- </div>- </li>- </template>- </ul>- <div class="empty-list-message" x-show="$store.tasks.visibleTasks().length === 0">- <p><i>No tasks to list.</i></p>- </div>+ <x-extension id="sidebar-tasks-list-view" class="sidebar-list-view"></x-extension>+ <template x-if="!$store.sidebar.hasListView('task')">+ <div class="sidebar-default-list">+ <ul class="config-list tasks-config-list no-scrollbar" x-show="$store.tasks.visibleTasks().length > 0">+ <template x-for="(task, taskIndex) in $store.tasks.visibleTasks()" :key="task.id">+ <li class="task-list-item"+ :class="{ 'sidebar-list-divider': $store.sidebar.hasRowDividerBefore('task', task, taskIndex, $store.tasks.visibleTasks()) }">+ <x-component path="sidebar/tasks/task-row.html"></x-component>+ </li>+ </template>+ </ul>+ <div class="empty-list-message" x-show="$store.tasks.visibleTasks().length === 0">+ <p><i>No tasks to list.</i></p>+ </div>+ </div>+ </template></div></div></div>@@ -76,8 +45,6 @@</div></template></div>- </template>- </div><style>/* Root wrappers provide flex context when embedded */