Skip to content

Remove serialization from Table<T> and make TaggedValue only store tooling/widget node inputs#4129

Open
Keavon wants to merge 17 commits intomasterfrom
no-serialized-tables
Open

Remove serialization from Table<T> and make TaggedValue only store tooling/widget node inputs#4129
Keavon wants to merge 17 commits intomasterfrom
no-serialized-tables

Conversation

@Keavon
Copy link
Copy Markdown
Member

@Keavon Keavon commented May 8, 2026

Split commit by commit.

Keavon added 17 commits May 7, 2026 21:22
…peDefault on load

Documents written before the TypeDefault mechanism existed have empty Table<Vector>/<Raster>/<Graphic>/<Artboard> values baked into every unwired exposed input. Walk each migrated node's inputs and rewrite any such placeholder NodeInput::Value into the equivalent NodeInput::type_default, so re-saved documents shed the placeholder payloads. Marked with a TODO for eventual removal once enough documents have been re-saved.
@Keavon Keavon requested review from TrueDoctor and adamgerhant and removed request for adamgerhant May 8, 2026 12:56
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 35 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the TaggedValue enum and its associated serialization/deserialization logic to move away from storing large, type-erased Table<T> structures in favor of more compact, type-specific variants. It introduces TypeDefault to handle default values for types where the specific variant has been removed, and implements custom migration logic for legacy document formats. I have identified a potential infinite recursion issue in the to_dynany and to_any methods regarding TypeDefault handling, which should be refactored into a shared helper function.

Comment on lines +118 to +128
Self::TypeDefault(td) => {
// Construct the actual default for types without a `TaggedValue` variant directly, instead of going through
// `from_type_or_none` (which would just return `TypeDefault` again and recurse forever).
let name = td.name.as_ref();
if name == std::any::type_name::<Table<Graphic>>() { return Box::new(Table::<Graphic>::default()); }
if name == std::any::type_name::<Table<Artboard>>() { return Box::new(Table::<Artboard>::default()); }
if name == std::any::type_name::<Table<Raster<CPU>>>() { return Box::new(Table::<Raster<CPU>>::default()); }
if name == std::any::type_name::<Table<Vector>>() { return Box::new(Table::<Vector>::default()); }
if name == std::any::type_name::<Table<String>>() { return Box::new(Table::<String>::default()); }
if name == std::any::type_name::<DocumentNode>() { return Box::new(DocumentNode::default()); }
Self::from_type_or_none(&Type::Concrete(td)).to_dynany()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The logic for materializing default values for TypeDefault is duplicated between to_dynany and to_any (lines 168-178). Additionally, the fallback recursion Self::from_type_or_none(&Type::Concrete(td)).to_dynany() is dangerous: if from_type returns TypeDefault for a type not explicitly handled in the if name == ... chain, it will cause an infinite loop.

Consider refactoring this into a helper function that maps a type name to its default value, and ensure the recursion has a base case or check to prevent cycles.

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