Fix reversed iteration overwriting newest diff and message values
In deriveTurnDiffSummaries, events are iterated newest-first via toReversed(). The filesByPath merging correctly used ?? so the first (newest) encounter takes priority. However, summary.unifiedDiff and summary.assistantMessageId were unconditionally overwritten on each iteration, so the oldest value ended up winning instead of the newest. Fix by using ??= (nullish coalescing assignment) so the first (newest) value encountered is preserved and older values do not overwrite it.
This commit is contained in:
1 parent
f889da13d0
commit
d9c24fafd3
1 file changed
+2
-2
@@ -579,7 +579,7 @@ export function deriveTurnDiffSummaries(events: ProviderEvent[]): TurnDiffSummar
|
||||
|
||||
if (event.method === "turn/diff/updated") {
|
||||
const diff = normalizeDetail(asString(asObject(event.payload)?.diff));
|
||||
if (diff) summary.unifiedDiff = diff;
|
||||
if (diff) summary.unifiedDiff ??= diff;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -588,7 +588,7 @@ export function deriveTurnDiffSummaries(events: ProviderEvent[]): TurnDiffSummar
|
||||
if (asString(item?.type) === "agentMessage") {
|
||||
const itemId = normalizeDetail(asString(item?.id));
|
||||
if (itemId) {
|
||||
summary.assistantMessageId = itemId;
|
||||
summary.assistantMessageId ??= itemId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user