Agent Zero AI framework
tool specific step badges
3clyp503e31dcbb421e
diff --git a/webui/components/messages/process-group/process-group-store.js b/webui/components/messages/process-group/process-group-store.jsindex ef71b4106..f0c61afdd 100644--- a/webui/components/messages/process-group/process-group-store.js+++ b/webui/components/messages/process-group/process-group-store.js@@ -1,6 +1,43 @@import { createStore } from "/js/AlpineStore.js";// Process Group Store - manages collapsible process groups in chat++// Unified mapping for both Tool Names and Step Types+// Specific tool names (keys) take precedence over generic types+const DISPLAY_CODES = {+ // --- Specific Tools ---+ 'call_subordinate': 'SUB',+ 'search_engine': 'WEB',+ 'a2a_chat': 'A2A',+ 'behaviour_adjustment': 'ADJ',+ 'document_query': 'DOC',+ 'vision_load': 'EYE',+ 'notify_user': 'NTF',+ 'scheduler': 'SCH',+ 'unknown': 'UNK',+ // Memory operations group+ 'memory_save': 'MEM',+ 'memory_load': 'MEM',+ 'memory_forget': 'MEM',+ 'memory_delete': 'MEM',++ // --- Step Types ---+ 'agent': 'GEN',+ 'response': 'END',+ 'tool': 'USE', // Generic fallback for tools+ 'code_exe': 'EXE',+ 'browser': 'BRW',+ 'progress': 'HLD',+ 'subagent': 'SUB', // Type fallback if tool name missing+ 'mcp': 'MCP',+ 'info': 'INF',+ 'hint': 'HNT',+ 'warning': 'WRN',+ 'error': 'ERR',+ 'util': 'UTL',+ 'done': 'END'+};+const model = {// Track which process groups are expanded (by group ID)expandedGroups: {},@@ -101,24 +138,16 @@ const model = {},// Status code (3-4 letter) for backend log types- getStepCode(type) {- const codes = {- 'agent': 'GEN',- 'response': 'END',- 'tool': 'TOOL',- 'mcp': 'MCP',- 'subagent': 'SUB',- 'code_exe': 'EXE',- 'browser': 'BRW',- 'progress': 'WAIT',- 'info': 'INF',- 'hint': 'HNT',- 'warning': 'WRN',- 'error': 'ERR',- 'util': 'UTL',- 'done': 'END'- };- return codes[type] || type?.toUpperCase()?.slice(0, 4) || 'GEN';+ // Looks up tool name first (specific), then falls back to type (generic)+ getStepCode(type, toolName = null) {+ // Specific tool codes only apply to generic 'tool' steps+ if (type === 'tool' && toolName && DISPLAY_CODES[toolName]) {+ return DISPLAY_CODES[toolName];+ }++ return DISPLAY_CODES[type] ||+ type?.toUpperCase()?.slice(0, 4) ||+ 'GEN';},// CSS color class for backend log typesdiff --git a/webui/components/messages/process-group/process-group.css b/webui/components/messages/process-group/process-group.cssindex 4387c4c2f..d7afee9aa 100644--- a/webui/components/messages/process-group/process-group.css+++ b/webui/components/messages/process-group/process-group.css@@ -155,7 +155,7 @@border: 1px solid rgba(34, 197, 94, 0.3);}-/* TOOL - tool type (amber/yellow) */+/* USE - tool usage (amber/yellow) */.status-tool {background-color: rgba(251, 191, 36, 0.15);color: #fbbf24;@@ -512,7 +512,7 @@.process-step-detail-content .step-kvps {display: flex;flex-direction: column;- gap: var(--spacing-xxs);+ gap: var(--spacing-sm);}.process-step-detail-content .step-kvp {diff --git a/webui/js/messages.js b/webui/js/messages.jsindex 4a4537585..86c1861e1 100644--- a/webui/js/messages.js+++ b/webui/js/messages.js@@ -13,6 +13,49 @@ const chatHistory = document.getElementById("chat-history");let messageGroup = null;let currentProcessGroup = null; // Track current process group for collapsible UI+/**+ * Resolve tool name from kvps, existing attribute, or previous siblings+ * For 'tool' type steps, inherits from preceding step if not directly available+ */+function resolveToolName(type, kvps, stepElement) {+ // Direct from kvps+ if (kvps?.tool_name) return kvps.tool_name;++ // Keep existing if present (for non-tool types during updates)+ if (type !== 'tool' && stepElement?.hasAttribute('data-tool-name')) {+ return stepElement.getAttribute('data-tool-name');+ }++ // Inherit from previous sibling (for tool steps)+ if (type === 'tool' && stepElement) {+ let prev = stepElement.previousElementSibling;+ while (prev) {+ if (prev.hasAttribute('data-tool-name')) {+ return prev.getAttribute('data-tool-name');+ }+ prev = prev.previousElementSibling;+ }+ }++ return null;+}++/**+ * Update status badge text content while preserving the icon+ */+function updateBadgeText(badge, newCode) {+ if (!badge) return;++ // Find and update text node, or append new one+ for (const node of badge.childNodes) {+ if (node.nodeType === Node.TEXT_NODE && node.textContent.trim()) {+ node.textContent = newCode;+ return;+ }+ }+ badge.appendChild(document.createTextNode(newCode));+}+// Process types that should be grouped into collapsible sectionsconst PROCESS_TYPES = ['agent', 'tool', 'code_exe', 'browser', 'progress', 'info', 'hint', 'util', 'warning'];// Main types that should always be visible (not collapsed)@@ -1182,6 +1225,19 @@ function addProcessStep(group, id, type, heading, content, kvps, timestamp = nulstep.setAttribute("data-type", type);step.setAttribute("data-step-id", id);+ // Resolve tool name (direct, inherited, or null)+ // For new steps, pass null as stepElement - inheritance uses stepsContainer query+ let toolNameToUse = kvps?.tool_name;+ if (type === 'tool' && !toolNameToUse) {+ const existingSteps = stepsContainer.querySelectorAll('.process-step[data-tool-name]');+ if (existingSteps.length > 0) {+ toolNameToUse = existingSteps[existingSteps.length - 1].getAttribute("data-tool-name");+ }+ }+ if (toolNameToUse) {+ step.setAttribute("data-tool-name", toolNameToUse);+ }+// Store timestamp for duration calculationif (timestamp) {step.setAttribute("data-timestamp", timestamp);@@ -1227,7 +1283,7 @@ function addProcessStep(group, id, type, heading, content, kvps, timestamp = nulstepHeader.classList.add("process-step-header");// Status code and color class from store (maps backend types)- const statusCode = processGroupStore.getStepCode(type);+ const statusCode = processGroupStore.getStepCode(type, toolNameToUse);const statusColorClass = processGroupStore.getStatusColorClass(type);// Icon extracted from heading (backend sends icon://xxx), fallback to type-based@@ -1290,6 +1346,14 @@ function updateProcessStep(stepElement, id, type, heading, content, kvps, duratistepElement.setAttribute("data-duration-ms", durationMs);}+ // Resolve and update tool name + badge+ const toolNameToUse = resolveToolName(type, kvps, stepElement);+ if (toolNameToUse) {+ stepElement.setAttribute("data-tool-name", toolNameToUse);+ const newCode = processGroupStore.getStepCode(type, toolNameToUse);+ updateBadgeText(stepElement.querySelector(".status-badge"), newCode);+ }+// Update detail contentconst detailContent = stepElement.querySelector(".process-step-detail-content");if (detailContent) {@@ -1644,12 +1708,13 @@ function updateProcessGroupHeader(group) {// Get the last step's type for statusconst lastStep = steps[steps.length - 1];const lastType = lastStep.getAttribute("data-type");+ const lastToolName = lastStep.getAttribute("data-tool-name");const lastTitle = lastStep.querySelector(".step-title")?.textContent || "";// Update status badge with icon (keep status-active during execution)if (statusEl) {// Status code and color class from store (maps backend types)- const statusCode = processGroupStore.getStepCode(lastType);+ const statusCode = processGroupStore.getStepCode(lastType, lastToolName);const statusColorClass = processGroupStore.getStatusColorClass(lastType);// Get icon from the last step's badge, fallback to type-basedconst lastStepBadge = lastStep.querySelector(".badge-icon");