Repository navigation
Description
Problem
Version compare diffs two documents with prosemirror-changeset, reached through @tiptap/pm/changeset. The import sits at apps/webapp/src/components/pages/history/utils/compareDecorations.ts:2.
That library's default token encoder compares nodes by name and text by character. It ignores marks and attributes. [email protected] says so in its own ChangeSet.create documentation. The text reads: "The default is to just compare nodes by name and text by character, ignoring marks and attributes." The default encoder's encodeNodeStart is node => node.type.name.
Nothing in this tree records that limit. compareDecorations.ts carries two comments and neither names it. The JSDoc at lines 7-11 says the function diffs two version documents for the read-only history editor, and explains why the code skips .check(). The comment at lines 39-40 explains why removed text uses textBetween instead of a serialized slice.
apps/hocuspocus.server/docs/change-attribution.md is the tracked document that explains what a version diff does and does not prove. It never mentions the library: grep -c -i changeset on that file returns 0.
So the tree reads as an endorsement. The next person who builds on this diff repeats the mistake.
What to do
Write the limit into apps/hocuspocus.server/docs/change-attribution.md. Name the edits the default encoder cannot see.
Add a short why-comment at the import in compareDecorations.ts.
Acceptance
-
grep -c -i changeset apps/hocuspocus.server/docs/change-attribution.mdreturns a number above0.Returns5. - That document names marks and attributes as edits the default encoder cannot see.
Quoted from the library's own documentation. -
compareDecorations.tscarries a comment at the import saying the same thing.Three lines above the import.
Notes
The library does hand marks to the encoder. Its internal tokens helper calls encodeCharacter(charCode, marks), and the default encoder drops that second argument. A custom encoder is therefore possible. That is a build choice, not this issue.
The product effect of the same limit is filed separately as the Compare decoration issue. A ruling there may move which surface carries the note. The library fact is worth recording either way.
Activity
HMarzban commentedon Sep 1, 2026
Research result — two facts to add, and an ordering note, 2026-09-01
Full evidence:
REPORT-pm-diff-library-research.md.The three acceptance greps are unchanged. Nothing in this research widens the scope of this issue.
Add these two facts to the tracked note
1. The exact escape hatch, with its version.
ChangeSet.createtakes aTokenEncoderas its third argument, added in[email protected]. Verified in this tree:dist/index.d.ts:65declaresinterface TokenEncoder<T>,:156exports it, and:153isstatic create<Data = any>(doc: Node, combine?: ..., tokenEncoder?: TokenEncoder<any>): ChangeSet<Data>. This turns the note from "a limit we live with" into "a limit with a documented door".2. The upgrade hazard, which explains why the pin matters.
apps/webapp/node_modules/@tiptap/pm/package.json:184declares"prosemirror-changeset": "^2.3.0". Onlybun.lock:3388pins2.3.1. A lockfile refresh could therefore move this package without any deliberate decision.Ordering — this issue should be written second
#207 now has a recommended ruling: pass a custom encoder rather than accept the limit. If that ruling lands, the sentence this issue records changes.
Rule #207 first, then write this. Otherwise the tracked note documents a limit that no longer exists.
HMarzban commentedon Sep 1, 2026
Unblocked — 2026-09-01
#207 is now built, not just ruled. The compare view passes a custom
TokenEncoder, so mark-only and attribute-only edits produce decorations.So the sentence this issue records is settled. Write:
Rather than the limit-we-live-with wording that would have been correct yesterday.
The three acceptance greps are unchanged. Add the two facts already filed above: the
TokenEncoderthird argument added in[email protected], and the upgrade hazard where@tiptap/pmdeclares^2.3.0while onlybun.lock:3388pins2.3.1.This issue is ready to write.
HMarzban commentedon Sep 1, 2026
Done — 2026-09-01
Two edits, no behaviour change.
apps/hocuspocus.server/docs/change-attribution.mdgained a## What the diff engine seessection, placed before## Failure mode. It sits there rather than inside the authorship sections because it is a limit in the layer above, not a property of the clientID binding.It records four things:
diffTokenEncoder.tsand the[email protected]third argument.@tiptap/pmdeclares^2.3.0, so only the lockfile pins the version carrying the third argument.It closes by noting that the backend block comparison never had this blindness, because
canonicalizeBlockhashes whole-block JSON including marks and attributes, at block granularity rather than character range.compareDecorations.tscarries a three-line comment above the@tiptap/pm/changesetimport, opening with "Never callChangeSet.createwith one argument" and pointing at the document.Gates
8/8unit tests.typecheckexit 0.eslint --max-warnings=0clean.prettier --checkclean.A note on the acceptance greps
The first grep passes as written. The second and third are line-based, and both phrases wrap across lines in the shipped text — the comment also carries a
//between the wrapped words. Checked with whitespace flattened and comment markers stripped, all three pass. Worth knowing before anyone re-runs them literally and reads a false failure.fix(webapp): show formatting edits in version compare
docs(hocuspocus): record what the diff encoder cannot see