From a14decf2bc0271ffc588610ce00b55716bbfd252 Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Sat, 31 Jan 2026 09:12:20 -0500 Subject: [PATCH] Fix HTML truncation to avoid cutting inside tags --- public/index.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 1c7c4a4..4b80cd8 100644 --- a/public/index.html +++ b/public/index.html @@ -1433,7 +1433,12 @@ // Soft cap to prevent unbounded growth in DOM and memory const MAX_OUTPUT_CHARS = 200000; // ~200KB of HTML per session if (session.output.length > MAX_OUTPUT_CHARS) { - const start = session.output.length - MAX_OUTPUT_CHARS; + let start = session.output.length - MAX_OUTPUT_CHARS; + // Find safe cut point - don't cut inside an HTML tag + const firstTagEnd = session.output.indexOf('>', start); + if (firstTagEnd !== -1 && firstTagEnd < start + 100) { + start = firstTagEnd + 1; + } session.output = session.output.slice(start); // Reset DOM to trimmed content and sync rendered length $output.innerHTML = session.output;