[NO-JIRA] Track Figma metadata for token release labels#4538
Open
IrinaWei wants to merge 5 commits into
Open
Conversation
0ff6b38 to
be5fa34
Compare
d903d37 to
789984c
Compare
|
Visit https://backpack.github.io/storybook-prs/4538 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4538 to see this build running in a browser. |
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.
Summary
This PR upgrades the Figma token sync release-label classifier from a token-path-based diff to a Figma-key-based diff, so renames in Figma show up as renames (one event) rather than as a delete + add (two events). It also splits the auto-generated PR summary into separate sections for renamed, changed, deleted, and added tokens so reviewers can scan the impact at a glance.
Why
Today the classifier compares two snapshots of
token-sync/tokens/*.jsonby token path (the/-joined position in the JSON tree).That's fine for value changes, but it has two real problems:
core/primarytocore/brand-primary, the classifier sees the old path disappear and a new path appear. The release is correctly labelledmajor— but the PR body says "deleted/renamed:core/primary" and "added:core/brand-primary" with no link between the two. Reviewers have to manually figure out it's the same token.semantic→semantic-color) currently shows up as N deletes + N adds, which buries any actually deleted token in the noise.The fix is to track the Figma-side identity of each variable (
id+key, both stable across renames) inside the emitted DTCG token, and key the diff off that identity instead of the path.Changes
1. Emit Figma metadata into the DTCG output
token-sync/src/dtcg-transformer.tsandtypes.tsnow write a$extensions.figmablock on every emitted leaf:{ "$value": "#0770e3", "$type": "color", "$extensions": { "figma": { "id": "VariableID:1234:5678", "key": "abc123def456..." } } }keyis the persistent published key Figma assigns to a variable; it does not change when the variable is renamed or moved between groups.idis included for traceability back to the Figma file.2. Classify by Figma key, fall back to token path
classify-release-label.tsnow has two diff paths:figma-keymode — used when every leaf in both snapshots carries$extensions.figma. Builds an identity map keyed by${fileName}:${figmaKey}and produces:renamedTokens— same key, differenttokenPathchangedTokens— same key, same path, different value fingerprintdeletedTokens— key in previous, missing in currentaddedTokens— key in current, missing in previoustoken-pathmode (fallback) — preserves the existing path-based behaviour for older generated JSON that hasn't been re-fetched yet.The chosen mode is exposed as
summary.classificationMethodso callers/tests can assert on it.The
majorvsminorrule is unchanged in spirit: any rename, value change, or deletion →major; pure additions →minor.3. Value fingerprint ignores
$extensionstokenFingerprintstrips$extensionsbefore serialising the leaf for comparison. This means a metadata-only churn (e.g. Figma reassigns an internalidbut the variable's value is unchanged) is not flagged as a value change.4. Separate PR body sections
Previously the auto-generated PR body had a single "Deleted or renamed tokens" section. It now renders four distinct sections in this order:
before → afterpathsEach token appears in only one section. Empty sections are omitted.
5. Workflow + docs
sync-figma-variables.yml: updated the in-PR-body release-label rules text to refer to "Figma variable keys" instead of "token paths". Also switchesactions/checkoutto use${{ github.ref }}so the workflow can be tested from a feature branch viaworkflow_dispatch.token-sync/README.mdandRUNBOOK.md: describe the key-based classification and the new PR body sections.Backwards compatibility
$extensions.figmacontinue to work — the classifier falls back to path-based diffing for that file set. The first run after this PR merges will write the metadata, and from then on key-based diffing applies.summary.deletedOrRenamedTokensis retained as a derived field (concat ofdeletedTokens+ previous paths fromrenamedTokens) for any existing consumers.Out of scope
$description-only changes aschanged. That can be tightened later if it proves noisy in practice.major/minorboundary itself — only to how each bucket is computed and presented.