From a03f5121474c80fb758902c56ea3243382d47a58 Mon Sep 17 00:00:00 2001 From: qazal <77887910+Qazalin@users.noreply.github.com> Date: Fri, 6 Mar 2026 22:36:10 +0200 Subject: [PATCH] viz: clean up old / unused paths in sidebar rendering (#15179) * src is unused * less --- tinygrad/viz/js/index.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tinygrad/viz/js/index.js b/tinygrad/viz/js/index.js index ff148bb88e..b9958aadc4 100644 --- a/tinygrad/viz/js/index.js +++ b/tinygrad/viz/js/index.js @@ -302,7 +302,8 @@ function setFocus(key) { } // instructions list renderer let instList = document.getElementById("insts"); - if (data.pcToShape.size > 0 && instList == null) { + if (data.pcToShape.size == 0) return d3.select(instList?.parentElement).html(""); + if (instList == null) { let contents = "", i = 0; for (const [k, v] of data.pcToShape) { contents += `
${i++}${v.wave} @@ -314,7 +315,7 @@ function setFocus(key) { } d3.select(instList).selectAll("span").classed("highlight", false); const instLine = document.getElementById(`inst-${key}`); instLine?.classList.add("highlight"); - if (instLine != null && instList != null) { + if (instLine != null) { const r = rect(instLine), c = rect(instList); if (Math.max(c.top-r.bottom, r.top-c.bottom)>=-30) instLine.scrollIntoView({ block:"center" }); } @@ -871,8 +872,6 @@ async function main() { // ** center graph const { currentCtx, currentStep, currentRewrite, expandSteps } = state; if (currentCtx == -1) return; - // always have a new sidebar when view changes - metadata.innerHTML = ""; const ctx = ctxs[currentCtx]; const step = ctx.steps[currentStep]; const ckey = step?.query; @@ -904,12 +903,9 @@ async function main() { opts = {heightScale:0.5, hideLabels:true, levelKey:step.name.includes("PKTS") ? (e) => parseInt(e.name.split(" ")[1].split(":")[1]) : null, colorByName:ckey.includes("pkts")}; return renderProfiler(ckey, "clk", opts); } - ret.metadata?.forEach(m => { - if (Array.isArray(m)) return metadata.appendChild(tabulate(m.map(({ label, value }) => { - return [label.trim(), typeof value === "string" ? value : formatUnit(value)]; - })).node()); - metadata.appendChild(codeBlock(m.src)).classList.add("full-height") - }); + metadata.replaceChildren(...((ret.metadata ?? []).map((m) => { + return tabulate(m.map((e) => [e.label.trim(), typeof e.value === "string" ? e.value : formatUnit(e.value)])).node(); + }))); // graph render if (ret.data != null) { metadata.prepend(showGraph.label);