fix(ui): prevent streaming text flicker and first-chunk loss
This commit is contained in:
@@ -314,9 +314,13 @@ export function createEventPipeline(input: EventPipelineInput) {
|
|||||||
} else {
|
} else {
|
||||||
d.queue[i] = normalizedPayload
|
d.queue[i] = normalizedPayload
|
||||||
if (normalizedPayload.type === "message.part.updated") {
|
if (normalizedPayload.type === "message.part.updated") {
|
||||||
const part = (normalizedPayload.properties as { part: { messageID: string; id: string } }).part
|
const part = (normalizedPayload.properties as { part: Record<string, unknown> & { messageID: string; id: string } }).part
|
||||||
d.staleDeltas.add(deltaKey(part.messageID, part.id, "text"))
|
for (const field of ["text", "output"] as const) {
|
||||||
d.staleDeltas.add(deltaKey(part.messageID, part.id, "output"))
|
const value = part[field]
|
||||||
|
if (typeof value === "string" && value.length > 0) {
|
||||||
|
d.staleDeltas.add(deltaKey(part.messageID, part.id, field))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
syncDebug.pipeline.coalesced(normalizedPayload.type, k)
|
syncDebug.pipeline.coalesced(normalizedPayload.type, k)
|
||||||
|
|||||||
@@ -1227,12 +1227,12 @@ function handleEvent(
|
|||||||
const messageID = getMessageIdFromPayload(payload) ?? undefined
|
const messageID = getMessageIdFromPayload(payload) ?? undefined
|
||||||
syncDebug.dispatch.eventNoChange(payload.type, sessionID, messageID)
|
syncDebug.dispatch.eventNoChange(payload.type, sessionID, messageID)
|
||||||
|
|
||||||
// Parts-gap recovery: if a part event was dropped because the parts array
|
// Parts-gap recovery: if a delta event was dropped because the parts array
|
||||||
// was missing (message not yet inserted or parts lost), trigger a repair
|
// was missing or the partID was not found, trigger a repair fetch for the
|
||||||
// fetch for the session.
|
// session. message.part.updated never needs repair — it only returns false
|
||||||
if (sessionID && messageID && (
|
// for intentionally skipped types (step-start, step-finish, patch) or when
|
||||||
payload.type === "message.part.delta" || payload.type === "message.part.updated"
|
// preserving an existing finished tool part, neither of which indicates missing data.
|
||||||
)) {
|
if (sessionID && messageID && payload.type === "message.part.delta") {
|
||||||
enqueuePartsRepair(resolvedDirectory, sessionID, childStores)
|
enqueuePartsRepair(resolvedDirectory, sessionID, childStores)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user