#436

fix(core): batch prose deltas instead of one text-delta per character

Openxubenqiangwants to merge intofrom

Fixes #421

createJsonRenderTransform walked every text-delta one character at a time and enqueued one output text-delta per prose character, so "Hello world.\n" became thirteen chunks. The per-character path was only needed because a line can still turn into a spec line ({, a fence prefix, or anything inside a fence) until it is classified.

Change

packages/core/src/types.ts

  • Prose that is already classified as text is collected and flushed at the end of the incoming delta, and before a line is classified, so ordering relative to data-spec chunks is unchanged.
  • Spec lines, fences and blank lines behave exactly as before; only the chunk granularity of prose changes.
  • flushBuffer flushes held prose first, so a text-end inside a partially buffered line still emits prose before the classified line.

Tests

packages/core/src/types.test.ts

  • batches the prose of one delta into a single text-delta: "Hello world.\n" now yields exactly ["Hello world.\n"].
  • emits held prose before the patch that ended the same delta: Intro\n{"op":...}\n emits the prose delta before the data-spec chunk.

Verified: pnpm exec vitest run packages/core/src/types.test.ts -> 126 passed; with types.ts reverted, the two tests above fail. tsc -p packages/core/tsconfig.check.json exits 0.

Activity

3
copilot-pull-request-reviewer[bot]reviewed16d ago
copilot-pull-request-reviewer[bot]16d ago

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

vercel[bot]16d ago

@xubenqiang is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.