MCPcopy Create free account
hub / github.com/anomalyco/opencode / project

Function project

packages/session-ui/src/components/markdown-stream.ts:93–110  ·  view source on GitHub ↗
(previous: Projection | undefined, text: string, live: boolean)

Source from the content-addressed store, hash-verified

91}
92
93export function project(previous: Projection | undefined, text: string, live: boolean): Projection {
94 if (!live || !previous || !text.startsWith(previous.text)) return { text, blocks: stream(text, live) }
95 const tail = previous.blocks.at(-1)
96 const suffix = text.slice(previous.text.length)
97 if (!suffix || tail?.mode !== "code" || tail.complete || closesFence(tail.raw, suffix))
98 return { text, blocks: stream(text, live) }
99 return {
100 text,
101 blocks: [
102 ...previous.blocks.slice(0, -1),
103 {
104 ...tail,
105 raw: tail.raw + suffix,
106 src: tail.src + suffix,
107 },
108 ],
109 }
110}

Callers 3

MarkdownFunction · 0.90
preloadMarkdownFunction · 0.90

Calls 3

closesFenceFunction · 0.85
atMethod · 0.80
streamFunction · 0.70

Tested by

no test coverage detected