core: split message part updates into delta events for smoother streaming

Streaming text and reasoning content now uses incremental delta events instead of sending full message parts on each update. This reduces bandwidth and improves real-time response smoothness in the TUI.
This commit is contained in:
Dax Raad 2026-01-30 11:13:16 -05:00
commit 498cbb2c26
7 changed files with 147 additions and 63 deletions

View file

@ -839,6 +839,23 @@ function createGlobalSync() {
)
break
}
case "message.part.delta": {
const parts = store.part[event.properties.messageID]
if (!parts) break
const result = Binary.search(parts, event.properties.partID, (p) => p.id)
if (!result.found) break
setStore(
"part",
event.properties.messageID,
produce((draft) => {
const part = draft[result.index]
const field = event.properties.field as keyof typeof part
const existing = part[field] as string | undefined
;(part[field] as string) = (existing ?? "") + event.properties.delta
}),
)
break
}
case "message.part.removed": {
const messageID = event.properties.messageID
const parts = store.part[messageID]