#436
fix(core): batch prose deltas instead of one text-delta per character
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-specchunks is unchanged. - Spec lines, fences and blank lines behave exactly as before; only the chunk granularity of prose changes.
flushBufferflushes held prose first, so atext-endinside 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":...}\nemits the prose delta before thedata-specchunk.
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
3copilot-pull-request-reviewer[bot]reviewed16d 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.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.