You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preview the tracked-change redline a text.rewrite would produce, without applying it #4150
A way to ask the engine, before applying anything, what tracked insertions and deletions a tracked text.rewrite step would create. For example, doc.mutations.preview could return them per step when the plan is previewed in tracked mode:
A standalone helper that diffs two strings with the same rules the engine uses for tracked rewrites would also work.
Why
Apps that propose edits for review (from people or from AI) usually show the proposed change as a redline before it is applied, so the reviewer can decide whether to apply it. Today that preview has to come from the app's own diff, because mutations.preview reports targets and match counts but not the resulting tracked changes.
The app's diff and the engine's diff then disagree on where words and punctuation split, how numbers are split, and how alternating changes are grouped. A reviewer approves one redline and then sees a different one in the document. Exposing the engine's own result would make preview and outcome match by construction, with no guessing.
You're right: mutations.preview doesn't show the redline today, so apps have to guess with their own diff. We're tracking it as a feature.
A string-diff helper alone wouldn't always match, because some changes depend on the document. So we're leaning toward having preview return the redline directly.
Quick question: do you just need the inserted and deleted text per step, or also how changes get grouped?
The inserted and deleted text per step is what we need most, in document order with the unchanged text between the changes. For example equal / delete / insert / equal …, split exactly as the document will show it after apply. That lets the preview read the same as the result.
If by grouping you mean those split points, which words land in one change versus separate ones, then yes, that part matters to us. Knowing which segments form a single tracked change (for example, a delete plus an insert as one replacement) would be nice to have, but we can do without it.
The goal is to allow us to render a preview of the entire tracked change to the user, so they can decide whether to apply it to the document or not. The more it looks like the real final superdoc redline the better.
Screenshot from my current app shows what we are going for, and I have it working pretty well, but every once in a while the superdoc redline will look different than the one I calculate in-app so the user doesn't quite get the exact thing they approved.
Activity
linear-code commentedon Nov 12, 2026
SD-8201
caio-pizzol commentedon Nov 12, 2026
Thanks, this is a great use case.
You're right:
mutations.previewdoesn't show the redline today, so apps have to guess with their own diff. We're tracking it as a feature.A string-diff helper alone wouldn't always match, because some changes depend on the document. So we're leaning toward having
previewreturn the redline directly.Quick question: do you just need the inserted and deleted text per step, or also how changes get grouped?
ohcedar commentedon Nov 12, 2026
Thanks, returning it from preview sounds right.
The inserted and deleted text per step is what we need most, in document order with the unchanged text between the changes. For example equal / delete / insert / equal …, split exactly as the document will show it after apply. That lets the preview read the same as the result.
If by grouping you mean those split points, which words land in one change versus separate ones, then yes, that part matters to us. Knowing which segments form a single tracked change (for example, a delete plus an insert as one replacement) would be nice to have, but we can do without it.
The goal is to allow us to render a preview of the entire tracked change to the user, so they can decide whether to apply it to the document or not. The more it looks like the real final superdoc redline the better.
Screenshot from my current app shows what we are going for, and I have it working pretty well, but every once in a while the superdoc redline will look different than the one I calculate in-app so the user doesn't quite get the exact thing they approved.