Problem
When a thinking-block agent response finishes, chat.js currently does:
if (_liveReplyEl && _finalReply) {
var _replyHtml = markdownModule.mdToHtml(markdownModule.squashOutsideCode(_finalReply));
_liveReplyEl.innerHTML = _replyHtml;
_liveReplyEl._streamRenderer was built up incrementally during streaming and already holds the correct content. The innerHTML = mdToHtml() call creates an entirely new DOM tree and discards the streamed one — one complete response-worth of detached Oilpan nodes per agent exchange.
Fix
When _liveReplyEl._streamRenderer exists, call update(_finalReply) to sync to the final post-processed text, then finalize() to freeze in place. Fall back to the existing innerHTML path only when the renderer is absent.
Impact
Eliminates the largest single-event Oilpan deposition per agent response — one full response-worth of DOM nodes freed per exchange rather than discarded as detached garbage.
Related to the OOM investigation in the fork.
Problem
When a thinking-block agent response finishes,
chat.jscurrently does:_liveReplyEl._streamRendererwas built up incrementally during streaming and already holds the correct content. TheinnerHTML = mdToHtml()call creates an entirely new DOM tree and discards the streamed one — one complete response-worth of detached Oilpan nodes per agent exchange.Fix
When
_liveReplyEl._streamRendererexists, callupdate(_finalReply)to sync to the final post-processed text, thenfinalize()to freeze in place. Fall back to the existinginnerHTMLpath only when the renderer is absent.Impact
Eliminates the largest single-event Oilpan deposition per agent response — one full response-worth of DOM nodes freed per exchange rather than discarded as detached garbage.
Related to the OOM investigation in the fork.