Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Fix exhaustive-deps lint and add lost-node-path e2e

Jonny Burger23bf6cb81f57
diff --git a/packages/example/e2e/constants.mts b/packages/example/e2e/constants.mts
index 4819dc7531..76a663bffb 100644
--- a/packages/example/e2e/constants.mts
+++ b/packages/example/e2e/constants.mts
@@ -18,6 +18,12 @@ export const visualControlsFile = path.join(
'VisualControls',
'index.tsx',
);
+export const lostNodePathE2eFile = path.join(
+ exampleDir,
+ 'src',
+ 'LostNodePathE2e',
+ 'LostNodePathRepro.tsx',
+);
export const newVideoFile = path.join(exampleDir, 'src', 'NewVideo.tsx');
export const remotionBin = path.join(
exampleDir,
@@ -38,6 +44,10 @@ export const ORIGINAL_VISUAL_CONTROLS_FILE = path.join(
os.tmpdir(),
'remotion-e2e-original-visual-controls.tsx',
);
+export const ORIGINAL_LOST_NODE_PATH_E2E_FILE = path.join(
+ os.tmpdir(),
+ 'remotion-e2e-original-lost-node-path-repro.tsx',
+);
export const PID_FILE = path.join(os.tmpdir(), 'remotion-e2e-studio.pid');
export const EXPANDED_SIDEBAR_STATE = path.join(
os.tmpdir(),
diff --git a/packages/example/e2e/global-setup.mts b/packages/example/e2e/global-setup.mts
index 6f0262b29f..7d0d914d4c 100644
--- a/packages/example/e2e/global-setup.mts
+++ b/packages/example/e2e/global-setup.mts
@@ -1,7 +1,9 @@
import fs from 'fs';
import {
ORIGINAL_CONTENT_FILE,
+ ORIGINAL_LOST_NODE_PATH_E2E_FILE,
ORIGINAL_VISUAL_CONTROLS_FILE,
+ lostNodePathE2eFile,
rootFile,
visualControlsFile,
} from './constants.mts';
@@ -12,4 +14,8 @@ export default async function globalSetup(): Promise<void> {
ORIGINAL_VISUAL_CONTROLS_FILE,
fs.readFileSync(visualControlsFile, 'utf-8'),
);
+ fs.writeFileSync(
+ ORIGINAL_LOST_NODE_PATH_E2E_FILE,
+ fs.readFileSync(lostNodePathE2eFile, 'utf-8'),
+ );
}
diff --git a/packages/example/e2e/global-teardown.mts b/packages/example/e2e/global-teardown.mts
index 57cd4390ee..b5ee3a492a 100644
--- a/packages/example/e2e/global-teardown.mts
+++ b/packages/example/e2e/global-teardown.mts
@@ -1,7 +1,9 @@
import fs from 'fs';
import {
ORIGINAL_CONTENT_FILE,
+ ORIGINAL_LOST_NODE_PATH_E2E_FILE,
ORIGINAL_VISUAL_CONTROLS_FILE,
+ lostNodePathE2eFile,
rootFile,
visualControlsFile,
} from './constants.mts';
@@ -19,4 +21,12 @@ export default async function globalTeardown(): Promise<void> {
);
fs.unlinkSync(ORIGINAL_VISUAL_CONTROLS_FILE);
}
+
+ if (fs.existsSync(ORIGINAL_LOST_NODE_PATH_E2E_FILE)) {
+ fs.writeFileSync(
+ lostNodePathE2eFile,
+ fs.readFileSync(ORIGINAL_LOST_NODE_PATH_E2E_FILE, 'utf-8'),
+ );
+ fs.unlinkSync(ORIGINAL_LOST_NODE_PATH_E2E_FILE);
+ }
}
diff --git a/packages/example/e2e/helpers.mts b/packages/example/e2e/helpers.mts
index edf953d0cf..a6c8c614c2 100644
--- a/packages/example/e2e/helpers.mts
+++ b/packages/example/e2e/helpers.mts
@@ -22,6 +22,16 @@ export async function navigateToVisualControls(page: Page): Promise<void> {
await expect(page).toHaveURL(/visual-controls/, {timeout: 10_000});
}
+export async function navigateToLostNodePathE2e(page: Page): Promise<void> {
+ await page.goto(`${STUDIO_URL}/lost-node-path-e2e`);
+ await expect(page).toHaveURL(/lost-node-path-e2e/, {timeout: 15_000});
+
+ await page.waitForFunction(
+ () => !document.body.innerText.includes('Loading...'),
+ {timeout: 30_000},
+ );
+}
+
export async function openVisualControlsPanel(page: Page): Promise<void> {
await navigateToVisualControls(page);
const controlsTab = page.getByText('Controls', {exact: true});
diff --git a/packages/example/e2e/lost-node-path.test.mts b/packages/example/e2e/lost-node-path.test.mts
new file mode 100644
index 0000000000..34405c6c82
--- /dev/null
+++ b/packages/example/e2e/lost-node-path.test.mts
@@ -0,0 +1,126 @@
+import fs from 'fs';
+import {expect, test} from '@playwright/test';
+import {EXPANDED_SIDEBAR_STATE, lostNodePathE2eFile} from './constants.mts';
+import {navigateToLostNodePathE2e, readStudioLogs, stripAnsi} from './helpers.mts';
+import {startStudio, stopStudio} from './studio-server.mts';
+
+const getSequenceLine = (content: string): number => {
+ const lineIndex = content
+ .split('\n')
+ .findIndex((line) => line.trim().startsWith('<Sequence'));
+ expect(lineIndex).toBeGreaterThan(-1);
+ return lineIndex + 1;
+};
+
+const applyIssue7393Refactor = (content: string): string => {
+ if (content.includes('const t = tint')) {
+ return content;
+ }
+
+ return content
+ .replace(
+ '\tconst experimentalEffects = Internals.useMemoizedEffectDefinitions([',
+ "\tconst t = tint({color: 'green', amount: 1});\n\tconst experimentalEffects = Internals.useMemoizedEffectDefinitions([",
+ )
+ .replace("\t\ttint({color: 'green', amount: 1}),", '\t\tt,');
+};
+
+const stackAttribution = (line: number) => `LostNodePathRepro.tsx:${line}`;
+
+test.use({storageState: EXPANDED_SIDEBAR_STATE});
+
+test.describe('lost node path recovery', () => {
+ test.beforeEach(async () => {
+ await startStudio();
+ });
+
+ test.afterEach(async () => {
+ await stopStudio();
+ });
+
+ test('recovers stack location and preserves expanded timeline state after refactor', async ({
+ page,
+ }) => {
+ const originalContent = fs.readFileSync(lostNodePathE2eFile, 'utf-8');
+ const initialLine = getSequenceLine(originalContent);
+ const refactoredContent = applyIssue7393Refactor(originalContent);
+ const refactoredLine = getSequenceLine(refactoredContent);
+ expect(refactoredLine).toBeGreaterThan(initialLine);
+
+ await navigateToLostNodePathE2e(page);
+
+ await expect(
+ page.getByText(stackAttribution(initialLine), {exact: true}),
+ ).toBeVisible({timeout: 30_000});
+
+ const expandTrack = page.getByRole('button', {
+ name: 'Expand track properties',
+ });
+ await expect(expandTrack).toBeVisible({timeout: 10_000});
+ await expandTrack.click();
+
+ const expandEffects = page.getByRole('button', {
+ name: 'Expand Effects section',
+ });
+ await expect(expandEffects).toBeVisible({timeout: 10_000});
+ await expandEffects.click();
+
+ const expandTint = page.getByRole('button', {
+ name: 'Expand Tint section',
+ });
+ await expect(expandTint).toBeVisible({timeout: 10_000});
+ await expandTint.click();
+
+ await expect(
+ page.getByRole('button', {name: 'Collapse track properties'}),
+ ).toBeVisible();
+ await expect(
+ page.getByRole('button', {name: 'Collapse Effects section'}),
+ ).toBeVisible();
+ await expect(
+ page.getByRole('button', {name: 'Collapse Tint section'}),
+ ).toBeVisible();
+
+ const logCountBefore = readStudioLogs().length;
+ fs.writeFileSync(lostNodePathE2eFile, refactoredContent);
+
+ await expect
+ .poll(
+ () => {
+ const newLogs = readStudioLogs().slice(logCountBefore).map(stripAnsi);
+ return newLogs.some((log) => log.includes('Built in'));
+ },
+ {
+ message:
+ 'Expected webpack to rebuild after LostNodePathRepro.tsx refactor',
+ timeout: 30_000,
+ },
+ )
+ .toBe(true);
+
+ await expect
+ .poll(
+ async () =>
+ page.getByText(stackAttribution(refactoredLine), {exact: true}).isVisible(),
+ {
+ message: `Expected timeline stack to update to ${stackAttribution(refactoredLine)}`,
+ timeout: 30_000,
+ },
+ )
+ .toBe(true);
+
+ await expect(
+ page.getByText(stackAttribution(initialLine), {exact: true}),
+ ).toHaveCount(0);
+
+ await expect(
+ page.getByRole('button', {name: 'Collapse track properties'}),
+ ).toBeVisible();
+ await expect(
+ page.getByRole('button', {name: 'Collapse Effects section'}),
+ ).toBeVisible();
+ await expect(
+ page.getByRole('button', {name: 'Collapse Tint section'}),
+ ).toBeVisible();
+ });
+});
diff --git a/packages/example/e2e/studio-server.mts b/packages/example/e2e/studio-server.mts
index f65d1750bc..751f2b5d68 100644
--- a/packages/example/e2e/studio-server.mts
+++ b/packages/example/e2e/studio-server.mts
@@ -5,11 +5,13 @@ import {
EXPANDED_SIDEBAR_STATE,
LOGS_FILE,
ORIGINAL_CONTENT_FILE,
+ ORIGINAL_LOST_NODE_PATH_E2E_FILE,
ORIGINAL_VISUAL_CONTROLS_FILE,
STUDIO_PORT,
STUDIO_URL,
e2eEntryPoint,
exampleDir,
+ lostNodePathE2eFile,
remotionBin,
rootFile,
visualControlsFile,
@@ -51,12 +53,23 @@ export async function startStudio(): Promise<void> {
);
}
+ if (!fs.existsSync(ORIGINAL_LOST_NODE_PATH_E2E_FILE)) {
+ fs.writeFileSync(
+ ORIGINAL_LOST_NODE_PATH_E2E_FILE,
+ fs.readFileSync(lostNodePathE2eFile, 'utf-8'),
+ );
+ }
+
// Restore original files before starting
fs.writeFileSync(rootFile, fs.readFileSync(ORIGINAL_CONTENT_FILE, 'utf-8'));
fs.writeFileSync(
visualControlsFile,
fs.readFileSync(ORIGINAL_VISUAL_CONTROLS_FILE, 'utf-8'),
);
+ fs.writeFileSync(
+ lostNodePathE2eFile,
+ fs.readFileSync(ORIGINAL_LOST_NODE_PATH_E2E_FILE, 'utf-8'),
+ );
fs.writeFileSync(LOGS_FILE, '');
fs.writeFileSync(
@@ -181,4 +194,11 @@ export async function stopStudio(): Promise<void> {
fs.readFileSync(ORIGINAL_VISUAL_CONTROLS_FILE, 'utf-8'),
);
}
+
+ if (fs.existsSync(ORIGINAL_LOST_NODE_PATH_E2E_FILE)) {
+ fs.writeFileSync(
+ lostNodePathE2eFile,
+ fs.readFileSync(ORIGINAL_LOST_NODE_PATH_E2E_FILE, 'utf-8'),
+ );
+ }
}
diff --git a/packages/example/src/E2eTestRoot.tsx b/packages/example/src/E2eTestRoot.tsx
index acff96343e..bfcf9654ae 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 {LostNodePathRepro} from './LostNodePathE2e/LostNodePathRepro';
import {NewVideoComp} from './NewVideo';
import {SchemaTest, schemaTestSchema} from './SchemaTest';
import {VisualControls} from './VisualControls';
@@ -44,6 +45,16 @@ export const E2eTestRoot: React.FC = () => {
durationInFrames={900}
/>
</Folder>
+ <Folder name="lost-node-path">
+ <Composition
+ id="lost-node-path-e2e"
+ component={LostNodePathRepro}
+ width={1920}
+ height={1080}
+ fps={30}
+ durationInFrames={90}
+ />
+ </Folder>
<NewVideoComp />
</>
);
diff --git a/packages/example/src/LostNodePathE2e/LostNodePathRepro.tsx b/packages/example/src/LostNodePathE2e/LostNodePathRepro.tsx
new file mode 100644
index 0000000000..0309385a28
--- /dev/null
+++ b/packages/example/src/LostNodePathE2e/LostNodePathRepro.tsx
@@ -0,0 +1,28 @@
+import {halftone} from '@remotion/effects/halftone';
+import {tint} from '@remotion/effects/tint';
+import React from 'react';
+import {AbsoluteFill, Internals, Sequence, useVideoConfig} from 'remotion';
+import {SimpleSvg} from './SimpleSvg';
+
+export const LostNodePathRepro: React.FC = () => {
+ const {durationInFrames} = useVideoConfig();
+ const experimentalEffects = Internals.useMemoizedEffectDefinitions([
+ halftone({
+ dotSize: 30,
+ dotSpacing: 20,
+ shape: 'square',
+ }),
+ tint({color: 'green', amount: 1}),
+ ]);
+
+ return (
+ <AbsoluteFill style={{backgroundColor: 'white'}}>
+ <Sequence
+ durationInFrames={durationInFrames}
+ _experimentalEffects={experimentalEffects}
+ >
+ <SimpleSvg />
+ </Sequence>
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/example/src/LostNodePathE2e/SimpleSvg.tsx b/packages/example/src/LostNodePathE2e/SimpleSvg.tsx
new file mode 100644
index 0000000000..083e9b7dc7
--- /dev/null
+++ b/packages/example/src/LostNodePathE2e/SimpleSvg.tsx
@@ -0,0 +1,9 @@
+import React from 'react';
+
+export const SimpleSvg: React.FC = () => {
+ return (
+ <svg width={200} height={200} viewBox="0 0 200 200">
+ <circle cx={100} cy={100} r={80} fill="#61dafb" />
+ </svg>
+ );
+};
diff --git a/packages/studio/src/components/Timeline/use-sequence-props-subscription.ts b/packages/studio/src/components/Timeline/use-sequence-props-subscription.ts
index 4677926c4f..42dcbb60e6 100644
--- a/packages/studio/src/components/Timeline/use-sequence-props-subscription.ts
+++ b/packages/studio/src/components/Timeline/use-sequence-props-subscription.ts
@@ -109,6 +109,10 @@ export const useSequencePropsSubscription = ({
return () => {
release();
};
+ // overrideIdToNodePathMappings is read only to snapshot this override's node
+ // path when location changes. Listing the full map would re-subscribe every
+ // sequence whenever any other sequence's node path updates.
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- see above
}, [
clientId,
effects,