Overcoming massive memory leaks originating from continuously mutated long strings.
In JavaScript (V8), strings are immutable. Concatening a large conversation (`chatHistory += newChunk`) generates a completely new memory blob, leaving the previous string to the Garbage Collector.
When streaming an infinitely long story iteratively, string concatenation triggers major GC pauses roughly every few seconds. We combat this by utilizing array buffering (`[...historyChunks, newChunk].join('')`) and isolating DOM renders, preserving V8 heap stability natively.