mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-03 11:29:56 +08:00
Two pieces of work ran on every streamed delta without producing a pixel. The first is the working-out. ``messageSegments`` is rebuilt from scratch whenever content arrives, so the trace — which stops changing the moment a turn starts writing its answer — handed React a brand-new element tree on every frame of that answer, and React cannot skip a subtree whose elements it has never seen. Profiled over one turn: 2905 renders of the process, against 2 milliseconds total for the answer's own markdown beside it. It now sits behind a memo keyed on what it holds rather than on the props it is given, and a turn that has started writing its answer marks the process above it settled, so even the event counts stop mattering. Measured the same way afterwards: 346 renders, every remaining one during the thinking phase where the trace really is still moving. The second is the reveal rate. A markdown consumer re-parses its whole document on every render, so a turn costs reveals × length — and revealing per delta made that quadratic in the answer's own length, which is the shape of "it streams fine at first and gets choppier the longer it runs". The rate cap has to be in time rather than characters, because a model sending three characters at a time sets the pace and there is nothing to reveal ahead of it. A page-length reply is untouched; a 5KB one reveals at 20fps. The list also handed every row a fresh onTraceToggle closure, which defeated the memo on AssistantMessage outright: every message in the conversation re-rendered on every delta of the turn at the bottom.