diff --git a/packages/coding-agent/src/core/export-html/index.ts b/packages/coding-agent/src/core/export-html/index.ts index c7b86e60..8024eb39 100644 --- a/packages/coding-agent/src/core/export-html/index.ts +++ b/packages/coding-agent/src/core/export-html/index.ts @@ -173,8 +173,8 @@ function generateHtml(sessionData: SessionData, themeName?: string): string { .replace("{{HIGHLIGHT_JS}}", hljsJs); } -/** Built-in tool names that have custom rendering in template.js */ -const BUILTIN_TOOLS = new Set(["bash", "read", "write", "edit", "ls", "find", "grep"]); +/** Tools rendered directly by the HTML template (not pre-rendered via TUI→ANSI→HTML pipeline) */ +const TEMPLATE_RENDERED_TOOLS = new Set(["bash", "read", "write", "edit", "ls"]); /** * Pre-render custom tools to HTML using their TUI renderers. @@ -192,7 +192,7 @@ function preRenderCustomTools( // Find tool calls in assistant messages if (msg.role === "assistant" && Array.isArray(msg.content)) { for (const block of msg.content) { - if (block.type === "toolCall" && !BUILTIN_TOOLS.has(block.name)) { + if (block.type === "toolCall" && !TEMPLATE_RENDERED_TOOLS.has(block.name)) { const callHtml = toolRenderer.renderCall(block.id, block.name, block.arguments); if (callHtml) { renderedTools[block.id] = { callHtml }; @@ -204,9 +204,9 @@ function preRenderCustomTools( // Find tool results if (msg.role === "toolResult" && msg.toolCallId) { const toolName = msg.toolName || ""; - // Only render if we have a pre-rendered call OR it's not a built-in tool + // Only render if we have a pre-rendered call OR it's not template-rendered const existing = renderedTools[msg.toolCallId]; - if (existing || !BUILTIN_TOOLS.has(toolName)) { + if (existing || !TEMPLATE_RENDERED_TOOLS.has(toolName)) { const rendered = toolRenderer.renderResult( msg.toolCallId, toolName, diff --git a/packages/coding-agent/src/core/export-html/template.js b/packages/coding-agent/src/core/export-html/template.js index f03aecc3..ff9e4641 100644 --- a/packages/coding-agent/src/core/export-html/template.js +++ b/packages/coding-agent/src/core/export-html/template.js @@ -76,8 +76,8 @@ // Create nodes for (const entry of entries) { - nodeMap.set(entry.id, { - entry, + nodeMap.set(entry.id, { + entry, children: [], label: labelMap.get(entry.id) }); @@ -200,7 +200,7 @@ const stack = []; // Add roots (prioritize branch containing active leaf) - const orderedRoots = [...roots].sort((a, b) => + const orderedRoots = [...roots].sort((a, b) => Number(containsActive.get(b)) - Number(containsActive.get(a)) ); for (let i = orderedRoots.length - 1; i >= 0; i--) { @@ -217,7 +217,7 @@ const multipleChildren = children.length > 1; // Order children (active branch first) - const orderedChildren = [...children].sort((a, b) => + const orderedChildren = [...children].sort((a, b) => Number(containsActive.get(b)) - Number(containsActive.get(a)) ); @@ -880,8 +880,8 @@ const renderResultImages = () => { const images = getResultImages(); if (images.length === 0) return ''; - return '