Skip to content

feat(strapi-plugin-rewind): remember what a relation pointed at - #174

Merged
kkukielka merged 3 commits into
mainfrom
feat/rewind-relation-labels
Aug 26, 2026
Merged

feat(strapi-plugin-rewind): remember what a relation pointed at#174
kkukielka merged 3 commits into
mainfrom
feat/rewind-relation-labels

Conversation

@kkukielka

@kkukielka kkukielka commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

A version stored which document a relation pointed at and nothing else, so once
the target was deleted the history said "2 linked items no longer exist" - the
id no longer resolved to anything, and the answer to "which two?" was exactly
what deletion had taken away.

Each relation now carries the target's name as it stood when the version was
taken, read from the field the Content Manager titles that type by
(mainField, then title/name/label, validated against the target's own
attributes).

What changes for a reader

  • The diff reads featured: + Plugin showcase, − Autumn release notes instead
    of + 1 linked, − 1 unlinked.
  • The restore preview says Doomed article no longer exists and will be left out.
  • The warning after a restore names what it skipped.

Where a target has no name - an untitled entry, a type with no string field, a
version taken before this existed - it falls back to counting. A row of
documentIds tells a reader less than the number does.

Two decisions worth stating

The label is a snapshot, not a lookup. A version from March says what the
author was called in March. That is the point: a name looked up now cannot
exist for a row that does not.

Labels are excluded from the content hash. Renaming an author does not
change which author an article points at, so hashing the name would make the
next save of every article mentioning them look like an edit, and produce a
version whose diff is empty. Excluding it also keeps hashes written before this
change valid, so upgrading produces no spurious version.

Populate is widened at the top level only. A relation nested inside a component
is stored as part of data rather than extracted, so selecting an extra column
there would change what a component holds - and with it every hash ever
computed.

Also here: the scope that was costing us minors

The third commit documents something found while checking this PR would release
correctly. It would not have: feat(rewind) resolves to no project, and nx
treats an unresolved scope as an indirect change rather than an error, so it
is silently downgraded to a patch. Rewind's feature was about to ship as 0.3.1.

nx matches the package's directory name, so the scope here is
strapi-plugin-rewind. Verified with a dry run:

strapi-plugin-rewind      0.3.0 -> 0.4.0   (minor)
strapi-plugin-greenlight  0.1.3 -> 0.1.4   (patch, root-file cascade)
strapi-plugin-blueprint   0.1.1 -> 0.1.2   (patch, root-file cascade)

useCommitScope: false was the other candidate and is worse: it gives
Greenlight and Blueprint a 0.2.0 for features they do not have, because two
past feat commits touched pnpm-lock.yaml. No config change was needed.

Verified

84 tests pass, including three new ones: the label survives the target being
deleted, a version keeps the name the target had at the time, and renaming a
target does not create a version of its own.

Checked in Chrome against the example app, which now tracks Page as well as
Article because Page is the one with a relation:

  • diff names both ends of a relation change
  • restore preview names a target deleted after the version was taken
  • the no-name fallback reads + 1 item beside a named − Doomed article

README and ROADMAP ship in this PR. Rewind's Next section moves on to
restoring a single field.

@github-actions github-actions Bot added documentation Improvements or additions to documentation pkg: rewind @qkix/strapi-plugin-rewind — document version history pkg: examples The Strapi, React, Astro and Nuxt example apps labels Aug 26, 2026
A version stored which document a relation pointed at and nothing else, so
once the target was deleted the history showed "2 linked items no longer
exist" - the id no longer resolved to anything, and the answer to "which
two?" was exactly what deletion had taken away.

Each relation now carries the target's name as it stood when the version was
taken, read from the field the Content Manager titles that type by. The diff
reads "author: + Grace, - Ada" instead of counting, and a restore preview
names what it is about to drop.

Two decisions worth stating:

- The label is a snapshot, not a lookup. A version from March says what the
  author was called in March. That is the point: a name looked up now cannot
  exist for a row that does not.
- Labels are excluded from the content hash. Renaming an author does not
  change which author an article points at, so hashing the name would make
  the next save of every article mentioning them look like an edit and
  produce a version whose diff is empty. Excluding it also keeps hashes
  written before this change valid, so upgrading produces no spurious
  version.

Populate is widened at the top level only. A relation nested inside a
component is stored as part of `data` rather than extracted, so selecting an
extra column there would change what a component holds - and with it every
hash ever computed.

The example app now tracks Page as well as Article, because Page is the one
with a relation.

The scope is the package directory name rather than "rewind": that is what
nx's matcher resolves, and a scope it cannot resolve is treated as an
indirect change and downgraded to a patch.
The claim that relations are reported by name is worth a picture, and the
dialog is where a reader meets it first.
`feat(rewind)` looks right and is not: nx resolves a scope against project
and directory names, so "rewind" matches nothing, and an unresolved scope is
not an error - the commit becomes an indirect change and is downgraded to a
patch. Rewind's own feature was about to ship as 0.3.1 for exactly this
reason.
@kkukielka
kkukielka force-pushed the feat/rewind-relation-labels branch from acd9943 to 667afd2 Compare August 26, 2026 09:03
@kkukielka kkukielka changed the title feat(rewind): remember what a relation pointed at feat(strapi-plugin-rewind): remember what a relation pointed at Aug 26, 2026
@kkukielka
kkukielka merged commit 7f87627 into main Aug 26, 2026
3 checks passed
@kkukielka
kkukielka deleted the feat/rewind-relation-labels branch August 26, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation pkg: examples The Strapi, React, Astro and Nuxt example apps pkg: rewind @qkix/strapi-plugin-rewind — document version history

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant