perf: avoid per-item arrays in journal projection (#20305)

Co-authored-by: Orca Worker <orca-worker@localhost>
This commit is contained in:
OrcaWin
2026-09-12 18:09:22 -07:00
committed by GitHub
co-authored by Orca Worker
parent 2411491c2f
commit b7a1aeda5d
@@ -137,10 +137,14 @@ const projectedItems = new WeakMap<AgentJournalRenderItem, NativeChatMessage | n
export function projectStructuredItemsToNativeChat(
items: readonly AgentJournalRenderItem[]
): NativeChatMessage[] {
return items.flatMap((item) => {
const messages: NativeChatMessage[] = []
items.forEach((item) => {
const projected = projectStructuredItemToNativeChat(item)
return projected ? [projected] : []
if (projected) {
messages.push(projected)
}
})
return messages
}
export function projectStructuredItemToNativeChat(