Skip to content

🎥 Make videos programmatically with React

Open sequence source on GitHub in read-only Studio

JonnyBurger0ccce5f78bf7
diff --git a/packages/studio/src/components/InspectorOpenInEditor.tsx b/packages/studio/src/components/InspectorOpenInEditor.tsx
index 0f5fd6f8ec..e4d9188c1d 100644
--- a/packages/studio/src/components/InspectorOpenInEditor.tsx
+++ b/packages/studio/src/components/InspectorOpenInEditor.tsx
@@ -6,7 +6,7 @@ import {getBrowserStudioOperations} from '../helpers/browser-studio-operations';
import {StudioServerConnectionCtx} from '../helpers/client-id';
import {LIGHT_TEXT} from '../helpers/colors';
import {
- hasReadOnlyGitSource,
+ getDefaultOpenInTarget,
openGitSource,
} from '../helpers/get-git-menu-item';
import {
@@ -59,8 +59,7 @@ export const InspectorOpenInEditor: React.FC<{
editorInfo,
} = useEditorOpening(previewServerState.type === 'connected');
const codingAgentInfo = useDefaultCodingAgentInfo(canConfigureApps);
- const canOpenInGitHub = hasReadOnlyGitSource();
- const defaultActionIsGitHub = !canOpenInEditor && canOpenInGitHub;
+ const defaultOpenInTarget = getDefaultOpenInTarget({canOpenInEditor});
const openWithEditor = useCallback(
async (editorId: EditorPickerId) => {
@@ -93,23 +92,23 @@ export const InspectorOpenInEditor: React.FC<{
},
[contextForAgents],
);
- const defaultAppName = defaultActionIsGitHub
- ? 'GitHub'
- : (defaultEditorName ?? 'default editor');
- const canOpenDefault =
- location !== null && (canOpenInEditor || canOpenInGitHub);
+ const defaultAppName =
+ defaultOpenInTarget === 'git-source'
+ ? 'GitHub'
+ : (defaultEditorName ?? 'default editor');
+ const canOpenDefault = location !== null && defaultOpenInTarget !== null;
const onOpenDefault: React.MouseEventHandler<HTMLButtonElement> = useCallback(
(event) => {
event.stopPropagation();
- if (defaultActionIsGitHub) {
+ if (defaultOpenInTarget === 'git-source') {
openGitSource({folder: locationType === 'folder', location});
- } else if (defaultEditorId) {
+ } else if (defaultOpenInTarget === 'editor' && defaultEditorId) {
openWithEditor(defaultEditorId).catch(() => undefined);
}
},
[
- defaultActionIsGitHub,
defaultEditorId,
+ defaultOpenInTarget,
location,
locationType,
openWithEditor,
@@ -178,15 +177,15 @@ export const InspectorOpenInEditor: React.FC<{
},
});
- return defaultActionIsGitHub
+ return defaultOpenInTarget === 'git-source'
? items.filter((item) => item.id !== 'open-in-github')
: items;
}, [
codingAgentInfo,
canOpenInEditor,
configureDefaultApps,
- defaultActionIsGitHub,
defaultEditorId,
+ defaultOpenInTarget,
editorInfo,
location,
locationType,
@@ -206,7 +205,7 @@ export const InspectorOpenInEditor: React.FC<{
renderContent: () => (
<>
{label}
- {defaultActionIsGitHub ? (
+ {defaultOpenInTarget === 'git-source' ? (
<GitHubIcon size={editorButtonIconSize} />
) : (
<EditorIcon
@@ -244,9 +243,9 @@ export const InspectorOpenInEditor: React.FC<{
return result;
}, [
canOpenDefault,
- defaultActionIsGitHub,
defaultAppName,
defaultEditorId,
+ defaultOpenInTarget,
label,
menuItems,
onOpenDefault,
@@ -256,7 +255,7 @@ export const InspectorOpenInEditor: React.FC<{
return null;
}
- if (previewServerState.type !== 'connected' && !canOpenInGitHub) {
+ if (previewServerState.type !== 'connected' && defaultOpenInTarget === null) {
return null;
}
diff --git a/packages/studio/src/components/InspectorPanel/CompositionInspectorHeader.tsx b/packages/studio/src/components/InspectorPanel/CompositionInspectorHeader.tsx
index 68544c02c9..313528af81 100644
--- a/packages/studio/src/components/InspectorPanel/CompositionInspectorHeader.tsx
+++ b/packages/studio/src/components/InspectorPanel/CompositionInspectorHeader.tsx
@@ -9,7 +9,7 @@ import {Internals} from 'remotion';
import type {OriginalPosition} from '../../error-overlay/react-overlay/utils/get-source-map';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {
- hasReadOnlyGitSource,
+ getDefaultOpenInTarget,
openGitSource,
} from '../../helpers/get-git-menu-item';
import {isCompositionStill} from '../../helpers/is-composition-still';
@@ -54,7 +54,7 @@ export const CompositionInspectorHeader = () => {
const {canOpenInEditor, defaultEditorId} = useEditorOpening(
previewServerState.type === 'connected',
);
- const canOpenInGitHub = hasReadOnlyGitSource();
+ const defaultOpenInTarget = getDefaultOpenInTarget({canOpenInEditor});
const currentComposition = useMemo(() => {
if (!video) {
@@ -104,18 +104,18 @@ export const CompositionInspectorHeader = () => {
const openSourceLocation = useCallback(
(location: OriginalPosition) => {
- if (canOpenInEditor && defaultEditorId) {
+ if (defaultOpenInTarget === 'editor' && defaultEditorId) {
openOriginalPositionInEditor(location, defaultEditorId).catch((err) => {
showNotification((err as Error).message, 2000);
});
return;
}
- if (canOpenInGitHub) {
+ if (defaultOpenInTarget === 'git-source') {
openGitSource({folder: false, location});
}
},
- [canOpenInEditor, canOpenInGitHub, defaultEditorId],
+ [defaultEditorId, defaultOpenInTarget],
);
const openFileLocation = useCallback(() => {
if (validatedLocation) {
@@ -161,9 +161,7 @@ export const CompositionInspectorHeader = () => {
/>
<InspectorSourceLocation
location={validatedLocation}
- canOpen={
- validatedLocation !== null && (canOpenInEditor || canOpenInGitHub)
- }
+ canOpen={validatedLocation !== null && defaultOpenInTarget !== null}
onOpen={openFileLocation}
renderIcon={renderCompositionIcon}
size="quick-action"
@@ -176,8 +174,7 @@ export const CompositionInspectorHeader = () => {
<InspectorSourceLocation
location={componentLocation}
canOpen={
- componentLocation !== null &&
- (canOpenInEditor || canOpenInGitHub)
+ componentLocation !== null && defaultOpenInTarget !== null
}
onOpen={openComponentLocation}
renderIcon={renderReactIcon}
diff --git a/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx b/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx
index 614cbabc9a..ddfda15da7 100644
--- a/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx
+++ b/packages/studio/src/components/InspectorPanel/SequenceInspectorHeader.tsx
@@ -2,10 +2,6 @@ import React, {useCallback, useContext, useMemo} from 'react';
import type {CodePosition} from '../../error-overlay/react-overlay/utils/get-source-map';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {CURRENT_COLOR} from '../../helpers/colors';
-import {
- hasReadOnlyGitSource,
- openGitSource,
-} from '../../helpers/get-git-menu-item';
import type {TimelineTrackData} from '../../helpers/get-timeline-sequence-sort-key';
import {ReactIcon} from '../../icons/react';
import {InlineEditableTitle} from '../InlineEditableTitle';
@@ -66,9 +62,8 @@ type SequenceInspectorSourceLocation = {
export const useSequenceInspectorSourceLocation = (
sequence: TimelineTrackData['sequence'],
): SequenceInspectorSourceLocation => {
- const {canOpenInEditor, openInEditor, originalLocation} =
+ const {canOpenSource, openSource, originalLocation} =
useOpenSequenceInApps(sequence);
- const canOpenInGitHub = hasReadOnlyGitSource();
const validatedLocation = useMemo(() => {
if (
@@ -87,18 +82,11 @@ export const useSequenceInspectorSourceLocation = (
}, [originalLocation]);
const openFileLocation = useCallback(() => {
- if (canOpenInEditor) {
- openInEditor(null);
- return;
- }
-
- if (canOpenInGitHub && validatedLocation) {
- openGitSource({folder: false, location: validatedLocation});
- }
- }, [canOpenInEditor, canOpenInGitHub, openInEditor, validatedLocation]);
+ openSource();
+ }, [openSource]);
return {
- canOpen: validatedLocation !== null && (canOpenInEditor || canOpenInGitHub),
+ canOpen: validatedLocation !== null && canOpenSource,
openFileLocation,
validatedLocation,
};
diff --git a/packages/studio/src/components/SelectedOutlineElement.tsx b/packages/studio/src/components/SelectedOutlineElement.tsx
index 91f2338cac..c44330d281 100644
--- a/packages/studio/src/components/SelectedOutlineElement.tsx
+++ b/packages/studio/src/components/SelectedOutlineElement.tsx
@@ -3,6 +3,10 @@ import type {ResolvedStackLocation} from 'remotion';
import {Internals} from 'remotion';
import {StudioServerConnectionCtx} from '../helpers/client-id';
import {getConnectedCompositions} from '../helpers/get-connected-compositions';
+import {
+ getDefaultOpenInTarget,
+ openGitSource,
+} from '../helpers/get-git-menu-item';
import {getSequenceDoubleClickAction} from '../helpers/get-sequence-double-click-action';
import {isStudioInteractivityEnabled} from '../helpers/interactivity-enabled';
import {
@@ -94,6 +98,9 @@ const SelectedOutlineElementUnmemoized: React.FC<
editorInfo,
} = useEditorOpening(previewServerState.type === 'connected');
const codingAgentInfo = useDefaultCodingAgentInfo(canConfigureApps);
+ const defaultOpenInTarget = getDefaultOpenInTarget({
+ canOpenInEditor: editorAvailable,
+ });
const {setPropStatuses} = useContext(Internals.VisualModeSettersContext);
const updateResolvedStackTrace = useContext(
Internals.SequenceStackTracesUpdateContext,
@@ -146,7 +153,7 @@ const SelectedOutlineElementUnmemoized: React.FC<
});
const action = getSequenceDoubleClickAction({
button,
- canOpenInEditor: editorAvailable,
+ canOpenSource: defaultOpenInTarget !== null,
numberOfConnectedCompositions: connectedCompositions.length,
sequenceWasDragged,
});
@@ -160,17 +167,24 @@ const SelectedOutlineElementUnmemoized: React.FC<
return true;
}
- const openTargetInEditor = async () => {
+ const openTargetSource = async () => {
const originalLocation =
await resolveOriginalLocation(doubleClickTarget);
- if (originalLocation === null || defaultEditorId === null) {
+ if (originalLocation === null) {
+ return;
+ }
+
+ if (defaultOpenInTarget === 'editor' && defaultEditorId !== null) {
+ await openOriginalPositionInEditor(originalLocation, defaultEditorId);
return;
}
- await openOriginalPositionInEditor(originalLocation, defaultEditorId);
+ if (defaultOpenInTarget === 'git-source') {
+ openGitSource({folder: false, location: originalLocation});
+ }
};
- openTargetInEditor().catch((err) => {
+ openTargetSource().catch((err) => {
showNotification((err as Error).message, 2000);
});
@@ -179,7 +193,7 @@ const SelectedOutlineElementUnmemoized: React.FC<
[
compositions,
defaultEditorId,
- editorAvailable,
+ defaultOpenInTarget,
resolveOriginalLocation,
selectComposition,
],
diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsx
index c31ca0389e..2f31599f90 100644
--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx
@@ -474,12 +474,14 @@ const TimelineSequenceInner: React.FC<{
const effectiveMaxMediaDuration = s.loopDisplay ? null : maxMediaDuration;
const {
- canOpenInEditor,
canConfigureApps,
+ canOpenInEditor,
+ canOpenSource,
codingAgentInfo,
editorInfo,
openInCodingAgent,
openInEditor,
+ openSource,
originalLocation,
} = useOpenSequenceInApps(s);
const validatedLocation = useMemo(() => {
@@ -558,7 +560,7 @@ const TimelineSequenceInner: React.FC<{
const action = getSequenceDoubleClickAction({
button: e.button,
- canOpenInEditor,
+ canOpenSource,
numberOfConnectedCompositions: connectedCompositions.length,
sequenceWasDragged:
dragAwareDoubleClick.consumePointerGestureWasDragged(),
@@ -582,13 +584,13 @@ const TimelineSequenceInner: React.FC<{
return;
}
- openInEditor(null);
+ openSource();
},
[
- canOpenInEditor,
+ canOpenSource,
connectedCompositions,
dragAwareDoubleClick,
- openInEditor,
+ openSource,
s,
selectComposition,
sequenceFrameOffset,
@@ -605,7 +607,7 @@ const TimelineSequenceInner: React.FC<{
[dragAwareDoubleClick, performSequenceDoubleClick],
);
const canHandleSequenceDoubleClick =
- connectedCompositions.length === 1 || canOpenInEditor;
+ connectedCompositions.length === 1 || canOpenSource;
const canDeleteFromSource = Boolean(nodePath && validatedLocation?.source);
const deleteDisabled =
!previewInteractive || !s.controls || !canDeleteFromSource;
diff --git a/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx b/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
index 126a0bd42c..38526c9865 100644
--- a/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
@@ -345,12 +345,14 @@ const TimelineSequenceItemInner: React.FC<{
const stopSequencePointerSession = useRef<(() => void) | null>(null);
const suppressNextClick = useRef(false);
const {
- canOpenInEditor,
canConfigureApps,
+ canOpenInEditor,
+ canOpenSource,
codingAgentInfo,
editorInfo,
openInCodingAgent,
openInEditor,
+ openSource,
originalLocation,
} = useOpenSequenceInApps(sequence);
@@ -929,7 +931,7 @@ const TimelineSequenceItemInner: React.FC<{
const action = getSequenceDoubleClickAction({
button: e.button,
- canOpenInEditor,
+ canOpenSource,
numberOfConnectedCompositions: connectedCompositions.length,
// The track list row reorders via native drag-and-drop, which
// already suppresses `dblclick` after a drag.
@@ -954,19 +956,19 @@ const TimelineSequenceItemInner: React.FC<{
return;
}
- openInEditor(null);
+ openSource();
},
[
- canOpenInEditor,
+ canOpenSource,
connectedCompositions,
- openInEditor,
+ openSource,
selectComposition,
sequence,
sequenceFrameOffset,
],
);
const canHandleSequenceDoubleClick =
- connectedCompositions.length === 1 || canOpenInEditor;
+ connectedCompositions.length === 1 || canOpenSource;
const canRenameSelectedSequence =
canRenameThisSequence &&
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 b2dd49095d..f3bd1ed0fd 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
@@ -7,6 +7,11 @@ import type {
import type {ResolvedStackLocation, TSequence} from 'remotion';
import {NoReactInternals} from 'remotion/no-react';
import {formatContextForAgents} from '../../helpers/format-file-location';
+import {
+ getDefaultOpenInTarget,
+ getGitSourceName,
+ openGitSource,
+} from '../../helpers/get-git-menu-item';
import {getOpenInMenuItems} from '../get-open-in-menu-items';
import type {ComboboxValue} from '../NewComposition/ComboBox';
import {showNotification} from '../Notifications/NotificationCenter';
@@ -135,6 +140,12 @@ export const getSequenceContextMenuItems = ({
(editor) => editor.id === defaultEditorId,
);
const editorName = defaultEditor?.nameWithType ?? null;
+ const defaultOpenInTarget = getDefaultOpenInTarget({canOpenInEditor});
+ const gitSourceName = window.remotion_gitSource
+ ? getGitSourceName(window.remotion_gitSource)
+ : null;
+ const defaultOpenInName =
+ defaultOpenInTarget === 'editor' ? editorName : gitSourceName;
const defaultCodingAgent = codingAgentInfo?.installedCodingAgents.find(
(codingAgent) => codingAgent.id === codingAgentInfo.defaultCodingAgent,
);
@@ -184,18 +195,31 @@ export const getSequenceContextMenuItems = ({
: [];
const items = [
- editorName
+ defaultOpenInTarget && defaultOpenInName
? {
type: 'item' as const,
- id: 'open-in-editor',
+ id:
+ defaultOpenInTarget === 'editor'
+ ? 'open-in-editor'
+ : 'open-in-git-source',
keyHint: null,
- label: `Open in ${editorName}`,
+ label: `Open in ${defaultOpenInName}`,
leftItem: null,
- disabled: !canOpenInEditor || !originalLocation,
- onClick: () => openInEditor(null),
+ disabled: !originalLocation,
+ onClick: () => {
+ if (defaultOpenInTarget === 'editor') {
+ openInEditor(null);
+ return;
+ }
+
+ openGitSource({folder: false, location: originalLocation});
+ },
quickSwitcherLabel: null,
subMenu: null,
- value: 'open-in-editor',
+ value:
+ defaultOpenInTarget === 'editor'
+ ? 'open-in-editor'
+ : 'open-in-git-source',
}
: null,
defaultCodingAgent
diff --git a/packages/studio/src/components/Timeline/use-open-sequence-in-apps.ts b/packages/studio/src/components/Timeline/use-open-sequence-in-apps.ts
index 494bd8d1dc..1259ddedf0 100644
--- a/packages/studio/src/components/Timeline/use-open-sequence-in-apps.ts
+++ b/packages/studio/src/components/Timeline/use-open-sequence-in-apps.ts
@@ -3,6 +3,10 @@ import type {EditorPickerId} from '@remotion/studio-shared';
import {useCallback, useContext, useMemo} from 'react';
import type {TSequence} from 'remotion';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
+import {
+ getDefaultOpenInTarget,
+ openGitSource,
+} from '../../helpers/get-git-menu-item';
import {
openInCodingAgent as launchCodingAgent,
openOriginalPositionInEditor,
@@ -32,6 +36,9 @@ export const useOpenSequenceInApps = (sequence: TSequence) => {
() => Boolean(editorAvailable && originalLocation),
[editorAvailable, originalLocation],
);
+ const defaultOpenInTarget = getDefaultOpenInTarget({canOpenInEditor});
+ const canOpenSource =
+ defaultOpenInTarget !== null && originalLocation !== null;
const openInEditor = useCallback(
async (editorId: EditorPickerId | null) => {
@@ -48,6 +55,20 @@ export const useOpenSequenceInApps = (sequence: TSequence) => {
},
[canOpenInEditor, defaultEditorId, originalLocation],
);
+ const openSource = useCallback(() => {
+ if (!originalLocation) {
+ return;
+ }
+
+ if (defaultOpenInTarget === 'editor') {
+ openInEditor(null);
+ return;
+ }
+
+ if (defaultOpenInTarget === 'git-source') {
+ openGitSource({folder: false, location: originalLocation});
+ }
+ }, [defaultOpenInTarget, openInEditor, originalLocation]);
const openInCodingAgent = useCallback(
async (
codingAgentId: DefaultCodingAgent,
@@ -70,12 +91,14 @@ export const useOpenSequenceInApps = (sequence: TSequence) => {
);
return {
+ canOpenSource,
canOpenInEditor,
canConfigureApps,
codingAgentInfo,
editorInfo,
openInCodingAgent,
openInEditor,
+ openSource,
originalLocation,
};
};
diff --git a/packages/studio/src/helpers/get-git-menu-item.ts b/packages/studio/src/helpers/get-git-menu-item.ts
index d13a6bdcf6..dfeb2b2846 100644
--- a/packages/studio/src/helpers/get-git-menu-item.ts
+++ b/packages/studio/src/helpers/get-git-menu-item.ts
@@ -76,6 +76,20 @@ export const hasReadOnlyGitSource = () => {
return Boolean(window.remotion_isReadOnlyStudio && window.remotion_gitSource);
};
+export type DefaultOpenInTarget = 'editor' | 'git-source';
+
+export const getDefaultOpenInTarget = ({
+ canOpenInEditor,
+}: {
+ readonly canOpenInEditor: boolean;
+}): DefaultOpenInTarget | null => {
+ if (canOpenInEditor) {
+ return 'editor';
+ }
+
+ return hasReadOnlyGitSource() ? 'git-source' : null;
+};
+
export const openGitSource = ({
folder,
location,
diff --git a/packages/studio/src/helpers/get-sequence-double-click-action.ts b/packages/studio/src/helpers/get-sequence-double-click-action.ts
index dc1e2e3ad7..5f9f48e48c 100644
--- a/packages/studio/src/helpers/get-sequence-double-click-action.ts
+++ b/packages/studio/src/helpers/get-sequence-double-click-action.ts
@@ -2,16 +2,16 @@ import type {TSequence} from 'remotion';
export type SequenceDoubleClickAction =
| 'open-connected-composition'
- | 'open-in-editor';
+ | 'open-source';
export const getSequenceDoubleClickAction = ({
button,
- canOpenInEditor,
+ canOpenSource,
numberOfConnectedCompositions,
sequenceWasDragged,
}: {
readonly button: number;
- readonly canOpenInEditor: boolean;
+ readonly canOpenSource: boolean;
readonly numberOfConnectedCompositions: number;
readonly sequenceWasDragged: boolean;
}): SequenceDoubleClickAction | null => {
@@ -30,7 +30,7 @@ export const getSequenceDoubleClickAction = ({
return 'open-connected-composition';
}
- return canOpenInEditor ? 'open-in-editor' : null;
+ return canOpenSource ? 'open-source' : null;
};
export const getConnectedCompositionFrame = ({
diff --git a/packages/studio/src/test/git-source-open.test.ts b/packages/studio/src/test/git-source-open.test.ts
index 665f046332..aa8e99ea3e 100644
--- a/packages/studio/src/test/git-source-open.test.ts
+++ b/packages/studio/src/test/git-source-open.test.ts
@@ -1,6 +1,7 @@
import {afterEach, expect, test} from 'bun:test';
import type {GitSource} from '@remotion/studio-shared';
import {
+ getDefaultOpenInTarget,
hasReadOnlyGitSource,
openGitSource,
} from '../helpers/get-git-menu-item';
@@ -59,6 +60,8 @@ test('uses GitHub as an open target in a read-only Studio', () => {
const openedUrls = installTestWindow({git: gitSource, readOnly: true});
expect(hasReadOnlyGitSource()).toBe(true);
+ expect(getDefaultOpenInTarget({canOpenInEditor: false})).toBe('git-source');
+ expect(getDefaultOpenInTarget({canOpenInEditor: true})).toBe('editor');
openGitSource({
folder: false,
location: {
@@ -86,4 +89,5 @@ test('opens the project folder on the configured GitHub ref', () => {
test('does not use GitHub as the fallback in an editable Studio', () => {
installTestWindow({git: gitSource, readOnly: false});
expect(hasReadOnlyGitSource()).toBe(false);
+ expect(getDefaultOpenInTarget({canOpenInEditor: false})).toBeNull();
});
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 a94fdc3a1f..bb72ab0469 100644
--- a/packages/studio/src/test/sequence-context-menu-items.test.ts
+++ b/packages/studio/src/test/sequence-context-menu-items.test.ts
@@ -1,4 +1,5 @@
import {afterEach, expect, test} from 'bun:test';
+import type {GitSource} from '@remotion/studio-shared';
import type {TSequence} from 'remotion';
import {getOpenInMenuItems} from '../components/get-open-in-menu-items';
import type {ComboboxValue} from '../components/NewComposition/ComboBox';
@@ -41,11 +42,15 @@ const installTestWindow = () => {
| 'remotion_cwd'
| 'remotion_editorName'
| 'remotion_fileSystemPlatform'
+ | 'remotion_gitSource'
+ | 'remotion_isReadOnlyStudio'
> = {
open: () => null,
remotion_cwd: '/project',
remotion_editorName: null,
remotion_fileSystemPlatform: 'darwin',
+ remotion_gitSource: null,
+ remotion_isReadOnlyStudio: false,
};
Object.defineProperty(globalThis, 'window', {
@@ -432,6 +437,60 @@ test('read-only sequence menus only contain non-mutating actions', () => {
]);
});
+test('read-only sequence menus open source locations on GitHub', () => {
+ installTestWindow();
+ const gitSource: GitSource = {
+ name: 'project',
+ org: 'example',
+ ref: 'main',
+ relativeFromGitRoot: '',
+ type: 'github',
+ };
+ window.remotion_gitSource = gitSource;
+ window.remotion_isReadOnlyStudio = true;
+ const openedUrls: string[] = [];
+ window.open = (url) => {
+ openedUrls.push(String(url));
+ return null;
+ };
+
+ const items = getSequenceContextMenuItems({
+ assetLinkInfo: null,
+ canOpenInEditor: false,
+ codingAgentInfo: null,
+ deleteDisabled: true,
+ disableInteractivityDisabled: true,
+ duplicateDisabled: true,
+ editorInfo: null,
+ includeSourceEditItems: false,
+ isProgrammaticallyDuplicated: false,
+ onConfigureApps: null,
+ onDeleteSequenceFromSource: noop,
+ onDisableSequenceInteractivity: noop,
+ onDuplicateSequenceFromSource: noop,
+ openInCodingAgent: noop,
+ openInEditor: noop,
+ originalLocation: {
+ column: 1,
+ line: 12,
+ source: '/project/src/Video.tsx',
+ },
+ selectAsset: noop,
+ sequence: {} as TSequence,
+ });
+
+ const openInGitHub = items.find((item) => item.id === 'open-in-git-source');
+ if (openInGitHub?.type !== 'item') {
+ throw new Error('Expected Open in GitHub menu item');
+ }
+
+ expect(openInGitHub.label).toBe('Open in GitHub');
+ openInGitHub.onClick('open-in-git-source', null);
+ expect(openedUrls).toEqual([
+ 'https://github.com/example/project/blob/main/src/Video.tsx#L12',
+ ]);
+});
+
test('sequence freeze context menu item is hidden for audio', () => {
expect(shouldShowFreezeFrameMenuItem({type: 'audio'} as TSequence)).toBe(
false,
diff --git a/packages/studio/src/test/timeline-selection.test.ts b/packages/studio/src/test/timeline-selection.test.ts
index d2e5206987..66de615117 100644
--- a/packages/studio/src/test/timeline-selection.test.ts
+++ b/packages/studio/src/test/timeline-selection.test.ts
@@ -3543,11 +3543,11 @@ test('Canvas outline selection uses conventional modifier keys', () => {
).toEqual({shiftKey: false, toggleKey: true});
});
-test('Sequence double-click opens one connected composition before the editor', () => {
+test('Sequence double-click opens one connected composition before its source', () => {
expect(
getSequenceDoubleClickAction({
button: 0,
- canOpenInEditor: true,
+ canOpenSource: true,
numberOfConnectedCompositions: 1,
sequenceWasDragged: false,
}),
@@ -3555,7 +3555,7 @@ test('Sequence double-click opens one connected composition before the editor',
expect(
getSequenceDoubleClickAction({
button: 0,
- canOpenInEditor: false,
+ canOpenSource: false,
numberOfConnectedCompositions: 1,
sequenceWasDragged: false,
}),
@@ -3563,23 +3563,23 @@ test('Sequence double-click opens one connected composition before the editor',
expect(
getSequenceDoubleClickAction({
button: 0,
- canOpenInEditor: true,
+ canOpenSource: true,
numberOfConnectedCompositions: 0,
sequenceWasDragged: false,
}),
- ).toBe('open-in-editor');
+ ).toBe('open-source');
expect(
getSequenceDoubleClickAction({
button: 0,
- canOpenInEditor: true,
+ canOpenSource: true,
numberOfConnectedCompositions: 2,
sequenceWasDragged: false,
}),
- ).toBe('open-in-editor');
+ ).toBe('open-source');
expect(
getSequenceDoubleClickAction({
button: 0,
- canOpenInEditor: false,
+ canOpenSource: false,
numberOfConnectedCompositions: 2,
sequenceWasDragged: false,
}),
@@ -3587,7 +3587,7 @@ test('Sequence double-click opens one connected composition before the editor',
expect(
getSequenceDoubleClickAction({
button: 2,
- canOpenInEditor: true,
+ canOpenSource: true,
numberOfConnectedCompositions: 1,
sequenceWasDragged: false,
}),
@@ -3598,7 +3598,7 @@ test('Sequence double-click does nothing when the second press dragged the seque
expect(
getSequenceDoubleClickAction({
button: 0,
- canOpenInEditor: true,
+ canOpenSource: true,
numberOfConnectedCompositions: 1,
sequenceWasDragged: true,
}),
@@ -3606,7 +3606,7 @@ test('Sequence double-click does nothing when the second press dragged the seque
expect(
getSequenceDoubleClickAction({
button: 0,
- canOpenInEditor: true,
+ canOpenSource: true,
numberOfConnectedCompositions: 0,
sequenceWasDragged: true,
}),