Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Websearch] Fix UI flicker #710

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/routes/conversation/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
const encoder = new TextDecoderStream();
const reader = response?.body?.pipeThrough(encoder).getReader();
let finalAnswer = "";
const messageUpdates: MessageUpdate[] = [];

// set str queue
// ex) if the last response is => {"type": "stream", "token":
Expand Down Expand Up @@ -172,6 +173,10 @@
try {
const update = JSON.parse(el) as MessageUpdate;

if (update.type !== "stream") {
messageUpdates.push(update);
}

if (update.type === "finalAnswer") {
finalAnswer = update.text;
reader.cancel();
Expand Down Expand Up @@ -224,9 +229,11 @@
});
}

// reset the websearchMessages
webSearchMessages = [];

const lastMessage = messages[messages.length - 1];
lastMessage.updates = messageUpdates;

await invalidate(UrlDependency.ConversationList);
} catch (err) {
if (err instanceof Error && err.message.includes("overloaded")) {
Expand Down