diff --git a/ui/suite/tasks/tasks.js b/ui/suite/tasks/tasks.js index 5bf1980..5b2221f 100644 --- a/ui/suite/tasks/tasks.js +++ b/ui/suite/tasks/tasks.js @@ -441,15 +441,32 @@ function handleWebSocketMessage(data) { break; case "manifest_update": - console.log("[Tasks WS] MANIFEST_UPDATE for task:", data.task_id); + console.log( + "[Tasks WS] MANIFEST_UPDATE for task:", + data.task_id, + "selected:", + TasksState.selectedTaskId, + ); // Update the progress log section with manifest data if (data.details) { try { const manifestData = JSON.parse(data.details); + console.log( + "[Tasks WS] Manifest parsed, sections:", + manifestData.sections?.length, + "status:", + manifestData.status, + ); renderManifestProgress(data.task_id, manifestData); } catch (e) { - console.error("[Tasks WS] Failed to parse manifest:", e); + console.error( + "[Tasks WS] Failed to parse manifest:", + e, + data.details?.substring(0, 200), + ); } + } else { + console.warn("[Tasks WS] manifest_update received but no details"); } break; } @@ -459,8 +476,16 @@ function handleWebSocketMessage(data) { const pendingManifestUpdates = new Map(); function renderManifestProgress(taskId, manifest, retryCount = 0) { + console.log( + "[Manifest] renderManifestProgress called for task:", + taskId, + "selected:", + TasksState.selectedTaskId, + ); + // Only update if this is the selected task if (TasksState.selectedTaskId !== taskId) { + console.log("[Manifest] Skipping - not selected task"); return; } @@ -471,6 +496,7 @@ function renderManifestProgress(taskId, manifest, retryCount = 0) { } if (!progressLog) { + console.log("[Manifest] No progress log element found, retry:", retryCount); // If task is selected but element not yet loaded, retry after a delay if (retryCount < 5) { pendingManifestUpdates.set(taskId, manifest); @@ -491,29 +517,28 @@ function renderManifestProgress(taskId, manifest, retryCount = 0) { pendingManifestUpdates.delete(taskId); if (!manifest || !manifest.sections) { + console.log("[Manifest] No sections in manifest"); return; } + console.log("[Manifest] Rendering", manifest.sections.length, "sections"); + const totalSteps = manifest.progress?.total || 60; // Update STATUS section if exists updateStatusSection(manifest); - // Update or create progress tree - let tree = progressLog.querySelector(".taskmd-tree"); - if (!tree) { - // First render - create full HTML - progressLog.innerHTML = buildProgressTreeHTML(manifest, totalSteps); - // Auto-expand running sections - progressLog - .querySelectorAll(".tree-section.running, .tree-child.running") - .forEach((el) => { - el.classList.add("expanded"); - }); - } else { - // Incremental update - only update changed elements - updateProgressTree(tree, manifest, totalSteps); - } + // Always rebuild the tree to ensure children are shown + // This is simpler and more reliable than incremental updates + const html = buildProgressTreeHTML(manifest, totalSteps); + progressLog.innerHTML = html; + + // Auto-expand running sections + progressLog + .querySelectorAll(".tree-section.running, .tree-child.running") + .forEach((el) => { + el.classList.add("expanded"); + }); // Update terminal stats updateTerminalStats(taskId, manifest); @@ -521,69 +546,116 @@ function renderManifestProgress(taskId, manifest, retryCount = 0) { function updateStatusSection(manifest) { const statusContent = document.querySelector(".taskmd-status-content"); - if (!statusContent) return; + if (!statusContent) { + console.log("[Manifest] No status content element found"); + return; + } // Update current action const actionText = statusContent.querySelector( ".status-current .status-text", ); - if (actionText && manifest.status?.current_action) { - actionText.textContent = manifest.status.current_action; + const currentAction = + manifest.status?.current_action || + manifest.current_status?.current_action || + "Processing..."; + if (actionText) { + actionText.textContent = currentAction; } // Update runtime const runtimeEl = statusContent.querySelector(".status-main .status-time"); - if (runtimeEl && manifest.status?.runtime_display) { - runtimeEl.innerHTML = `Runtime: ${manifest.status.runtime_display} `; + const runtime = + manifest.status?.runtime_display || manifest.runtime || "Not started"; + if (runtimeEl) { + runtimeEl.innerHTML = `Runtime: ${runtime} `; } // Update estimated const estimatedEl = statusContent.querySelector( ".status-current .status-time", ); - if (estimatedEl && manifest.status?.estimated_display) { - estimatedEl.innerHTML = `Estimated: ${manifest.status.estimated_display} ⚙`; + const estimated = + manifest.status?.estimated_display || + (manifest.estimated_seconds + ? `${manifest.estimated_seconds} sec` + : "calculating..."); + if (estimatedEl) { + estimatedEl.innerHTML = `Estimated: ${estimated} ⚙`; } + + console.log( + "[Manifest] Status updated - action:", + currentAction, + "runtime:", + runtime, + "estimated:", + estimated, + ); } function buildProgressTreeHTML(manifest, totalSteps) { let html = '