feat(strapi-plugin-rewind): remember what a relation pointed at - #174
Merged
Conversation
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
force-pushed
the
feat/rewind-relation-labels
branch
from
August 26, 2026 09:03
acd9943 to
667afd2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, thentitle/name/label, validated against the target's ownattributes).
What changes for a reader
featured: + Plugin showcase, − Autumn release notesinsteadof
+ 1 linked, − 1 unlinked.Doomed article no longer exists and will be left out.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
datarather than extracted, so selecting an extra columnthere 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 nxtreats 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:useCommitScope: falsewas the other candidate and is worse: it givesGreenlight and Blueprint a 0.2.0 for features they do not have, because two
past
featcommits touchedpnpm-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:
+ 1 itembeside a named− Doomed articleREADME and ROADMAP ship in this PR. Rewind's
Nextsection moves on torestoring a single field.