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

Function initialResult

packages/session-ui/src/components/markdown.tsx:328–353  ·  view source on GitHub ↗
(text: string, key: string | undefined, projection: Projection, owner: string)

Source from the content-addressed store, hash-verified

326}
327
328function initialResult(text: string, key: string | undefined, projection: Projection, owner: string): RenderResult {
329 if (!text) return { text, blocks: [] }
330 const base = key ?? checksum(text)
331 if (base) {
332 const blocks = projection.blocks.flatMap((block, index) => {
333 if (block.mode === "code") return []
334 const cacheKey = `${base}:${index}:${block.mode}`
335 const cached = getCachedMarkdown(cacheKey)
336 if (cached?.raw !== block.raw) return []
337 return [{ key: `${owner}:${cacheKey}`, mode: block.mode, ...cached }]
338 })
339 if (blocks.length === projection.blocks.length) return { text, blocks }
340 }
341 return {
342 text,
343 blocks: [
344 {
345 key: "initial",
346 mode: "full",
347 raw: text,
348 hash: checksum(text) ?? "",
349 html: fallback(text),
350 },
351 ],
352 }
353}
354
355export function Markdown(
356 props: ComponentProps<"div"> & {

Callers 1

MarkdownFunction · 0.85

Calls 3

checksumFunction · 0.90
getCachedMarkdownFunction · 0.90
fallbackFunction · 0.70

Tested by

no test coverage detected