Skip to content

@remotion/studio: Accept z.discriminatedUnion() as top-level composition schema#6977

Merged
JonnyBurger merged 1 commit intomainfrom
studio/discriminated-union-root-schema
Apr 4, 2026
Merged

@remotion/studio: Accept z.discriminatedUnion() as top-level composition schema#6977
JonnyBurger merged 1 commit intomainfrom
studio/discriminated-union-root-schema

Conversation

@JonnyBurger
Copy link
Copy Markdown
Member

Summary

  • Accept z.discriminatedUnion() as the top-level composition schema type in Remotion Studio, in addition to z.object()
  • Renders ZodDiscriminatedUnionEditor at the root when the schema is a discriminated union, providing a dropdown to switch between union variants
  • Updates the error message to mention z.discriminatedUnion() as a valid option

Closes #6976

Test plan

  • bun run build passes
  • bun run stylecheck passes
  • Existing schema tests pass (create-zod-values.test.ts, extract-zod-enums.test.ts)
  • Open Remotion Studio (cd packages/example && bun run dev), navigate to Schema > discriminated-union-root composition, verify the discriminator dropdown works and switching between "Simple" and "Fancy" correctly shows/hides the outline field

Made with Cursor

@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog bot commented Apr 3, 2026

Reviewed PR #6977 — no actionable issues found. The change cleanly reuses the existing ZodDiscriminatedUnionEditor at the top level, with correct data flow through variant switching and the discriminatedUnionReplacement prop. Review posted.

Task list (4/4 completed)
  • Checkout PR branch and read diff
  • Review changed files in detail
  • Trace data flow and verify correctness
  • Submit review or report progress

Pullfrog  | View workflow run | Triggered by Pullfrog | Using Big Pickle (free) | 𝕏

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bugs Ready Ready Preview, Comment Apr 3, 2026 6:11pm
remotion Ready Ready Preview, Comment Apr 3, 2026 6:11pm

Request Review

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog bot left a comment

Choose a reason for hiding this comment

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

Clean, minimal change that reuses the existing ZodDiscriminatedUnionEditor (already used for nested discriminated unions) at the top level. Data flow through SchemaEditorZodDiscriminatedUnionEditorZodObjectEditor 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.

Pullfrog  | View workflow run | Using Big Pickle (free) | 𝕏

@JonnyBurger JonnyBurger merged commit 895eade into main Apr 4, 2026
19 checks passed
@JonnyBurger JonnyBurger deleted the studio/discriminated-union-root-schema branch April 4, 2026 07:49
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.

Feature: Accept z.discriminatedUnion (and other unions) as composition schema root

1 participant