Fixes #420
A line that starts with { and has an "op" key but fails parseSpecStreamLine — a truncated patch, for example — was handled two ways and neither reported it: inside a ```spec fence it was dropped silently, outside one it was shown as prose. When the token limit cuts a replace short the spec stays valid, so a validator sees nothing wrong and the user sees an edit that never happened.
Change
packages/core/src/types.ts
onInvalid?(line)onMixedStreamCallbacksand on a newJsonRenderTransformOptionspassed tocreateJsonRenderTransform(options?). It fires only for patch-shaped lines ({…"op":), so ordinary prose that starts with{is unaffected.dropInvalidPatches?: booleanon both: a patch-shaped line outside a fence is then dropped instead of streamed as text. Inside a fence such a line is always dropped, as before.createMixedStreamParser(callbacks, options?)keeps its existing call shape; the second argument is optional.- Exported
MixedStreamParserOptionsandJsonRenderTransformOptionsfrom the package.
Tests
packages/core/src/types.test.ts
- Mixed parser: reports an unparsable patch inside a fence (no text, no patch); reports one outside a fence and still emits it as text by default; drops it outside a fence with
dropInvalidPatches: true; leaves{not a patch}alone. - Transform: the same inside-fence and outside-fence cases over real chunks, including the dropped-line text assertion.
Verified: pnpm exec vitest run packages/core/src/types.test.ts -> 131 passed; with types.ts reverted, the six new tests fail. tsc -p packages/core/tsconfig.check.json exits 0 and prettier --check is clean.
Activity
4@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.