MCPcopy Create free account
hub / github.com/ShipSecAI/studio / chunksToMessages

Function chunksToMessages

frontend/src/components/timeline/AgentTracePanel.tsx:860–882  ·  view source on GitHub ↗
(chunks: UIMessageChunk[])

Source from the content-addressed store, hash-verified

858}
859
860async function chunksToMessages(chunks: UIMessageChunk[]): Promise<UIMessage[]> {
861 if (!chunks.length) {
862 return [];
863 }
864 const stream = simulateReadableStream<UIMessageChunk>({ chunks });
865 const iterator = readUIMessageStream({ stream });
866 const snapshots: UIMessage[] = [];
867 for await (const message of iterator) {
868 snapshots.push(message);
869 }
870 const latestById = new Map<string, UIMessage>();
871 const orderedIds: string[] = [];
872 for (const snapshot of snapshots) {
873 const key = snapshot.id ?? `message-${orderedIds.length}`;
874 if (!latestById.has(key)) {
875 orderedIds.push(key);
876 }
877 latestById.set(key, snapshot);
878 }
879 return orderedIds
880 .map((id) => latestById.get(id))
881 .filter((message): message is UIMessage => Boolean(message));
882}
883
884function deriveAgentSteps(parts: AgentTraceChunk[]): AgentDerivedStep[] {
885 if (!parts.length) {

Callers 2

AgentRunCardFunction · 0.85
loadFunction · 0.85

Calls 4

hasMethod · 0.80
pushMethod · 0.65
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected