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;