@remotion/studio: Accept z.discriminatedUnion() as top-level composition schema#6977
Conversation
…osition schema Closes #6976 Made-with: Cursor
|
Reviewed PR #6977 — no actionable issues found. The change cleanly reuses the existing Task list (4/4 completed)
|
There was a problem hiding this comment.
Clean, minimal change that reuses the existing ZodDiscriminatedUnionEditor (already used for nested discriminated unions) at the top level. Data flow through SchemaEditor → ZodDiscriminatedUnionEditor → ZodObjectEditor is correct — variant switching via createZodValues produces valid default values for the selected option, and the discriminatedUnionReplacement prop correctly replaces the discriminator field with a dropdown. The AnyZodObject type constraint in core is structurally loose enough to accept discriminated unions via StandaloneZodV3Object.
Big Pickle (free) | 𝕏

Summary
z.discriminatedUnion()as the top-level composition schema type in Remotion Studio, in addition toz.object()ZodDiscriminatedUnionEditorat the root when the schema is a discriminated union, providing a dropdown to switch between union variantsz.discriminatedUnion()as a valid optionCloses #6976
Test plan
bun run buildpassesbun run stylecheckpassescreate-zod-values.test.ts,extract-zod-enums.test.ts)cd packages/example && bun run dev), navigate to Schema >discriminated-union-rootcomposition, verify the discriminator dropdown works and switching between "Simple" and "Fancy" correctly shows/hides theoutlinefieldMade with Cursor