/** * Agent Timeline — visual execution timeline built from SSE events */ let containerEl; let steps = []; export function initTimeline() { // The timeline renders inside the inspector; this module manages the data containerEl = null; steps = []; } export function addTimelineStep({ step, totalSteps, agent, description, status }) { steps.push({ step, totalSteps, agent, description, status: status || 'executing', tools: [], }); renderTimeline(); } export function updateTimelineStep(agent, { tool, status }) { // Find the last step for this agent for (let i = steps.length - 1; i >= 0; i--) { if (steps[i].agent === agent) { if (tool) { steps[i].tools.push({ name: tool, status: status || 'completed' }); } break; } } renderTimeline(); } export function clearTimeline() { steps = []; renderTimeline(); } function renderTimeline() { // Find or create the timeline container in the inspector const inspector = document.getElementById('inspector'); if (!inspector) return; // Remove existing timeline section let existing = document.getElementById('live-timeline-section'); if (existing) existing.remove(); if (steps.length === 0) return; const section = document.createElement('div'); section.className = 'inspector-section'; section.id = 'live-timeline-section'; let html = '