🎥 Make videos programmatically with React
`@remotion/studio`: Preserve value when deleting all keyframes (#9293)
Jonny Burgerf6efe3f408e0
diff --git a/packages/studio-server/src/codemods/update-keyframes/update-keyframes.ts b/packages/studio-server/src/codemods/update-keyframes/update-keyframes.tsindex 4163f4b91e..4242235d32 100644--- a/packages/studio-server/src/codemods/update-keyframes/update-keyframes.ts+++ b/packages/studio-server/src/codemods/update-keyframes/update-keyframes.ts@@ -158,6 +158,7 @@ export type KeyframeOperation =| {type: 'remove';frame: number;+ valueWhenLastKeyframeDeleted: unknown | null;}| {type: 'settings';@@ -1163,10 +1164,12 @@ const removeKeyframe = ({expression,frame,videoConfigValues,+ valueWhenLastKeyframeDeleted,}: {expression: Expression;frame: number;videoConfigValues: VideoConfigIdentifierValues;+ valueWhenLastKeyframeDeleted: unknown | null;}): {expression: ExpressionKind; introduced: IntroducedKeyframeIdentifiers} => {const existing = getInterpolationExpression(expression, videoConfigValues);if (!existing) {@@ -1186,7 +1189,10 @@ const removeKeyframe = ({if (nextKeyframes.length === 0) {return {- expression: existing.keyframes[keyframeIndex].output,+ expression:+ valueWhenLastKeyframeDeleted === null+ ? existing.keyframes[keyframeIndex].output+ : parseValueExpression(valueWhenLastKeyframeDeleted),introduced: noIntroducedIdentifiers,};}@@ -1367,6 +1373,7 @@ const applyKeyframeOperation = ({expression,frame: operation.frame,videoConfigValues,+ valueWhenLastKeyframeDeleted: operation.valueWhenLastKeyframeDeleted,});};diff --git a/packages/studio-server/src/preview-server/routes/delete-keyframes.ts b/packages/studio-server/src/preview-server/routes/delete-keyframes.tsindex 4e39c1090f..9714bb890c 100644--- a/packages/studio-server/src/preview-server/routes/delete-keyframes.ts+++ b/packages/studio-server/src/preview-server/routes/delete-keyframes.ts@@ -196,6 +196,8 @@ export const deleteKeyframes = async ({operation: {type: 'remove',frame: keyframe.frame,+ valueWhenLastKeyframeDeleted:+ keyframe.valueWhenLastKeyframeDeleted ?? null,},})),});@@ -235,6 +237,8 @@ export const deleteKeyframes = async ({operation: {type: 'remove',frame: keyframe.frame,+ valueWhenLastKeyframeDeleted:+ keyframe.valueWhenLastKeyframeDeleted ?? null,},})),});diff --git a/packages/studio-server/src/test/delete-keyframes.test.ts b/packages/studio-server/src/test/delete-keyframes.test.tsindex 356bb70fe2..ee48de571f 100644--- a/packages/studio-server/src/test/delete-keyframes.test.ts+++ b/packages/studio-server/src/test/delete-keyframes.test.ts@@ -64,9 +64,27 @@ test('deleteKeyframes batches sequence and effect deletes into one undo entry',key: 'style.opacity',frame: 0,schema: NoReactInternals.sequenceSchema,+ valueWhenLastKeyframeDeleted: 0.4,+ },+ {+ fileName,+ nodePath,+ key: 'style.opacity',+ frame: 10,+ schema: NoReactInternals.sequenceSchema,+ valueWhenLastKeyframeDeleted: 0.4,},],effectKeyframes: [+ {+ fileName,+ sequenceNodePath: nodePath,+ effectIndex: 0,+ key: 'amount',+ frame: 0,+ schema: NoReactInternals.sequenceSchema,+ valueWhenLastKeyframeDeleted: 0.6,+ },{fileName,sequenceNodePath: nodePath,@@ -74,6 +92,7 @@ test('deleteKeyframes batches sequence and effect deletes into one undo entry',key: 'amount',frame: 20,schema: NoReactInternals.sequenceSchema,+ valueWhenLastKeyframeDeleted: 0.6,},],clientId: 'test-client',@@ -82,10 +101,8 @@ test('deleteKeyframes batches sequence and effect deletes into one undo entry',});const output = readFileSync(filePath, 'utf-8');- expect(output).toContain(- 'style={{opacity: interpolate(frame, [10], [1])}}',- );- expect(output).toContain('amount: interpolate(frame, [0], [0.2])');+ expect(output).toContain('style={{opacity: 0.4}}');+ expect(output).toContain('amount: 0.6');expect(getUndoStack()).toHaveLength(1);expect(popUndo()).toEqual({success: true});diff --git a/packages/studio-server/src/test/update-keyframes-imports.test.ts b/packages/studio-server/src/test/update-keyframes-imports.test.tsindex ebab198b5b..496ab54e41 100644--- a/packages/studio-server/src/test/update-keyframes-imports.test.ts+++ b/packages/studio-server/src/test/update-keyframes-imports.test.ts@@ -240,7 +240,16 @@ export const Example: React.FC = () => {videoConfigValues: null,input,nodePath: lineColumnToNodePath(input, getLine(input, 'opacity')),- updates: [{key: 'style.opacity', operation: {type: 'remove', frame: 50}}],+ updates: [+ {+ key: 'style.opacity',+ operation: {+ type: 'remove',+ frame: 50,+ valueWhenLastKeyframeDeleted: null,+ },+ },+ ],});expect(serialized).not.toContain('useCurrentFrame');@@ -507,7 +516,16 @@ export const Comp = () => {getLine(input, '<HtmlInCanvas'),),effectIndex: 0,- updates: [{key: 'amount', operation: {type: 'remove', frame: 50}}],+ updates: [+ {+ key: 'amount',+ operation: {+ type: 'remove',+ frame: 50,+ valueWhenLastKeyframeDeleted: null,+ },+ },+ ],});const after = (serialized.match(/const frame = useCurrentFrame/g) ?? []).length;diff --git a/packages/studio-server/src/test/update-keyframes.test.ts b/packages/studio-server/src/test/update-keyframes.test.tsindex c0fa731e00..b5c5e07b20 100644--- a/packages/studio-server/src/test/update-keyframes.test.ts+++ b/packages/studio-server/src/test/update-keyframes.test.ts@@ -1233,7 +1233,11 @@ test('updateSequenceKeyframes keeps an interpolation when one keyframe remains',updates: [{key: 'style.scale',- operation: {type: 'remove', frame: 0},+ operation: {+ type: 'remove',+ frame: 0,+ valueWhenLastKeyframeDeleted: null,+ },},],});@@ -1262,7 +1266,11 @@ export const Example: React.FC = () => {updates: [{key: 'style.scale',- operation: {type: 'remove', frame: 91},+ operation: {+ type: 'remove',+ frame: 91,+ valueWhenLastKeyframeDeleted: null,+ },},],});@@ -1291,7 +1299,11 @@ export const Example: React.FC = () => {updates: [{key: 'style.scale',- operation: {type: 'remove', frame: 38},+ operation: {+ type: 'remove',+ frame: 38,+ valueWhenLastKeyframeDeleted: null,+ },},],});@@ -1448,7 +1460,11 @@ test('updateSequenceKeyframes converts the last keyframe to a static value', asyupdates: [{key: 'style.scale',- operation: {type: 'remove', frame: 12},+ operation: {+ type: 'remove',+ frame: 12,+ valueWhenLastKeyframeDeleted: null,+ },},],});@@ -1470,6 +1486,32 @@ test('updateSequenceKeyframes converts the last keyframe to a static value', asy});});+test('updateSequenceKeyframes preserves the playhead value when all keyframes are removed', async () => {+ for (const frames of [+ [0, 100],+ [100, 0],+ ]) {+ const {output} = await updateSequenceKeyframes({+ videoConfigValues: null,+ input: sequenceInput,+ nodePath: lineColumnToNodePath(+ sequenceInput,+ getLine(sequenceInput, 'scale'),+ ),+ updates: frames.map((frame) => ({+ key: 'style.scale',+ operation: {+ type: 'remove' as const,+ frame,+ valueWhenLastKeyframeDeleted: 3,+ },+ })),+ });++ expect(output).toContain('style={{scale: 3}}');+ }+});+test('updateSequenceKeyframes keeps a color interpolation when one keyframe remains', async () => {const {output, oldValueStrings} = await updateSequenceKeyframes({videoConfigValues: null,@@ -1478,7 +1520,11 @@ test('updateSequenceKeyframes keeps a color interpolation when one keyframe remaupdates: [{key: 'color',- operation: {type: 'remove', frame: 0},+ operation: {+ type: 'remove',+ frame: 0,+ valueWhenLastKeyframeDeleted: null,+ },},],});@@ -1626,7 +1672,11 @@ test('updateSequenceKeyframes converts the last color keyframe to a static valueupdates: [{key: 'color',- operation: {type: 'remove', frame: 15},+ operation: {+ type: 'remove',+ frame: 15,+ valueWhenLastKeyframeDeleted: null,+ },},],});@@ -1660,7 +1710,11 @@ test('updateEffectKeyframes removes a keyframe from an effect prop interpolationupdates: [{key: 'amount',- operation: {type: 'remove', frame: 50},+ operation: {+ type: 'remove',+ frame: 50,+ valueWhenLastKeyframeDeleted: null,+ },},],});@@ -1749,7 +1803,11 @@ test('updateEffectKeyframes keeps an effect prop interpolation with one keyframeupdates: [{key: 'amount',- operation: {type: 'remove', frame: 100},+ operation: {+ type: 'remove',+ frame: 100,+ valueWhenLastKeyframeDeleted: null,+ },},],});@@ -1774,7 +1832,11 @@ test('updateEffectKeyframes converts the last effect keyframe to a static value'updates: [{key: 'amount',- operation: {type: 'remove', frame: 40},+ operation: {+ type: 'remove',+ frame: 40,+ valueWhenLastKeyframeDeleted: null,+ },},],});diff --git a/packages/studio-shared/src/api-requests.ts b/packages/studio-shared/src/api-requests.tsindex 63155a2fe0..3092534e81 100644--- a/packages/studio-shared/src/api-requests.ts+++ b/packages/studio-shared/src/api-requests.ts@@ -464,6 +464,7 @@ export type DeleteSequenceKeyframe = {key: string;frame: number;schema: InteractivitySchema;+ valueWhenLastKeyframeDeleted?: unknown;};export type MoveSequenceKeyframe = {@@ -496,6 +497,7 @@ export type DeleteEffectKeyframe = {key: string;frame: number;schema: InteractivitySchema;+ valueWhenLastKeyframeDeleted?: unknown;};export type MoveEffectKeyframe = {diff --git a/packages/studio-shared/src/optimistic-delete-keyframe.ts b/packages/studio-shared/src/optimistic-delete-keyframe.tsindex 40f80596b7..9bc8539df1 100644--- a/packages/studio-shared/src/optimistic-delete-keyframe.ts+++ b/packages/studio-shared/src/optimistic-delete-keyframe.ts@@ -24,9 +24,11 @@ const getEasingIndexToRemove = ({const removeKeyframeFromPropStatus = ({status,frame,+ valueWhenLastKeyframeDeleted,}: {status: CanUpdateSequencePropStatus;frame: number;+ valueWhenLastKeyframeDeleted: unknown | null;}): CanUpdateSequencePropStatus => {if (status.status !== 'keyframed') {return status;@@ -41,7 +43,10 @@ const removeKeyframeFromPropStatus = ({if (keyframes.length === 0) {return {status: 'static',- codeValue: status.keyframes[index].value,+ codeValue:+ valueWhenLastKeyframeDeleted === null+ ? status.keyframes[index].value+ : valueWhenLastKeyframeDeleted,};}@@ -68,10 +73,12 @@ export const optimisticDeleteSequenceKeyframe = ({previous,fieldKey,frame,+ valueWhenLastKeyframeDeleted,}: {previous: CanUpdateSequencePropsResponse;fieldKey: string;frame: number;+ valueWhenLastKeyframeDeleted?: unknown;}): CanUpdateSequencePropsResponse => {if (!previous.canUpdate) {return previous;@@ -86,7 +93,11 @@ export const optimisticDeleteSequenceKeyframe = ({...previous,props: {...previous.props,- [fieldKey]: removeKeyframeFromPropStatus({status, frame}),+ [fieldKey]: removeKeyframeFromPropStatus({+ status,+ frame,+ valueWhenLastKeyframeDeleted: valueWhenLastKeyframeDeleted ?? null,+ }),},};};@@ -96,7 +107,11 @@ export const optimisticDeleteSequenceKeyframes = ({keyframes,}: {previous: CanUpdateSequencePropsResponse;- keyframes: {fieldKey: string; frame: number}[];+ keyframes: {+ fieldKey: string;+ frame: number;+ valueWhenLastKeyframeDeleted?: unknown;+ }[];}): CanUpdateSequencePropsResponse => {return keyframes.reduce((current, keyframe) =>@@ -104,6 +119,7 @@ export const optimisticDeleteSequenceKeyframes = ({previous: current,fieldKey: keyframe.fieldKey,frame: keyframe.frame,+ valueWhenLastKeyframeDeleted: keyframe.valueWhenLastKeyframeDeleted,}),previous,);@@ -114,11 +130,13 @@ export const optimisticDeleteEffectKeyframe = ({effectIndex,fieldKey,frame,+ valueWhenLastKeyframeDeleted,}: {previous: CanUpdateSequencePropsResponse;effectIndex: number;fieldKey: string;frame: number;+ valueWhenLastKeyframeDeleted?: unknown;}): CanUpdateSequencePropsResponse => {if (!previous.canUpdate) {return previous;@@ -145,7 +163,11 @@ export const optimisticDeleteEffectKeyframe = ({...target,props: {...target.props,- [fieldKey]: removeKeyframeFromPropStatus({status, frame}),+ [fieldKey]: removeKeyframeFromPropStatus({+ status,+ frame,+ valueWhenLastKeyframeDeleted: valueWhenLastKeyframeDeleted ?? null,+ }),},};@@ -163,7 +185,12 @@ export const optimisticDeleteEffectKeyframes = ({keyframes,}: {previous: CanUpdateSequencePropsResponse;- keyframes: {effectIndex: number; fieldKey: string; frame: number}[];+ keyframes: {+ effectIndex: number;+ fieldKey: string;+ frame: number;+ valueWhenLastKeyframeDeleted?: unknown;+ }[];}): CanUpdateSequencePropsResponse => {return keyframes.reduce((current, keyframe) =>@@ -172,6 +199,7 @@ export const optimisticDeleteEffectKeyframes = ({effectIndex: keyframe.effectIndex,fieldKey: keyframe.fieldKey,frame: keyframe.frame,+ valueWhenLastKeyframeDeleted: keyframe.valueWhenLastKeyframeDeleted,}),previous,);diff --git a/packages/studio-shared/src/test/optimistic-delete-keyframe.test.ts b/packages/studio-shared/src/test/optimistic-delete-keyframe.test.tsindex f9c5f6daf8..af93790e82 100644--- a/packages/studio-shared/src/test/optimistic-delete-keyframe.test.ts+++ b/packages/studio-shared/src/test/optimistic-delete-keyframe.test.ts@@ -215,6 +215,48 @@ test('optimisticDeleteSequenceKeyframes deletes multiple keyframes in one pass',expect(status.easing).toEqual([]);});+test('optimisticDeleteSequenceKeyframes uses the playhead value when deleting all keyframes', () => {+ const previous: CanUpdateSequencePropsResponse = {+ canUpdate: true,+ props: {+ width: {+ status: 'keyframed',+ interpolationFunction: 'interpolate',+ keyframes: [+ {frame: 0, value: 100},+ {frame: 30, value: 200},+ ],+ easing: [{type: 'linear'}],+ clamping: {left: 'extend', right: 'extend'},+ posterize: undefined,+ output: undefined,+ },+ },+ effects: [],+ };++ const updated = optimisticDeleteSequenceKeyframes({+ previous,+ keyframes: [+ {+ fieldKey: 'width',+ frame: 0,+ valueWhenLastKeyframeDeleted: 150,+ },+ {+ fieldKey: 'width',+ frame: 30,+ valueWhenLastKeyframeDeleted: 150,+ },+ ],+ });++ expect(updated.canUpdate && updated.props.width).toEqual({+ status: 'static',+ codeValue: 150,+ });+});+test('optimisticDeleteEffectKeyframe removes the matching keyframe on the target effect', () => {const previous: CanUpdateSequencePropsResponse = {canUpdate: true,@@ -386,3 +428,56 @@ test('optimisticDeleteEffectKeyframes deletes multiple keyframes in one pass', (expect(status.keyframes).toEqual([{frame: 30, value: 0.5}]);expect(status.easing).toEqual([]);});++test('optimisticDeleteEffectKeyframes uses the playhead value when deleting all keyframes', () => {+ const previous: CanUpdateSequencePropsResponse = {+ canUpdate: true,+ props: {},+ effects: [+ {+ canUpdate: true,+ effectIndex: 0,+ callee: 'tint',+ importPath: null,+ props: {+ amount: {+ status: 'keyframed',+ interpolationFunction: 'interpolate',+ keyframes: [+ {frame: 0, value: 0},+ {frame: 30, value: 1},+ ],+ easing: [{type: 'linear'}],+ clamping: {left: 'extend', right: 'extend'},+ posterize: undefined,+ output: undefined,+ },+ },+ },+ ],+ };++ const updated = optimisticDeleteEffectKeyframes({+ previous,+ keyframes: [+ {+ effectIndex: 0,+ fieldKey: 'amount',+ frame: 0,+ valueWhenLastKeyframeDeleted: 0.5,+ },+ {+ effectIndex: 0,+ fieldKey: 'amount',+ frame: 30,+ valueWhenLastKeyframeDeleted: 0.5,+ },+ ],+ });++ const effect = updated.canUpdate ? updated.effects[0] : null;+ expect(effect?.canUpdate && effect.props.amount).toEqual({+ status: 'static',+ codeValue: 0.5,+ });+});diff --git a/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx b/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsxindex 67cf5edaaa..5c93d66f7a 100644--- a/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx+++ b/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx@@ -890,6 +890,8 @@ export const TimelineClipboardKeybindings: React.FC = () => {setPropStatuses,clientId,confirm,+ propStatuses,+ timelinePosition: timelinePositionRef.current,});return deletePromise?.then((deleted) => {if (!deleted) {@@ -1010,6 +1012,7 @@ export const TimelineClipboardKeybindings: React.FC = () => {fieldKey: keyframeTarget.fieldKey,sourceFrame,schema: keyframeTarget.schema,+ valueWhenLastKeyframeDeleted: null,}),);diff --git a/packages/studio/src/components/Timeline/TimelineDeleteKeybindings.tsx b/packages/studio/src/components/Timeline/TimelineDeleteKeybindings.tsxindex 61328642e7..674d60aa01 100644--- a/packages/studio/src/components/Timeline/TimelineDeleteKeybindings.tsx+++ b/packages/studio/src/components/Timeline/TimelineDeleteKeybindings.tsx@@ -83,6 +83,8 @@ export const TimelineDeleteKeybindings: React.FC = () => {setPropStatuses,clientId,confirm,+ propStatuses,+ timelinePosition: timelinePositionRef.current,});if (deletePromise !== null) {diff --git a/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx b/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsxindex b3cd5a9d19..c039d8e68c 100644--- a/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx+++ b/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx@@ -355,6 +355,7 @@ const getDeleteChange = (fieldKey: target.fieldKey,sourceFrame: target.sourceFrame,schema: target.schema,+ valueWhenLastKeyframeDeleted: null,};if (target.effectIndex === null) {diff --git a/packages/studio/src/components/Timeline/call-delete-keyframe.ts b/packages/studio/src/components/Timeline/call-delete-keyframe.tsindex 0037dd1f91..f0c0b20e47 100644--- a/packages/studio/src/components/Timeline/call-delete-keyframe.ts+++ b/packages/studio/src/components/Timeline/call-delete-keyframe.ts@@ -15,6 +15,7 @@ export type DeleteSequenceKeyframeChange = {fieldKey: string;sourceFrame: number;schema: InteractivitySchema;+ valueWhenLastKeyframeDeleted: unknown | null;};export type DeleteEffectKeyframeChange = DeleteSequenceKeyframeChange & {@@ -154,6 +155,7 @@ export const callDeleteKeyframes = ({keyframes: keyframes.map((keyframe) => ({fieldKey: keyframe.fieldKey,frame: keyframe.sourceFrame,+ valueWhenLastKeyframeDeleted: keyframe.valueWhenLastKeyframeDeleted,})),}),);@@ -172,6 +174,7 @@ export const callDeleteKeyframes = ({effectIndex: keyframe.effectIndex,fieldKey: keyframe.fieldKey,frame: keyframe.sourceFrame,+ valueWhenLastKeyframeDeleted: keyframe.valueWhenLastKeyframeDeleted,})),}),);@@ -184,6 +187,7 @@ export const callDeleteKeyframes = ({key: keyframe.fieldKey,frame: keyframe.sourceFrame,schema: keyframe.schema,+ valueWhenLastKeyframeDeleted: keyframe.valueWhenLastKeyframeDeleted,})),effectKeyframes: effectKeyframes.map((keyframe) => ({fileName: keyframe.fileName,@@ -192,6 +196,7 @@ export const callDeleteKeyframes = ({key: keyframe.fieldKey,frame: keyframe.sourceFrame,schema: keyframe.schema,+ valueWhenLastKeyframeDeleted: keyframe.valueWhenLastKeyframeDeleted,})),clientId,}).then(() => undefined);diff --git a/packages/studio/src/components/Timeline/delete-selected-keyframe.ts b/packages/studio/src/components/Timeline/delete-selected-keyframe.tsindex 279918c069..a00e3d43b0 100644--- a/packages/studio/src/components/Timeline/delete-selected-keyframe.ts+++ b/packages/studio/src/components/Timeline/delete-selected-keyframe.ts@@ -1,4 +1,10 @@-import type {OverrideIdToNodePaths, TSequence} from 'remotion';+import type {+ CanUpdateSequencePropStatus,+ OverrideIdToNodePaths,+ PropStatuses,+ TSequence,+} from 'remotion';+import {Internals} from 'remotion';import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';import {callDeleteEffectKeyframe,@@ -15,16 +21,40 @@ type SelectedKeyframeDeletion =| ({type: 'sequence'} & DeleteSequenceKeyframeChange)| ({type: 'effect'} & DeleteEffectKeyframeChange);+const getValueWhenLastKeyframeDeleted = ({+ propStatus,+ playheadSourceFrame,+}: {+ propStatus: CanUpdateSequencePropStatus | null | undefined;+ playheadSourceFrame: number | null;+}): unknown | null => {+ if (propStatus?.status !== 'keyframed' || playheadSourceFrame === null) {+ return null;+ }++ return (+ Internals.interpolateKeyframedStatus({+ forceSpringAllowTail: null,+ frame: playheadSourceFrame,+ status: propStatus,+ }) ?? null+ );+};+const getSelectedKeyframeDeletion = ({nodePathInfo,frame,sequences,overrideIdsToNodePaths,+ propStatuses,+ timelinePosition,}: {nodePathInfo: SequenceNodePathInfo;frame: number;sequences: TSequence[];overrideIdsToNodePaths: OverrideIdToNodePaths;+ propStatuses: PropStatuses | null;+ timelinePosition: number | null;}): SelectedKeyframeDeletion | null => {const field = parseKeyframeFieldFromNodePath(nodePathInfo.auxiliaryKeys);if (field === null) {@@ -42,6 +72,10 @@ const getSelectedKeyframeDeletion = ({}const sourceFrame = frame - (track?.keyframeDisplayOffset ?? 0);+ const playheadSourceFrame =+ timelinePosition === null+ ? null+ : timelinePosition - (track?.keyframeDisplayOffset ?? 0);const nodePath = nodePathInfo.sequenceSubscriptionKey;const fileName = nodePath.absolutePath;@@ -51,6 +85,23 @@ const getSelectedKeyframeDeletion = ({return null;}+ const effectStatus =+ propStatuses !== null+ ? Internals.getEffectPropStatusesCtx({+ propStatuses,+ nodePath,+ effectIndex: field.effectIndex,+ })+ : null;+ const effectPropStatus =+ effectStatus?.type === 'can-update-effect'+ ? effectStatus.props[field.fieldKey]+ : null;+ const effectValueWhenLastKeyframeDeleted = getValueWhenLastKeyframeDeleted({+ propStatus: effectPropStatus,+ playheadSourceFrame,+ });+return {type: 'effect',fileName,@@ -59,9 +110,19 @@ const getSelectedKeyframeDeletion = ({fieldKey: field.fieldKey,sourceFrame,schema: effect.schema,+ valueWhenLastKeyframeDeleted: effectValueWhenLastKeyframeDeleted,};}+ const sequencePropStatus =+ propStatuses !== null+ ? Internals.getPropStatusesCtx(propStatuses, nodePath)?.[field.fieldKey]+ : null;+ const sequenceValueWhenLastKeyframeDeleted = getValueWhenLastKeyframeDeleted({+ propStatus: sequencePropStatus,+ playheadSourceFrame,+ });+return {type: 'sequence',fileName,@@ -69,6 +130,7 @@ const getSelectedKeyframeDeletion = ({fieldKey: field.fieldKey,sourceFrame,schema: sequence.controls.schema,+ valueWhenLastKeyframeDeleted: sequenceValueWhenLastKeyframeDeleted,};};@@ -92,6 +154,8 @@ export const deleteSelectedKeyframe = ({frame,sequences,overrideIdsToNodePaths,+ propStatuses: null,+ timelinePosition: null,});if (deletion === null) {return null;@@ -118,6 +182,8 @@ export const deleteSelectedKeyframes = ({overrideIdsToNodePaths,setPropStatuses,clientId,+ propStatuses,+ timelinePosition,}: {keyframes: {nodePathInfo: SequenceNodePathInfo;@@ -127,6 +193,8 @@ export const deleteSelectedKeyframes = ({overrideIdsToNodePaths: OverrideIdToNodePaths;setPropStatuses: SetPropStatuses;clientId: string;+ propStatuses: PropStatuses;+ timelinePosition: number;}): Promise<void> | null => {const deletions = keyframes.map((keyframe) =>@@ -135,6 +203,8 @@ export const deleteSelectedKeyframes = ({frame: keyframe.frame,sequences,overrideIdsToNodePaths,+ propStatuses,+ timelinePosition,}),).filter(diff --git a/packages/studio/src/components/Timeline/delete-selected-timeline-item.ts b/packages/studio/src/components/Timeline/delete-selected-timeline-item.tsindex a72352ef0b..06353f773e 100644--- a/packages/studio/src/components/Timeline/delete-selected-timeline-item.ts+++ b/packages/studio/src/components/Timeline/delete-selected-timeline-item.ts@@ -419,6 +419,8 @@ export const deleteSelectedTimelineItems = ({setPropStatuses,clientId,confirm,+ propStatuses,+ timelinePosition,}: {selections: readonly TimelineSelection[];sequences: TSequence[];@@ -426,6 +428,8 @@ export const deleteSelectedTimelineItems = ({setPropStatuses: SetPropStatuses;clientId: string;confirm: ConfirmationDialogFunction;+ propStatuses: PropStatuses;+ timelinePosition: number;}): Promise<boolean> | null => {const firstSelection = selections[0];if (!firstSelection) {@@ -447,6 +451,8 @@ export const deleteSelectedTimelineItems = ({overrideIdsToNodePaths,setPropStatuses,clientId,+ propStatuses,+ timelinePosition,});return promise?.then(() => true) ?? null;}diff --git a/packages/studio/src/test/timeline-selection.test.ts b/packages/studio/src/test/timeline-selection.test.tsindex 9f42ccfda1..a4b61d508e 100644--- a/packages/studio/src/test/timeline-selection.test.ts+++ b/packages/studio/src/test/timeline-selection.test.ts@@ -5628,6 +5628,8 @@ test('Deleting unsupported mixed timeline selection types returns null', () => {setPropStatuses: () => undefined,clientId: 'client',confirm,+ propStatuses: {},+ timelinePosition: 0,}),).toBe(null);});@@ -5837,6 +5839,8 @@ test('Deleting selected keyframes ignores selected easings', async () => {setPropStatuses: () => undefined,clientId: 'client',confirm: () => Promise.resolve(true),+ propStatuses: {},+ timelinePosition: 0,});expect(result).toBe(true);@@ -5851,6 +5855,108 @@ test('Deleting selected keyframes ignores selected easings', async () => {key: 'opacity',frame: 12,schema,+ valueWhenLastKeyframeDeleted: null,+ },+ ],+ effectKeyframes: [],+ clientId: 'client',+ },+ },+ ]);+ } finally {+ globalThis.fetch = previousFetch;+ }+});++test('Deleting all selected keyframes preserves the value at the playhead', async () => {+ const schema = {+ opacity: {type: 'number', default: 1, hiddenFromList: false},+ } satisfies InteractivitySchema;+ const opacityNodePathInfo = makeNodePathInfo(+ ['body', 0],+ ['controls', 'opacity'],+ );+ const nodePath = opacityNodePathInfo.sequenceSubscriptionKey;+ const propStatuses = {+ [Internals.makeSequencePropsSubscriptionKey(nodePath)]: {+ canUpdate: true,+ props: {+ opacity: {+ status: 'keyframed',+ interpolationFunction: 'interpolate',+ keyframes: [+ {frame: 0, value: 0},+ {frame: 10, value: 1},+ ],+ easing: [{type: 'linear'}],+ clamping: {left: 'extend', right: 'extend'},+ posterize: undefined,+ output: undefined,+ },+ },+ effects: [],+ },+ } satisfies PropStatuses;+ const fetchCalls: unknown[] = [];+ const previousFetch = globalThis.fetch;+ globalThis.fetch = ((input, init) => {+ fetchCalls.push({+ input,+ body:+ typeof init?.body === 'string'+ ? JSON.parse(init.body)+ : (init?.body ?? null),+ });++ return Promise.resolve({+ json: () => Promise.resolve({success: true, data: {}}),+ } as Response);+ }) as typeof fetch;++ try {+ const result = await deleteSelectedTimelineItems({+ selections: [+ {+ type: 'keyframe',+ nodePathInfo: opacityNodePathInfo,+ frame: 0,+ },+ {+ type: 'keyframe',+ nodePathInfo: opacityNodePathInfo,+ frame: 10,+ },+ ],+ sequences: [makeTimelineSequence({schema})],+ overrideIdsToNodePaths: {override: nodePath},+ setPropStatuses: () => undefined,+ clientId: 'client',+ confirm: () => Promise.resolve(true),+ propStatuses,+ timelinePosition: 5,+ });++ expect(result).toBe(true);+ expect(fetchCalls).toEqual([+ {+ input: '/api/delete-keyframes',+ body: {+ sequenceKeyframes: [+ {+ fileName: '/project/src/Comp.tsx',+ nodePath,+ key: 'opacity',+ frame: 0,+ schema,+ valueWhenLastKeyframeDeleted: 0.5,+ },+ {+ fileName: '/project/src/Comp.tsx',+ nodePath,+ key: 'opacity',+ frame: 10,+ schema,+ valueWhenLastKeyframeDeleted: 0.5,},],effectKeyframes: [],