Skip to content

Version diffs in the history modal, rendered on the document page - #352

Open
namedgraph wants to merge 2 commits into
developfrom
ft-version-diff
Open

Version diffs in the history modal, rendered on the document page#352
namedgraph wants to merge 2 commits into
developfrom
ft-version-diff

Conversation

@namedgraph

Copy link
Copy Markdown
Member

Adds version comparison to the graph-versioning history UI (P2.2 remainder).

Selection UI

The history modal's version table gains From/To radio columns (headers colored to match the diff colors) and a Compare button. Defaults preselect the viewed version and its predecessor.

Diff as display state

Compare navigates to <doc>?version=<to>&diff=<from>. The diff param is display state like ?mode=: read from the URL at render time, never sent to the server (ldh:snapshot-params unchanged), surviving into ldh:PushState. Back/forward re-render the diff; a direct load degrades to the plain ?version= snapshot.

Rendered union

ldh:RDFDocumentLoad fetches the compared version through a self-guarding promise step; ldh:rdf-document-response then renders the union of both versions' descriptions (reusing ldh:merge-metadata/ldh:MergeRDF, plus a prune pass so a changed typed block keeps only its current rdf:value — its hydration factory cannot handle two). The one-sided triple-key sets are tunneled down the shared template chain:

  • whole blocks get diff-added (green) / diff-removed (red) / diff-changed (amber) borders via the new ldh:diff-class() in the bs2:Row emitters
  • individual property values get marked <dd>s via ldh:value-diff-class()
  • a changed XHTML block stacks its old content (red-marked) above the new (green-marked)
  • both versions' rdf:_N entries survive the merge, so removed blocks render near their old positions
  • a legend alert next to the historical-version notice explains the colors

Shared diff core

ldh:triple-key() (subject | predicate | object identity, XMLLiterals keyed on serialized content, opt-in numeric normalization) is extracted from ldh:triples-map(); the origin-vs-local comparison in layout.xsl is refactored onto the same functions.

Known limitations

  • Residual blank nodes show as spurious remove/add pairs (serializer-generated labels; writes are skolemized so rare)
  • Edits inside an XMLLiteral mark the whole value, not the changed words (word-level literal diff deferred to the history/provenance UI item)
  • SSR of a ?diff= URL renders the plain snapshot

🤖 Generated with Claude Code

namedgraph and others added 2 commits August 20, 2026 13:17
Add From/To version selection to the Memento history modal and render a
client-side triple diff between the two selected versions as Turtle-style
hunks: subject header, then -/+ predicate-object lines (red/green, matching
the From/To column headers), changed values of the same property paired up.

The diff is the set difference over canonical triple keys, computed with the
new shared ldh:triples-map() extracted from the origin-vs-local comparison in
layout.xsl. The shared key gains an rdf:parseType="Literal" branch (XMLLiteral
objects previously keyed on empty text) and an opt-in numeric normalization:
layout.xsl keeps it for cross-serializer comparison, the version diff compares
exact lexical forms.

Both ?version= representations are fetched with a per-branch-context
ixsl:http-request fan-out joined by ixsl:all; no server changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Compare in the history modal now navigates to ?version=<to>&diff=<from> -
the diff is display state like ?mode=, read from the URL at render time and
never sent to the server, so back/forward re-render it and a plain reload
degrades to the ?version= snapshot.

ldh:RDFDocumentLoad fetches the compared version through a self-guarding
promise step; ldh:rdf-document-response renders the union of both versions
(ldh:merge-metadata reused, plus a prune pass so a changed typed block keeps
only its current rdf:value) with the one-sided triple-key sets tunneled down
the shared template chain. Blocks get diff-added/diff-removed/diff-changed
borders via ldh:diff-class() in the bs2:Row emitters, individual property
values get marked <dd>s, and a changed XHTML block stacks its old content
(red) above the new (green). A legend alert next to the historical-version
notice explains the colors.

ldh:triple-key() is extracted from ldh:triples-map() so the dd/block
decorators and the map builder share one triple identity. The Turtle-hunk
rendering from the previous commit is removed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant