feat: keep bouncing dots until first streaming chunk arrives
Browse filesPreviously startAssistantMessage() was called immediately before the
stream loop, replacing the typing indicator with an empty bubble at
once. Now it is called lazily on the first actual chunk, so the three
bouncing dots remain visible for the full backend think/TTFB period.
If the stream completes with zero chunks (empty response), the
assistant bubble is still started so finalizeAssistantMessage has a
valid element to work with.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- src/components/app.js +7 -1
src/components/app.js
CHANGED
|
@@ -288,14 +288,20 @@ export class App {
|
|
| 288 |
const apiMessages = formatMessagesForApi([...(preConv?.messages || []), userMessage]);
|
| 289 |
|
| 290 |
try {
|
| 291 |
-
|
| 292 |
let fullText = '';
|
| 293 |
|
| 294 |
for await (const chunk of streamCompletion(settings.baseUrl, settings.apiKey, model, apiMessages)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
fullText += chunk;
|
| 296 |
this.chat.appendToAssistantMessage(chunk);
|
| 297 |
}
|
| 298 |
|
|
|
|
|
|
|
| 299 |
// Finalize
|
| 300 |
this.chat.finalizeAssistantMessage(fullText);
|
| 301 |
store.addMessage(convId, {
|
|
|
|
| 288 |
const apiMessages = formatMessagesForApi([...(preConv?.messages || []), userMessage]);
|
| 289 |
|
| 290 |
try {
|
| 291 |
+
let started = false;
|
| 292 |
let fullText = '';
|
| 293 |
|
| 294 |
for await (const chunk of streamCompletion(settings.baseUrl, settings.apiKey, model, apiMessages)) {
|
| 295 |
+
if (!started) {
|
| 296 |
+
this.chat.startAssistantMessage();
|
| 297 |
+
started = true;
|
| 298 |
+
}
|
| 299 |
fullText += chunk;
|
| 300 |
this.chat.appendToAssistantMessage(chunk);
|
| 301 |
}
|
| 302 |
|
| 303 |
+
if (!started) this.chat.startAssistantMessage();
|
| 304 |
+
|
| 305 |
// Finalize
|
| 306 |
this.chat.finalizeAssistantMessage(fullText);
|
| 307 |
store.addMessage(convId, {
|