🎥 Make videos programmatically with React
`@remotion/studio`: Collapse duplicated timeline rows (#10164)
Jonny Burgerf1de2c2edc83
diff --git a/packages/docs/elements/data/horizontal-bar-chart/horizontal-bar-chart.tsx b/packages/docs/elements/data/horizontal-bar-chart/horizontal-bar-chart.tsxindex 538acfff2f..f6fba02870 100644--- a/packages/docs/elements/data/horizontal-bar-chart/horizontal-bar-chart.tsx+++ b/packages/docs/elements/data/horizontal-bar-chart/horizontal-bar-chart.tsx@@ -21,8 +21,7 @@ const Bar: React.FC<{readonly highlighted: boolean;readonly label: string;readonly value: number;- readonly showInTimeline: boolean;-}> = ({highlighted, label, showInTimeline, value}) => {+}> = ({highlighted, label, value}) => {const frame = useCurrentFrame();return (@@ -33,7 +32,6 @@ const Bar: React.FC<{extrapolateRight: 'clamp',})}name={'Bar'}- showInTimeline={showInTimeline}style={{alignItems: 'center',backgroundColor: highlighted ? '#2858e8' : '#d1d5db',@@ -50,7 +48,6 @@ const Bar: React.FC<{><Interactive.Divname={'Label'}- showInTimeline={showInTimeline}style={{fontSize: 40,fontWeight: 700,@@ -65,8 +62,7 @@ const Bar: React.FC<{{label}</Interactive.Div><Interactive.Div- name={`${label} value`}- showInTimeline={showInTimeline}+ name="Value"style={{fontSize: 48,fontWeight: 800,@@ -124,12 +120,7 @@ export const HorizontalBarChart: React.FC = () => {style={{width: `${(value / maxValue) * 100}%`, height: '100%'}}showInTimeline={false}>- <Bar- highlighted={highlighted}- label={label}- showInTimeline={index === 0}- value={value}- />+ <Bar highlighted={highlighted} label={label} value={value} /></Interactive.Div></div>))}diff --git a/packages/docs/src/components/Elements/ElementPreviewComposition.tsx b/packages/docs/src/components/Elements/ElementPreviewComposition.tsxindex f55c3bd4e8..be037d4e94 100644--- a/packages/docs/src/components/Elements/ElementPreviewComposition.tsx+++ b/packages/docs/src/components/Elements/ElementPreviewComposition.tsx@@ -43,6 +43,7 @@ export const ElementPreviewComposition: React.FC<{alignItems: 'center',justifyContent: 'center',}}+ showInTimeline={false}><Sequence height={elementHeight} layout="none" width={elementWidth}><div@@ -72,7 +73,10 @@ export const ElementAssetComposition: React.FC<{const definition = getElementDefinition(slug);return (- <AbsoluteFill style={{backgroundColor: ELEMENT_PREVIEW_BACKGROUND}}>+ <AbsoluteFill+ style={{backgroundColor: ELEMENT_PREVIEW_BACKGROUND}}+ showInTimeline={false}+ ><ElementPreviewComposition definition={definition} /></AbsoluteFill>);diff --git a/packages/example/e2e/studio.test.mts b/packages/example/e2e/studio.test.mtsindex 4eed5eb979..6a1bb5f256 100644--- a/packages/example/e2e/studio.test.mts+++ b/packages/example/e2e/studio.test.mts@@ -75,6 +75,76 @@ test.describe('visual mode', () => {});});+ test('should collapse programmatically duplicated timeline rows', async ({+ page,+ }) => {+ await page.addInitScript(() => {+ window.localStorage.setItem(+ 'remotion.sidebarRightCollapsing',+ 'expanded',+ );+ });+ await page.goto(`${STUDIO_URL}/AnimatedBarChart`);++ const firstGridline = page.getByText('0% gridline', {exact: true});+ await expect(firstGridline).toBeVisible({timeout: 15_000});+ await expect(+ firstGridline+ .locator('..')+ .getByLabel('4 other programmatically duplicated instances are hidden'),+ ).toBeVisible({timeout: 15_000});+ await expect(page.getByText('25% gridline', {exact: true})).toHaveCount(0);+ const visibleOutlines = page.locator(+ '.remotion-studio-composition-container > svg[aria-hidden="true"] > polygon[stroke-opacity="1"]',+ );++ await firstGridline.hover();+ await expect(visibleOutlines).toHaveCount(5);++ const northCanvasLabel = page+ .locator('.remotion-studio-composition-container')+ .getByText('North', {exact: true});+ await northCanvasLabel.hover({force: true});+ await expect(visibleOutlines).toHaveCount(5);+ const centralCanvasLabel = page+ .locator('.remotion-studio-composition-container')+ .getByText('Central', {exact: true});+ const northLabelTitles = page.getByTitle('North label');+ const northLabelTitleCountBeforeSelection = await northLabelTitles.count();+ await centralCanvasLabel.click({force: true});+ await expect(northLabelTitles).toHaveCount(+ northLabelTitleCountBeforeSelection + 1,+ );+ await page.mouse.move(0, 0);+ await expect(visibleOutlines).toHaveCount(5);++ await firstGridline.click();+ const duplicationLabel = page.getByText('5 instances', {+ exact: true,+ });+ await expect(duplicationLabel).toBeVisible();+ await expect(duplicationLabel).toHaveCSS('color', 'rgb(166, 167, 169)');+ await expect(duplicationLabel).toHaveCSS('font-family', 'sans-serif');+ await expect(duplicationLabel).toHaveCSS('font-size', '12px');+ await expect(duplicationLabel).toHaveCSS('font-weight', '400');+ await expect(duplicationLabel).toHaveCSS('line-height', '24px');+ await expect(duplicationLabel).toHaveCSS('margin-top', '2px');+ await expect(duplicationLabel).toHaveCSS('margin-bottom', '2px');++ await page+ .locator('[data-timeline-marquee-item][title="0% gridline"]')+ .click({button: 'right'});+ const duplicateMenuItem = page+ .locator('.__remotion-studio-menu-item')+ .filter({hasText: 'Duplicate'});+ await expect(duplicateMenuItem).toHaveCSS('opacity', '0.5');+ await expect(+ page+ .locator('.__remotion-studio-menu-item')+ .filter({hasText: 'Delete all'}),+ ).toBeVisible();+ });+test('should pass the copied inspector prompt to editable coding agents', async ({context,page,diff --git a/packages/example/src/E2eTestRoot.tsx b/packages/example/src/E2eTestRoot.tsxindex a83ab1c98b..0e29021fab 100644--- a/packages/example/src/E2eTestRoot.tsx+++ b/packages/example/src/E2eTestRoot.tsx@@ -1,5 +1,6 @@import React from 'react';import {Composition, Folder} from 'remotion';+import {BarChart} from './BarChart';import {EffectKeyframeE2e} from './EffectKeyframeE2e';import {ErrorOverlayRepro,@@ -43,6 +44,14 @@ export const E2eTestRoot: React.FC = () => {}}/></Folder>+ <Composition+ id="AnimatedBarChart"+ component={BarChart}+ durationInFrames={180}+ fps={30}+ width={1280}+ height={720}+ /><Folder name="visual-controls"><Compositionid="visual-controls"diff --git a/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx b/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsxindex e25ec9d695..be229247e9 100644--- a/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx+++ b/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx@@ -10,7 +10,11 @@ import {InspectorSourceLocation} from '../InspectorSourceLocation';import {COMPACT_INLINE_ROW_HEIGHT} from '../layout';import {useOpenSequenceInEditor} from '../Timeline/use-open-sequence-in-editor';import {useRenameSequence} from '../Timeline/use-rename-sequence';-import {InspectorInlineAction, InspectorSectionDivider} from './common';+import {+ InspectorInlineAction,+ InspectorSection,+ InspectorSectionDivider,+} from './common';import {ConnectedCompositionsSection,useConnectedCompositions,@@ -165,6 +169,38 @@ export const SequenceInspectorHeader: React.FC<{);};+export const SequenceInspectorDuplicationSection: React.FC<{+ readonly track: TimelineTrackData;+}> = ({track}) => {+ const numberOfInstances =+ track.nodePathInfo?.numberOfSequencesWithThisNodePath ?? 0;+ if (numberOfInstances <= 1) {+ return null;+ }++ return (+ <InspectorSection+ header={+ <span+ style={{+ color: 'inherit',+ display: 'block',+ fontFamily: 'inherit',+ fontSize: 'inherit',+ fontWeight: 'normal',+ lineHeight: 'inherit',+ margin: '2px 0',+ }}+ >+ {numberOfInstances} instances+ </span>+ }+ >+ {null}+ </InspectorSection>+ );+};+export const SequenceInspectorSections: React.FC<{readonly track: TimelineTrackData;}> = ({track}) => {@@ -174,6 +210,7 @@ export const SequenceInspectorSections: React.FC<{return (<><SequenceInspectorHeader sourceLocation={sourceLocation} track={track} />+ <SequenceInspectorDuplicationSection track={track} />{connectedCompositions.length > 0 ? (<><InspectorSectionDivider />diff --git a/packages/studio/src/components/InspectorPanel/SequenceSelectionInspector.tsx b/packages/studio/src/components/InspectorPanel/SequenceSelectionInspector.tsxindex 701edcb560..d1ba82fc12 100644--- a/packages/studio/src/components/InspectorPanel/SequenceSelectionInspector.tsx+++ b/packages/studio/src/components/InspectorPanel/SequenceSelectionInspector.tsx@@ -38,6 +38,7 @@ import {} from './ConnectedCompositionsSection';import type {SequenceSectionSelection} from './inspector-selection';import {+ SequenceInspectorDuplicationSection,SequenceInspectorHeader,useSequenceInspectorSourceLocation,} from './SequenceInspectorHeader';@@ -275,6 +276,7 @@ const SequenceExpandedInspector: React.FC<{onPointerDown={selectSequenceOnInspectorPointerDown}><SequenceInspectorHeader sourceLocation={sourceLocation} track={track} />+ <SequenceInspectorDuplicationSection track={track} />{connectedCompositions.length > 0 ? (<><InspectorSectionDivider />diff --git a/packages/studio/src/components/SelectedOutlineElement.tsx b/packages/studio/src/components/SelectedOutlineElement.tsxindex 3dca87a7c8..0969cf092f 100644--- a/packages/studio/src/components/SelectedOutlineElement.tsx+++ b/packages/studio/src/components/SelectedOutlineElement.tsx@@ -513,10 +513,10 @@ const SelectedOutlinePolygon: React.FC<{);const drag = target?.drag ?? null;const selected = target?.selected ?? false;- const containsSelection = target?.containsSelection ?? false;+ const showSelectedOutline = target?.showSelectedOutline ?? false;const effectDrop = target?.effectDrop ?? null;const [effectDropHovered, setEffectDropHovered] = useState(false);- const visible = containsSelection || hovered;+ const visible = showSelectedOutline || hovered;const onPointerDown = React.useCallback((event: React.PointerEvent<SVGPolygonElement>) => {@@ -1600,6 +1600,8 @@ export const SelectedOutlineElement: React.FC<{!sourceEditingEnabled ||!target.sequence.controls ||!nodePath.absolutePath;+ const isProgrammaticallyDuplicated =+ target.nodePathInfo.numberOfSequencesWithThisNodePath > 1;const canAddEffect =target.nodePathInfo.supportsEffects &&!sourceEditDisabled &&@@ -1611,10 +1613,11 @@ export const SelectedOutlineElement: React.FC<{canOpenInEditor,deleteDisabled: sourceEditDisabled,disableInteractivityDisabled,- duplicateDisabled: sourceEditDisabled,+ duplicateDisabled: sourceEditDisabled || isProgrammaticallyDuplicated,editorInfo: null,fileLocation,includeSourceEditItems: sourceEditingEnabled,+ isProgrammaticallyDuplicated,onDeleteSequenceFromSource: async () => {if (sourceEditDisabled || previewServerState.type !== 'connected') {return;diff --git a/packages/studio/src/components/SelectedOutlineOverlay.tsx b/packages/studio/src/components/SelectedOutlineOverlay.tsxindex a3dd5e62d9..3633f53ff3 100644--- a/packages/studio/src/components/SelectedOutlineOverlay.tsx+++ b/packages/studio/src/components/SelectedOutlineOverlay.tsx@@ -15,10 +15,12 @@ import {} from 'remotion';import {NoReactInternals} from 'remotion/no-react';import {StudioServerConnectionCtx} from '../helpers/client-id';+import type {SequenceNodePathInfo} from '../helpers/get-timeline-sequence-sort-key';import {isStudioInteractivityEnabled,isStudioSelectionEnabled,} from '../helpers/interactivity-enabled';+import {timelineSequenceNodePathToKey} from '../helpers/timeline-node-path-key';import {useIsFullscreen} from '../helpers/use-is-fullscreen';import {useKeybinding} from '../helpers/use-keybinding';import {useRuntimeValueSnapshots} from '../helpers/use-runtime-values';@@ -702,18 +704,6 @@ export const SelectedOutlineOverlay: React.FC<{},[setHoveredSequence],);- const onHoverChange = useCallback(- (key: string | null) => {- setHoveredSequence((currentHover) => {- if (key !== null) {- return {key, source: 'canvas'};- }-- return currentHover?.source === 'canvas' ? null : currentHover;- });- },- [setHoveredSequence],- );const onSnapPointsChange = useCallback((snapPoints: readonly SelectedOutlineSnapPoint[]) => {setActiveSnapPoints(snapPoints);@@ -744,11 +734,14 @@ export const SelectedOutlineOverlay: React.FC<{overrideIdsToNodePaths: overrideIdToNodePathMappings,compositions,timelinePosition,- }).flatMap(({key, sequence}) => {+ }).flatMap(({key, nodePathInfo, sequence}) => {+ const nodePathKey = timelineSequenceNodePathToKey(+ nodePathInfo.sequenceSubscriptionKey,+ );if (!selectedSequenceKeys.has(key) &&!sequenceKeysContainingSelection.has(key) &&- hoveredSequence?.key !== key+ hoveredSequence?.nodePathKey !== nodePathKey) {return [];}@@ -758,7 +751,7 @@ export const SelectedOutlineOverlay: React.FC<{}, [compositions,editorShowOutlines,- hoveredSequence?.key,+ hoveredSequence?.nodePathKey,isFullscreen,overrideIdToNodePathMappings,previewSelectionAvailable,@@ -803,12 +796,37 @@ export const SelectedOutlineOverlay: React.FC<{? previewServerState.clientId: null;- return getSequencesWithSelectableOutlines({+ const selectableOutlines = getSequencesWithSelectableOutlines({sequences,overrideIdsToNodePaths: overrideIdToNodePathMappings,compositions,timelinePosition,- }).map(({key, keyframeDisplayOffset, nodePathInfo, sequence}) => {+ });+ const firstNodePathInfoBySourceNode = new Map<+ string,+ SequenceNodePathInfo+ >();+ const selectedSourceNodeKeys = new Set<string>();+ for (const {key, nodePathInfo} of selectableOutlines) {+ const sourceNodeKey = timelineSequenceNodePathToKey(+ nodePathInfo.sequenceSubscriptionKey,+ );+ if (selectedSequenceKeys.has(key)) {+ selectedSourceNodeKeys.add(sourceNodeKey);+ }++ const currentFirst = firstNodePathInfoBySourceNode.get(sourceNodeKey);+ if (+ currentFirst === undefined ||+ nodePathInfo.index < currentFirst.index+ ) {+ firstNodePathInfoBySourceNode.set(sourceNodeKey, nodePathInfo);+ }+ }++ return selectableOutlines.map((selectableOutline) => {+ const {key, keyframeDisplayOffset, nodePathInfo, sequence} =+ selectableOutline;if (sequence.refForOutline === null) {throw new Error('Expected sequence to have a ref for outline');}@@ -816,6 +834,15 @@ export const SelectedOutlineOverlay: React.FC<{const selected = selectedSequenceKeys.has(key);const containsSelection = sequenceKeysContainingSelection.has(key);const nodePath = nodePathInfo.sequenceSubscriptionKey;+ const sourceNodeKey = timelineSequenceNodePathToKey(nodePath);+ const showSelectedOutline =+ containsSelection || selectedSourceNodeKeys.has(sourceNodeKey);+ const selectionNodePathInfo =+ firstNodePathInfoBySourceNode.get(sourceNodeKey);+ if (selectionNodePathInfo === undefined) {+ throw new Error('Expected a first sequence for the source node');+ }+const {controls} = sequence;const nodePropStatuses = Internals.getPropStatusesCtx(propStatuses,@@ -996,7 +1023,11 @@ export const SelectedOutlineOverlay: React.FC<{nodePathInfo,ref: sequence.refForOutline,selected,- selection: {type: 'sequence', nodePathInfo},+ showSelectedOutline,+ selection: {+ type: 'sequence',+ nodePathInfo: selectionNodePathInfo,+ },sequence,drag: canDrag? {@@ -1139,6 +1170,46 @@ export const SelectedOutlineOverlay: React.FC<{timelinePosition,outlineRuntimeValuesByStore,]);+ const nodePathKeyByOutlineKey = useMemo(() => {+ return new Map(+ outlineTargets.map((target) => [+ target.key,+ timelineSequenceNodePathToKey(+ target.nodePathInfo.sequenceSubscriptionKey,+ ),+ ]),+ );+ }, [outlineTargets]);+ const onHoverChange = useCallback(+ (key: string | null) => {+ setHoveredSequence((currentHover) => {+ if (key !== null) {+ const nodePathKey = nodePathKeyByOutlineKey.get(key);+ if (nodePathKey === undefined) {+ return currentHover;+ }++ return {key, nodePathKey, source: 'canvas'};+ }++ return currentHover?.source === 'canvas' ? null : currentHover;+ });+ },+ [nodePathKeyByOutlineKey, setHoveredSequence],+ );+ const hoveredOutlineKeys = useMemo(() => {+ if (hoveredSequence === null) {+ return new Set<string>();+ }++ return new Set(+ outlineTargets.flatMap((target) =>+ nodePathKeyByOutlineKey.get(target.key) === hoveredSequence.nodePathKey+ ? [target.key]+ : [],+ ),+ );+ }, [hoveredSequence, nodePathKeyByOutlineKey, outlineTargets]);useEffect(() => {if (@@ -1580,7 +1651,7 @@ export const SelectedOutlineOverlay: React.FC<{allRotationDragTargets={allRotationDragTargets}allScaleDragTargets={allScaleDragTargets}dragging={draggingOutline}- hovered={hoveredSequence?.key === outline.key}+ hovered={hoveredOutlineKeys.has(outline.key)}outline={outline}onDraggingChange={onDraggingChange}onHoverChange={onHoverChange}diff --git a/packages/studio/src/components/Timeline/Timeline.tsx b/packages/studio/src/components/Timeline/Timeline.tsxindex bd13f9386c..8c7520f68a 100644--- a/packages/studio/src/components/Timeline/Timeline.tsx+++ b/packages/studio/src/components/Timeline/Timeline.tsx@@ -10,6 +10,7 @@ import {isStudioInteractivityEnabled} from '../../helpers/interactivity-enabled'import {useIsStill} from '../../helpers/is-current-selected-still';import {useCachedCompositionComponentInfo} from '../../helpers/open-in-editor';import {getStudioMaxTimelineTracks} from '../../helpers/studio-runtime-config';+import {timelineSequenceNodePathToKey} from '../../helpers/timeline-node-path-key';import {callApi} from '../call-api';import {ContextMenu} from '../ContextMenu';import {importAssets, pickFilesToImport} from '../import-assets';@@ -282,14 +283,35 @@ const TimelineInner: React.FC = () => {);}, [durationInFrames, timeline]);+ // Keep `filtered` complete so a future toggle can show every programmatic+ // instance without recalculating the timeline or losing its instance index.+ const collapsed = useMemo(() => {+ const seenNodePaths = new Set<string>();+ return filtered.filter((track) => {+ if (track.nodePathInfo === null) {+ return true;+ }++ const key = timelineSequenceNodePathToKey(+ track.nodePathInfo.sequenceSubscriptionKey,+ );+ if (seenNodePaths.has(key)) {+ return false;+ }++ seenNodePaths.add(key);+ return true;+ });+ }, [filtered]);+const maxTimelineTracks = getStudioMaxTimelineTracks();const shown = useMemo(() => {- return filtered.length > maxTimelineTracks- ? filtered.slice(0, maxTimelineTracks)- : filtered;- }, [filtered, maxTimelineTracks]);+ return collapsed.length > maxTimelineTracks+ ? collapsed.slice(0, maxTimelineTracks)+ : collapsed;+ }, [collapsed, maxTimelineTracks]);- const hasBeenCut = filtered.length > shown.length;+ const hasBeenCut = collapsed.length > shown.length;return (<TimelineContextMenuArea>diff --git a/packages/studio/src/components/Timeline/TimelineDuplicateCount.tsx b/packages/studio/src/components/Timeline/TimelineDuplicateCount.tsxnew file mode 100644index 0000000000..126a5a9d2e--- /dev/null+++ b/packages/studio/src/components/Timeline/TimelineDuplicateCount.tsx@@ -0,0 +1,33 @@+import React from 'react';+import {WHITE_ALPHA_20, WHITE_ALPHA_60} from '../../helpers/colors';++const badgeStyle: React.CSSProperties = {+ alignItems: 'center',+ border: `1px solid ${WHITE_ALPHA_20}`,+ borderRadius: 4,+ boxSizing: 'border-box',+ color: WHITE_ALPHA_60,+ display: 'inline-flex',+ flexShrink: 0,+ fontSize: 10,+ fontWeight: 300,+ height: 14,+ justifyContent: 'center',+ lineHeight: '12px',+ minWidth: 18,+ padding: '0 3px',+ userSelect: 'none',+ WebkitUserSelect: 'none',+};++export const TimelineDuplicateCount: React.FC<{+ readonly count: number;+}> = ({count}) => {+ const label = `${count} other programmatically duplicated ${count === 1 ? 'instance is' : 'instances are'} hidden`;++ return (+ <span style={badgeStyle} title={label} aria-label={label}>+ +{count}+ </span>+ );+};diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsxindex 1591da5ed1..4b1dd5648a 100644--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx@@ -396,7 +396,9 @@ const TimelineSequenceInner: React.FC<{const canDeleteFromSource = Boolean(nodePath && validatedLocation?.source);const deleteDisabled =!previewInteractive || !s.controls || !canDeleteFromSource;- const duplicateDisabled = deleteDisabled;+ const isProgrammaticallyDuplicated =+ (nodePathInfo?.numberOfSequencesWithThisNodePath ?? 1) > 1;+ const duplicateDisabled = deleteDisabled || isProgrammaticallyDuplicated;const disableInteractivityDisabled =!previewInteractive ||!s.showInTimeline ||@@ -507,6 +509,7 @@ const TimelineSequenceInner: React.FC<{editorInfo,fileLocation,includeSourceEditItems: isStudioInteractivityEnabled(),+ isProgrammaticallyDuplicated,onDeleteSequenceFromSource,onDisableSequenceInteractivity,onDuplicateSequenceFromSource,@@ -526,6 +529,7 @@ const TimelineSequenceInner: React.FC<{duplicateDisabled,editorInfo,fileLocation,+ isProgrammaticallyDuplicated,mediaSrc,nodePath,onSelect,diff --git a/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx b/packages/studio/src/components/Timeline/TimelineSequenceItem.tsxindex e8c68a9dbd..776f9fb863 100644--- a/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx+++ b/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx@@ -63,6 +63,7 @@ import {getSequenceContextMenuItems} from './get-sequence-context-menu-items';import {getCurrentFrame} from './imperative-state';import {saveSequenceProps} from './save-sequence-prop';import {getTimelineAssetLinkInfo} from './timeline-asset-link';+import {TimelineDuplicateCount} from './TimelineDuplicateCount';import {TimelineExpandArrowButton,TimelineExpandArrowSpacer,@@ -335,6 +336,10 @@ const TimelineSequenceItemInner: React.FC<{sequence.displayName === '' && connectedCompositions.length === 1? connectedCompositions[0].id: displayName;+ const numberOfHiddenDuplicates = Math.max(+ 0,+ (nodePathInfo?.numberOfSequencesWithThisNodePath ?? 1) - 1,+ );const canDeleteFromSource = Boolean(nodePath && validatedLocation?.source);const nodePathKey = useMemo(@@ -355,7 +360,9 @@ const TimelineSequenceItemInner: React.FC<{[previewInteractive, sequence.controls, canDeleteFromSource],);- const duplicateDisabled = deleteDisabled;+ const isProgrammaticallyDuplicated =+ (nodePathInfo?.numberOfSequencesWithThisNodePath ?? 1) > 1;+ const duplicateDisabled = deleteDisabled || isProgrammaticallyDuplicated;const disableInteractivityDisabled =!previewInteractive ||!sequence.showInTimeline ||@@ -974,6 +981,7 @@ const TimelineSequenceItemInner: React.FC<{editorInfo,fileLocation,includeSourceEditItems: isStudioInteractivityEnabled(),+ isProgrammaticallyDuplicated,onDeleteSequenceFromSource,onDisableSequenceInteractivity,onDuplicateSequenceFromSource,@@ -1047,6 +1055,7 @@ const TimelineSequenceItemInner: React.FC<{duplicateDisabled,editorInfo,fileLocation,+ isProgrammaticallyDuplicated,mediaSrc,nodePath,nodePathInfo?.supportsEffects,@@ -1218,6 +1227,12 @@ const TimelineSequenceItemInner: React.FC<{onCancelEditing={onCancelRenaming}onSaveName={onSaveName}/>+ {numberOfHiddenDuplicates > 0 ? (+ <>+ <Spacing x={0.5} />+ <TimelineDuplicateCount count={numberOfHiddenDuplicates} />+ </>+ ) : null}{mediaSrc ? (<><Spacing x={0.5} /> <TimelineMediaInfo src={mediaSrc} />diff --git a/packages/studio/src/components/Timeline/get-sequence-context-menu-items.ts b/packages/studio/src/components/Timeline/get-sequence-context-menu-items.tsindex 5e70914d38..9f4f37ab56 100644--- a/packages/studio/src/components/Timeline/get-sequence-context-menu-items.ts+++ b/packages/studio/src/components/Timeline/get-sequence-context-menu-items.ts@@ -40,6 +40,7 @@ export const getSequenceContextMenuItems = ({deleteDisabled,disableInteractivityDisabled,duplicateDisabled,+ isProgrammaticallyDuplicated,fileLocation,includeSourceEditItems,editorInfo,@@ -57,6 +58,7 @@ export const getSequenceContextMenuItems = ({readonly deleteDisabled: boolean;readonly disableInteractivityDisabled: boolean;readonly duplicateDisabled: boolean;+ readonly isProgrammaticallyDuplicated: boolean;readonly fileLocation: string | null;readonly includeSourceEditItems: boolean;readonly editorInfo: GetDefaultEditorInfoResponse | null;@@ -253,7 +255,7 @@ export const getSequenceContextMenuItems = ({keyHint: null,label: 'Duplicate',leftItem: null,- disabled: duplicateDisabled,+ disabled: duplicateDisabled || isProgrammaticallyDuplicated,onClick: onDuplicateSequenceFromSource,quickSwitcherLabel: null,subMenu: null,@@ -271,7 +273,7 @@ export const getSequenceContextMenuItems = ({type: 'item' as const,id: 'delete-sequence',keyHint: null,- label: 'Delete',+ label: isProgrammaticallyDuplicated ? 'Delete all' : 'Delete',leftItem: null,disabled: deleteDisabled,onClick: onDeleteSequenceFromSource,diff --git a/packages/studio/src/components/selected-outline-types.ts b/packages/studio/src/components/selected-outline-types.tsindex 85f2ba4cb3..ae5f55612e 100644--- a/packages/studio/src/components/selected-outline-types.ts+++ b/packages/studio/src/components/selected-outline-types.ts@@ -28,6 +28,7 @@ export type SelectedOutlineTarget = {readonly nodePathInfo: SequenceNodePathInfo;readonly ref: React.RefObject<Element | null>;readonly selected: boolean;+ readonly showSelectedOutline: boolean;readonly selection: TimelineSelection;readonly sequence: TSequence;readonly crop: {diff --git a/packages/studio/src/helpers/calculate-timeline.ts b/packages/studio/src/helpers/calculate-timeline.tsindex 5e3c6f47d0..f8d32a28fc 100644--- a/packages/studio/src/helpers/calculate-timeline.ts+++ b/packages/studio/src/helpers/calculate-timeline.ts@@ -1,4 +1,3 @@-import {stringifySequenceSubscriptionKey} from '@remotion/studio-shared';import type {_InternalTypes,LoopDisplay,@@ -19,6 +18,7 @@ import type {} from './get-timeline-sequence-sort-key';import {getTimelineSequenceSortKey} from './get-timeline-sequence-sort-key';import {sortItemsByNonceHistory} from './sort-by-nonce-history';+import {timelineSequenceNodePathToKey} from './timeline-node-path-key';const getInheritedLoopDisplay = (sequence: TSequence,@@ -165,7 +165,7 @@ export const calculateTimeline = ({return track;}- const key = stringifySequenceSubscriptionKey(+ const key = timelineSequenceNodePathToKey(track.nodePathInfo.sequenceSubscriptionKey,);const index = nodePathIndexCounters.get(key) ?? 0;@@ -186,7 +186,7 @@ export const calculateTimeline = ({return track;}- const key = stringifySequenceSubscriptionKey(+ const key = timelineSequenceNodePathToKey(track.nodePathInfo.sequenceSubscriptionKey,);diff --git a/packages/studio/src/helpers/timeline-node-path-key.ts b/packages/studio/src/helpers/timeline-node-path-key.tsindex 82691ec36f..a6de704789 100644--- a/packages/studio/src/helpers/timeline-node-path-key.ts+++ b/packages/studio/src/helpers/timeline-node-path-key.ts@@ -1,6 +1,11 @@import {stringifySequenceExpandedRowKey} from '@remotion/studio-shared';+import type {SequencePropsSubscriptionKey} from 'remotion';import type {SequenceNodePathInfo} from './get-timeline-sequence-sort-key';+export const timelineSequenceNodePathToKey = (+ key: SequencePropsSubscriptionKey,+): string => `${key.absolutePath}:${JSON.stringify(key.nodePath)}`;+export const timelineNodePathInfoToKey = (info: SequenceNodePathInfo): string =>[stringifySequenceExpandedRowKey(info.sequenceSubscriptionKey),diff --git a/packages/studio/src/state/timeline-sequence-hover.ts b/packages/studio/src/state/timeline-sequence-hover.tsindex f6cc03e471..2563c2b2af 100644--- a/packages/studio/src/state/timeline-sequence-hover.ts+++ b/packages/studio/src/state/timeline-sequence-hover.ts@@ -1,10 +1,14 @@import type {Dispatch, SetStateAction} from 'react';import {createContext, useCallback, useContext, useMemo} from 'react';import type {SequenceNodePathInfo} from '../helpers/get-timeline-sequence-sort-key';-import {timelineNodePathInfoToKey} from '../helpers/timeline-node-path-key';+import {+ timelineNodePathInfoToKey,+ timelineSequenceNodePathToKey,+} from '../helpers/timeline-node-path-key';export type TimelineSequenceHover = {readonly key: string;+ readonly nodePathKey: string;readonly source: 'canvas' | 'timeline';};@@ -34,14 +38,25 @@ export const useTimelineSequenceHover = (: timelineNodePathInfoToKey({...nodePathInfo, auxiliaryKeys: []}),[nodePathInfo],);+ const nodePathKey = useMemo(+ () =>+ nodePathInfo === null+ ? null+ : timelineSequenceNodePathToKey(nodePathInfo.sequenceSubscriptionKey),+ [nodePathInfo],+ );const onPointerEnter = useCallback(() => {- if (sequenceKey === null) {+ if (sequenceKey === null || nodePathKey === null) {return;}- setHoveredSequence({key: sequenceKey, source: 'timeline'});- }, [sequenceKey, setHoveredSequence]);+ setHoveredSequence({+ key: sequenceKey,+ nodePathKey,+ source: 'timeline',+ });+ }, [nodePathKey, sequenceKey, setHoveredSequence]);const onPointerLeave = useCallback(() => {setHoveredSequence((currentHover) => {@@ -56,7 +71,8 @@ export const useTimelineSequenceHover = (});}, [sequenceKey, setHoveredSequence]);- const hovered = sequenceKey !== null && hoveredSequence?.key === sequenceKey;+ const hovered =+ nodePathKey !== null && hoveredSequence?.nodePathKey === nodePathKey;return useMemo(() => ({hovered, onPointerEnter, onPointerLeave}),diff --git a/packages/studio/src/test/sequence-context-menu-items.test.ts b/packages/studio/src/test/sequence-context-menu-items.test.tsindex 8f2a5971bc..b0b3ed8474 100644--- a/packages/studio/src/test/sequence-context-menu-items.test.ts+++ b/packages/studio/src/test/sequence-context-menu-items.test.ts@@ -83,6 +83,7 @@ test('sequence context menu does not put two dividers between docs and rename',editorInfo: null,fileLocation: 'src/Video.tsx:10:2',includeSourceEditItems: true,+ isProgrammaticallyDuplicated: false,onDeleteSequenceFromSource: noop,onDisableSequenceInteractivity: noop,onDuplicateSequenceFromSource: noop,@@ -132,6 +133,7 @@ test('Interactive.Svg context menu can copy the rendered SVG', () => {editorInfo: null,fileLocation: 'src/Video.tsx:10:2',includeSourceEditItems: true,+ isProgrammaticallyDuplicated: false,onDeleteSequenceFromSource: noop,onDisableSequenceInteractivity: noop,onDuplicateSequenceFromSource: noop,@@ -167,6 +169,38 @@ test('Interactive.Svg context menu can copy the rendered SVG', () => {expect(items[copySvgIndex + 1]?.type).toBe('divider');});+test('programmatically duplicated sequence menus apply actions to all instances', () => {+ installTestWindow();++ const items = getSequenceContextMenuItems({+ assetLinkInfo: null,+ canOpenInEditor: false,+ deleteDisabled: false,+ disableInteractivityDisabled: false,+ duplicateDisabled: false,+ editorInfo: null,+ fileLocation: 'src/Video.tsx:10:2',+ includeSourceEditItems: true,+ isProgrammaticallyDuplicated: true,+ onDeleteSequenceFromSource: noop,+ onDisableSequenceInteractivity: noop,+ onDuplicateSequenceFromSource: noop,+ openInEditor: noop,+ originalLocation: null,+ selectAsset: noop,+ sequence: {} as TSequence,+ });++ const duplicateItem = items.find((item) => item.id === 'duplicate-sequence');+ const deleteItem = items.find((item) => item.id === 'delete-sequence');+ if (duplicateItem?.type !== 'item' || deleteItem?.type !== 'item') {+ throw new Error('Expected duplicate and delete menu items');+ }++ expect(duplicateItem.disabled).toBe(true);+ expect(deleteItem.label).toBe('Delete all');+});+test('read-only sequence menus only contain non-mutating actions', () => {installTestWindow();@@ -179,6 +213,7 @@ test('read-only sequence menus only contain non-mutating actions', () => {editorInfo: null,fileLocation: 'src/Video.tsx:10:2',includeSourceEditItems: false,+ isProgrammaticallyDuplicated: false,onDeleteSequenceFromSource: noop,onDisableSequenceInteractivity: noop,onDuplicateSequenceFromSource: noop,