refactor(desktop): index every part row in backfill and say why anchors differ

The query side reads identity through transcriptRowIds, which takes
sourceRowId from every part, while the index side still filtered on
`part.type === 'text'`. Only text parts are ever stamped, so the filter
did nothing but make the two sides use different rules; drop it.

Replace the comment that restated the rowId-vs-last-part ternary with
the reason for it: a fold with a rowId is addressed by its first source
row (hydration's key); without one, its last part row is the final
reply the settled live bubble holds, so pending rows land before it.
No behaviour change.
This commit is contained in:
kshitijk4poor
2026-10-01 18:54:07 +05:30
committed by kshitij
parent 9d1d52f24b
commit bc3de98ed7

View File

@@ -110,7 +110,7 @@ export function mergeOlderTranscriptPage(existing: ChatMessage[], olderPage: Cha
}
for (const part of message.parts) {
if (part.type === 'text' && part.sourceRowId !== undefined) {
if (part.sourceRowId !== undefined) {
existingPartRowIndices.set(part.sourceRowId, index)
}
}
@@ -138,7 +138,10 @@ export function mergeOlderTranscriptPage(existing: ChatMessage[], olderPage: Cha
return undefined
}
// Anchor on the message's own row when it has one, else its last part row.
// With a rowId the fold is addressed by its FIRST source row, the same key
// hydration uses. Without one its part rows are the only identity, and the
// last of them is the turn's final reply — the row the settled live bubble
// holds (#123801) — so preceding pending rows land before that bubble.
return message.rowId !== undefined ? anchors[0] : anchors[anchors.length - 1]
}