#420

Add an onInvalid hook for patch lines that do not parse

Openpeter-cynomiopened 20d ago

Version: @json-render/core 0.21.0

A line that starts with { and has an "op" key, but fails parseSpecStreamLine, is handled in one of two ways, and neither reports it:

  • Outside a fence, createJsonRenderTransform shows it as prose.
  • Inside a fence, it drops the line without telling anyone. createMixedStreamParser does the same.

This happens, for example, when the token limit cuts a patch short. Nothing downstream can catch the loss: a dropped replace leaves the spec valid, so a validator sees nothing wrong, and the user sees an edit that never happened.

Repro

Stream Intro\n{"op":"add","path":"/elements/x","value":{\nDone.:

  • Outside a fence, the broken line appears in the prose.
  • Inside a ```spec fence, it vanishes with no signal.

Ask

  • An onInvalid(line) option on createJsonRenderTransform and createMixedStreamParser.
  • An option to drop a patch-shaped line that appears outside a fence, instead of showing it as prose.

Activity

0

No activity yet.