Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Fix duplicate Open in actions

Jonny Burgeraa391d1d7d71
diff --git a/packages/studio/src/components/CompositionSelectorItem.tsx b/packages/studio/src/components/CompositionSelectorItem.tsx
index 3dc82abb0f..77e60bb5ae 100644
--- a/packages/studio/src/components/CompositionSelectorItem.tsx
+++ b/packages/studio/src/components/CompositionSelectorItem.tsx
@@ -16,7 +16,6 @@ import React, {
} from 'react';
import {type _InternalTypes} from 'remotion';
import {getBrowserStudioOperations} from '../helpers/browser-studio-operations';
-import {StudioServerConnectionCtx} from '../helpers/client-id';
import {
CURRENT_COLOR,
LIGHT_TEXT,
@@ -41,11 +40,11 @@ import {SetSelectedModalContext} from '../state/modals';
import {makeCompositionDragData} from './composition-drag-data';
import {getCompositionContextMenuItems} from './composition-menu-items';
import {
- type CompositionSelectorActiveDrag,
compositionSelectorDragDataToSymbolicatedStack,
hasCompositionSelectorDragData,
makeCompositionSelectorDragData,
parseCompositionSelectorDragData,
+ type CompositionSelectorActiveDrag,
type CompositionSelectorDragData,
} from './composition-selector-drag-data';
import {CompositionContextButton} from './CompositionContextButton';
@@ -58,7 +57,7 @@ import {showNotification} from './Notifications/NotificationCenter';
import {applyCodemod} from './RenderQueue/actions';
import {SidebarRenderButton} from './SidebarRenderButton';
import {useResolvedStack} from './Timeline/use-resolved-stack';
-import {useEditorOpening} from './use-default-editor-info';
+import {useOpenInMenuApps} from './use-open-in-menu-apps';
const itemStyle: React.CSSProperties = {
paddingRight: 2,
@@ -345,11 +344,7 @@ export const CompositionSelectorItem: React.FC<{
);
const {setSelectedModal} = useContext(SetSelectedModalContext);
- const connectionStatus = useContext(StudioServerConnectionCtx)
- .previewServerState.type;
- const {defaultEditorId, defaultEditorName} = useEditorOpening(
- connectionStatus === 'connected',
- );
+ const {connectionStatus, openInApps} = useOpenInMenuApps();
const resolvedLocation = useResolvedStack(
item.type === 'composition' ? item.composition.stack : item.folder.stack,
);
@@ -360,9 +355,8 @@ export const CompositionSelectorItem: React.FC<{
closeMenu: noop,
composition: item.composition,
connectionStatus,
- editorId: defaultEditorId,
- editorName: defaultEditorName,
includeCompositionManagementItems: true,
+ openInApps,
resolvedLocation,
setSelectedModal,
readOnlyStudio: window.remotion_isReadOnlyStudio,
@@ -372,21 +366,14 @@ export const CompositionSelectorItem: React.FC<{
return getFolderMenuItems({
closeMenu: noop,
connectionStatus,
- editorId: defaultEditorId,
- editorName: defaultEditorName,
+ editorId: openInApps.defaultEditorId,
+ editorName: openInApps.defaultEditorName,
folder: item.folder,
resolvedLocation,
setSelectedModal,
readOnlyStudio: window.remotion_isReadOnlyStudio,
});
- }, [
- connectionStatus,
- defaultEditorId,
- defaultEditorName,
- item,
- resolvedLocation,
- setSelectedModal,
- ]);
+ }, [connectionStatus, item, openInApps, resolvedLocation, setSelectedModal]);
const onItemDragStart = useCallback(
(event: DragEvent<HTMLElement>) => {
diff --git a/packages/studio/src/components/InspectorOpenInEditor.tsx b/packages/studio/src/components/InspectorOpenInEditor.tsx
index d39a475d6d..79953d0c66 100644
--- a/packages/studio/src/components/InspectorOpenInEditor.tsx
+++ b/packages/studio/src/components/InspectorOpenInEditor.tsx
@@ -124,15 +124,17 @@ export const InspectorOpenInEditor: React.FC<{
);
const menuItems = useMemo((): ComboboxValue[] => {
const items = getOpenInMenuItems({
+ canOpenDesktopApps: canConfigureApps,
codingAgentInfo,
editorDisabled: location === null || !canOpenInEditor,
editorInfo,
excludeCodingAgentId: null,
excludeEditorId: defaultEditorId,
+ excludeGitSource: defaultOpenInTarget === 'git-source',
fileManagerDisabled:
!location?.source || previewServerState.type !== 'connected',
folder: locationType === 'folder',
- location,
+ gitSourceDisabled: location === null,
onConfigureApps: configureDefaultApps,
onOpenInCodingAgent: (codingAgentId, codingAgentName) => {
openWithCodingAgent(codingAgentId, codingAgentName).catch(
@@ -165,6 +167,9 @@ export const InspectorOpenInEditor: React.FC<{
);
});
},
+ onOpenInGitSource: () => {
+ openGitSource({folder: locationType === 'folder', location});
+ },
onOpenInTerminal: (terminalId) => {
if (!location?.source || locationType !== 'folder') {
return;
@@ -185,11 +190,10 @@ export const InspectorOpenInEditor: React.FC<{
},
});
- return defaultOpenInTarget === 'git-source'
- ? items.filter((item) => item.id !== 'open-in-github')
- : items;
+ return items;
}, [
codingAgentInfo,
+ canConfigureApps,
canOpenInEditor,
configureDefaultApps,
defaultEditorId,
diff --git a/packages/studio/src/components/InspectorPanel/ConnectedCompositionsSection.tsx b/packages/studio/src/components/InspectorPanel/ConnectedCompositionsSection.tsx
index 8449f72a1e..c3036a99f4 100644
--- a/packages/studio/src/components/InspectorPanel/ConnectedCompositionsSection.tsx
+++ b/packages/studio/src/components/InspectorPanel/ConnectedCompositionsSection.tsx
@@ -1,7 +1,6 @@
import React, {useCallback, useContext, useMemo} from 'react';
import type {_InternalTypes} from 'remotion';
import {Internals} from 'remotion';
-import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {getConnectedCompositions} from '../../helpers/get-connected-compositions';
import type {TimelineTrackData} from '../../helpers/get-timeline-sequence-sort-key';
import {noop} from '../../helpers/noop';
@@ -11,7 +10,7 @@ import {CompositionOrStillIcon} from '../CompositionOrStillIcon';
import {ContextMenu} from '../ContextMenu';
import {useSelectComposition} from '../InitialCompositionLoader';
import {useResolvedStack} from '../Timeline/use-resolved-stack';
-import {useEditorOpening} from '../use-default-editor-info';
+import {useOpenInMenuApps} from '../use-open-in-menu-apps';
import {CollapsibleInspectorSection} from './CollapsibleInspectorSection';
import {InspectorQuickAction} from './common';
@@ -72,11 +71,7 @@ const ConnectedCompositionRow: React.FC<{
}> = ({composition}) => {
const selectComposition = useSelectComposition();
const {setSelectedModal} = useContext(SetSelectedModalContext);
- const connectionStatus = useContext(StudioServerConnectionCtx)
- .previewServerState.type;
- const {defaultEditorId, defaultEditorName} = useEditorOpening(
- connectionStatus === 'connected',
- );
+ const {connectionStatus, openInApps} = useOpenInMenuApps();
const resolvedLocation = useResolvedStack(composition.stack);
const getContextMenuItems = useCallback(
() =>
@@ -84,9 +79,8 @@ const ConnectedCompositionRow: React.FC<{
closeMenu: noop,
composition,
connectionStatus,
- editorId: defaultEditorId,
- editorName: defaultEditorName,
includeCompositionManagementItems: false,
+ openInApps,
readOnlyStudio: window.remotion_isReadOnlyStudio,
resolvedLocation,
setSelectedModal,
@@ -94,8 +88,7 @@ const ConnectedCompositionRow: React.FC<{
[
composition,
connectionStatus,
- defaultEditorId,
- defaultEditorName,
+ openInApps,
resolvedLocation,
setSelectedModal,
],
diff --git a/packages/studio/src/components/MenuCompositionName.tsx b/packages/studio/src/components/MenuCompositionName.tsx
index e290861af4..d88a78a5b4 100644
--- a/packages/studio/src/components/MenuCompositionName.tsx
+++ b/packages/studio/src/components/MenuCompositionName.tsx
@@ -1,6 +1,5 @@
import React, {useCallback, useContext, useMemo} from 'react';
import {Internals} from 'remotion';
-import {StudioServerConnectionCtx} from '../helpers/client-id';
import {
LIGHT_TEXT,
TRANSPARENT,
@@ -17,7 +16,7 @@ import {getCompositionContextMenuItems} from './composition-menu-items';
import {ContextMenu} from './ContextMenu';
import {InlineDropdown} from './InlineDropdown';
import {useResolvedStack} from './Timeline/use-resolved-stack';
-import {useEditorOpening} from './use-default-editor-info';
+import {useOpenInMenuApps} from './use-open-in-menu-apps';
const baseStyle: React.CSSProperties = {
cursor: 'default',
@@ -79,20 +78,15 @@ export const MenuCompositionName: React.FC = () => {
}, [canvasContent, compositions]);
const asset = canvasContent?.type === 'asset' ? canvasContent.asset : null;
const {setSelectedModal} = useContext(SetSelectedModalContext);
- const connectionStatus = useContext(StudioServerConnectionCtx)
- .previewServerState.type;
- const {defaultEditorId, defaultEditorName} = useEditorOpening(
- connectionStatus === 'connected',
- );
+ const {connectionStatus, openInApps} = useOpenInMenuApps();
const resolvedLocation = useResolvedStack(composition?.stack ?? null);
const getContextMenuItems = useCallback(() => {
return getCompositionContextMenuItems({
closeMenu: noop,
composition,
connectionStatus,
- editorId: defaultEditorId,
- editorName: defaultEditorName,
includeCompositionManagementItems: true,
+ openInApps,
resolvedLocation,
setSelectedModal,
readOnlyStudio: window.remotion_isReadOnlyStudio,
@@ -100,8 +94,7 @@ export const MenuCompositionName: React.FC = () => {
}, [
composition,
connectionStatus,
- defaultEditorId,
- defaultEditorName,
+ openInApps,
resolvedLocation,
setSelectedModal,
]);
diff --git a/packages/studio/src/components/QuickSwitcher/QuickSwitcherResult.tsx b/packages/studio/src/components/QuickSwitcher/QuickSwitcherResult.tsx
index 914a41247a..3757f407da 100644
--- a/packages/studio/src/components/QuickSwitcher/QuickSwitcherResult.tsx
+++ b/packages/studio/src/components/QuickSwitcher/QuickSwitcherResult.tsx
@@ -7,7 +7,6 @@ import React, {
useState,
} from 'react';
import type {_InternalTypes} from 'remotion';
-import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {
LIGHT_TEXT,
TRANSPARENT,
@@ -28,7 +27,7 @@ import {ContextMenu} from '../ContextMenu';
import {Spacing} from '../layout';
import type {ComboboxValue} from '../NewComposition/ComboBox';
import {useResolvedStack} from '../Timeline/use-resolved-stack';
-import {useEditorOpening} from '../use-default-editor-info';
+import {useOpenInMenuApps} from '../use-open-in-menu-apps';
import {
QUICK_SWITCHER_RESULT_LABEL_FONT_SIZE,
useScrollIntoViewOnSelected,
@@ -129,11 +128,7 @@ export const QuickSwitcherResult: React.FC<{
const onSelected = result.type === 'folder' ? null : result.onSelected;
const composition = result.type === 'composition' ? result.composition : null;
const {setSelectedModal} = useContext(SetSelectedModalContext);
- const connectionStatus = useContext(StudioServerConnectionCtx)
- .previewServerState.type;
- const {defaultEditorId, defaultEditorName} = useEditorOpening(
- connectionStatus === 'connected',
- );
+ const {connectionStatus, openInApps} = useOpenInMenuApps();
const resolvedLocation = useResolvedStack(composition?.stack ?? null);
const getContextMenuItems = useCallback((): ComboboxValue[] => {
if (composition === null) {
@@ -144,9 +139,8 @@ export const QuickSwitcherResult: React.FC<{
closeMenu: noop,
composition,
connectionStatus,
- editorId: defaultEditorId,
- editorName: defaultEditorName,
includeCompositionManagementItems: true,
+ openInApps,
resolvedLocation,
setSelectedModal,
readOnlyStudio: window.remotion_isReadOnlyStudio,
@@ -154,8 +148,7 @@ export const QuickSwitcherResult: React.FC<{
}, [
composition,
connectionStatus,
- defaultEditorId,
- defaultEditorName,
+ openInApps,
resolvedLocation,
setSelectedModal,
]);
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 8ac8c38e5b..ee7c43ed9f 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
@@ -189,9 +189,6 @@ export const getSequenceContextMenuItems = ({
: null;
const defaultOpenInName =
defaultOpenInTarget === 'editor' ? editorName : gitSourceName;
- const defaultCodingAgent = codingAgentInfo?.installedCodingAgents.find(
- (codingAgent) => codingAgent.id === codingAgentInfo.defaultCodingAgent,
- );
const contextForAgents = formatContextForAgents({
location: originalLocation,
name: sequence.displayName || sequence.controls?.componentName || null,
@@ -208,34 +205,35 @@ export const getSequenceContextMenuItems = ({
);
};
- const openInMenuItems = onConfigureApps
- ? getOpenInMenuItems({
- codingAgentInfo,
- editorDisabled: !canOpenInEditor || !originalLocation,
- editorInfo,
- excludeCodingAgentId: defaultCodingAgent?.id ?? null,
- excludeEditorId: defaultEditorId,
- fileManagerDisabled: !originalLocation?.source,
- folder: false,
- location: originalLocation,
- onConfigureApps,
- onOpenInCodingAgent: openInCodingAgentWithContext,
- onOpenInEditor: openInEditor,
- onOpenInFileExplorer: () => {
- if (!originalLocation?.source) {
- return;
- }
+ const openInMenuItems = getOpenInMenuItems({
+ canOpenDesktopApps: onConfigureApps !== null,
+ codingAgentInfo,
+ editorDisabled: !canOpenInEditor || !originalLocation,
+ editorInfo,
+ excludeCodingAgentId: null,
+ excludeEditorId: defaultEditorId,
+ excludeGitSource: defaultOpenInTarget === 'git-source',
+ fileManagerDisabled: !originalLocation?.source,
+ folder: false,
+ gitSourceDisabled: !originalLocation,
+ onConfigureApps,
+ onOpenInCodingAgent: openInCodingAgentWithContext,
+ onOpenInEditor: openInEditor,
+ onOpenInFileExplorer: () => {
+ if (!originalLocation?.source) {
+ return;
+ }
- openInFileExplorer({directory: originalLocation.source}).catch(
- (err) => {
- showNotification(`Could not open file: ${err.message}`, 2000);
- },
- );
- },
- onOpenInGitClient: () => undefined,
- onOpenInTerminal: null,
- })
- : [];
+ openInFileExplorer({directory: originalLocation.source}).catch((err) => {
+ showNotification(`Could not open file: ${err.message}`, 2000);
+ });
+ },
+ onOpenInGitClient: () => undefined,
+ onOpenInGitSource: () => {
+ openGitSource({folder: false, location: originalLocation});
+ },
+ onOpenInTerminal: null,
+ });
const items = [
defaultOpenInTarget && defaultOpenInName
@@ -265,25 +263,7 @@ export const getSequenceContextMenuItems = ({
: 'open-in-git-source',
}
: null,
- defaultCodingAgent
- ? {
- type: 'item' as const,
- id: 'open-in-default-coding-agent',
- keyHint: null,
- label: `Open in ${defaultCodingAgent.nameWithType}`,
- leftItem: null,
- disabled: false,
- onClick: () =>
- openInCodingAgentWithContext(
- defaultCodingAgent.id,
- defaultCodingAgent.nameWithType,
- ),
- quickSwitcherLabel: null,
- subMenu: null,
- value: 'open-in-default-coding-agent',
- }
- : null,
- onConfigureApps
+ openInMenuItems.length > 0
? {
type: 'item' as const,
id: 'open-in-another-app',
diff --git a/packages/studio/src/components/composition-menu-items.ts b/packages/studio/src/components/composition-menu-items.ts
index ca102ba155..d4aba9cb9f 100644
--- a/packages/studio/src/components/composition-menu-items.ts
+++ b/packages/studio/src/components/composition-menu-items.ts
@@ -1,3 +1,4 @@
+import type {DefaultCodingAgent} from '@remotion/renderer';
import type {EditorPickerId} from '@remotion/studio-shared';
import type {SetStateAction} from 'react';
import type {ResolvedStackLocation, _InternalTypes} from 'remotion';
@@ -6,17 +7,25 @@ import {
formatContextForAgents,
formatFileLocation,
} from '../helpers/format-file-location';
-import {getGitSourceName, openGitSource} from '../helpers/get-git-menu-item';
+import {
+ getDefaultOpenInTarget,
+ getGitSourceName,
+ openGitSource,
+} from '../helpers/get-git-menu-item';
import {
loadCompositionComponentInfo,
openCompositionComponentInEditor,
+ openInCodingAgent,
openOriginalPositionInEditor,
} from '../helpers/open-in-editor';
import type {PreviewServerConnectionState} from '../helpers/preview-server-events';
import type {ModalState} from '../state/modals';
+import {getOpenInMenuItems} from './get-open-in-menu-items';
import type {ComboboxValue} from './NewComposition/ComboBox';
import {showNotification} from './Notifications/NotificationCenter';
import {getOpenInNewWindowMenuItem} from './open-in-new-window';
+import {openInFileExplorer} from './RenderQueue/actions';
+import type {OpenInMenuApps} from './use-open-in-menu-apps';
export const getCompositionMenuItems = ({
composition,
@@ -26,8 +35,7 @@ export const getCompositionMenuItems = ({
closeMenu,
readOnlyStudio,
includeCompositionManagementItems,
- editorId,
- editorName,
+ openInApps,
}: {
composition: _InternalTypes['AnyComposition'] | null;
connectionStatus: PreviewServerConnectionState['type'];
@@ -36,9 +44,17 @@ export const getCompositionMenuItems = ({
closeMenu: () => void;
readOnlyStudio: boolean;
includeCompositionManagementItems: boolean;
- editorId: EditorPickerId | null;
- editorName: string | null;
+ openInApps: OpenInMenuApps;
}): ComboboxValue[] => {
+ const {
+ canOpenDesktopApps,
+ canOpenInEditor,
+ codingAgentInfo,
+ defaultEditorId,
+ defaultEditorName,
+ editorInfo,
+ onConfigureApps,
+ } = openInApps;
const fileLocation = formatFileLocation({
location: resolvedLocation,
root: window.remotion_cwd,
@@ -48,125 +64,258 @@ export const getCompositionMenuItems = ({
name: composition?.id ?? null,
root: window.remotion_cwd,
});
- const showInEditorDisabled =
- !editorId ||
- !composition ||
- connectionStatus !== 'connected' ||
- !resolvedLocation;
+ const openCompositionInEditorDisabled =
+ !defaultEditorId || !composition || !canOpenInEditor || !resolvedLocation;
const openComponentInEditorDisabled =
- showInEditorDisabled || !resolvedLocation?.source;
+ openCompositionInEditorDisabled || !resolvedLocation?.source;
const gitSourceName = window.remotion_gitSource
? getGitSourceName(window.remotion_gitSource)
: null;
+ const defaultOpenInTarget = getDefaultOpenInTarget({canOpenInEditor});
+ const defaultOpenInName =
+ defaultOpenInTarget === 'editor' ? defaultEditorName : gitSourceName;
const openCompositionInGitSourceDisabled = !composition || !resolvedLocation;
const openComponentInGitSourceDisabled =
openCompositionInGitSourceDisabled ||
!resolvedLocation?.source ||
(!readOnlyStudio && connectionStatus !== 'connected');
const copyFileLocationDisabled = !composition || !fileLocation;
+ const openWithCodingAgent = async (
+ codingAgentId: DefaultCodingAgent,
+ codingAgentName: string,
+ ) => {
+ try {
+ const response = await openInCodingAgent(
+ codingAgentId,
+ codingAgentId === 'copilot' ? null : contextForAgents,
+ );
+ if (!response.success) {
+ showNotification(`Could not open ${codingAgentName}`, 2000);
+ }
+ } catch (err) {
+ showNotification((err as Error).message, 2000);
+ }
+ };
+
+ const openCompositionWithEditor = async (editorId: EditorPickerId) => {
+ closeMenu();
+ if (!composition || !resolvedLocation) {
+ return;
+ }
+
+ try {
+ await openOriginalPositionInEditor(resolvedLocation, editorId);
+ } catch (err) {
+ showNotification((err as Error).message, 2000);
+ }
+ };
+
+ const openComponentWithEditor = async (editorId: EditorPickerId) => {
+ closeMenu();
+ if (!composition || !resolvedLocation?.source) {
+ return;
+ }
+
+ try {
+ await openCompositionComponentInEditor({
+ compositionFile: resolvedLocation.source,
+ compositionId: composition.id,
+ editorId,
+ });
+ } catch (err) {
+ showNotification((err as Error).message, 2000);
+ }
+ };
+
+ const openComponentInGitSource = async () => {
+ closeMenu();
+ if (!composition || !resolvedLocation?.source) {
+ return;
+ }
+
+ try {
+ const info = await loadCompositionComponentInfo({
+ compositionFile: resolvedLocation.source,
+ compositionId: composition.id,
+ });
+ openGitSource({folder: false, location: info.location});
+ } catch (err) {
+ showNotification((err as Error).message, 2000);
+ }
+ };
+
+ const openCompositionInFileExplorer = () => {
+ if (!resolvedLocation?.source) {
+ return;
+ }
+
+ openInFileExplorer({directory: resolvedLocation.source}).catch((err) => {
+ showNotification(`Could not open file: ${err.message}`, 2000);
+ });
+ };
+
+ const openComponentInFileExplorer = async () => {
+ if (!composition || !resolvedLocation?.source) {
+ return;
+ }
+
+ try {
+ const info = await loadCompositionComponentInfo({
+ compositionFile: resolvedLocation.source,
+ compositionId: composition.id,
+ });
+ await openInFileExplorer({directory: info.location.source});
+ } catch (err) {
+ showNotification(`Could not open file: ${(err as Error).message}`, 2000);
+ }
+ };
+
+ const commonOpenInMenuItems = {
+ canOpenDesktopApps,
+ codingAgentInfo,
+ editorInfo,
+ excludeCodingAgentId: null,
+ excludeEditorId: defaultOpenInTarget === 'editor' ? defaultEditorId : null,
+ excludeGitSource: defaultOpenInTarget === 'git-source',
+ folder: false,
+ onConfigureApps,
+ onOpenInCodingAgent: (codingAgentId: DefaultCodingAgent, name: string) => {
+ openWithCodingAgent(codingAgentId, name).catch(() => undefined);
+ },
+ onOpenInGitClient: () => undefined,
+ onOpenInTerminal: null,
+ };
+ const compositionOpenInMenuItems = getOpenInMenuItems({
+ ...commonOpenInMenuItems,
+ editorDisabled: openCompositionInEditorDisabled,
+ fileManagerDisabled:
+ !resolvedLocation?.source || connectionStatus !== 'connected',
+ gitSourceDisabled: openCompositionInGitSourceDisabled,
+ onOpenInEditor: (editorId) => {
+ openCompositionWithEditor(editorId).catch(() => undefined);
+ },
+ onOpenInFileExplorer: openCompositionInFileExplorer,
+ onOpenInGitSource: () => {
+ closeMenu();
+ openGitSource({folder: false, location: resolvedLocation});
+ },
+ });
+ const componentOpenInMenuItems = getOpenInMenuItems({
+ ...commonOpenInMenuItems,
+ editorDisabled: openComponentInEditorDisabled,
+ fileManagerDisabled:
+ !resolvedLocation?.source || connectionStatus !== 'connected',
+ gitSourceDisabled: openComponentInGitSourceDisabled,
+ onOpenInEditor: (editorId) => {
+ openComponentWithEditor(editorId).catch(() => undefined);
+ },
+ onOpenInFileExplorer: () => {
+ openComponentInFileExplorer().catch(() => undefined);
+ },
+ onOpenInGitSource: () => {
+ openComponentInGitSource().catch(() => undefined);
+ },
+ });
+ const hasOpenInItems =
+ defaultOpenInName !== null ||
+ compositionOpenInMenuItems.length > 0 ||
+ componentOpenInMenuItems.length > 0;
return [
- editorName
+ defaultOpenInTarget && defaultOpenInName
? {
- id: 'show-in-editor',
+ id:
+ defaultOpenInTarget === 'editor'
+ ? 'show-in-editor'
+ : 'open-composition-in-git-source',
keyHint: null,
- label: `Open composition in ${editorName}`,
+ label: `Open composition in ${defaultOpenInName}`,
leftItem: null,
- onClick: async () => {
- closeMenu();
- if (!composition || !resolvedLocation || !editorId) {
- return;
- }
-
- try {
- await openOriginalPositionInEditor(resolvedLocation, editorId);
- } catch (err) {
- showNotification((err as Error).message, 2000);
+ onClick: () => {
+ if (defaultOpenInTarget === 'editor' && defaultEditorId !== null) {
+ openCompositionWithEditor(defaultEditorId).catch(() => undefined);
+ } else if (defaultOpenInTarget === 'git-source') {
+ closeMenu();
+ openGitSource({folder: false, location: resolvedLocation});
}
},
- quickSwitcherLabel: `Open composition in ${editorName}`,
+ quickSwitcherLabel: `Open composition in ${defaultOpenInName}`,
subMenu: null,
type: 'item' as const,
- value: 'show-in-editor',
- disabled: showInEditorDisabled,
+ value:
+ defaultOpenInTarget === 'editor'
+ ? 'show-in-editor'
+ : 'open-composition-in-git-source',
+ disabled:
+ defaultOpenInTarget === 'editor'
+ ? openCompositionInEditorDisabled
+ : openCompositionInGitSourceDisabled,
}
: null,
- editorName
+ compositionOpenInMenuItems.length > 0
? {
- id: 'open-component-in-editor',
+ id: 'open-composition-in-another-app',
keyHint: null,
- label: `Open component in ${editorName}`,
+ label: 'Open composition in...',
leftItem: null,
- onClick: async () => {
- closeMenu();
- if (!composition || !resolvedLocation?.source || !editorId) {
- return;
- }
-
- try {
- await openCompositionComponentInEditor({
- compositionFile: resolvedLocation.source,
- compositionId: composition.id,
- editorId,
- });
- } catch (err) {
- showNotification((err as Error).message, 2000);
- }
+ onClick: () => undefined,
+ quickSwitcherLabel: null,
+ subMenu: {
+ items: compositionOpenInMenuItems,
+ leaveLeftSpace: true,
+ preselectIndex: false as const,
},
- quickSwitcherLabel: `Open composition component in ${editorName}`,
- subMenu: null,
type: 'item' as const,
- value: 'open-component-in-editor',
- disabled: openComponentInEditorDisabled,
+ value: 'open-composition-in-another-app',
}
: null,
- gitSourceName
+ defaultOpenInTarget && defaultOpenInName
? {
- id: 'open-composition-in-git-source',
+ id:
+ defaultOpenInTarget === 'editor'
+ ? 'open-component-in-editor'
+ : 'open-component-in-git-source',
keyHint: null,
- label: `Open composition in ${gitSourceName}`,
+ label: `Open component in ${defaultOpenInName}`,
leftItem: null,
onClick: () => {
- closeMenu();
- openGitSource({folder: false, location: resolvedLocation});
+ if (defaultOpenInTarget === 'editor' && defaultEditorId !== null) {
+ openComponentWithEditor(defaultEditorId).catch(() => undefined);
+ } else if (defaultOpenInTarget === 'git-source') {
+ openComponentInGitSource().catch(() => undefined);
+ }
},
- quickSwitcherLabel: `Open composition in ${gitSourceName}`,
+ quickSwitcherLabel: `Open composition component in ${defaultOpenInName}`,
subMenu: null,
type: 'item' as const,
- value: 'open-composition-in-git-source',
- disabled: openCompositionInGitSourceDisabled,
+ value:
+ defaultOpenInTarget === 'editor'
+ ? 'open-component-in-editor'
+ : 'open-component-in-git-source',
+ disabled:
+ defaultOpenInTarget === 'editor'
+ ? openComponentInEditorDisabled
+ : openComponentInGitSourceDisabled,
}
: null,
- gitSourceName
+ componentOpenInMenuItems.length > 0
? {
- id: 'open-component-in-git-source',
+ id: 'open-component-in-another-app',
keyHint: null,
- label: `Open component in ${gitSourceName}`,
+ label: 'Open component in...',
leftItem: null,
- onClick: async () => {
- closeMenu();
- if (!composition || !resolvedLocation?.source) {
- return;
- }
-
- try {
- const info = await loadCompositionComponentInfo({
- compositionFile: resolvedLocation.source,
- compositionId: composition.id,
- });
- openGitSource({folder: false, location: info.location});
- } catch (err) {
- showNotification((err as Error).message, 2000);
- }
+ onClick: () => undefined,
+ quickSwitcherLabel: null,
+ subMenu: {
+ items: componentOpenInMenuItems,
+ leaveLeftSpace: true,
+ preselectIndex: false as const,
},
- quickSwitcherLabel: `Open composition component in ${gitSourceName}`,
- subMenu: null,
type: 'item' as const,
- value: 'open-component-in-git-source',
- disabled: openComponentInGitSourceDisabled,
+ value: 'open-component-in-another-app',
}
: null,
- (editorName || gitSourceName) && includeCompositionManagementItems
+ hasOpenInItems && includeCompositionManagementItems
? {
type: 'divider' as const,
id: 'show-in-editor-divider',
@@ -246,7 +395,7 @@ export const getCompositionMenuItems = ({
disabled: !composition || readOnlyStudio,
}
: null,
- editorName || gitSourceName || includeCompositionManagementItems
+ hasOpenInItems || includeCompositionManagementItems
? {
type: 'divider' as const,
id: 'copy-actions-divider',
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 52366c7857..777ae59ad2 100644
--- a/packages/studio/src/components/get-open-in-menu-items.tsx
+++ b/packages/studio/src/components/get-open-in-menu-items.tsx
@@ -1,15 +1,14 @@
import type {DefaultCodingAgent} from '@remotion/renderer';
-import type {GitClientId, TerminalId} from '@remotion/studio-shared';
import type {
EditorPickerId,
GetDefaultCodingAgentInfoResponse,
GetDefaultEditorInfoResponse,
+ GitClientId,
+ TerminalId,
} from '@remotion/studio-shared';
import React from 'react';
import {NoReactInternals} from 'remotion/no-react';
-import type {OriginalPosition} from '../error-overlay/react-overlay/utils/get-source-map';
import {getFileManagerName} from '../helpers/get-file-manager-name';
-import {openGitSource} from '../helpers/get-git-menu-item';
import {EditorIcon} from '../icons/editor';
import {FinderIcon} from '../icons/finder';
import {GitClientIcon} from '../icons/git-client';
@@ -55,29 +54,34 @@ export const getConfigureDefaultAppsMenuItems = ({
};
export const getOpenInMenuItems = ({
+ canOpenDesktopApps,
codingAgentInfo,
editorDisabled,
editorInfo,
excludeCodingAgentId,
excludeEditorId,
+ excludeGitSource,
fileManagerDisabled,
folder,
- location,
+ gitSourceDisabled,
onConfigureApps,
onOpenInCodingAgent,
onOpenInEditor,
onOpenInFileExplorer,
onOpenInGitClient,
+ onOpenInGitSource,
onOpenInTerminal,
}: {
+ readonly canOpenDesktopApps: boolean;
readonly codingAgentInfo: GetDefaultCodingAgentInfoResponse | null;
readonly editorDisabled: boolean;
readonly editorInfo: GetDefaultEditorInfoResponse | null;
readonly excludeCodingAgentId: DefaultCodingAgent | null;
readonly excludeEditorId: EditorPickerId | null;
+ readonly excludeGitSource: boolean;
readonly fileManagerDisabled: boolean;
readonly folder: boolean;
- readonly location: OriginalPosition | null;
+ readonly gitSourceDisabled: boolean;
readonly onConfigureApps: (() => void) | null;
readonly onOpenInCodingAgent: (
codingAgentId: DefaultCodingAgent,
@@ -86,13 +90,17 @@ export const getOpenInMenuItems = ({
readonly onOpenInEditor: (editorId: EditorPickerId) => void;
readonly onOpenInFileExplorer: () => void;
readonly onOpenInGitClient: (gitClientId: GitClientId) => void;
+ readonly onOpenInGitSource: () => void;
readonly onOpenInTerminal: ((terminalId: TerminalId) => void) | null;
}): ComboboxValue[] => {
- const showFinder = window.remotion_fileSystemPlatform === 'darwin';
+ const showFinder =
+ canOpenDesktopApps && window.remotion_fileSystemPlatform === 'darwin';
const fileManagerName = getFileManagerName(
window.remotion_fileSystemPlatform,
);
- const editors: ComboboxValue[] = (editorInfo?.installedEditors ?? [])
+ const editors: ComboboxValue[] = (
+ canOpenDesktopApps ? (editorInfo?.installedEditors ?? []) : []
+ )
.filter((editor) => editor.id !== excludeEditorId)
.map((editor) => ({
disabled: editorDisabled,
@@ -111,7 +119,7 @@ export const getOpenInMenuItems = ({
value: editor.id,
}));
const codingAgents: ComboboxValue[] = (
- codingAgentInfo?.installedCodingAgents ?? []
+ canOpenDesktopApps ? (codingAgentInfo?.installedCodingAgents ?? []) : []
)
.filter((codingAgent) => codingAgent.id !== excludeCodingAgentId)
.map((codingAgent) => ({
@@ -126,23 +134,33 @@ export const getOpenInMenuItems = ({
type: 'item' as const,
value: `coding-agent-${codingAgent.id}`,
}));
- const terminals = folder ? (codingAgentInfo?.installedTerminals ?? []) : [];
- const gitClients = folder ? (codingAgentInfo?.installedGitClients ?? []) : [];
- const gitHubItem: ComboboxValue | null = window.remotion_gitSource
- ? {
- id: 'open-in-github',
- keyHint: null,
- label: <span style={menuLabel}>GitHub.com</span>,
- leftItem: <GitHubIcon size={16} />,
- onClick: () => {
- openGitSource({folder, location});
- },
- quickSwitcherLabel: null,
- subMenu: null,
- type: 'item' as const,
- value: 'github',
- }
- : null;
+ const terminals =
+ canOpenDesktopApps && folder
+ ? (codingAgentInfo?.installedTerminals ?? [])
+ : [];
+ const gitClients =
+ canOpenDesktopApps && folder
+ ? (codingAgentInfo?.installedGitClients ?? [])
+ : [];
+ const gitHubItem: ComboboxValue | null =
+ window.remotion_gitSource && !excludeGitSource
+ ? {
+ disabled: gitSourceDisabled,
+ id: 'open-in-github',
+ keyHint: null,
+ label: <span style={menuLabel}>GitHub.com</span>,
+ leftItem: <GitHubIcon size={16} />,
+ onClick: () => {
+ if (!gitSourceDisabled) {
+ onOpenInGitSource();
+ }
+ },
+ quickSwitcherLabel: null,
+ subMenu: null,
+ type: 'item' as const,
+ value: 'github',
+ }
+ : null;
const systemApps: ComboboxValue[] = [
gitHubItem,
showFinder
diff --git a/packages/studio/src/components/use-open-in-menu-apps.ts b/packages/studio/src/components/use-open-in-menu-apps.ts
new file mode 100644
index 0000000000..78b6a51eec
--- /dev/null
+++ b/packages/studio/src/components/use-open-in-menu-apps.ts
@@ -0,0 +1,58 @@
+import type {
+ EditorPickerId,
+ GetDefaultCodingAgentInfoResponse,
+ GetDefaultEditorInfoResponse,
+} from '@remotion/studio-shared';
+import {useContext, useMemo} from 'react';
+import {StudioServerConnectionCtx} from '../helpers/client-id';
+import {useConfigureDefaultApps} from './use-configure-default-apps';
+import {
+ useDefaultCodingAgentInfo,
+ useEditorOpening,
+} from './use-default-editor-info';
+
+export type OpenInMenuApps = {
+ readonly canOpenDesktopApps: boolean;
+ readonly canOpenInEditor: boolean;
+ readonly codingAgentInfo: GetDefaultCodingAgentInfoResponse | null;
+ readonly defaultEditorId: EditorPickerId | null;
+ readonly defaultEditorName: string | null;
+ readonly editorInfo: GetDefaultEditorInfoResponse | null;
+ readonly onConfigureApps: (() => void) | null;
+};
+
+export const useOpenInMenuApps = () => {
+ const connectionStatus = useContext(StudioServerConnectionCtx)
+ .previewServerState.type;
+ const {
+ canConfigureApps,
+ canOpenInEditor,
+ defaultEditorId,
+ defaultEditorName,
+ editorInfo,
+ } = useEditorOpening(connectionStatus === 'connected');
+ const codingAgentInfo = useDefaultCodingAgentInfo(canConfigureApps);
+ const onConfigureApps = useConfigureDefaultApps();
+ const openInApps = useMemo(
+ (): OpenInMenuApps => ({
+ canOpenDesktopApps: canConfigureApps,
+ canOpenInEditor,
+ codingAgentInfo,
+ defaultEditorId,
+ defaultEditorName,
+ editorInfo,
+ onConfigureApps,
+ }),
+ [
+ canOpenInEditor,
+ canConfigureApps,
+ codingAgentInfo,
+ defaultEditorId,
+ defaultEditorName,
+ editorInfo,
+ onConfigureApps,
+ ],
+ );
+
+ return {connectionStatus, openInApps};
+};
diff --git a/packages/studio/src/helpers/use-menu-structure.tsx b/packages/studio/src/helpers/use-menu-structure.tsx
index 034e7f8a38..829600a37b 100644
--- a/packages/studio/src/helpers/use-menu-structure.tsx
+++ b/packages/studio/src/helpers/use-menu-structure.tsx
@@ -17,7 +17,7 @@ import {openInFileExplorer} from '../components/RenderQueue/actions';
import {getPreviewSizeLabel, getUniqueSizes} from '../components/SizeSelector';
import {useResolvedStack} from '../components/Timeline/use-resolved-stack';
import {inOutHandles} from '../components/TimelineInOutToggle';
-import {useEditorOpening} from '../components/use-default-editor-info';
+import {useOpenInMenuApps} from '../components/use-open-in-menu-apps';
import {Checkmark} from '../icons/Checkmark';
import {drawRef} from '../state/canvas-ref';
import {CheckerboardContext} from '../state/checkerboard';
@@ -35,7 +35,6 @@ import {
getBrowserStudioOperations,
} from './browser-studio-operations';
import {checkFullscreenSupport} from './check-fullscreen-support';
-import {StudioServerConnectionCtx} from './client-id';
import {CURRENT_COLOR} from './colors';
import {getFileManagerName} from './get-file-manager-name';
import {getGitMenuItem} from './get-git-menu-item';
@@ -314,10 +313,8 @@ export const useMenuStructure = (
const {canvasContent, compositions} = useContext(
Internals.CompositionManager,
);
- const {type} = useContext(StudioServerConnectionCtx).previewServerState;
- const {defaultEditorId, defaultEditorName} = useEditorOpening(
- type === 'connected',
- );
+ const {connectionStatus: type, openInApps} = useOpenInMenuApps();
+ const {defaultEditorId, defaultEditorName} = openInApps;
const keyboardShortcutsDisabled = areKeyboardShortcutsDisabled();
const resetZoomShortcut = useKeyboardShortcutLabel('resetZoom');
const toggleSnappingShortcut = useKeyboardShortcutLabel('toggleSnapping');
@@ -906,9 +903,8 @@ export const useMenuStructure = (
closeMenu,
composition: currentComposition,
connectionStatus: type,
- editorId: defaultEditorId,
- editorName: defaultEditorName,
includeCompositionManagementItems: true,
+ openInApps,
resolvedLocation: resolvedCompositionLocation,
setSelectedModal,
readOnlyStudio,
@@ -1184,6 +1180,7 @@ export const useMenuStructure = (
mobileLayout,
defaultEditorId,
defaultEditorName,
+ openInApps,
keyboardShortcutsDisabled,
studioAskAIEnabled,
askAIShortcut,
diff --git a/packages/studio/src/test/composition-menu-items.test.ts b/packages/studio/src/test/composition-menu-items.test.ts
index d0e28359b1..66357c7f03 100644
--- a/packages/studio/src/test/composition-menu-items.test.ts
+++ b/packages/studio/src/test/composition-menu-items.test.ts
@@ -94,11 +94,23 @@ const commonArgs = {
closeMenu: () => undefined,
composition,
connectionStatus: 'connected' as const,
- editorId: 'vscode' as const,
- editorName: 'Code',
readOnlyStudio: false,
resolvedLocation: null,
setSelectedModal: () => undefined,
+ openInApps: {
+ canOpenDesktopApps: true,
+ canOpenInEditor: true,
+ codingAgentInfo: null,
+ defaultEditorId: 'vscode' as const,
+ defaultEditorName: 'Code',
+ editorInfo: {
+ defaultEditor: 'vscode' as const,
+ installedEditors: [
+ {id: 'vscode' as const, name: 'Code', nameWithType: 'Code'},
+ ],
+ },
+ onConfigureApps: null,
+ },
};
const ids = (items: ReturnType<typeof getCompositionMenuItems>) =>
@@ -127,9 +139,14 @@ test('connected composition context menus omit management actions', () => {
const items = getCompositionContextMenuItems({
...commonArgs,
- editorId: null,
- editorName: null,
includeCompositionManagementItems: false,
+ openInApps: {
+ ...commonArgs.openInApps,
+ canOpenInEditor: false,
+ defaultEditorId: null,
+ defaultEditorName: null,
+ editorInfo: null,
+ },
});
expect(ids(items)).toEqual([
@@ -221,11 +238,19 @@ test('editor actions use Open labels and are adjacent', () => {
});
test('read-only composition menus keep navigation and copy actions enabled', () => {
- installTestWindowWithEditor();
+ installTestWindowWithGitSource({readOnly: true});
const items = getCompositionContextMenuItems({
...commonArgs,
includeCompositionManagementItems: true,
+ openInApps: {
+ ...commonArgs.openInApps,
+ canOpenDesktopApps: false,
+ canOpenInEditor: false,
+ defaultEditorId: null,
+ defaultEditorName: null,
+ editorInfo: null,
+ },
readOnlyStudio: true,
resolvedLocation,
});
@@ -239,8 +264,11 @@ test('read-only composition menus keep navigation and copy actions enabled', ()
};
expect(itemById('open-in-new-window').disabled).not.toBe(true);
- expect(itemById('show-in-editor').disabled).toBe(false);
- expect(itemById('open-component-in-editor').disabled).toBe(false);
+ expect(itemById('open-composition-in-git-source').disabled).toBe(false);
+ expect(itemById('open-component-in-git-source').disabled).toBe(false);
+ expect(ids(items)).not.toContain('show-in-editor');
+ expect(ids(items)).not.toContain('open-composition-in-another-app');
+ expect(ids(items)).not.toContain('open-component-in-another-app');
expect(itemById('copy-context-for-agents').disabled).toBe(false);
expect(itemById('copy-file-location').disabled).toBe(false);
expect(itemById('copy-id').disabled).toBe(false);
@@ -253,9 +281,15 @@ test('composition context menus can open source locations on GitHub', () => {
const openedUrls = installTestWindowWithGitSource({readOnly: true});
const items = getCompositionContextMenuItems({
...commonArgs,
- editorId: null,
- editorName: null,
includeCompositionManagementItems: true,
+ openInApps: {
+ ...commonArgs.openInApps,
+ canOpenDesktopApps: false,
+ canOpenInEditor: false,
+ defaultEditorId: null,
+ defaultEditorName: null,
+ editorInfo: null,
+ },
readOnlyStudio: true,
resolvedLocation,
});
@@ -279,15 +313,70 @@ test('composition context menus can open source locations on GitHub', () => {
]);
});
-test('interactive composition context menus retain GitHub actions', () => {
+test('interactive composition context menus list GitHub as an alternative', () => {
installTestWindowWithGitSource({readOnly: false});
const items = getCompositionContextMenuItems({
...commonArgs,
includeCompositionManagementItems: false,
+ openInApps: {
+ ...commonArgs.openInApps,
+ codingAgentInfo: {
+ defaultCodingAgent: 'cursor',
+ installedCodingAgents: [
+ {
+ id: 'cursor',
+ name: 'Cursor',
+ nameWithType: 'Cursor Agent',
+ },
+ ],
+ installedGitClients: [],
+ installedTerminals: [],
+ },
+ editorInfo: {
+ defaultEditor: 'vscode',
+ installedEditors: [
+ {id: 'vscode', name: 'Code', nameWithType: 'Code'},
+ {id: 'cursor', name: 'Cursor', nameWithType: 'Cursor Editor'},
+ ],
+ },
+ onConfigureApps: () => undefined,
+ },
resolvedLocation,
});
expect(ids(items)).toContain('show-in-editor');
- expect(ids(items)).toContain('open-composition-in-git-source');
- expect(ids(items)).toContain('open-component-in-git-source');
+ expect(ids(items)).not.toContain('open-composition-in-git-source');
+ expect(ids(items)).not.toContain('open-component-in-git-source');
+
+ const compositionAlternatives = items.find(
+ (item) => item.id === 'open-composition-in-another-app',
+ );
+ const componentAlternatives = items.find(
+ (item) => item.id === 'open-component-in-another-app',
+ );
+ if (
+ compositionAlternatives?.type !== 'item' ||
+ compositionAlternatives.subMenu === null ||
+ componentAlternatives?.type !== 'item' ||
+ componentAlternatives.subMenu === null
+ ) {
+ throw new Error('Expected composition and component Open in submenus');
+ }
+
+ expect(compositionAlternatives.subMenu.items.map((item) => item.id)).toEqual(
+ expect.arrayContaining([
+ 'open-in-cursor',
+ 'open-in-coding-agent-cursor',
+ 'open-in-github',
+ 'change-default-apps',
+ ]),
+ );
+ expect(componentAlternatives.subMenu.items.map((item) => item.id)).toEqual(
+ expect.arrayContaining([
+ 'open-in-cursor',
+ 'open-in-coding-agent-cursor',
+ 'open-in-github',
+ 'change-default-apps',
+ ]),
+ );
});
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 00cf497040..846da85e39 100644
--- a/packages/studio/src/test/sequence-context-menu-items.test.ts
+++ b/packages/studio/src/test/sequence-context-menu-items.test.ts
@@ -103,19 +103,22 @@ test('the file manager entry is only shown on macOS', () => {
installTestWindow();
const getItems = () =>
getOpenInMenuItems({
+ canOpenDesktopApps: true,
codingAgentInfo: null,
editorDisabled: false,
editorInfo: null,
excludeCodingAgentId: null,
excludeEditorId: null,
+ excludeGitSource: false,
fileManagerDisabled: false,
folder: false,
- location: null,
+ gitSourceDisabled: false,
onConfigureApps: noop,
onOpenInCodingAgent: noop,
onOpenInEditor: noop,
onOpenInFileExplorer: noop,
onOpenInGitClient: noop,
+ onOpenInGitSource: noop,
onOpenInTerminal: null,
});
@@ -187,6 +190,13 @@ test('sequence context menu normalizes dividers before source actions', () => {
test('sequence context menu shares alternate apps without repeating defaults', () => {
installTestWindow();
window.remotion_editorName = 'Cursor Editor';
+ window.remotion_gitSource = {
+ name: 'project',
+ org: 'example',
+ ref: 'main',
+ relativeFromGitRoot: '',
+ type: 'github',
+ };
const openedEditors: Array<string | null> = [];
const openedCodingAgents: Array<{
@@ -252,17 +262,13 @@ test('sequence context menu shares alternate apps without repeating defaults', (
sequence: {displayName: 'Intro card'} as TSequence,
});
- expect(items.slice(0, 3).map((item) => item.id)).toEqual([
+ expect(items.slice(0, 2).map((item) => item.id)).toEqual([
'open-in-editor',
- 'open-in-default-coding-agent',
'open-in-another-app',
]);
expect(items[0]?.type === 'item' ? items[0].label : null).toBe(
'Open in Cursor Editor',
);
- expect(items[1]?.type === 'item' ? items[1].label : null).toBe(
- 'Open in Cursor Agent',
- );
const openIn = items.find((item) => item.id === 'open-in-another-app');
if (openIn?.type !== 'item' || openIn.subMenu === null) {
throw new Error('Expected Open in submenu');
@@ -270,22 +276,23 @@ 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-cursor');
expect(submenuIds).toContain('open-in-coding-agent-claude-code');
+ expect(submenuIds).toContain('open-in-github');
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 gitHubIndex = submenuIds.indexOf('open-in-github');
+ expect(openIn.subMenu.items[gitHubIndex - 1]?.type).toBe('divider');
- const defaultAgent = items.find(
- (item) => item.id === 'open-in-default-coding-agent',
+ const cursorAgent = openIn.subMenu.items.find(
+ (item) => item.id === 'open-in-coding-agent-cursor',
);
- if (defaultAgent?.type !== 'item') {
- throw new Error('Expected default coding agent item');
+ if (cursorAgent?.type !== 'item') {
+ throw new Error('Expected Cursor coding agent item');
}
- defaultAgent.onClick('open-in-default-coding-agent', null);
+ cursorAgent.onClick('open-in-coding-agent-cursor', null);
const claudeCode = openIn.subMenu.items.find(
(item) => item.id === 'open-in-coding-agent-claude-code',
);
@@ -495,6 +502,7 @@ test('read-only sequence menus open source locations on GitHub', () => {
expect(openedUrls).toEqual([
'https://github.com/example/project/blob/main/src/Video.tsx#L12',
]);
+ expect(items.some((item) => item.id === 'open-in-another-app')).toBe(false);
});
test('sequence freeze context menu item is hidden for audio', () => {