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

Function pendingBlocks

packages/session-ui/src/components/markdown.tsx:517–544  ·  view source on GitHub ↗
(
  result: RenderResult | undefined,
  projection: Projection | undefined,
  cacheKey: string | undefined,
  owner: string,
)

Source from the content-addressed store, hash-verified

515}
516
517function pendingBlocks(
518 result: RenderResult | undefined,
519 projection: Projection | undefined,
520 cacheKey: string | undefined,
521 owner: string,
522) {
523 if (!result) return []
524 if (!projection || result.text === projection.text) return result.blocks
525 const initial = result.blocks.length === 1 && result.blocks[0]?.key === "initial"
526 return projection.blocks.map((block, index) => {
527 const current = initial ? undefined : result.blocks[index]
528 if (current && canReusePendingBlock(current, block)) return current
529 const key = markdownBlockKey(owner, cacheKey, index, block.mode)
530 if (block.mode !== "code")
531 return { key, mode: block.mode, raw: block.raw, hash: String(block.raw.length), html: fallback(block.src) }
532 return {
533 key,
534 mode: block.mode,
535 raw: block.raw,
536 hash: String(block.raw.length),
537 language: block.language ?? "text",
538 complete: !!block.complete,
539 stable: [],
540 generation: 0,
541 unstable: [[block.src, ""] as MarkdownToken],
542 }
543 })
544}
545
546function disposeCode(key: string) {
547 disposeStreamingCode(key)

Callers 1

MarkdownFunction · 0.85

Calls 3

canReusePendingBlockFunction · 0.90
markdownBlockKeyFunction · 0.90
fallbackFunction · 0.70

Tested by

no test coverage detected