MCPcopy
hub / github.com/ChatGPTNextWeb/NextChat / animateResponseText

Function animateResponseText

app/utils/chat.ts:198–217  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

196
197 // animate response to make it looks smooth
198 function animateResponseText() {
199 if (finished || controller.signal.aborted) {
200 responseText += remainText;
201 console.log("[Response Animation] finished");
202 if (responseText?.length === 0) {
203 options.onError?.(new Error("empty response from server"));
204 }
205 return;
206 }
207
208 if (remainText.length > 0) {
209 const fetchCount = Math.max(1, Math.round(remainText.length / 60));
210 const fetchText = remainText.slice(0, fetchCount);
211 responseText += fetchText;
212 remainText = remainText.slice(fetchCount);
213 options.onUpdate?.(responseText, fetchText);
214 }
215
216 requestAnimationFrame(animateResponseText);
217 }
218
219 // start animaion
220 animateResponseText();

Callers 5

chatMethod · 0.85
chatMethod · 0.85
chatMethod · 0.85
streamFunction · 0.85
streamWithThinkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected