Agent Zero AI framework
Add timestamps and per-step execution time
Wabifocus72439d596613
diff --git a/python/helpers/log.py b/python/helpers/log.pyindex a79966658..a396de0b5 100644--- a/python/helpers/log.py+++ b/python/helpers/log.py@@ -1,5 +1,6 @@from dataclasses import dataclass, fieldimport json+import timefrom typing import Any, Literal, Optional, Dict, TypeVar, TYPE_CHECKINGT = TypeVar("T")@@ -131,9 +132,11 @@ class LogItem:kvps: Optional[OrderedDict] = None # Use OrderedDict for kvpsid: Optional[str] = None # Add id fieldguid: str = ""+ timestamp: float = 0.0 # Unix timestamp in secondsdef __post_init__(self):self.guid = self.log.guid+ self.timestamp = time.time() # Record creation timedef update(self,@@ -181,6 +184,7 @@ class LogItem:"content": self.content,"temp": self.temp,"kvps": self.kvps,+ "timestamp": self.timestamp, # Unix timestamp in seconds}diff --git a/webui/components/messages/process-group/process-group.css b/webui/components/messages/process-group/process-group.cssindex 62c9bc661..1d3267949 100644--- a/webui/components/messages/process-group/process-group.css+++ b/webui/components/messages/process-group/process-group.css@@ -6,7 +6,7 @@margin: var(--spacing-sm) 0;padding: var(--spacing-sm) var(--spacing-md);border-radius: var(--border-radius);- background: rgba(31, 60, 30, 0.3);+ background: #1f3c1e;border: 1px solid rgba(255, 255, 255, 0.06);min-width: 200px;max-width: 100%;@@ -23,7 +23,7 @@margin: 0;border-radius: var(--border-radius) var(--border-radius) 0 0;border-bottom: 1px solid rgba(255, 255, 255, 0.08);- background: rgba(31, 60, 30, 0.4);+ background: transparent;}/* Message container with embedded process group */@@ -87,23 +87,43 @@}.process-group-header .group-title {+ flex: 1;font-size: var(--font-size-smaller);font-weight: 400;color: var(--color-text);opacity: 0.7;white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;}.process-group-header .step-count {font-size: 0.7rem;color: var(--color-text);- opacity: 0.5;+ opacity: 0.6;flex-shrink: 0;background-color: rgba(255, 255, 255, 0.06);padding: 1px 6px;border-radius: 8px;}+.process-group-header .group-timestamp {+ font-size: 0.65rem;+ color: rgba(255, 255, 255, 0.65);+ flex-shrink: 0;+ font-family: var(--font-family-code);+ margin-left: auto;+}++.process-group-header .group-duration {+ font-size: 0.7rem;+ color: #81c784;+ flex-shrink: 0;+ font-family: var(--font-family-code);+ min-width: 40px;+ text-align: right;+}+/* Process Group Content - Animated expand/collapse */.process-group-content {display: grid;@@ -163,19 +183,14 @@.process-step[data-type="util"]:hover,.process-step[data-type="info"]:hover,.process-step[data-type="hint"]:hover {- background-color: rgba(120, 115, 100, 0.18);+ background-color: rgba(255, 255, 255, 0.03);}-.light-mode .process-step[data-type="util"],-.light-mode .process-step[data-type="info"],-.light-mode .process-step[data-type="hint"] {- background-color: rgba(91, 85, 64, 0.06);-}.light-mode .process-step[data-type="util"]:hover,.light-mode .process-step[data-type="info"]:hover,.light-mode .process-step[data-type="hint"]:hover {- background-color: rgba(91, 85, 64, 0.1);+ background-color: rgba(0, 0, 0, 0.04);}/* Step Header (clickable) */@@ -225,6 +240,15 @@text-overflow: ellipsis;}+.process-step-header .step-time {+ font-size: 0.65rem;+ color: #81c784;+ flex-shrink: 0;+ font-family: var(--font-family-code);+ min-width: 35px;+ text-align: right;+}+.process-step-header .step-expand-icon {font-size: 0.8rem;opacity: 0.4;@@ -353,6 +377,18 @@color: #188216;}+.light-mode .process-group-header .group-timestamp {+ color: rgba(0, 0, 0, 0.5);+}++.light-mode .process-group-header .group-duration {+ color: #2e7d32;+}++.light-mode .process-step-header .step-time {+ color: #388e3c;+}+/* Animation for loading state */@keyframes pulse-step {0%, 100% { opacity: 0.5; }diff --git a/webui/index.js b/webui/index.jsindex f09423828..614cd9055 100644--- a/webui/index.js+++ b/webui/index.js@@ -185,8 +185,8 @@ async function updateUserTime() {updateUserTime();setInterval(updateUserTime, 1000);-function setMessage(id, type, heading, content, temp, kvps = null) {- const result = msgs.setMessage(id, type, heading, content, temp, kvps);+function setMessage(id, type, heading, content, temp, kvps = null, timestamp = null) {+ const result = msgs.setMessage(id, type, heading, content, temp, kvps, timestamp);const chatHistoryEl = document.getElementById("chat-history");if (preferencesStore.autoScroll && chatHistoryEl) {chatHistoryEl.scrollTop = chatHistoryEl.scrollHeight;@@ -310,7 +310,8 @@ export async function poll() {log.heading,log.content,log.temp,- log.kvps+ log.kvps,+ log.timestamp);}afterMessagesUpdate(response.logs);diff --git a/webui/js/messages.js b/webui/js/messages.jsindex 5b8faa107..286e23cd6 100644--- a/webui/js/messages.js+++ b/webui/js/messages.js@@ -19,7 +19,7 @@ const MAIN_TYPES = ['user', 'response', 'warning', 'error', 'rate_limit'];// Simplified implementation - no complex interactions needed-export function setMessage(id, type, heading, content, temp, kvps = null) {+export function setMessage(id, type, heading, content, temp, kvps = null, timestamp = null) {// Check if this is a process type messageconst isProcessType = PROCESS_TYPES.includes(type);const isMainType = MAIN_TYPES.includes(type);@@ -49,7 +49,7 @@ export function setMessage(id, type, heading, content, temp, kvps = null) {}// Add step to current process group- processStepElement = addProcessStep(currentProcessGroup, id, type, heading, content, kvps);+ processStepElement = addProcessStep(currentProcessGroup, id, type, heading, content, kvps, timestamp);return processStepElement;}@@ -1136,6 +1136,7 @@ function createProcessGroup(id) {<span class="material-symbols-outlined group-icon">neurology</span><span class="group-title">Processing...</span><span class="step-count">0 steps</span>+ <span class="group-timestamp"></span>`;// Add click handler for expansion@@ -1164,7 +1165,7 @@ function createProcessGroup(id) {/*** Add a step to a process group*/-function addProcessStep(group, id, type, heading, content, kvps) {+function addProcessStep(group, id, type, heading, content, kvps, timestamp = null) {const groupId = group.getAttribute("data-group-id");const stepsContainer = group.querySelector(".process-steps");@@ -1175,6 +1176,21 @@ function addProcessStep(group, id, type, heading, content, kvps) {step.setAttribute("data-type", type);step.setAttribute("data-step-id", id);+ // Store timestamp for duration calculation+ if (timestamp) {+ step.setAttribute("data-timestamp", timestamp);++ // Set group start time from first step+ if (!group.getAttribute("data-start-timestamp")) {+ group.setAttribute("data-start-timestamp", timestamp);+ // Update header with formatted datetime+ const timestampEl = group.querySelector(".group-timestamp");+ if (timestampEl) {+ timestampEl.textContent = formatDateTime(timestamp);+ }+ }+ }+// Add message-util class for utility/info types (controlled by showUtils preference)if (type === "util" || type === "info" || type === "hint") {step.classList.add("message-util");@@ -1198,10 +1214,22 @@ function addProcessStep(group, id, type, heading, content, kvps) {// Create step headerconst stepHeader = document.createElement("div");stepHeader.classList.add("process-step-header");++ // Calculate relative time from group start+ let relativeTimeStr = "";+ if (timestamp) {+ const groupStartTime = parseFloat(group.getAttribute("data-start-timestamp") || "0");+ if (groupStartTime > 0) {+ const relativeMs = (timestamp - groupStartTime) * 1000;+ relativeTimeStr = formatRelativeTime(relativeMs);+ }+ }+stepHeader.innerHTML = `<span class="material-symbols-outlined step-icon">${icon}</span><span class="step-type">${label}</span><span class="step-title">${escapeHTML(title)}</span>+ ${relativeTimeStr ? `<span class="step-time">${relativeTimeStr}</span>` : ""}<span class="material-symbols-outlined step-expand-icon">expand_more</span>`;@@ -1426,3 +1454,33 @@ export function resetProcessGroups() {currentProcessGroup = null;messageGroup = null;}++/**+ * Format Unix timestamp as date-time string (YYYY-MM-DD HH:MM:SS)+ */+function formatDateTime(timestamp) {+ const date = new Date(timestamp * 1000); // Convert seconds to milliseconds+ const year = date.getFullYear();+ const month = String(date.getMonth() + 1).padStart(2, "0");+ const day = String(date.getDate()).padStart(2, "0");+ const hours = String(date.getHours()).padStart(2, "0");+ const minutes = String(date.getMinutes()).padStart(2, "0");+ const seconds = String(date.getSeconds()).padStart(2, "0");+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;+}++/**+ * Format relative time for steps (e.g., +0.5s, +2.3s)+ */+function formatRelativeTime(ms) {+ if (ms < 100) {+ return "+0s";+ }+ const seconds = ms / 1000;+ if (seconds < 60) {+ return `+${seconds.toFixed(1)}s`;+ }+ const minutes = Math.floor(seconds / 60);+ const remainingSeconds = Math.round(seconds % 60);+ return `+${minutes}m${remainingSeconds}s`;+}