Skip to content

Agent Zero AI framework

detail modes for process groups/steps

3clyp5054248d493761
diff --git a/webui/components/messages/process-group/process-group-store.js b/webui/components/messages/process-group/process-group-store.js
index 256c5e570..e2be3a79b 100644
--- a/webui/components/messages/process-group/process-group-store.js
+++ b/webui/components/messages/process-group/process-group-store.js
@@ -175,6 +175,61 @@ const model = {
}
}
this._persist();
+ },
+
+ // Get current detail mode from preferences
+ _getDetailMode() {
+ return window.Alpine?.store("preferences")?.detailMode || "current";
+ },
+
+ expandGroup(groupId, isActiveAndGenerating = false) {
+ const mode = this._getDetailMode();
+ if (mode === "collapsed") {
+ // Only expand if generating, not for completed groups
+ return isActiveAndGenerating;
+ }
+ if (mode === "current" || mode === "expanded") return true;
+ return !this.defaultCollapsed;
+ },
+
+ expandStep(groupId, stepId, isActive = false) {
+ const mode = this._getDetailMode();
+ if (mode === "collapsed") return false;
+ if (mode === "expanded") return true;
+ if (mode === "current") return isActive;
+ return this.isStepExpanded(groupId, stepId);
+ },
+
+ // Apply current mode to all existing DOM elements
+ applyModeSteps() {
+ const mode = this._getDetailMode();
+ const showUtils = window.Alpine?.store("preferences")?.showUtils || false;
+ const allGroups = document.querySelectorAll(".process-group");
+
+ // Find the last VISIBLE step using targeted selector
+ const stepSelector = showUtils ? ".process-step" : ".process-step:not(.message-util)";
+ const visibleSteps = document.querySelectorAll(stepSelector);
+ const lastStep = visibleSteps.length > 0 ? visibleSteps[visibleSteps.length - 1] : null;
+
+ // Get all steps for applying expansion
+ const allSteps = document.querySelectorAll(".process-step");
+
+ // Apply to groups
+ allGroups.forEach(group => {
+ group.classList.toggle("expanded", mode !== "collapsed");
+ });
+
+ // Apply to steps
+ allSteps.forEach(step => {
+ let shouldExpand = false;
+ if (mode === "expanded") {
+ shouldExpand = true;
+ } else if (mode === "current") {
+ // Expand the last step and any parent steps containing it (for nested subordinate steps)
+ shouldExpand = step === lastStep || step.contains(lastStep);
+ }
+ step.classList.toggle("step-expanded", shouldExpand);
+ });
}
};
diff --git a/webui/components/sidebar/bottom/preferences/preferences-panel.html b/webui/components/sidebar/bottom/preferences/preferences-panel.html
index f54626c28..92c0e4867 100644
--- a/webui/components/sidebar/bottom/preferences/preferences-panel.html
+++ b/webui/components/sidebar/bottom/preferences/preferences-panel.html
@@ -27,20 +27,6 @@
<span class="slider"></span>
</label>
</li>
- <li x-data>
- <span class="switch-label">Speech</span>
- <label class="switch">
- <input type="checkbox" x-model="$store.preferences.speech">
- <span class="slider"></span>
- </label>
- </li>
- <li x-data>
- <span>Show utility messages</span>
- <label class="switch">
- <input type="checkbox" x-model="$store.preferences.showUtils">
- <span class="slider"></span>
- </label>
- </li>
<li x-data class="chat-width-setting">
<span class="width-label">Width</span>
<div class="width-buttons">
@@ -56,6 +42,37 @@
</template>
</div>
</li>
+ <li x-data class="detail-mode-setting">
+ <span class="detail-label">Detail</span>
+ <div class="detail-buttons">
+ <template x-for="(opt, idx) in $store.preferences.detailModeOptions" :key="opt.value">
+ <span class="detail-btn-wrapper">
+ <button type="button"
+ class="detail-btn"
+ :class="{ 'active': $store.preferences.detailMode === opt.value }"
+ @click="$store.preferences.detailMode = opt.value"
+ :title="opt.title">
+ <span class="material-symbols-outlined" x-text="opt.icon"></span>
+ </button>
+ <span class="detail-sep" x-show="idx < $store.preferences.detailModeOptions.length - 1">·</span>
+ </span>
+ </template>
+ </div>
+ </li>
+ <li x-data>
+ <span class="switch-label">Speech</span>
+ <label class="switch">
+ <input type="checkbox" x-model="$store.preferences.speech">
+ <span class="slider"></span>
+ </label>
+ </li>
+ <li x-data>
+ <span>Show utility messages</span>
+ <label class="switch">
+ <input type="checkbox" x-model="$store.preferences.showUtils">
+ <span class="slider"></span>
+ </label>
+ </li>
</ul>
</span>
</div>
@@ -144,6 +161,48 @@
margin: 0 0.1rem;
opacity: 0.5;
}
+
+ /* Detail mode button bar */
+ .detail-mode-setting {
+ gap: 0.25rem;
+ }
+ .detail-mode-setting .detail-label {
+ flex: 1;
+ }
+ .detail-buttons {
+ display: flex;
+ align-items: center;
+ gap: 0;
+ }
+ .detail-btn-wrapper {
+ display: flex;
+ align-items: center;
+ }
+ .detail-btn {
+ background: none;
+ border: none;
+ color: var(--color-primary);
+ padding: 0.15rem 0.25rem;
+ cursor: pointer;
+ opacity: 0.7;
+ transition: opacity 0.15s ease;
+ }
+ .detail-btn .material-symbols-outlined {
+ font-size: 1rem;
+ }
+ .detail-btn:hover {
+ opacity: 0.85;
+ }
+ .detail-btn.active {
+ opacity: 1;
+ color: var(--color-text);
+ }
+ .detail-sep {
+ color: var(--color-text-secondary, #666);
+ font-size: 0.6rem;
+ margin: 0 0.1rem;
+ opacity: 0.5;
+ }
</style>
</body>
</html>
diff --git a/webui/components/sidebar/bottom/preferences/preferences-store.js b/webui/components/sidebar/bottom/preferences/preferences-store.js
index a11d7269a..2012ff2f9 100644
--- a/webui/components/sidebar/bottom/preferences/preferences-store.js
+++ b/webui/components/sidebar/bottom/preferences/preferences-store.js
@@ -1,6 +1,7 @@
import { createStore } from "/js/AlpineStore.js";
import * as css from "/js/css.js";
import { store as speechStore } from "/components/chat/speech/speech-store.js";
+import { store as processGroupStore } from "/components/messages/process-group/process-group-store.js";
// Preferences store centralizes user preference toggles and side-effects
const model = {
@@ -68,6 +69,23 @@ const model = {
{ label: "FULL", value: "full" },
],
+ // Detail mode for process groups/steps expansion
+ get detailMode() {
+ return this._detailMode;
+ },
+ set detailMode(value) {
+ this._detailMode = value;
+ this._applyDetailMode(value);
+ },
+ _detailMode: "current", // Default: show current step only
+
+ // Detail mode options for UI sidebar
+ detailModeOptions: [
+ { label: "MIN", value: "collapsed", icon: "unfold_less", title: "All collapsed" },
+ { label: "CUR", value: "current", icon: "step", title: "Current step only" },
+ { label: "ALL", value: "expanded", icon: "unfold_more", title: "All expanded" },
+ ],
+
// Initialize preferences and apply current state
init() {
try {
@@ -104,6 +122,16 @@ const model = {
this._chatWidth = "55"; // Default to standard
}
+ // Load detail mode preference
+ try {
+ const storedDetailMode = localStorage.getItem("detailMode");
+ if (storedDetailMode && this.detailModeOptions.some(opt => opt.value === storedDetailMode)) {
+ this._detailMode = storedDetailMode;
+ }
+ } catch {
+ this._detailMode = "current"; // Default
+ }
+
// Apply all preferences
this._applyDarkMode(this._darkMode);
this._applyAutoScroll(this._autoScroll);
@@ -111,6 +139,7 @@ const model = {
this._applyShowUtils(this._showUtils);
this._applyCollapseProcessGroups(this._collapseProcessGroups);
this._applyChatWidth(this._chatWidth);
+ this._applyDetailMode(this._detailMode);
} catch (e) {
console.error("Failed to initialize preferences store", e);
}
@@ -148,19 +177,14 @@ const model = {
document.querySelectorAll(".process-step.message-util").forEach((el) => {
el.classList.toggle("show-util", value);
});
+ // Re-apply detail mode to reset current visible step
+ processGroupStore.applyModeSteps();
},
_applyCollapseProcessGroups(value) {
localStorage.setItem("collapseProcessGroups", value);
// Update process group store default
- try {
- const processGroupStore = window.Alpine?.store("processGroup");
- if (processGroupStore) {
- processGroupStore.defaultCollapsed = value;
- }
- } catch (e) {
- // Store may not be initialized yet
- }
+ processGroupStore.defaultCollapsed = value;
},
_applyChatWidth(value) {
@@ -173,6 +197,14 @@ const model = {
root.style.setProperty("--chat-max-width", `${value}em`);
}
},
+
+ _applyDetailMode(value) {
+ localStorage.setItem("detailMode", value);
+ // Sync defaultCollapsed based on mode
+ processGroupStore.defaultCollapsed = value === "collapsed";
+ // Apply mode to all existing DOM elements
+ processGroupStore.applyModeSteps();
+ },
};
export const store = createStore("preferences", model);
diff --git a/webui/index.js b/webui/index.js
index 8a19ae5c8..bd3bd37ff 100644
--- a/webui/index.js
+++ b/webui/index.js
@@ -11,6 +11,7 @@ import { store as chatsStore } from "/components/sidebar/chats/chats-store.js";
import { store as tasksStore } from "/components/sidebar/tasks/tasks-store.js";
import { store as chatTopStore } from "/components/chat/top-section/chat-top-store.js";
import { store as _tooltipsStore } from "/components/tooltips/tooltip-store.js";
+import { store as processGroupStore } from "/components/messages/process-group/process-group-store.js";
globalThis.fetchApi = api.fetchApi; // TODO - backward compatibility for non-modular scripts, remove once refactored to alpine
@@ -414,6 +415,8 @@ function afterMessagesUpdate(logs) {
if (localStorage.getItem("speech") == "true") {
speakMessages(logs);
}
+ // Apply messages expansion mode after rendering
+ processGroupStore.applyModeSteps();
}
function speakMessages(logs) {
diff --git a/webui/js/messages.js b/webui/js/messages.js
index 4d51a7c4b..a92bf47d7 100644
--- a/webui/js/messages.js
+++ b/webui/js/messages.js
@@ -17,6 +17,9 @@ let activeProcessGroupId = null; // Only one process group should show "running"
let activeProcessGroupEl = null;
let activeStepTitleEl = null;
+// Expose activeProcessGroupId for store access
+window.activeProcessGroupId = null;
+
/**
* Mark current process group as active and clear active badges.
*/
@@ -32,6 +35,7 @@ function setActiveProcessGroup(group) {
activeProcessGroupId = group.id;
activeProcessGroupEl = group;
+ window.activeProcessGroupId = group.id; // Keep window copy in sync for store access
}
@@ -1154,8 +1158,8 @@ function createProcessGroup(id) {
group.classList.add("process-group");
group.setAttribute("data-group-id", groupId);
- // Check initial expansion state from store (respects user preference)
- const initiallyExpanded = processGroupStore.isGroupExpanded(groupId);
+ // Check initial expansion state from store
+ const initiallyExpanded = processGroupStore.expandGroup(groupId, true); // true = is active
if (initiallyExpanded) {
group.classList.add('expanded');
}
@@ -1291,9 +1295,17 @@ function addProcessStep(group, id, type, heading, content, kvps, timestamp = nul
const title = getStepTitle(heading, kvps, type);
// Check if step should be expanded
- // Warning steps auto-expand to show content (errors are external MAIN_TYPES, not in process groups)
- const isStepExpanded = processGroupStore.isStepExpanded(groupId, id) ||
- type === "warning";
+ const isActiveStep = !isGroupCompleted && group.id === activeProcessGroupId;
+ const isStepExpanded = processGroupStore.expandStep(groupId, id, isActiveStep);
+
+ // In "current" mode, collapse all other steps
+ const detailMode = preferencesStore.detailMode;
+ if (detailMode === "current" && isStepExpanded) {
+ document.querySelectorAll(".process-step.step-expanded").forEach(s => {
+ s.classList.remove("step-expanded");
+ });
+ }
+
if (isStepExpanded) {
step.classList.add("step-expanded");
}
@@ -1356,11 +1368,6 @@ function addProcessStep(group, id, type, heading, content, kvps, timestamp = nul
const parentStep = currentDelegationSteps[agentNumber - 1];
appendTarget = getNestedContainer(parentStep);
step.classList.add("nested-step");
-
- // Auto-expand parent if this nested step is a warning (errors are external MAIN_TYPES)
- if (type === "warning") {
- parentStep.classList.add("step-expanded");
- }
}
// Remove shiny effect from the previously active step title (O(1))
@@ -1959,6 +1966,7 @@ function markProcessGroupComplete(group, responseTitle) {
// Add completed class to group
group.classList.add("process-group-completed");
+
// Calculate final duration from backend data (sum of all step durations)
const steps = group.querySelectorAll(".process-step");
let totalDurationMs = 0;
@@ -1984,6 +1992,7 @@ export function resetProcessGroups() {
messageGroup = null;
activeProcessGroupId = null;
activeProcessGroupEl = null;
+ window.activeProcessGroupId = null; // Keep window copy in sync
if (activeStepTitleEl) {
activeStepTitleEl.classList.remove("shiny-text");
}