Fix HTML truncation to avoid cutting inside tags
This commit is contained in:
parent
3e5afbd5a8
commit
a14decf2bc
1 changed files with 6 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue