Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Add Finder to Open in menu (#10231)

Jonny Burgerce3f63cc4f89
diff --git a/packages/studio/src/components/InspectorOpenInEditor.tsx b/packages/studio/src/components/InspectorOpenInEditor.tsx
index c186d4a4b6..3ec63bc27e 100644
--- a/packages/studio/src/components/InspectorOpenInEditor.tsx
+++ b/packages/studio/src/components/InspectorOpenInEditor.tsx
@@ -22,6 +22,7 @@ import type {RenderInlineAction} from './InlineAction';
import {InlineDropdown} from './InlineDropdown';
import type {ComboboxValue} from './NewComposition/ComboBox';
import {showNotification} from './Notifications/NotificationCenter';
+import {openInFileExplorer} from './RenderQueue/actions';
import {
canUseEditorPicker,
getPreferredEditorId,
@@ -159,6 +160,7 @@ export const InspectorOpenInEditor: React.FC<{
editorInfo,
excludeCodingAgentId: null,
excludeEditorId: preferredEditorId,
+ fileManagerDisabled: !location?.source,
onConfigureApps: () => {
setSelectedModal({
type: 'settings',
@@ -175,6 +177,15 @@ export const InspectorOpenInEditor: React.FC<{
onOpenInEditor: (editorId) => {
openWithEditor(editorId).catch(() => undefined);
},
+ onOpenInFileExplorer: () => {
+ if (!location?.source) {
+ return;
+ }
+
+ openInFileExplorer({directory: location.source}).catch((err) => {
+ showNotification(`Could not open file: ${err.message}`, 2000);
+ });
+ },
});
}, [
codingAgentInfo,
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.ts
index ddb43b1a6d..4bb55701d7 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
@@ -10,6 +10,7 @@ import {formatContextForAgents} from '../../helpers/format-file-location';
import {getOpenInMenuItems} from '../get-open-in-menu-items';
import type {ComboboxValue} from '../NewComposition/ComboBox';
import {showNotification} from '../Notifications/NotificationCenter';
+import {openInFileExplorer} from '../RenderQueue/actions';
import type {TimelineAssetLinkInfo} from './timeline-asset-link';
import {openTimelineAssetLink} from './timeline-asset-link';
@@ -114,9 +115,21 @@ export const getSequenceContextMenuItems = ({
editorInfo,
excludeCodingAgentId: defaultCodingAgent?.id ?? null,
excludeEditorId: defaultEditorId,
+ fileManagerDisabled: !originalLocation?.source,
onConfigureApps,
onOpenInCodingAgent: openInCodingAgentWithContext,
onOpenInEditor: openInEditor,
+ onOpenInFileExplorer: () => {
+ if (!originalLocation?.source) {
+ return;
+ }
+
+ openInFileExplorer({directory: originalLocation.source}).catch(
+ (err) => {
+ showNotification(`Could not open file: ${err.message}`, 2000);
+ },
+ );
+ },
})
: [];
diff --git a/packages/studio/src/components/get-open-in-menu-items.tsx b/packages/studio/src/components/get-open-in-menu-items.tsx
index f6ccdff99e..8efe7c1b0a 100644
--- a/packages/studio/src/components/get-open-in-menu-items.tsx
+++ b/packages/studio/src/components/get-open-in-menu-items.tsx
@@ -5,7 +5,9 @@ import type {
GetDefaultEditorInfoResponse,
} from '@remotion/studio-shared';
import React from 'react';
+import {getFileManagerName} from '../helpers/get-file-manager-name';
import {EditorIcon} from '../icons/editor';
+import {FinderIcon} from '../icons/finder';
import {CodingAgentIcon} from './CodingAgentIcon';
import type {ComboboxValue} from './NewComposition/ComboBox';
@@ -22,22 +24,30 @@ export const getOpenInMenuItems = ({
editorInfo,
excludeCodingAgentId,
excludeEditorId,
+ fileManagerDisabled,
onConfigureApps,
onOpenInCodingAgent,
onOpenInEditor,
+ onOpenInFileExplorer,
}: {
readonly codingAgentInfo: GetDefaultCodingAgentInfoResponse | null;
readonly editorDisabled: boolean;
readonly editorInfo: GetDefaultEditorInfoResponse | null;
readonly excludeCodingAgentId: DefaultCodingAgent | null;
readonly excludeEditorId: EditorPickerId | null;
+ readonly fileManagerDisabled: boolean;
readonly onConfigureApps: () => void;
readonly onOpenInCodingAgent: (
codingAgentId: DefaultCodingAgent,
codingAgentName: string,
) => void;
readonly onOpenInEditor: (editorId: EditorPickerId) => void;
+ readonly onOpenInFileExplorer: () => void;
}): ComboboxValue[] => {
+ const showFinder = window.remotion_fileSystemPlatform === 'darwin';
+ const fileManagerName = getFileManagerName(
+ window.remotion_fileSystemPlatform,
+ );
const editors: ComboboxValue[] = (editorInfo?.installedEditors ?? [])
.filter((editor) => editor.id !== excludeEditorId)
.map((editor) => ({
@@ -94,7 +104,35 @@ export const getOpenInMenuItems = ({
...codingAgents,
]
: []),
- ...(editors.length > 0 || codingAgents.length > 0
+ ...(showFinder
+ ? [
+ ...(editors.length > 0 || codingAgents.length > 0
+ ? [
+ {
+ type: 'divider' as const,
+ id: 'open-in-file-explorer-divider',
+ },
+ ]
+ : []),
+ {
+ disabled: fileManagerDisabled,
+ id: 'open-in-file-explorer',
+ keyHint: null,
+ label: <span style={menuLabel}>{fileManagerName}</span>,
+ leftItem: <FinderIcon />,
+ onClick: () => {
+ if (!fileManagerDisabled) {
+ onOpenInFileExplorer();
+ }
+ },
+ quickSwitcherLabel: null,
+ subMenu: null,
+ type: 'item' as const,
+ value: 'file-explorer',
+ },
+ ]
+ : []),
+ ...(editors.length > 0 || codingAgents.length > 0 || showFinder
? [{type: 'divider' as const, id: 'open-in-settings-divider'}]
: []),
{
diff --git a/packages/studio/src/icons/finder.tsx b/packages/studio/src/icons/finder.tsx
new file mode 100644
index 0000000000..157e46b069
--- /dev/null
+++ b/packages/studio/src/icons/finder.tsx
@@ -0,0 +1,22 @@
+import React from 'react';
+
+const iconStyle: React.CSSProperties = {
+ flexShrink: 0,
+ height: 18,
+ width: 18,
+};
+
+const finderIconDataUrl =
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAIFElEQVRYCe1XXWxcRxU+M3P33l177Wx+ajtbk9SJIyuhUghCQgKnJYAAKaJVoA/QB0BCPJSfPFBVRAiQJURfeOEFeCgvCFSpqQhR1KqhbQhClIcqwpX60qTrFKdJwK7/7fX67v3j++buXd+7rcszqGc1OzNnzpzzzTlnfq7IB/Q/5gH1X/FOXXX2ffr+ezzlDUSJckS3Va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0Ewi2O2t6TlgevoZ+Npw9/nDcQf3NOSwtvchK9mpVuHwwPG2RxceH2lZcu/5L8POFqLJL/zytL7vBHXjf9ow9od1eNn6npMgHAtpFTPNi6bY6nBV/W0sQXy4OHA6n1p1uc2u0Njy1v8FrlUbC2unrrb3+9+q0fPXH2VY7n6V2AONh648JbSRS8bPrryOlSDXu0DFCae9U+znmz2m8b1HysZ23UmwA0tmdLJkZwkvNMQ1bj4zEKw7C11Wq+/fbs7PnfPfWb7z/50x/+PQ8ka3MLvR8Z2TO+f/DQl+qqes+gMS4+Tvmg3pl8hPLEqC+fOwasCDU+6pMw8sOldxbW//yn5+80Go1/YTYT4QP6//DAfwC3xW1pQd6lDwAAAABJRU5ErkJggg==';
+
+export const FinderIcon: React.FC = () => {
+ return (
+ <img
+ alt=""
+ aria-hidden
+ draggable={false}
+ src={finderIconDataUrl}
+ style={iconStyle}
+ />
+ );
+};
diff --git a/packages/studio/src/test/sequence-context-menu-items.test.ts b/packages/studio/src/test/sequence-context-menu-items.test.ts
index dc43fa12cd..68e11a8f51 100644
--- a/packages/studio/src/test/sequence-context-menu-items.test.ts
+++ b/packages/studio/src/test/sequence-context-menu-items.test.ts
@@ -1,5 +1,6 @@
import {afterEach, expect, test} from 'bun:test';
import type {TSequence} from 'remotion';
+import {getOpenInMenuItems} from '../components/get-open-in-menu-items';
import type {ComboboxValue} from '../components/NewComposition/ComboBox';
import {getSequenceContextMenuItems} from '../components/Timeline/get-sequence-context-menu-items';
import {getTimelineMediaStartFrame} from '../components/Timeline/get-timeline-media-start-frame';
@@ -35,11 +36,15 @@ afterEach(() => {
const installTestWindow = () => {
const testWindow: Pick<
Window,
- 'open' | 'remotion_cwd' | 'remotion_editorName'
+ | 'open'
+ | 'remotion_cwd'
+ | 'remotion_editorName'
+ | 'remotion_fileSystemPlatform'
> = {
open: () => null,
remotion_cwd: '/project',
remotion_editorName: null,
+ remotion_fileSystemPlatform: 'darwin',
};
Object.defineProperty(globalThis, 'window', {
@@ -63,6 +68,35 @@ const renameSequenceItem: ComboboxValue = {
const noop = () => undefined;
+test('the file manager entry is only shown on macOS', () => {
+ installTestWindow();
+ const getItems = () =>
+ getOpenInMenuItems({
+ codingAgentInfo: null,
+ editorDisabled: false,
+ editorInfo: null,
+ excludeCodingAgentId: null,
+ excludeEditorId: null,
+ fileManagerDisabled: false,
+ onConfigureApps: noop,
+ onOpenInCodingAgent: noop,
+ onOpenInEditor: noop,
+ onOpenInFileExplorer: noop,
+ });
+
+ expect(getItems().some((item) => item.id === 'open-in-file-explorer')).toBe(
+ true,
+ );
+ window.remotion_fileSystemPlatform = 'win32';
+ expect(getItems().some((item) => item.id === 'open-in-file-explorer')).toBe(
+ false,
+ );
+ window.remotion_fileSystemPlatform = 'linux';
+ expect(getItems().some((item) => item.id === 'open-in-file-explorer')).toBe(
+ false,
+ );
+});
+
const expectNoExtraDividers = (items: ComboboxValue[]) => {
expect(items[0]?.type).not.toBe('divider');
expect(items[items.length - 1]?.type).not.toBe('divider');
@@ -200,9 +234,12 @@ test('sequence context menu shares alternate apps without repeating defaults', (
const submenuIds = openIn.subMenu.items.map((item) => item.id);
expect(submenuIds).toContain('open-in-vscode');
expect(submenuIds).toContain('open-in-coding-agent-claude-code');
+ expect(submenuIds).toContain('open-in-file-explorer');
expect(submenuIds).toContain('change-default-apps');
expect(submenuIds).not.toContain('open-in-cursor');
expect(submenuIds).not.toContain('open-in-coding-agent-cursor');
+ const finderIndex = submenuIds.indexOf('open-in-file-explorer');
+ expect(openIn.subMenu.items[finderIndex - 1]?.type).toBe('divider');
const defaultAgent = items.find(
(item) => item.id === 'open-in-default-coding-agent',