Skip to content

🎥 Make videos programmatically with React

Studio: Hide unavailable browser agent hints and offer project download

Igor Samokhovets1470aa767508
diff --git a/packages/studio/src/components/AgentPrompt.tsx b/packages/studio/src/components/AgentPrompt.tsx
index aaca15e361..6594347918 100644
--- a/packages/studio/src/components/AgentPrompt.tsx
+++ b/packages/studio/src/components/AgentPrompt.tsx
@@ -1,4 +1,5 @@
import React, {useCallback, useContext} from 'react';
+import {getBrowserStudioOperations} from '../helpers/browser-studio-operations';
import {StudioServerConnectionCtx} from '../helpers/client-id';
import {BLACK_ALPHA_30, BLUE, LIGHT_TEXT, WHITE} from '../helpers/colors';
import {copyText} from '../helpers/copy-text';
@@ -110,6 +111,10 @@ export const AgentPrompt: React.FC<{
[installCopied],
);
+ if (getBrowserStudioOperations() !== null) {
+ return null;
+ }
+
return (
<>
{skillAvailable ? null : (
diff --git a/packages/studio/src/components/FixComputedValueModal.tsx b/packages/studio/src/components/FixComputedValueModal.tsx
index 6910bbbee7..9b721e7f96 100644
--- a/packages/studio/src/components/FixComputedValueModal.tsx
+++ b/packages/studio/src/components/FixComputedValueModal.tsx
@@ -9,6 +9,7 @@ import React, {
import {resolveFileSource} from '../error-overlay/react-overlay/effects/resolve-file-source';
import {OpenInEditor} from '../error-overlay/remotion-overlay/OpenInEditor';
import {StackElement} from '../error-overlay/remotion-overlay/StackFrame';
+import {getBrowserStudioOperations} from '../helpers/browser-studio-operations';
import {StudioServerConnectionCtx} from '../helpers/client-id';
import {LIGHT_TEXT} from '../helpers/colors';
import {getCodexAnnotation} from '../helpers/get-codex-annotation';
@@ -22,6 +23,7 @@ import {ModalHeader} from './ModalHeader';
import {DismissableModal} from './NewComposition/DismissableModal';
import {useSettings} from './SettingsContext';
import {useEditorOpening} from './use-default-editor-info';
+import {useDownloadProject} from './use-download-project';
const panelStyle: React.CSSProperties = {
borderRadius: 6,
@@ -98,7 +100,10 @@ export const FixComputedValueModal: React.FC<{
? `${sourcePreview.stack.originalFileName}:${sourcePreview.stack.originalLineNumber}:${sourcePreview.stack.originalColumnNumber}`
: `${state.location.source}:${state.location.line}:${state.location.column}`;
const promptDetails = ` ${promptLocation} make "${state.prop}" interactive`;
+ const isBrowserStudio = getBrowserStudioOperations() !== null;
+ const downloadProject = useDownloadProject();
const canAnnotate =
+ !isBrowserStudio &&
sourcePreview.type === 'loaded' &&
!window.remotion_isReadOnlyStudio &&
getCodexAnnotation() !== null;
@@ -202,18 +207,35 @@ export const FixComputedValueModal: React.FC<{
: `Could not load code preview: ${sourcePreview.message}`}
</div>
)}
- <AgentPrompt
- action={
- canAnnotate ? (
- <ModalButton size="compact" onClick={onSendToChatGPT}>
- Send to ChatGPT
- </ModalButton>
- ) : null
- }
- availableText="Use this prompt to make this value editable:"
- promptDetails={promptDetails}
- skillId="remotion-interactivity"
- />
+ {isBrowserStudio ? (
+ <>
+ <div style={text}>
+ This value requires a code change to become editable. Code editing
+ and agent-assisted refactoring are unavailable in
+ remotion.dev/new. Download the project to continue locally.
+ </div>
+ {downloadProject ? (
+ <div style={{marginTop: 16}}>
+ <ModalButton onClick={downloadProject}>
+ Download project
+ </ModalButton>
+ </div>
+ ) : null}
+ </>
+ ) : (
+ <AgentPrompt
+ action={
+ canAnnotate ? (
+ <ModalButton size="compact" onClick={onSendToChatGPT}>
+ Send to ChatGPT
+ </ModalButton>
+ ) : null
+ }
+ availableText="Use this prompt to make this value editable:"
+ promptDetails={promptDetails}
+ skillId="remotion-interactivity"
+ />
+ )}
</div>
</DismissableModal>
);
diff --git a/packages/studio/src/components/InspectorPanel/CompositionInspector.tsx b/packages/studio/src/components/InspectorPanel/CompositionInspector.tsx
index 6a746f2c5b..4489f9082b 100644
--- a/packages/studio/src/components/InspectorPanel/CompositionInspector.tsx
+++ b/packages/studio/src/components/InspectorPanel/CompositionInspector.tsx
@@ -1,5 +1,4 @@
import React, {
- useCallback,
useContext,
useEffect,
useImperativeHandle,
@@ -9,10 +8,7 @@ import React, {
useState,
} from 'react';
import type {_InternalTypes} from 'remotion';
-import {getBrowserStudioOperations} from '../../helpers/browser-studio-operations';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
-import {LIGHT_TEXT} from '../../helpers/colors';
-import {downloadBlob} from '../../helpers/download-blob';
import {isStudioInteractivityEnabled} from '../../helpers/interactivity-enabled';
import {CloudDownloadIcon} from '../../icons/cloud-download';
import {PicIcon} from '../../icons/frame';
@@ -20,12 +16,9 @@ import {SolidIcon} from '../../icons/solid';
import {SparklesIcon} from '../../icons/sparkles';
import {FilmIcon} from '../../icons/video';
import {VisualControlsContext} from '../../visual-controls/VisualControls';
-import {useConfirmationDialog} from '../ConfirmationDialog';
import {DefaultPropsEditor} from '../DefaultPropsEditor';
import {useZodIfPossible, useZodTypesIfPossible} from '../get-zod-if-possible';
-import {LicenseExplanation} from '../LicenseExplanation';
import {VERTICAL_SCROLLBAR_CLASSNAME} from '../Menu/is-menu-item';
-import {showNotification} from '../Notifications/NotificationCenter';
import {ObserveDefaultPropsContext} from '../ObserveDefaultPropsContext';
import {
type DataEditorMode,
@@ -40,6 +33,7 @@ import type {UpdaterFunction} from '../RenderModal/SchemaEditor/ZodSwitch';
import {WarningIndicatorButton} from '../RenderModal/WarningIndicatorButton';
import type {SegmentedControlItem} from '../SegmentedControl';
import {SegmentedControl} from '../SegmentedControl';
+import {useDownloadProject} from '../use-download-project';
import {VisualControlsContent} from '../VisualControls/VisualControlsContent';
import {CollapsibleInspectorSection} from './CollapsibleInspectorSection';
import {CollapsibleInspectorSectionHeader} from './CollapsibleInspectorSectionHeader';
@@ -66,22 +60,6 @@ import {
import {useCompositionActions} from './use-composition-actions';
import {useInspectorSectionExpanded} from './use-inspector-section-expanded';
-const downloadLicenseAgreement: React.CSSProperties = {
- color: LIGHT_TEXT,
- fontFamily: 'sans-serif',
- fontSize: 14,
- lineHeight: 1.5,
- marginBottom: 0,
- marginTop: 20,
-};
-
-const downloadLicenseLink: React.CSSProperties = {
- color: LIGHT_TEXT,
- fontFamily: 'sans-serif',
- fontSize: 14,
- lineHeight: '21px',
-};
-
const CompositionActions: React.FC = () => {
const {
canInsertAsset,
@@ -96,59 +74,7 @@ const CompositionActions: React.FC = () => {
generateWithAgent,
canShowGenerateWithAgent,
} = useCompositionActions();
- const downloadProject = getBrowserStudioOperations()?.downloadProject ?? null;
- const confirm = useConfirmationDialog();
-
- const onDownloadProject = useCallback(async () => {
- if (downloadProject === null) {
- return;
- }
-
- const accepted = await confirm({
- title: 'Download project',
- message: (
- <>
- <LicenseExplanation />
- <p style={downloadLicenseAgreement}>
- By downloading this project, you agree to comply with the{' '}
- <a
- href="https://remotion.dev/license"
- rel="noopener noreferrer"
- style={downloadLicenseLink}
- target="_blank"
- >
- license
- </a>
- .
- </p>
- </>
- ),
- confirmLabel: 'Accept and download',
- cancelLabel: 'Cancel',
- });
- if (!accepted) {
- return;
- }
-
- try {
- const {data, fileName} = await downloadProject();
- const arrayBuffer = data.buffer.slice(
- data.byteOffset,
- data.byteOffset + data.byteLength,
- ) as ArrayBuffer;
- downloadBlob(
- new Blob([arrayBuffer], {type: 'application/zip'}),
- fileName,
- );
- } catch (error) {
- showNotification(
- `Could not download project: ${
- error instanceof Error ? error.message : String(error)
- }`,
- 2000,
- );
- }
- }, [confirm, downloadProject]);
+ const downloadProject = useDownloadProject();
if (
!canShowInsertAsset &&
@@ -219,7 +145,7 @@ const CompositionActions: React.FC = () => {
{downloadProject ? (
<InspectorQuickAction
disabled={false}
- onClick={onDownloadProject}
+ onClick={downloadProject}
renderIcon={(color) => (
<CloudDownloadIcon
color={color}
diff --git a/packages/studio/src/components/InspectorPanel/use-composition-actions.ts b/packages/studio/src/components/InspectorPanel/use-composition-actions.ts
index 45d55dd668..658ca6b0ca 100644
--- a/packages/studio/src/components/InspectorPanel/use-composition-actions.ts
+++ b/packages/studio/src/components/InspectorPanel/use-composition-actions.ts
@@ -95,9 +95,9 @@ export const useCompositionActions = () => {
const canShowInsertComposition = canShowInsertAsset && videoConfig !== null;
const canInsertComposition = canShowInsertComposition && !isAddingComposition;
const canShowGenerateWithAgent =
+ browserStudioOperations === null &&
!window.remotion_isReadOnlyStudio &&
- ((previewInteractive && browserStudioOperations === null) ||
- getCodexAnnotation() !== null) &&
+ (previewInteractive || getCodexAnnotation() !== null) &&
currentCompositionId !== null;
const insertSolid = useCallback(async () => {
diff --git a/packages/studio/src/components/PrecomposeRefactorModal.tsx b/packages/studio/src/components/PrecomposeRefactorModal.tsx
index a75b044e33..f0400156ce 100644
--- a/packages/studio/src/components/PrecomposeRefactorModal.tsx
+++ b/packages/studio/src/components/PrecomposeRefactorModal.tsx
@@ -51,11 +51,12 @@ export const PrecomposeRefactorModal: React.FC<{readonly state: State}> = ({
const markupSkillAvailable = Boolean(
markupSkill?.installedInProject || markupSkill?.installedGlobally,
);
+ const isBrowserStudio = getBrowserStudioOperations() !== null;
const canAnnotate =
+ !isBrowserStudio &&
markupSkillAvailable &&
!window.remotion_isReadOnlyStudio &&
getCodexAnnotation() !== null;
- const isBrowserStudio = getBrowserStudioOperations() !== null;
const canSuggestAgent =
!isBrowserStudio &&
!window.remotion_isReadOnlyStudio &&
@@ -114,7 +115,7 @@ export const PrecomposeRefactorModal: React.FC<{readonly state: State}> = ({
) : (
<div style={text}>
{isBrowserStudio
- ? 'Agent-assisted refactoring is unavailable in Browser Studio.'
+ ? 'Agent-assisted refactoring is unavailable in remotion.dev/new.'
: remotionSkillsInfo === null && error === null
? 'Checking whether /remotion-markup is available...'
: 'The /remotion-markup Agent Skill is unavailable in this Studio.'}
diff --git a/packages/studio/src/components/WrapRefactorModal.tsx b/packages/studio/src/components/WrapRefactorModal.tsx
index 14b0307d6b..82df0e3104 100644
--- a/packages/studio/src/components/WrapRefactorModal.tsx
+++ b/packages/studio/src/components/WrapRefactorModal.tsx
@@ -51,9 +51,11 @@ export const WrapRefactorModal: React.FC<{readonly state: State}> = ({
const markupSkillAvailable = Boolean(
markupSkill?.installedInProject || markupSkill?.installedGlobally,
);
- const canAnnotate =
- !window.remotion_isReadOnlyStudio && getCodexAnnotation() !== null;
const isBrowserStudio = getBrowserStudioOperations() !== null;
+ const canAnnotate =
+ !isBrowserStudio &&
+ !window.remotion_isReadOnlyStudio &&
+ getCodexAnnotation() !== null;
const canSuggestAgent =
!isBrowserStudio &&
!window.remotion_isReadOnlyStudio &&
@@ -117,7 +119,7 @@ export const WrapRefactorModal: React.FC<{readonly state: State}> = ({
) : (
<div style={text}>
{isBrowserStudio
- ? 'Agent-assisted refactoring is unavailable in Browser Studio.'
+ ? 'Agent-assisted refactoring is unavailable in remotion.dev/new.'
: remotionSkillsInfo === null && error === null
? 'Checking whether /remotion-markup is available...'
: 'The /remotion-markup Agent Skill is unavailable in this Studio.'}
diff --git a/packages/studio/src/components/use-download-project.tsx b/packages/studio/src/components/use-download-project.tsx
new file mode 100644
index 0000000000..f8a7b3485a
--- /dev/null
+++ b/packages/studio/src/components/use-download-project.tsx
@@ -0,0 +1,81 @@
+import React, {useCallback} from 'react';
+import {getBrowserStudioOperations} from '../helpers/browser-studio-operations';
+import {LIGHT_TEXT} from '../helpers/colors';
+import {downloadBlob} from '../helpers/download-blob';
+import {useConfirmationDialog} from './ConfirmationDialog';
+import {LicenseExplanation} from './LicenseExplanation';
+import {showNotification} from './Notifications/NotificationCenter';
+
+const downloadLicenseAgreement: React.CSSProperties = {
+ color: LIGHT_TEXT,
+ fontFamily: 'sans-serif',
+ fontSize: 14,
+ lineHeight: 1.5,
+ marginBottom: 0,
+ marginTop: 20,
+};
+
+const downloadLicenseLink: React.CSSProperties = {
+ color: LIGHT_TEXT,
+ fontFamily: 'sans-serif',
+ fontSize: 14,
+ lineHeight: '21px',
+};
+
+export const useDownloadProject = () => {
+ const downloadProject = getBrowserStudioOperations()?.downloadProject ?? null;
+ const confirm = useConfirmationDialog();
+
+ const onDownloadProject = useCallback(async () => {
+ if (downloadProject === null) {
+ return;
+ }
+
+ const accepted = await confirm({
+ title: 'Download project',
+ message: (
+ <>
+ <LicenseExplanation />
+ <p style={downloadLicenseAgreement}>
+ By downloading this project, you agree to comply with the{' '}
+ <a
+ href="https://remotion.dev/license"
+ rel="noopener noreferrer"
+ style={downloadLicenseLink}
+ target="_blank"
+ >
+ license
+ </a>
+ .
+ </p>
+ </>
+ ),
+ confirmLabel: 'Accept and download',
+ cancelLabel: 'Cancel',
+ });
+ if (!accepted) {
+ return;
+ }
+
+ try {
+ const {data, fileName} = await downloadProject();
+ const arrayBuffer = data.buffer.slice(
+ data.byteOffset,
+ data.byteOffset + data.byteLength,
+ ) as ArrayBuffer;
+ downloadBlob(
+ new Blob([arrayBuffer], {type: 'application/zip'}),
+ fileName,
+ );
+ } catch (error) {
+ showNotification(
+ `Could not download project: ${
+ error instanceof Error ? error.message : String(error)
+ }`,
+ 2000,
+ );
+ }
+ }, [confirm, downloadProject]);
+
+ return downloadProject === null ? null : onDownloadProject;
+};