Skip to content

Commit f35e104

Browse files
author
Mishig
authored
[Websearch] Fix UI flicker (#710)
* [Wbesarch] Fix UI flicker Co-authored-by: Michael Fried mikelfried@gmail.com * format
1 parent b1cf529 commit f35e104

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/routes/conversation/[id]/+page.svelte

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
const encoder = new TextDecoderStream();
138138
const reader = response?.body?.pipeThrough(encoder).getReader();
139139
let finalAnswer = "";
140+
const messageUpdates: MessageUpdate[] = [];
140141
141142
// set str queue
142143
// ex) if the last response is => {"type": "stream", "token":
@@ -172,6 +173,10 @@
172173
try {
173174
const update = JSON.parse(el) as MessageUpdate;
174175
176+
if (update.type !== "stream") {
177+
messageUpdates.push(update);
178+
}
179+
175180
if (update.type === "finalAnswer") {
176181
finalAnswer = update.text;
177182
reader.cancel();
@@ -224,9 +229,11 @@
224229
});
225230
}
226231
227-
// reset the websearchMessages
228232
webSearchMessages = [];
229233
234+
const lastMessage = messages[messages.length - 1];
235+
lastMessage.updates = messageUpdates;
236+
230237
await invalidate(UrlDependency.ConversationList);
231238
} catch (err) {
232239
if (err instanceof Error && err.message.includes("overloaded")) {

0 commit comments

Comments
 (0)