Skip to content

Agent Zero AI framework

fix(sidebar): render workers beyond the first child level

Alessandro894b3f6eb876
diff --git a/tests/test_sidebar_row_actions.py b/tests/test_sidebar_row_actions.py
index c61b11119..391c4acf8 100644
--- a/tests/test_sidebar_row_actions.py
+++ b/tests/test_sidebar_row_actions.py
@@ -9,10 +9,11 @@ def test_chat_rows_have_hover_scoped_overflow_actions() -> None:
PROJECT_ROOT / "webui/components/sidebar/chats/chat-tree.html"
).read_text(encoding="utf-8")
- assert html.count('aria-label="More chat actions"') == 2
+ assert html.count('aria-label="More chat actions"') == 1
+ assert '<x-component path="sidebar/chats/chat-tree.html"></x-component>' in html
assert 'class="btn-icon-action chat-list-action-btn"' in html
assert '<x-icon name="more_vert"></x-icon>' in html
- assert html.count("$store.sidebar.rowMenuToggle(") == 2
+ assert html.count("$store.sidebar.rowMenuToggle(") == 1
def test_task_rows_have_overflow_actions_after_standard_buttons() -> None:
diff --git a/tests/test_webui_chat_deletion.py b/tests/test_webui_chat_deletion.py
index 9492036ca..96ee00aed 100644
--- a/tests/test_webui_chat_deletion.py
+++ b/tests/test_webui_chat_deletion.py
@@ -95,6 +95,8 @@ assert(
const tree = [
{{ id: "parent", created_at: 20 }},
{{ id: "child", parent_context_id: "parent", created_at: 10 }},
+ {{ id: "grandchild", parent_context_id: "child", created_at: 5 }},
+ {{ id: "greatgrandchild", parent_context_id: "grandchild", created_at: 1 }},
];
reset(tree, "");
model.applyContexts(tree);
@@ -107,6 +109,21 @@ assert(
model.expandedParents.parent === true,
"selection synchronization must still run for unchanged contexts",
);
+model.expandedParents = {{}};
+model.setSelected("greatgrandchild");
+assert(
+ ["parent", "child", "grandchild"].every(id => model.isExpanded(id)),
+ "selecting a deep worker opens every ancestor",
+);
+model.expandedParents = {{}};
+model.applyContexts(tree);
+assert(
+ ["parent", "child", "grandchild"].every(id => model.isExpanded(id)),
+ "restoring a deep selection opens every ancestor",
+);
+const expanded = model.expandedParents;
+model.applyContexts(tree);
+assert(model.expandedParents === expanded, "unchanged expansion does not republish state");
reset(chats, "b");
globalThis.__context = "a";
diff --git a/webui/components/sidebar/AGENTS.md b/webui/components/sidebar/AGENTS.md
index 8d3f8a19d..39c2f5a7d 100644
--- a/webui/components/sidebar/AGENTS.md
+++ b/webui/components/sidebar/AGENTS.md
@@ -17,6 +17,8 @@
- Preserve responsive sidebar behavior and collapsed/expanded state.
- Keep chat and task list updates compatible with WebSocket state sync.
- Contexts with `parent_context_id` render as indented children beneath their parent chat; they must remain selectable while hidden from the top-level chat list.
+- The shared chat tree recurses through every subordinate level, mounting children only while expanded. Selecting or restoring a descendant expands all ancestors in both list views.
+- Indentation tapers at the third child level and stops increasing after it, preserving room for titles and actions in narrow sidebars.
- Chat tree expand/collapse controls use a parent-only leading slot, with right/down chevrons for collapsed/expanded state. Use spacing tokens for compact rows and the additional child indentation without consuming normal chat row text margin.
- A restored selected parent chat with children auto-expands once during context hydration unless the user has already toggled it.
- The Tasks list is reserved for scheduler-backed task contexts and must not be used for chat-bound parallel children.
diff --git a/webui/components/sidebar/chats/chat-tree.html b/webui/components/sidebar/chats/chat-tree.html
index 3f5510747..995163467 100644
--- a/webui/components/sidebar/chats/chat-tree.html
+++ b/webui/components/sidebar/chats/chat-tree.html
@@ -2,7 +2,7 @@
<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}"
+ <div :class="{'chat-container': true, 'chat-child-container': !!context.parent_context_id, '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)"
@@ -29,31 +29,17 @@
<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-if="$store.chats.isExpanded(context.id) && $store.chats.hasChildren(context.id)">
+ <ul class="chat-child-list">
<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 x-data="{ get context() { return child; } }">
+ <x-component path="sidebar/chats/chat-tree.html"></x-component>
</div>
</li>
</template>
</ul>
+ </template>
</div>
</body>
</html>
diff --git a/webui/components/sidebar/chats/chats-list.html b/webui/components/sidebar/chats/chats-list.html
index 9a3b2f4b1..c84167f44 100644
--- a/webui/components/sidebar/chats/chats-list.html
+++ b/webui/components/sidebar/chats/chats-list.html
@@ -99,9 +99,10 @@
.chat-child-list {
list-style: none;
- padding: 0;
+ padding: 0 0 0 calc(var(--spacing-md) + var(--spacing-sm));
margin: 0;
width: 100%;
+ box-sizing: border-box;
}
.chats-config-list .chat-child-list > li {
@@ -109,9 +110,12 @@
padding: 0;
}
- .chat-child-indent {
- width: calc(var(--spacing-md) + var(--spacing-sm));
- flex-shrink: 0;
+ .chat-child-list .chat-child-list .chat-child-list {
+ padding-left: var(--spacing-sm);
+ }
+
+ .chat-child-list .chat-child-list .chat-child-list .chat-child-list {
+ padding-left: 0;
}
.chat-expand-btn {
diff --git a/webui/components/sidebar/chats/chats-store.js b/webui/components/sidebar/chats/chats-store.js
index 4d5301c77..0cb685b44 100644
--- a/webui/components/sidebar/chats/chats-store.js
+++ b/webui/components/sidebar/chats/chats-store.js
@@ -91,12 +91,7 @@ const model = {
if (updated) {
if (this.selectedContext !== updated) this.selectedContext = updated;
if (updated.parent_context_id) {
- if (!this.expandedParents[updated.parent_context_id]) {
- this.expandedParents = {
- ...this.expandedParents,
- [updated.parent_context_id]: true,
- };
- }
+ this.expandAncestors(updated);
} else if (
this.hasChildren(selectedId) &&
this.expandedParents[selectedId] === undefined
@@ -125,7 +120,17 @@ const model = {
},
hasChildren(parentId) {
- return this.childContexts(parentId).length > 0;
+ return this.contexts.some((context) => context.parent_context_id === parentId);
+ },
+
+ expandAncestors(context) {
+ const seen = new Set();
+ while (context?.parent_context_id && !seen.has(context.parent_context_id)) {
+ const parentId = context.parent_context_id;
+ seen.add(parentId);
+ if (!this.expandedParents[parentId]) this.expandedParents[parentId] = true;
+ context = this.contexts.find((row) => row.id === parentId);
+ }
},
isExpanded(parentId) {
@@ -396,6 +401,7 @@ const model = {
this.selectedContext = this.contexts.find((ctx) => ctx.id === this.selected);
// if not found in contexts, try to find in tasks < not nice, will need refactor later
if(!this.selectedContext) this.selectedContext = tasksStore.tasks.find((ctx) => ctx.id === this.selected);
+ this.expandAncestors(this.selectedContext);
if (this.selected) {
sessionStorage.setItem("lastSelectedChat", this.selected);
} else {