#435
fix(core): keep the mixed parser's prose identical to the stream
Fixes #423
createMixedStreamParser called onText without the line break and skipped blank lines, so the prose it rebuilt differed from what createJsonRenderTransform streamed for the same text. Storing the raw transcript and re-splitting it on reload could therefore show different prose than the live stream.
Change
packages/core/src/types.ts
onTextnow receives the text exactly as the transform emits it: a prose line arrives with its trailing"\n", a blank line arrives as a single"\n", and the```specfence lines are swallowed together with their own newline (they were already swallowed, but without also removing the surrounding blank-line semantics).flush()mirrors the transform'sflushBuffer: an unterminated final line keeps its own bytes and gets no added newline.- New
splitSpecText(text): { segments, invalid }, exported from the package: the same split for a complete string, in document order, with adjacent prose merged.invalidreports lines inside a fence that do not parse as patches (the transform drops them). - New exported types
SpecTextSegment,SpecPatchSegment,SpecSegment,SplitSpecTextResult.
Tests
packages/core/src/types.test.ts
createMixedStreamParser > reproduces the prose the transform streams for a fenced spec: feeds the issue's example through both the parser andcreateJsonRenderTransformand asserts the concatenatedonTextoutput equals the transform's prose (and equals"Here is your report.\n\n\nLet me know.").createMixedStreamParser > keeps blank lines as paragraph breaks(wasskips empty lines):"\n\n\n"now yields three"\n"callbacks.splitSpecText: the same prose as the transform, plusinvalidfor a non-patch line inside a fence.- Existing assertions that expected newline-less
onText/textsvalues were updated to the new, transform-matching values ("Hello"->"Hello\n"etc.).
Verified: pnpm exec vitest run packages/core/src/types.test.ts -> 131 passed; with types.ts reverted, 7 tests fail (the parser tests above and the existing text assertions). tsc -p packages/core/tsconfig.check.json exits 0.
Activity
4copilot-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.
vercel[bot]reviewed16d ago
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.