Skip to content

🎥 Make videos programmatically with React

Polish Studio paths and installation controls

Jonny Burgercfc5127151f4
diff --git a/packages/studio/src/components/AgentPrompt.tsx b/packages/studio/src/components/AgentPrompt.tsx
index c05d2040f8..d628bb630d 100644
--- a/packages/studio/src/components/AgentPrompt.tsx
+++ b/packages/studio/src/components/AgentPrompt.tsx
@@ -1,12 +1,6 @@
import React, {useCallback, useContext} from 'react';
import {StudioServerConnectionCtx} from '../helpers/client-id';
-import {
- BLACK_ALPHA_30,
- BLUE,
- BORDER_WHITE_ALPHA_12,
- LIGHT_TEXT,
- WHITE,
-} from '../helpers/colors';
+import {BLACK_ALPHA_30, BLUE, LIGHT_TEXT, WHITE} from '../helpers/colors';
import {copyText} from '../helpers/copy-text';
import {useCopyFeedback} from '../helpers/use-copy-feedback';
import {CopyIcon} from '../icons/copy';
@@ -67,7 +61,6 @@ const promptHeader: React.CSSProperties = {
justifyContent: 'space-between',
};
const skillRowContainer: React.CSSProperties = {
- borderTop: BORDER_WHITE_ALPHA_12,
marginTop: 10,
};
const skillError: React.CSSProperties = {marginTop: 10};
@@ -126,7 +119,7 @@ export const AgentPrompt: React.FC<{
role="list"
style={skillRowContainer}
>
- <SkillSettingsRow isLast={false} skill={skill} />
+ <SkillSettingsRow skill={skill} />
</div>
) : (
<div style={commandField}>
diff --git a/packages/studio/src/components/InspectorOpenInEditor.tsx b/packages/studio/src/components/InspectorOpenInEditor.tsx
index 79953d0c66..0802bc8b00 100644
--- a/packages/studio/src/components/InspectorOpenInEditor.tsx
+++ b/packages/studio/src/components/InspectorOpenInEditor.tsx
@@ -5,6 +5,7 @@ import type {OriginalPosition} from '../error-overlay/react-overlay/utils/get-so
import {getBrowserStudioOperations} from '../helpers/browser-studio-operations';
import {StudioServerConnectionCtx} from '../helpers/client-id';
import {LIGHT_TEXT} from '../helpers/colors';
+import {copyText} from '../helpers/copy-text';
import {
getDefaultOpenInTarget,
openGitSource,
@@ -100,6 +101,17 @@ export const InspectorOpenInEditor: React.FC<{
},
[contextForAgents],
);
+ const copyPath = useCallback(() => {
+ if (!location?.source) {
+ return;
+ }
+
+ copyText(location.source)
+ .then(() => showNotification('Copied path', 1500))
+ .catch((err: Error) => {
+ showNotification(`Could not copy path: ${err.message}`, 2000);
+ });
+ }, [location]);
const defaultAppName =
defaultOpenInTarget === 'git-source'
? 'GitHub'
@@ -136,6 +148,8 @@ export const InspectorOpenInEditor: React.FC<{
folder: locationType === 'folder',
gitSourceDisabled: location === null,
onConfigureApps: configureDefaultApps,
+ onCopyPath:
+ locationType === 'folder' && location?.source ? copyPath : undefined,
onOpenInCodingAgent: (codingAgentId, codingAgentName) => {
openWithCodingAgent(codingAgentId, codingAgentName).catch(
() => undefined,
@@ -196,6 +210,7 @@ export const InspectorOpenInEditor: React.FC<{
canConfigureApps,
canOpenInEditor,
configureDefaultApps,
+ copyPath,
defaultEditorId,
defaultOpenInTarget,
editorInfo,
diff --git a/packages/studio/src/components/ModelManager.tsx b/packages/studio/src/components/ModelManager.tsx
index 93576ed88f..6dfc84ab66 100644
--- a/packages/studio/src/components/ModelManager.tsx
+++ b/packages/studio/src/components/ModelManager.tsx
@@ -1,14 +1,11 @@
import {formatBytes} from '@remotion/studio-shared';
import React, {useCallback, useEffect, useRef, useState} from 'react';
-import {
- BLUE,
- BORDER_WHITE_ALPHA_12,
- LIGHT_TEXT,
- WHITE,
-} from '../helpers/colors';
+import {BLUE, LIGHT_TEXT} from '../helpers/colors';
import {CheckCircleFilled} from '../icons/check-circle-filled';
import {CloudDownloadIcon} from '../icons/cloud-download';
+import {ModelsIcon} from '../icons/models';
import {TrashIcon} from '../icons/trash';
+import {ActionTooltip} from './ActionTooltip';
import type {RenderInlineAction} from './InlineAction';
import {InlineAction} from './InlineAction';
import {VERTICAL_SCROLLBAR_CLASSNAME} from './Menu/is-menu-item';
@@ -43,15 +40,14 @@ const descriptionStyle: React.CSSProperties = {
const list: React.CSSProperties = {marginTop: 14};
const modelRow: React.CSSProperties = {
alignItems: 'center',
- borderBottom: BORDER_WHITE_ALPHA_12,
display: 'flex',
gap: 10,
minHeight: 38,
- padding: '0 10px',
};
-const lastModelRow: React.CSSProperties = {
- ...modelRow,
- borderBottom: 'none',
+const modelIcon: React.CSSProperties = {
+ flexShrink: 0,
+ height: 16,
+ width: 16,
};
const statusIcon: React.CSSProperties = {
flexShrink: 0,
@@ -59,7 +55,7 @@ const statusIcon: React.CSSProperties = {
width: 14,
};
const modelName: React.CSSProperties = {
- color: WHITE,
+ color: LIGHT_TEXT,
flex: 1,
fontFamily: 'monospace',
fontSize: 13,
@@ -259,7 +255,7 @@ export const ModelManager = <Model extends string>({
role="list"
aria-label={ariaLabel}
>
- {availableModels.map((model, index) => {
+ {availableModels.map((model) => {
const cached = cachedModels?.has(model.name) ?? false;
const processingThisModel =
actionState.type !== 'idle' &&
@@ -279,13 +275,8 @@ export const ModelManager = <Model extends string>({
: formatBytes(model.webGpuDownloadSize);
return (
- <div
- key={model.name}
- role="listitem"
- style={
- index === availableModels.length - 1 ? lastModelRow : modelRow
- }
- >
+ <div key={model.name} role="listitem" style={modelRow}>
+ <ModelsIcon aria-hidden color={LIGHT_TEXT} style={modelIcon} />
<span style={modelName}>{model.name}</span>
<span style={status} title={modelStatus}>
{modelStatus}
@@ -301,21 +292,37 @@ export const ModelManager = <Model extends string>({
<Spinner duration={0.5} size={14} />
</span>
) : cached ? (
- <InlineAction
- disabled={actionInProgress}
- onClick={() => remove(model.name)}
- renderAction={renderRemoveIcon}
- title={`Remove ${model.name}`}
- variant={null}
- />
+ <ActionTooltip
+ label="Uninstall"
+ shortcut={null}
+ delay={800}
+ dismissOnClick
+ >
+ <InlineAction
+ aria-label={`Remove ${model.name}`}
+ title=""
+ disabled={actionInProgress}
+ onClick={() => remove(model.name)}
+ renderAction={renderRemoveIcon}
+ variant={null}
+ />
+ </ActionTooltip>
) : (
- <InlineAction
- disabled={cachedModels === null || actionInProgress}
- onClick={() => downloadModel(model.name)}
- renderAction={renderDownloadIcon}
- title={`Download ${model.name}`}
- variant={null}
- />
+ <ActionTooltip
+ label="Install"
+ shortcut={null}
+ delay={800}
+ dismissOnClick
+ >
+ <InlineAction
+ aria-label={`Download ${model.name}`}
+ title=""
+ disabled={cachedModels === null || actionInProgress}
+ onClick={() => downloadModel(model.name)}
+ renderAction={renderDownloadIcon}
+ variant={null}
+ />
+ </ActionTooltip>
)}
</div>
);
diff --git a/packages/studio/src/components/SkillsSettings.tsx b/packages/studio/src/components/SkillsSettings.tsx
index 2232bc772a..d8efa6ff0a 100644
--- a/packages/studio/src/components/SkillsSettings.tsx
+++ b/packages/studio/src/components/SkillsSettings.tsx
@@ -1,19 +1,15 @@
import type {GetRemotionSkillsInfoResponse} from '@remotion/studio-shared';
import React, {useCallback, useContext, useMemo} from 'react';
import {StudioServerConnectionCtx} from '../helpers/client-id';
-import {
- BLACK_ALPHA_22,
- BLUE,
- BORDER_WHITE_ALPHA_12,
- LIGHT_TEXT,
- WHITE,
-} from '../helpers/colors';
+import {BLACK_ALPHA_22, BLUE, LIGHT_TEXT, WHITE} from '../helpers/colors';
import {copyText} from '../helpers/copy-text';
import {useCopyFeedback} from '../helpers/use-copy-feedback';
import {CheckCircleFilled} from '../icons/check-circle-filled';
import {CloudDownloadIcon} from '../icons/cloud-download';
import {CopyIcon} from '../icons/copy';
+import {SkillsIcon} from '../icons/skills';
import {TrashIcon} from '../icons/trash';
+import {ActionTooltip} from './ActionTooltip';
import type {RenderInlineAction} from './InlineAction';
import {InlineAction} from './InlineAction';
import {ValidationMessage} from './NewComposition/ValidationMessage';
@@ -71,16 +67,15 @@ const list: React.CSSProperties = {
const skillRow: React.CSSProperties = {
alignItems: 'center',
- borderBottom: BORDER_WHITE_ALPHA_12,
display: 'flex',
gap: 10,
minHeight: 38,
- padding: '0 10px',
};
-const lastSkillRow: React.CSSProperties = {
- ...skillRow,
- borderBottom: 'none',
+const skillIcon: React.CSSProperties = {
+ flexShrink: 0,
+ height: 16,
+ width: 16,
};
const statusIcon: React.CSSProperties = {
@@ -90,7 +85,7 @@ const statusIcon: React.CSSProperties = {
};
const skillName: React.CSSProperties = {
- color: WHITE,
+ color: LIGHT_TEXT,
flex: 1,
fontFamily: 'monospace',
fontSize: 13,
@@ -128,9 +123,8 @@ const loading: React.CSSProperties = {
};
export const SkillSettingsRow: React.FC<{
- readonly isLast: boolean;
readonly skill: GetRemotionSkillsInfoResponse['skills'][number];
-}> = ({isLast, skill}) => {
+}> = ({skill}) => {
const {installSkill, removeSkill, skillAction} = useSettings();
const {previewServerState} = useContext(StudioServerConnectionCtx);
const canInstall =
@@ -154,7 +148,8 @@ export const SkillSettingsRow: React.FC<{
}, []);
return (
- <div role="listitem" style={isLast ? lastSkillRow : skillRow}>
+ <div role="listitem" style={skillRow}>
+ <SkillsIcon aria-hidden color={LIGHT_TEXT} style={skillIcon} />
<span style={skillName}>/{skill.name}</span>
{processingThisSkill ? (
<span style={status}>
@@ -171,25 +166,37 @@ export const SkillSettingsRow: React.FC<{
<Spinner duration={0.5} size={14} />
</span>
) : installed && canInstall ? (
- <InlineAction
- title={
- skill.installedInProject
- ? `Remove ${skill.name} from this project`
- : `Remove ${skill.name} globally`
- }
- disabled={skillAction !== null}
- onClick={() => removeSkill(skill.name)}
- renderAction={renderRemoveAction}
- variant={null}
- />
+ <ActionTooltip
+ label="Uninstall"
+ shortcut={null}
+ delay={800}
+ dismissOnClick
+ >
+ <InlineAction
+ aria-label={`Remove ${skill.name}`}
+ title=""
+ disabled={skillAction !== null}
+ onClick={() => removeSkill(skill.name)}
+ renderAction={renderRemoveAction}
+ variant={null}
+ />
+ </ActionTooltip>
) : canInstall ? (
- <InlineAction
- title={`Install ${skill.name} in this project`}
- disabled={skillAction !== null}
- onClick={() => installSkill(skill.name)}
- renderAction={renderInstallAction}
- variant={null}
- />
+ <ActionTooltip
+ label="Install"
+ shortcut={null}
+ delay={800}
+ dismissOnClick
+ >
+ <InlineAction
+ aria-label={`Install ${skill.name}`}
+ title=""
+ disabled={skillAction !== null}
+ onClick={() => installSkill(skill.name)}
+ renderAction={renderInstallAction}
+ variant={null}
+ />
+ </ActionTooltip>
) : null}
</div>
);
@@ -269,14 +276,8 @@ export const SkillsSettings: React.FC = () => {
) : null}
{remotionSkillsInfo ? (
<div style={list} role="list" aria-label="Remotion Agent Skills">
- {remotionSkillsInfo.skills.map((skill, index) => {
- return (
- <SkillSettingsRow
- key={skill.name}
- isLast={index === remotionSkillsInfo.skills.length - 1}
- skill={skill}
- />
- );
+ {remotionSkillsInfo.skills.map((skill) => {
+ return <SkillSettingsRow key={skill.name} skill={skill} />;
})}
</div>
) : null}
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 c57f4c2343..285d299507 100644
--- a/packages/studio/src/components/get-open-in-menu-items.tsx
+++ b/packages/studio/src/components/get-open-in-menu-items.tsx
@@ -8,7 +8,9 @@ import type {
} from '@remotion/studio-shared';
import React from 'react';
import {NoReactInternals} from 'remotion/no-react';
+import {LIGHT_TEXT} from '../helpers/colors';
import {getFileManagerName} from '../helpers/get-file-manager-name';
+import {ClipboardIcon} from '../icons/clipboard';
import {EditorIcon} from '../icons/editor';
import {FinderIcon} from '../icons/finder';
import {GitClientIcon} from '../icons/git-client';
@@ -24,6 +26,8 @@ const menuLabel: React.CSSProperties = {
lineHeight: '16px',
};
+const copyIcon: React.CSSProperties = {height: 16, width: 16};
+
export const getConfigureDefaultAppsMenuItems = ({
hasPreviousItems,
onConfigureApps,
@@ -65,6 +69,7 @@ export const getOpenInMenuItems = ({
folder,
gitSourceDisabled,
onConfigureApps,
+ onCopyPath,
onOpenInCodingAgent,
onOpenInEditor,
onOpenInFileExplorer,
@@ -83,6 +88,7 @@ export const getOpenInMenuItems = ({
readonly folder: boolean;
readonly gitSourceDisabled: boolean;
readonly onConfigureApps: (() => void) | null;
+ readonly onCopyPath?: () => void;
readonly onOpenInCodingAgent: (
codingAgentId: DefaultCodingAgent,
codingAgentName: string,
@@ -181,6 +187,19 @@ export const getOpenInMenuItems = ({
value: 'file-explorer',
}
: null,
+ onCopyPath
+ ? {
+ id: 'copy-path',
+ keyHint: null,
+ label: <span style={menuLabel}>Copy path</span>,
+ leftItem: <ClipboardIcon color={LIGHT_TEXT} style={copyIcon} />,
+ onClick: onCopyPath,
+ quickSwitcherLabel: 'Copy path',
+ subMenu: null,
+ type: 'item' as const,
+ value: 'copy-path',
+ }
+ : null,
].filter(NoReactInternals.truthy);
const hasCategorizedApps =
editors.length > 0 ||
diff --git a/packages/studio/src/error-overlay/remotion-overlay/OpenInEditor.tsx b/packages/studio/src/error-overlay/remotion-overlay/OpenInEditor.tsx
index e27a99bddc..f8c34c2cb6 100644
--- a/packages/studio/src/error-overlay/remotion-overlay/OpenInEditor.tsx
+++ b/packages/studio/src/error-overlay/remotion-overlay/OpenInEditor.tsx
@@ -8,9 +8,13 @@ import type {ComboboxValue} from '../../components/NewComposition/ComboBox';
import {showNotification} from '../../components/Notifications/NotificationCenter';
import {useSettings} from '../../components/SettingsContext';
import {useConfigureDefaultApps} from '../../components/use-configure-default-apps';
+import {LIGHT_TEXT} from '../../helpers/colors';
+import {copyText} from '../../helpers/copy-text';
import {openInEditor} from '../../helpers/open-in-editor';
import {useKeybinding} from '../../helpers/use-keybinding';
+import {ClipboardIcon} from '../../icons/clipboard';
import {EditorIcon} from '../../icons/editor';
+import {formatLocation} from './format-location';
import {ShortcutHint} from './ShortcutHint';
const menuLabel: React.CSSProperties = {
@@ -20,6 +24,8 @@ const menuLabel: React.CSSProperties = {
lineHeight: '16px',
};
+const copyIcon: React.CSSProperties = {height: 16, width: 16};
+
export const OpenInEditor: React.FC<{
readonly stack: SymbolicatedStackFrame;
readonly canHaveKeyboardShortcuts: boolean;
@@ -30,6 +36,9 @@ export const OpenInEditor: React.FC<{
const {editorInfo} = useSettings();
const configureDefaultApps = useConfigureDefaultApps();
const {registerKeybinding} = useKeybinding();
+ const sourcePath = stack.originalFileName
+ ? formatLocation(stack.originalFileName)
+ : null;
const openWithEditor = useCallback(
async (selectedEditorId: EditorPickerId, selectedEditorName: string) => {
@@ -48,6 +57,17 @@ export const OpenInEditor: React.FC<{
const openPreferredEditor = useCallback(() => {
openWithEditor(editorId, editorName).catch(() => undefined);
}, [editorId, editorName, openWithEditor]);
+ const copyPath = useCallback(() => {
+ if (sourcePath === null) {
+ return;
+ }
+
+ copyText(sourcePath)
+ .then(() => showNotification('Copied path', 1500))
+ .catch((err: Error) => {
+ showNotification(`Could not copy path: ${err.message}`, 2000);
+ });
+ }, [sourcePath]);
useEffect(() => {
if (!canHaveKeyboardShortcuts) {
@@ -84,8 +104,34 @@ export const OpenInEditor: React.FC<{
value: editor.id,
}));
- return editorItems;
- }, [editorId, editorInfo?.installedEditors, openWithEditor]);
+ if (sourcePath === null) {
+ return editorItems;
+ }
+
+ return [
+ ...editorItems,
+ ...(editorItems.length > 0
+ ? [{type: 'divider' as const, id: 'copy-path-divider'}]
+ : []),
+ {
+ id: 'copy-path',
+ keyHint: null,
+ label: <span style={menuLabel}>Copy path</span>,
+ leftItem: <ClipboardIcon color={LIGHT_TEXT} style={copyIcon} />,
+ onClick: copyPath,
+ quickSwitcherLabel: null,
+ subMenu: null,
+ type: 'item',
+ value: 'copy-path',
+ },
+ ];
+ }, [
+ copyPath,
+ editorId,
+ editorInfo?.installedEditors,
+ openWithEditor,
+ sourcePath,
+ ]);
return (
<AppLaunchButton
diff --git a/packages/studio/src/error-overlay/remotion-overlay/StackFrame.tsx b/packages/studio/src/error-overlay/remotion-overlay/StackFrame.tsx
index dd7991415c..d9c734b46c 100644
--- a/packages/studio/src/error-overlay/remotion-overlay/StackFrame.tsx
+++ b/packages/studio/src/error-overlay/remotion-overlay/StackFrame.tsx
@@ -2,7 +2,7 @@ import type {
EditorPickerId,
SymbolicatedStackFrame,
} from '@remotion/studio-shared';
-import React, {useCallback, useState} from 'react';
+import React, {useCallback, useLayoutEffect, useRef, useState} from 'react';
import {Button} from '../../components/Button';
import {CodeFrame} from '../../components/CodeFrame';
import {
@@ -23,7 +23,18 @@ import {formatLocation} from './format-location';
const location: React.CSSProperties = {
color: LIGHT_TEXT,
fontFamily: 'monospace',
- overflowWrap: 'anywhere',
+ textAlign: 'left',
+ whiteSpace: 'nowrap',
+};
+
+const locationMask =
+ 'linear-gradient(to right, black calc(100% - 20px), transparent)';
+
+const locationContainer: React.CSSProperties = {
+ ...location,
+ maskImage: locationMask,
+ overflow: 'hidden',
+ WebkitMaskImage: locationMask,
};
const header: React.CSSProperties = {
@@ -72,6 +83,30 @@ export const StackElement: React.FC<{
!s.originalFileName?.startsWith('webpack/')) ||
isFirst,
);
+ const locationRef = useRef<HTMLDivElement>(null);
+ const [locationOverflows, setLocationOverflows] = useState(false);
+ const fileLocation = s.originalFileName
+ ? `${formatLocation(s.originalFileName)}:${s.originalLineNumber}`
+ : null;
+ useLayoutEffect(() => {
+ const element = locationRef.current;
+ if (!element) {
+ return;
+ }
+
+ const update = () => {
+ setLocationOverflows(element.scrollWidth > element.clientWidth);
+ };
+
+ update();
+ const observer = new ResizeObserver(update);
+ observer.observe(element);
+ if (element.firstElementChild) {
+ observer.observe(element.firstElementChild);
+ }
+
+ return () => observer.disconnect();
+ }, [fileLocation, fontSize]);
const canOpenFileLocation = Boolean(editorId && s.originalFileName);
const onOpenFileLocation = useCallback(() => {
if (!canOpenFileLocation) {
@@ -106,8 +141,12 @@ export const StackElement: React.FC<{
{functionName === null ? null : (
<div style={{...fnName, fontSize}}>{functionName}</div>
)}
- {s.originalFileName ? (
- <div style={{...location, fontSize}}>
+ {fileLocation ? (
+ <div
+ ref={locationRef}
+ style={{...locationContainer, fontSize}}
+ title={locationOverflows ? fileLocation : undefined}
+ >
{canOpenFileLocation ? (
<button
type="button"
@@ -129,14 +168,10 @@ export const StackElement: React.FC<{
padding: 0,
}}
>
- {formatLocation(s.originalFileName as string)}:
- {s.originalLineNumber}
+ {fileLocation}
</button>
) : (
- <>
- {formatLocation(s.originalFileName as string)}:
- {s.originalLineNumber}
- </>
+ fileLocation
)}
</div>
) : null}