Skip to content

fix(expand): treat Figma's unset swap id as no swap - #259

Merged
runkids merged 1 commit into
mainfrom
fix/empty-swap-guid
Nov 16, 2026
Merged

runkids merged 1 commit into
mainfrom
fix/empty-swap-guid

Conversation

@runkids

@runkids runkids commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Summary

Figma writes the unset GUID 4294967295:4294967295 in overriddenSymbolID to mean "not swapped" (storytold/figcraft#2206: a real file had it on a nested instance). Override rows already ignored it through guid_key; three Json readers did not.

 fields(INSTANCE)                         # REST componentId
-  overriddenSymbolID.guid  ?? symbolData.symbolID
+  overriddenSymbolID.node_guid ?? symbolData.symbolID
 properties(instance)                     # search component properties
-  main = guid(overriddenSymbolID) ?? symbolID
+  main = node_guid(overriddenSymbolID) ?? symbolID
 bind_properties(OVERRIDDEN_SYMBOL_ID)    # instance-swap assignment in expansion
-  swap = "{session}:{local}"
+  swap = node_guid(symbolIdValue.guid)

rest::node_guid takes over the check rest/semantics::definition_id already made (unset id, out-of-range parts); definition_id now calls it, so the sentinel is written once.

Evidence

Three new unit tests, one per reader. With node_guid temporarily reduced to plain guid (the old behaviour):

  • Before:
    • rest::tests::an_unset_swap_guid_keeps_the_instance_on_its_main: componentId was "4294967295:4294967295", expected "1:2".
    • expand::tests::an_unset_swap_property_keeps_the_default_main_and_its_children: Iinst;1:3;icon;leaf was missing (the nested instance had no children).
    • search::semantic::input_tests::an_instance_with_an_unset_swap_guid_reads_its_mains_properties: properties were [].
  • After: all three pass.
  • Checks run: cargo test (841 lib tests plus the integration suites, all pass), cargo fmt --check, cargo clippy --all-targets -D warnings and python3 scripts/ai-context.py check, all in Docker.

Local evidence is limited. In 7 local sample files the unset id never appears in nodes 0:0 output, so the rule is recorded as Pending (external evidence only) in wiki/instances.md.

Interfaces: CLI, MCP, Pi, OpenCode and OMP all read the same nodes and search output. There is no new option or field, so help, READMEs, the skill and the site need no change.

Not changed:

  • prop_value_source: REST componentProperties values can still show the unset id for an instance-swap property, because Figma's REST output for that case is unknown.
  • An outer override row writing the unset id over an inner swap still keeps the inner swap. FigCraft resets to the default there. Settling that needs a Figma fixture.

Merge Danger

Door: two-way

Blast Radius: narrow

Only instances whose swap field holds the unset id change: they now resolve to their default main instead of a missing id. Every other GUID is accepted exactly as before.

Figma writes 4294967295:4294967295 in overriddenSymbolID to mean "not
swapped" (seen in storytold/figcraft#2206's reporter file). Expansion of
override rows already ignored it via guid_key, but three Json readers took
it as a component id: REST componentId named a node that does not exist,
search read no component properties for that instance, and an
instance-swap assignment holding it swapped to a missing main, so the
nested instance lost its children.

rest::node_guid now owns the check that rest/semantics' definition_id
already made, so the sentinel lives in one place.
@runkids

runkids commented Nov 16, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T02:20:05.468621Z 9ba8dff Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 9ba8dffada

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@runkids
runkids marked this pull request as ready for review November 16, 2026 02:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9ba8dffada

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/expand.rs
.and_then(|s| s.get("guid"))
&& let (Some(session), Some(local)) =
(guid["sessionID"].as_u64(), guid["localID"].as_u64())
.and_then(crate::rest::node_guid)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Invalidate persisted indexes after changing swap expansion

For a workspace indexed before this fix, an unchanged .fig containing an unset instance-swap assignment will continue to have its default-main children missing from workspace search after upgrading. The generation compatibility key in src/search/store.rs::versions() is unchanged, and src/workspace/jobs.rs:2591–2609 returns unchanged before parsing when that key and the snapshot match, so even index refresh preserves the incorrect results while reporting a complete generation. Revise the persisted-generation compatibility key alongside this extraction change so existing indexes require rebuilding.

Useful? React with 👍 / 👎.

@runkids
runkids merged commit 1672a5d into main Nov 16, 2026
28 checks passed
@runkids
runkids deleted the fix/empty-swap-guid branch November 16, 2026 03:27
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