Skip to content

🎥 Make videos programmatically with React

Fix sequence prop schema saves (#8350)

Jonny Burger13856c2d2798
diff --git a/packages/studio-server/src/preview-server/routes/save-sequence-props.ts b/packages/studio-server/src/preview-server/routes/save-sequence-props.ts
index 88f4c65c89..8e7905464b 100644
--- a/packages/studio-server/src/preview-server/routes/save-sequence-props.ts
+++ b/packages/studio-server/src/preview-server/routes/save-sequence-props.ts
@@ -7,9 +7,9 @@ import type {
SaveSequencePropsResult,
} from '@remotion/studio-shared';
import {getAllSchemaKeys} from '@remotion/studio-shared';
-import {NoReactInternals} from 'remotion/no-react';
import {
type RemovedProp,
+ type SequencePropsNodeUpdate,
updateMultipleSequenceProps,
} from '../../codemods/update-sequence-props/update-sequence-props';
import {writeFileAndNotifyFileWatchers} from '../../file-watcher';
@@ -56,6 +56,25 @@ type SequencePropEditResult = {
formatted: boolean;
};
+export const convertSequencePropEditToCodemodChange = (
+ edit: Pick<
+ ResolvedSequencePropEdit,
+ 'nodePath' | 'key' | 'value' | 'defaultValue' | 'schema'
+ >,
+): SequencePropsNodeUpdate => {
+ return {
+ nodePath: edit.nodePath.nodePath,
+ updates: [
+ {
+ key: edit.key,
+ value: edit.value,
+ defaultValue: edit.defaultValue,
+ },
+ ],
+ schema: edit.schema,
+ };
+};
+
export const shouldSuppressHmrForSequencePropEdits = (
edits: readonly {key: string}[],
): boolean => {
@@ -126,19 +145,7 @@ export const saveSequencePropsHandler: ApiHandler<
results: updateResults,
} = await updateMultipleSequenceProps({
input: fileContents,
- changes: group.edits.map((edit) => {
- return {
- nodePath: edit.nodePath.nodePath,
- updates: [
- {
- key: edit.key,
- value: edit.value,
- defaultValue: edit.defaultValue,
- },
- ],
- schema: NoReactInternals.sequenceSchema,
- };
- }),
+ changes: group.edits.map(convertSequencePropEditToCodemodChange),
prettierConfigOverride: null,
});
diff --git a/packages/studio-server/src/test/save-sequence-props.test.ts b/packages/studio-server/src/test/save-sequence-props.test.ts
index b68644a6f1..fe32949e07 100644
--- a/packages/studio-server/src/test/save-sequence-props.test.ts
+++ b/packages/studio-server/src/test/save-sequence-props.test.ts
@@ -1,5 +1,18 @@
import {expect, test} from 'bun:test';
-import {shouldSuppressHmrForSequencePropEdits} from '../preview-server/routes/save-sequence-props';
+import type {SequenceSchema} from 'remotion';
+import {
+ convertSequencePropEditToCodemodChange,
+ shouldSuppressHmrForSequencePropEdits,
+} from '../preview-server/routes/save-sequence-props';
+
+const starSchema = {
+ points: {
+ type: 'number',
+ default: 5,
+ description: 'Points',
+ hiddenFromList: false,
+ },
+} satisfies SequenceSchema;
test('saveSequenceProps suppresses HMR for regular visual prop edits', () => {
expect(
@@ -18,3 +31,30 @@ test('saveSequenceProps does not suppress HMR for showInTimeline edits', () => {
]),
).toBe(false);
});
+
+test('saveSequenceProps forwards element schemas to the codemod', () => {
+ const change = convertSequencePropEditToCodemodChange({
+ nodePath: {
+ absolutePath: '/tmp/Composition.tsx',
+ nodePath: ['program', 'body', 0],
+ sequenceKeys: [],
+ effectKeys: [],
+ },
+ key: 'points',
+ value: 7,
+ defaultValue: 5,
+ schema: starSchema,
+ });
+
+ expect(change).toEqual({
+ nodePath: ['program', 'body', 0],
+ updates: [
+ {
+ key: 'points',
+ value: 7,
+ defaultValue: 5,
+ },
+ ],
+ schema: starSchema,
+ });
+});