MCPcopy Index your code
hub / github.com/cursor/cookbook / appendAssistantDelta

Function appendAssistantDelta

sdk/coding-agent-cli/src/tui/App.tsx:824–850  ·  view source on GitHub ↗
(
  items: TranscriptEntry[],
  assistantId: string,
  text: string
)

Source from the content-addressed store, hash-verified

822}
823
824function appendAssistantDelta(
825 items: TranscriptEntry[],
826 assistantId: string,
827 text: string
828) {
829 const last = items.at(-1)
830
831 if (last?.kind === "assistant" && last.id.startsWith(`assistant-${assistantId}`)) {
832 return items.map((item, index) =>
833 index === items.length - 1 ? { ...item, text: item.text + text } : item
834 )
835 }
836
837 const segmentCount = items.filter((item) =>
838 item.id.startsWith(`assistant-${assistantId}`)
839 ).length
840
841 return [
842 ...items,
843 {
844 id: `assistant-${assistantId}-${segmentCount}`,
845 kind: "assistant" as const,
846 label: "agent",
847 text,
848 },
849 ]
850}
851
852function applyAgentEvent(
853 items: TranscriptEntry[],

Callers 1

applyAgentEventFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected