This commit is contained in:
Timothy Jaeryang Baek committed 2026-08-16 22:57:01 -07:00
1 parent 3258330729
commit f7a533cda6
2 files changed
+20 -16

No files matched your search

@@ -121,13 +121,17 @@
export let messageId;
export let selectedModels = [];
let message: MessageType = structuredClone(history.messages[messageId]);
let messageSource = history.messages[messageId];
let message: MessageType = structuredClone(messageSource);
$: if (history.messages) {
const source = history.messages[messageId];
if (source) {
// Fast path: O(1) check on the fields that change most often (content during streaming, done at end)
// Avoids 2x O(n) JSON.stringify calls that are always true during streaming anyway
if (
// Fast path for the fields that change most often while streaming.
// Responses streams update output even when legacy content is unchanged.
if (source !== messageSource) {
messageSource = source;
message = structuredClone(source);
} else if (
message.content !== source.content ||
message.done !== source.done ||
message.output?.length !== source.output?.length