Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Add upgrade and action menu for Agent Skills

Jonny Burgere2fd0d363bfb
diff --git a/packages/studio-server/src/detect-outdated-remotion-skills.ts b/packages/studio-server/src/detect-outdated-remotion-skills.ts
index d79c3c6dd3..7599c76bad 100644
--- a/packages/studio-server/src/detect-outdated-remotion-skills.ts
+++ b/packages/studio-server/src/detect-outdated-remotion-skills.ts
@@ -41,7 +41,7 @@ export const parseRemotionSkillVersion = (contents: string): string | null => {
);
};
-const readRemotionSkill = (
+export const readRemotionSkill = (
skillFile: string,
): {installed: boolean; version: string | null} => {
if (!existsSync(skillFile)) {
diff --git a/packages/studio-server/src/preview-server/api-routes.ts b/packages/studio-server/src/preview-server/api-routes.ts
index a19017eb63..d729919cce 100644
--- a/packages/studio-server/src/preview-server/api-routes.ts
+++ b/packages/studio-server/src/preview-server/api-routes.ts
@@ -34,6 +34,7 @@ import {insertElementHandler} from './routes/insert-element';
import {
installRemotionSkillHandler,
removeRemotionSkillHandler,
+ upgradeRemotionSkillHandler,
} from './routes/install-remotion-skill';
import {invalidateBundleHandler} from './routes/invalidate-bundle';
import {logStudioErrorHandler} from './routes/log-studio-error';
@@ -51,7 +52,10 @@ import {projectInfoHandler} from './routes/project-info';
import {redoHandler} from './routes/redo';
import {registerClientRenderHandler} from './routes/register-client-render';
import {getReleaseNotesHandler} from './routes/release-notes';
-import {remotionSkillsInfoHandler} from './routes/remotion-skills-info';
+import {
+ openRemotionSkillHandler,
+ remotionSkillsInfoHandler,
+} from './routes/remotion-skills-info';
import {handleRemoveRender} from './routes/remove-render';
import {renameCompositionHandler} from './routes/rename-composition';
import {renameFolderHandler} from './routes/rename-folder';
@@ -159,6 +163,8 @@ export const allApiRoutes: {
'/api/remotion-skills-info': remotionSkillsInfoHandler,
'/api/install-remotion-skill': installRemotionSkillHandler,
'/api/remove-remotion-skill': removeRemotionSkillHandler,
+ '/api/upgrade-remotion-skill': upgradeRemotionSkillHandler,
+ '/api/open-remotion-skill': openRemotionSkillHandler,
'/api/project-info': projectInfoHandler,
'/api/delete-static-file': deleteStaticFileHandler,
'/api/rename-static-file': renameStaticFileHandler,
diff --git a/packages/studio-server/src/preview-server/routes/install-remotion-skill.ts b/packages/studio-server/src/preview-server/routes/install-remotion-skill.ts
index 7c4b19a67b..7dfcbfd250 100644
--- a/packages/studio-server/src/preview-server/routes/install-remotion-skill.ts
+++ b/packages/studio-server/src/preview-server/routes/install-remotion-skill.ts
@@ -4,6 +4,7 @@ import type {
GetRemotionSkillsInfoResponse,
InstallRemotionSkillRequest,
RemoveRemotionSkillRequest,
+ UpgradeRemotionSkillRequest,
} from '@remotion/studio-shared';
import {getPackageManagerSpawnOptions} from '../../helpers/package-manager-spawn-options';
import {remotionSkillNames} from '../../remotion-skill-names';
@@ -21,7 +22,7 @@ const changeRemotionSkill = async ({
}: Parameters<
ApiHandler<InstallRemotionSkillRequest, GetRemotionSkillsInfoResponse>
>[0] & {
- readonly action: 'install' | 'remove';
+ readonly action: 'install' | 'remove' | 'upgrade';
}): Promise<GetRemotionSkillsInfoResponse> => {
if (!remotionSkillNames.some((name) => name === skill)) {
throw new Error(`Unknown Remotion skill: ${JSON.stringify(skill)}`);
@@ -29,27 +30,39 @@ const changeRemotionSkill = async ({
if (changingSkillsInProjects.has(remotionRoot)) {
throw new Error(
- 'A skill is already being installed or removed. Please try again once it finishes.',
+ 'A skill is already being installed, upgraded, or removed. Please try again once it finishes.',
);
}
changingSkillsInProjects.add(remotionRoot);
try {
- const installedSkill = getRemotionSkillsInfo({remotionRoot}).skills.find(
- ({name}) => name === skill,
- );
+ const currentInfo = getRemotionSkillsInfo({remotionRoot});
+ const installedSkill = currentInfo.skills.find(({name}) => name === skill);
const removingGlobally =
action === 'remove' &&
installedSkill?.installedInProject === false &&
installedSkill.installedGlobally;
if (
- action === 'remove' &&
- !removingGlobally &&
- !installedSkill?.installedInProject
+ action !== 'install' &&
+ !installedSkill?.installedInProject &&
+ !installedSkill?.installedGlobally
) {
throw new Error(`${skill} is not installed.`);
}
+ const scopes =
+ action === 'upgrade'
+ ? currentInfo.installations
+ .filter(
+ (installation) =>
+ installation.name === skill && installation.outdated,
+ )
+ .map(({scope}) => scope)
+ : [removingGlobally ? 'global' : 'project'];
+ if (scopes.length === 0) {
+ throw new Error(`${skill} is already up to date.`);
+ }
+
const packageManager = getPackageManager({
remotionRoot,
packageManager: undefined,
@@ -63,87 +76,112 @@ const changeRemotionSkill = async ({
: process.platform === 'win32'
? 'npx.cmd'
: 'npx';
- const commandArgs =
- action === 'install'
- ? ['add', `remotion-dev/skills@${skill}`, '--yes']
- : ['remove', ...(removingGlobally ? ['--global'] : []), skill, '--yes'];
- const args = useBunx
- ? ['--silent', '[email protected]', ...commandArgs]
- : ['--yes', '--loglevel=error', '[email protected]', ...commandArgs];
- RenderInternals.Log.info(
- {indent: false, logLevel},
- RenderInternals.chalk.gray(`╭─ ${executable} ${args.join(' ')}`),
- );
- const time = Date.now();
- try {
- await new Promise<void>((resolve, reject) => {
- const child = spawn(executable, args, {
- cwd: remotionRoot,
- env: {...process.env, DISABLE_TELEMETRY: '1'},
- stdio: ['ignore', 'pipe', 'pipe'],
- ...getPackageManagerSpawnOptions(),
+ for (const scope of scopes) {
+ const commandArgs =
+ action === 'remove'
+ ? [
+ 'remove',
+ ...(scope === 'global' ? ['--global'] : []),
+ skill,
+ '--yes',
+ ]
+ : [
+ 'add',
+ `remotion-dev/skills@${skill}`,
+ ...(scope === 'global' ? ['--global'] : []),
+ '--yes',
+ ];
+ const args = useBunx
+ ? ['--silent', '[email protected]', ...commandArgs]
+ : ['--yes', '--loglevel=error', '[email protected]', ...commandArgs];
+ RenderInternals.Log.info(
+ {indent: false, logLevel},
+ RenderInternals.chalk.gray(`╭─ ${executable} ${args.join(' ')}`),
+ );
+ const time = Date.now();
+ try {
+ await new Promise<void>((resolve, reject) => {
+ const child = spawn(executable, args, {
+ cwd: remotionRoot,
+ env: {...process.env, DISABLE_TELEMETRY: '1'},
+ stdio: ['ignore', 'pipe', 'pipe'],
+ ...getPackageManagerSpawnOptions(),
+ });
+ let output = '';
+ const onData = (data: Buffer) => {
+ output = (output + data.toString()).slice(-8000);
+ data
+ .toString()
+ .trim()
+ .split('\n')
+ .forEach((line) =>
+ RenderInternals.Log.info({indent: true, logLevel}, line),
+ );
+ };
+
+ child.stdout.on('data', onData);
+ child.stderr.on('data', onData);
+ child.on('error', reject);
+ child.on('close', (code, signal) => {
+ if (code === 0) {
+ resolve();
+ } else {
+ reject(
+ new Error(
+ `Could not ${action} ${skill} (exit code ${code}, signal ${signal}). ${output.trim()}`,
+ ),
+ );
+ }
+ });
});
- let output = '';
- const onData = (data: Buffer) => {
- output = (output + data.toString()).slice(-8000);
- data
- .toString()
- .trim()
- .split('\n')
- .forEach((line) =>
- RenderInternals.Log.info({indent: true, logLevel}, line),
- );
- };
- child.stdout.on('data', onData);
- child.stderr.on('data', onData);
- child.on('error', reject);
- child.on('close', (code, signal) => {
- if (code === 0) {
- resolve();
- } else {
- reject(
- new Error(
- `Could not ${action} ${skill} (exit code ${code}, signal ${signal}). ${output.trim()}`,
- ),
+ const info = getRemotionSkillsInfo({remotionRoot});
+ const updatedSkill = info.skills.find(({name}) => name === skill);
+ if (action === 'install' && !updatedSkill?.installedInProject) {
+ throw new Error(
+ `The installer finished, but ${skill} was not found in the project. Please try again.`,
+ );
+ }
+
+ if (action === 'upgrade') {
+ const upgradedInstallation = info.installations.find(
+ (installation) =>
+ installation.name === skill && installation.scope === scope,
+ );
+ if (!upgradedInstallation || upgradedInstallation.outdated) {
+ throw new Error(
+ `The installer finished, but ${skill} ${scope === 'global' ? 'globally' : 'in the project'} is still out of date. Please try again.`,
);
}
- });
- });
+ }
- const info = getRemotionSkillsInfo({remotionRoot});
- const updatedSkill = info.skills.find(({name}) => name === skill);
- if (action === 'install' && !updatedSkill?.installedInProject) {
- throw new Error(
- `The installer finished, but ${skill} was not found in the project. Please try again.`,
- );
- }
+ if (
+ action === 'remove' &&
+ (removingGlobally
+ ? updatedSkill?.installedGlobally
+ : updatedSkill?.installedInProject)
+ ) {
+ throw new Error(
+ `The remover finished, but ${skill} is still installed ${removingGlobally ? 'globally' : 'in the project'}. Please try again.`,
+ );
+ }
- if (
- action === 'remove' &&
- (removingGlobally
- ? updatedSkill?.installedGlobally
- : updatedSkill?.installedInProject)
- ) {
- throw new Error(
- `The remover finished, but ${skill} is still installed ${removingGlobally ? 'globally' : 'in the project'}. Please try again.`,
+ RenderInternals.Log.info(
+ {indent: false, logLevel},
+ RenderInternals.chalk.gray('╰─ '),
+ `Done in ${Date.now() - time}ms`,
);
+ } catch (error) {
+ RenderInternals.Log.info(
+ {indent: false, logLevel},
+ RenderInternals.chalk.gray('╰─ '),
+ RenderInternals.chalk.red(`Errored in ${Date.now() - time}ms`),
+ );
+ throw error;
}
-
- RenderInternals.Log.info(
- {indent: false, logLevel},
- RenderInternals.chalk.gray('╰─ '),
- `Done in ${Date.now() - time}ms`,
- );
- return info;
- } catch (error) {
- RenderInternals.Log.info(
- {indent: false, logLevel},
- RenderInternals.chalk.gray('╰─ '),
- RenderInternals.chalk.red(`Errored in ${Date.now() - time}ms`),
- );
- throw error;
}
+
+ return getRemotionSkillsInfo({remotionRoot});
} finally {
changingSkillsInProjects.delete(remotionRoot);
}
@@ -162,3 +200,10 @@ export const removeRemotionSkillHandler: ApiHandler<
> = (input) => {
return changeRemotionSkill({...input, action: 'remove'});
};
+
+export const upgradeRemotionSkillHandler: ApiHandler<
+ UpgradeRemotionSkillRequest,
+ GetRemotionSkillsInfoResponse
+> = (input) => {
+ return changeRemotionSkill({...input, action: 'upgrade'});
+};
diff --git a/packages/studio-server/src/preview-server/routes/remotion-skills-info.ts b/packages/studio-server/src/preview-server/routes/remotion-skills-info.ts
index d47f9e6685..aa23a4ef19 100644
--- a/packages/studio-server/src/preview-server/routes/remotion-skills-info.ts
+++ b/packages/studio-server/src/preview-server/routes/remotion-skills-info.ts
@@ -4,8 +4,15 @@ import path from 'node:path';
import type {
GetRemotionSkillsInfoRequest,
GetRemotionSkillsInfoResponse,
+ OpenRemotionSkillRequest,
} from '@remotion/studio-shared';
-import {getRemotionSkillsDirectories} from '../../detect-outdated-remotion-skills';
+import {VERSION} from 'remotion/version';
+import semver from 'semver';
+import {
+ getRemotionSkillsDirectories,
+ readRemotionSkill,
+} from '../../detect-outdated-remotion-skills';
+import {openDirectoryInFinder} from '../../open-directory-in-finder';
import {
remotionSkillNames,
type RemotionSkillName,
@@ -23,13 +30,37 @@ export const getRemotionSkillsInfo = ({
cwd: remotionRoot,
homeDirectory,
});
+ const installations = remotionSkillNames.flatMap((name) => {
+ return (['project', 'global'] as const).flatMap((scope) => {
+ const {installed, version} = readRemotionSkill(
+ path.join(skillsDirectories[scope], name, 'SKILL.md'),
+ );
+ if (!installed) {
+ return [];
+ }
+
+ return [
+ {
+ name,
+ scope,
+ version,
+ outdated:
+ version === null ||
+ semver.valid(version) === null ||
+ semver.lt(version, VERSION),
+ },
+ ];
+ });
+ });
const skills = remotionSkillNames.map((name) => ({
name,
- installedInProject: existsSync(
- path.join(skillsDirectories.project, name, 'SKILL.md'),
+ installedInProject: installations.some(
+ (installation) =>
+ installation.name === name && installation.scope === 'project',
),
- installedGlobally: existsSync(
- path.join(skillsDirectories.global, name, 'SKILL.md'),
+ installedGlobally: installations.some(
+ (installation) =>
+ installation.name === name && installation.scope === 'global',
),
}));
const isSkillAvailable = (skillName: RemotionSkillName) => {
@@ -42,6 +73,7 @@ export const getRemotionSkillsInfo = ({
remotionInteractivitySkillAvailable: isSkillAvailable(
'remotion-interactivity',
),
+ installations,
skills,
};
};
@@ -50,3 +82,29 @@ export const remotionSkillsInfoHandler: ApiHandler<
GetRemotionSkillsInfoRequest,
GetRemotionSkillsInfoResponse
> = ({remotionRoot}) => Promise.resolve(getRemotionSkillsInfo({remotionRoot}));
+
+export const openRemotionSkillHandler: ApiHandler<
+ OpenRemotionSkillRequest,
+ void
+> = ({remotionRoot, input: {skill, scope}}) => {
+ if (!remotionSkillNames.some((name) => name === skill)) {
+ throw new Error(`Unknown Remotion skill: ${JSON.stringify(skill)}`);
+ }
+
+ if (scope !== 'project' && scope !== 'global') {
+ throw new Error(`Unknown skill scope: ${JSON.stringify(scope)}`);
+ }
+
+ const directories = getRemotionSkillsDirectories({
+ cwd: remotionRoot,
+ homeDirectory: homedir(),
+ });
+ const skillDirectory = path.join(directories[scope], skill);
+ if (!existsSync(path.join(skillDirectory, 'SKILL.md'))) {
+ throw new Error(
+ `${skill} is not installed ${scope === 'global' ? 'globally' : 'in the project'}.`,
+ );
+ }
+
+ return openDirectoryInFinder(skillDirectory, directories[scope]);
+};
diff --git a/packages/studio-server/src/preview-server/update-available.ts b/packages/studio-server/src/preview-server/update-available.ts
index 2def8c5a7d..bd1a296899 100644
--- a/packages/studio-server/src/preview-server/update-available.ts
+++ b/packages/studio-server/src/preview-server/update-available.ts
@@ -1,7 +1,11 @@
+import path from 'node:path';
import type {LogLevel} from '@remotion/renderer';
import type {UpdateAvailableResponse} from '@remotion/studio-shared';
import semver from 'semver';
-import {detectOutdatedRemotionSkills} from '../detect-outdated-remotion-skills';
+import {
+ detectOutdatedRemotionSkills,
+ readRemotionSkill,
+} from '../detect-outdated-remotion-skills';
import {getLatestRemotionVersion} from '../get-latest-remotion-version';
import {getPackageManager} from './get-package-manager';
@@ -11,7 +15,10 @@ const getSkillsUpdateInfo = ({
}: {
remotionRoot: string;
currentVersion: string;
-}) => {
+}): Pick<
+ UpdateAvailableResponse,
+ 'skillsUpdateAvailable' | 'skillsUpdateDetails'
+> => {
const projectSkills = detectOutdatedRemotionSkills({
cwd: remotionRoot,
currentVersion,
@@ -19,6 +26,26 @@ const getSkillsUpdateInfo = ({
return {
skillsUpdateAvailable: projectSkills.type === 'outdated',
+ skillsUpdateDetails:
+ projectSkills.type === 'outdated'
+ ? {
+ outdatedSkills: projectSkills.outdatedSkillNames.map((name) => {
+ const {version} = readRemotionSkill(
+ path.join(projectSkills.skillsDirectory, name, 'SKILL.md'),
+ );
+ return {
+ name,
+ installedVersion: version,
+ reason:
+ version === null
+ ? 'missing-version'
+ : semver.valid(version) === null
+ ? 'invalid-version'
+ : 'older-version',
+ };
+ }),
+ }
+ : null,
};
};
diff --git a/packages/studio-shared/src/api-requests.ts b/packages/studio-shared/src/api-requests.ts
index b4c0b0ac17..e97d492ba8 100644
--- a/packages/studio-shared/src/api-requests.ts
+++ b/packages/studio-shared/src/api-requests.ts
@@ -1300,6 +1300,13 @@ export type UpdateAvailableResponse = {
latestVersion: string;
updateAvailable: boolean;
skillsUpdateAvailable: boolean;
+ skillsUpdateDetails: {
+ outdatedSkills: {
+ name: string;
+ installedVersion: string | null;
+ reason: 'older-version' | 'missing-version' | 'invalid-version';
+ }[];
+ } | null;
timedOut: boolean;
packageManager: PackageManager | 'unknown';
};
@@ -1325,9 +1332,22 @@ export type InstallRemotionSkillRequest = {
export type RemoveRemotionSkillRequest = {
skill: string;
};
+export type UpgradeRemotionSkillRequest = {
+ skill: string;
+};
+export type OpenRemotionSkillRequest = {
+ skill: string;
+ scope: 'project' | 'global';
+};
export type GetRemotionSkillsInfoResponse = {
remotionUpgradeSkillAvailable: boolean;
remotionInteractivitySkillAvailable: boolean;
+ installations: {
+ name: string;
+ scope: 'project' | 'global';
+ version: string | null;
+ outdated: boolean;
+ }[];
skills: {
name: string;
installedInProject: boolean;
@@ -1628,6 +1648,11 @@ export type ApiRoutes = {
RemoveRemotionSkillRequest,
GetRemotionSkillsInfoResponse
>;
+ '/api/upgrade-remotion-skill': ReqAndRes<
+ UpgradeRemotionSkillRequest,
+ GetRemotionSkillsInfoResponse
+ >;
+ '/api/open-remotion-skill': ReqAndRes<OpenRemotionSkillRequest, void>;
'/api/add-composition': ReqAndRes<
AddCompositionRequest,
CompositionEditResponse
diff --git a/packages/studio-shared/src/index.ts b/packages/studio-shared/src/index.ts
index 75650d949f..544f79b352 100644
--- a/packages/studio-shared/src/index.ts
+++ b/packages/studio-shared/src/index.ts
@@ -78,6 +78,8 @@ export {
GetRemotionSkillsInfoResponse,
InstallRemotionSkillRequest,
RemoveRemotionSkillRequest,
+ UpgradeRemotionSkillRequest,
+ OpenRemotionSkillRequest,
GetReleaseNotesRequest,
GetReleaseNotesResponse,
GoogleFontSourceEdit,
diff --git a/packages/studio/src/components/SettingsContext.tsx b/packages/studio/src/components/SettingsContext.tsx
index 0df074df94..2a40efff5a 100644
--- a/packages/studio/src/components/SettingsContext.tsx
+++ b/packages/studio/src/components/SettingsContext.tsx
@@ -21,7 +21,7 @@ import {UpdateStatusProvider} from './UpdateStatusContext';
type SkillAction = {
readonly skill: string;
- readonly type: 'installing' | 'removing';
+ readonly type: 'installing' | 'removing' | 'upgrading';
};
type SettingsContextValue = {
@@ -36,6 +36,7 @@ type SettingsContextValue = {
readonly setPublicLicenseKey: (publicLicenseKey: string | null) => void;
readonly installSkill: (skill: string) => Promise<void>;
readonly removeSkill: (skill: string) => Promise<void>;
+ readonly upgradeSkill: (skill: string) => Promise<void>;
readonly skillAction: SkillAction | null;
readonly skillActionError: string | null;
};
@@ -51,7 +52,7 @@ export const SettingsProvider: React.FC<{
const [settings, setSettings] = useState<
Omit<
SettingsContextValue,
- 'setPublicLicenseKey' | 'installSkill' | 'removeSkill'
+ 'setPublicLicenseKey' | 'installSkill' | 'removeSkill' | 'upgradeSkill'
>
>({
codingAgentInfo: null,
@@ -65,6 +66,7 @@ export const SettingsProvider: React.FC<{
skillAction: null,
skillActionError: null,
});
+ const [skillsRevision, setSkillsRevision] = useState(0);
useEffect(() => {
if (
@@ -162,63 +164,91 @@ export const SettingsProvider: React.FC<{
};
});
}, []);
- const installSkill = useCallback(async (skill: string) => {
- setSettings((currentSettings) => ({
- ...currentSettings,
- skillAction: {skill, type: 'installing'},
- skillActionError: null,
- }));
- try {
- const remotionSkillsInfo = await callApi('/api/install-remotion-skill', {
- skill,
- });
- setSettings((currentSettings) => ({
- ...currentSettings,
- remotionSkillsInfo,
- skillAction: null,
- revision: currentSettings.revision + 1,
- }));
- showNotification(`Installed ${skill}.`, 5000);
- } catch (err) {
+ const changeSkill = useCallback(
+ async (skill: string, action: 'install' | 'remove' | 'upgrade') => {
setSettings((currentSettings) => ({
...currentSettings,
- skillAction: null,
- skillActionError: (err as Error).message,
+ skillAction: {
+ skill,
+ type:
+ action === 'install'
+ ? 'installing'
+ : action === 'upgrade'
+ ? 'upgrading'
+ : 'removing',
+ },
+ skillActionError: null,
}));
- }
- }, []);
- const removeSkill = useCallback(async (skill: string) => {
- setSettings((currentSettings) => ({
- ...currentSettings,
- skillAction: {skill, type: 'removing'},
- skillActionError: null,
- }));
- try {
- const remotionSkillsInfo = await callApi('/api/remove-remotion-skill', {
- skill,
- });
- setSettings((currentSettings) => ({
- ...currentSettings,
- remotionSkillsInfo,
- skillAction: null,
- revision: currentSettings.revision + 1,
- }));
- showNotification(`Removed ${skill}.`, 5000);
- } catch (err) {
- setSettings((currentSettings) => ({
- ...currentSettings,
- skillAction: null,
- skillActionError: (err as Error).message,
- }));
- }
- }, []);
+ try {
+ const endpoint =
+ action === 'install'
+ ? '/api/install-remotion-skill'
+ : action === 'upgrade'
+ ? '/api/upgrade-remotion-skill'
+ : '/api/remove-remotion-skill';
+ const remotionSkillsInfo = await callApi(endpoint, {
+ skill,
+ });
+ setSettings((currentSettings) => ({
+ ...currentSettings,
+ remotionSkillsInfo,
+ skillAction: null,
+ revision: currentSettings.revision + 1,
+ }));
+ setSkillsRevision((revision) => revision + 1);
+ const verb =
+ action === 'install'
+ ? 'Installed'
+ : action === 'upgrade'
+ ? 'Upgraded'
+ : 'Removed';
+ showNotification(`${verb} ${skill}.`, 5000);
+ } catch (err) {
+ const remotionSkillsInfo = await callApi(
+ '/api/remotion-skills-info',
+ {},
+ ).catch(() => null);
+ setSettings((currentSettings) => ({
+ ...currentSettings,
+ remotionSkillsInfo:
+ remotionSkillsInfo ?? currentSettings.remotionSkillsInfo,
+ skillAction: null,
+ skillActionError: (err as Error).message,
+ }));
+ if (remotionSkillsInfo !== null) {
+ setSkillsRevision((revision) => revision + 1);
+ }
+ }
+ },
+ [],
+ );
+ const installSkill = useCallback(
+ (skill: string) => changeSkill(skill, 'install'),
+ [changeSkill],
+ );
+ const removeSkill = useCallback(
+ (skill: string) => changeSkill(skill, 'remove'),
+ [changeSkill],
+ );
+ const upgradeSkill = useCallback(
+ (skill: string) => changeSkill(skill, 'upgrade'),
+ [changeSkill],
+ );
const value = useMemo<SettingsContextValue>(() => {
- return {...settings, setPublicLicenseKey, installSkill, removeSkill};
- }, [installSkill, removeSkill, setPublicLicenseKey, settings]);
+ return {
+ ...settings,
+ setPublicLicenseKey,
+ installSkill,
+ removeSkill,
+ upgradeSkill,
+ };
+ }, [installSkill, removeSkill, setPublicLicenseKey, settings, upgradeSkill]);
return (
<SettingsContext.Provider value={value}>
- <UpdateStatusProvider>{children}</UpdateStatusProvider>
+ <UpdateStatusProvider skillsRevision={skillsRevision}>
+ {children}
+ </UpdateStatusProvider>
</SettingsContext.Provider>
);
};
diff --git a/packages/studio/src/components/SkillsSettings.tsx b/packages/studio/src/components/SkillsSettings.tsx
index 40b1ce99a8..b2b587fc33 100644
--- a/packages/studio/src/components/SkillsSettings.tsx
+++ b/packages/studio/src/components/SkillsSettings.tsx
@@ -1,19 +1,26 @@
import type {GetRemotionSkillsInfoResponse} from '@remotion/studio-shared';
import React, {useCallback, useContext, useMemo} from 'react';
+import {getBrowserStudioOperations} from '../helpers/browser-studio-operations';
import {StudioServerConnectionCtx} from '../helpers/client-id';
-import {BLACK_ALPHA_22, BLUE, LIGHT_TEXT, WHITE} from '../helpers/colors';
+import {BLACK_ALPHA_22, LIGHT_TEXT, WHITE} from '../helpers/colors';
import {copyText} from '../helpers/copy-text';
+import {getFileManagerName} from '../helpers/get-file-manager-name';
+import {canEditStudioConfig} from '../helpers/settings-tab-availability';
import {useCopyFeedback} from '../helpers/use-copy-feedback';
-import {CheckCircleFilled} from '../icons/check-circle-filled';
+import {BookIcon} from '../icons/book';
+import {CaretDown} from '../icons/caret';
import {CloudDownloadIcon} from '../icons/cloud-download';
import {CopyIcon} from '../icons/copy';
+import {FinderIcon} from '../icons/finder';
import {SkillsIcon} from '../icons/skills';
import {TrashIcon} from '../icons/trash';
-import {ActionTooltip} from './ActionTooltip';
+import {callApi} from './call-api';
import type {RenderInlineAction} from './InlineAction';
import {InlineAction} from './InlineAction';
+import type {ComboboxValue} from './NewComposition/ComboBox';
import {ValidationMessage} from './NewComposition/ValidationMessage';
import {showNotification} from './Notifications/NotificationCenter';
+import {SegmentedButton, type SegmentedButtonSegment} from './SegmentedButton';
import {useSettings} from './SettingsContext';
import {Spinner} from './Spinner';
@@ -78,12 +85,6 @@ const skillIcon: React.CSSProperties = {
width: 16,
};
-const statusIcon: React.CSSProperties = {
- flexShrink: 0,
- height: 14,
- width: 14,
-};
-
const skillName: React.CSSProperties = {
color: LIGHT_TEXT,
flex: 1,
@@ -108,15 +109,6 @@ const actionIcon: React.CSSProperties = {
width: 14,
};
-const actionSlot: React.CSSProperties = {
- alignItems: 'center',
- display: 'inline-flex',
- flexShrink: 0,
- height: 24,
- justifyContent: 'center',
- width: 24,
-};
-
const loading: React.CSSProperties = {
...description,
marginTop: 14,
@@ -125,12 +117,28 @@ const loading: React.CSSProperties = {
export const SkillSettingsRow: React.FC<{
readonly skill: GetRemotionSkillsInfoResponse['skills'][number];
}> = ({skill}) => {
- const {installSkill, removeSkill, skillAction} = useSettings();
+ const {
+ installSkill,
+ removeSkill,
+ upgradeSkill,
+ skillAction,
+ remotionSkillsInfo,
+ } = useSettings();
+ const installations = useMemo(
+ () =>
+ (remotionSkillsInfo?.installations ?? []).filter(
+ ({name}) => name === skill.name,
+ ),
+ [remotionSkillsInfo, skill.name],
+ );
const {previewServerState} = useContext(StudioServerConnectionCtx);
- const canInstall =
- !window.remotion_isReadOnlyStudio &&
- previewServerState.type === 'connected';
+ const canManageSkills = canEditStudioConfig({
+ isBrowserStudio: getBrowserStudioOperations() !== null,
+ previewServerConnected: previewServerState.type === 'connected',
+ readOnlyStudio: window.remotion_isReadOnlyStudio,
+ });
const installed = skill.installedInProject || skill.installedGlobally;
+ const upgradeAvailable = installations.some(({outdated}) => outdated);
const processingThisSkill = skillAction?.skill === skill.name;
const installedLocation =
skill.installedInProject && skill.installedGlobally
@@ -140,12 +148,158 @@ export const SkillSettingsRow: React.FC<{
: skill.installedGlobally
? 'Global'
: null;
- const renderInstallAction: RenderInlineAction = useCallback((color) => {
- return <CloudDownloadIcon color={color} style={actionIcon} />;
- }, []);
- const renderRemoveAction: RenderInlineAction = useCallback((color) => {
- return <TrashIcon color={color} style={actionIcon} />;
- }, []);
+ const menuItems = useMemo((): ComboboxValue[] => {
+ const items: ComboboxValue[] = [];
+ if (canManageSkills && installed && upgradeAvailable) {
+ items.push({
+ id: 'delete',
+ value: 'delete',
+ type: 'item',
+ label: 'Delete',
+ leftItem: <TrashIcon color={LIGHT_TEXT} style={actionIcon} />,
+ disabled: skillAction !== null,
+ onClick: () => removeSkill(skill.name),
+ keyHint: null,
+ quickSwitcherLabel: null,
+ subMenu: null,
+ });
+ }
+
+ if (canManageSkills) {
+ const fileManagerName = getFileManagerName(
+ window.remotion_fileSystemPlatform,
+ );
+ for (const installation of installations) {
+ const label =
+ installations.length > 1
+ ? `Open ${installation.scope} skill in ${fileManagerName}`
+ : `Open in ${fileManagerName}`;
+ items.push({
+ id: `open-${installation.scope}`,
+ value: `open-${installation.scope}`,
+ type: 'item',
+ label,
+ leftItem:
+ window.remotion_fileSystemPlatform === 'darwin' ? (
+ <FinderIcon size={16} />
+ ) : null,
+ disabled: skillAction !== null,
+ onClick: () => {
+ callApi('/api/open-remotion-skill', {
+ skill: skill.name,
+ scope: installation.scope,
+ }).catch((err: Error) => {
+ showNotification(`Could not open skill: ${err.message}`, 3000);
+ });
+ },
+ keyHint: null,
+ quickSwitcherLabel: null,
+ subMenu: null,
+ });
+ }
+ }
+
+ items.push({
+ id: 'docs',
+ value: 'docs',
+ type: 'item',
+ label: 'View docs',
+ leftItem: <BookIcon color={LIGHT_TEXT} style={actionIcon} />,
+ onClick: () => {
+ window.open(
+ `https://www.remotion.dev/skills#${skill.name}`,
+ '_blank',
+ 'noopener,noreferrer',
+ );
+ },
+ keyHint: null,
+ quickSwitcherLabel: null,
+ subMenu: null,
+ });
+ return items;
+ }, [
+ canManageSkills,
+ installed,
+ installations,
+ removeSkill,
+ skill.name,
+ skillAction,
+ upgradeAvailable,
+ ]);
+ const segments = useMemo((): SegmentedButtonSegment[] => {
+ const result: SegmentedButtonSegment[] = [];
+ if (canManageSkills) {
+ const actionLabel = upgradeAvailable
+ ? 'Upgrade'
+ : installed
+ ? 'Delete'
+ : 'Install';
+ result.push({
+ ariaLabel: `${actionLabel} ${skill.name}`,
+ buttonId: null,
+ disabled: skillAction !== null,
+ idleColor: LIGHT_TEXT,
+ onClick: () =>
+ upgradeAvailable
+ ? upgradeSkill(skill.name)
+ : installed
+ ? removeSkill(skill.name)
+ : installSkill(skill.name),
+ onPointerDown: null,
+ renderContent: (color) =>
+ processingThisSkill ? (
+ <Spinner duration={0.5} size={14} />
+ ) : installed && !upgradeAvailable ? (
+ <TrashIcon color={color} style={actionIcon} />
+ ) : (
+ <>
+ <CloudDownloadIcon color={color} style={actionIcon} />
+ {upgradeAvailable ? (
+ <span
+ style={{fontSize: 12, lineHeight: '16px', color: 'inherit'}}
+ >
+ Upgrade
+ </span>
+ ) : null}
+ </>
+ ),
+ segmentId: 'primary',
+ style: upgradeAvailable
+ ? {columnGap: 4, padding: '0 4px'}
+ : {padding: 0, width: 24},
+ tooltipLabel: actionLabel,
+ type: 'action',
+ });
+ }
+
+ result.push({
+ ariaLabel: `More actions for ${skill.name}`,
+ buttonId: null,
+ disabled: false,
+ idleColor: LIGHT_TEXT,
+ leaveLeftSpace: true,
+ onOpenChange: null,
+ renderContent: (color) => <CaretDown color={color} />,
+ segmentId: 'secondary',
+ selectedId: null,
+ style: {padding: 0, width: 20},
+ tooltipLabel: 'More actions',
+ type: 'menu',
+ values: menuItems,
+ });
+ return result;
+ }, [
+ canManageSkills,
+ installSkill,
+ installed,
+ menuItems,
+ processingThisSkill,
+ removeSkill,
+ skill.name,
+ skillAction,
+ upgradeAvailable,
+ upgradeSkill,
+ ]);
return (
<div role="listitem" style={skillRow}>
@@ -153,49 +307,19 @@ export const SkillSettingsRow: React.FC<{
<span style={skillName}>/{skill.name}</span>
{processingThisSkill ? (
<span style={status}>
- {skillAction.type === 'installing' ? 'Installing…' : 'Removing…'}
+ {skillAction.type === 'installing'
+ ? 'Installing…'
+ : skillAction.type === 'upgrading'
+ ? 'Upgrading…'
+ : 'Removing…'}
</span>
) : installedLocation ? (
- <span style={status}>{installedLocation}</span>
- ) : null}
- {installed ? (
- <CheckCircleFilled aria-hidden style={{...statusIcon, fill: BLUE}} />
- ) : null}
- {processingThisSkill ? (
- <span style={actionSlot}>
- <Spinner duration={0.5} size={14} />
+ <span style={status}>
+ {installedLocation}
+ {upgradeAvailable ? ' · Out of date' : ''}
</span>
- ) : installed && canInstall ? (
- <ActionTooltip
- label="Uninstall"
- shortcut={null}
- delay={800}
- dismissOnClick
- >
- <InlineAction
- aria-label={`Remove ${skill.name}`}
- disabled={skillAction !== null}
- onClick={() => removeSkill(skill.name)}
- renderAction={renderRemoveAction}
- variant={null}
- />
- </ActionTooltip>
- ) : canInstall ? (
- <ActionTooltip
- label="Install"
- shortcut={null}
- delay={800}
- dismissOnClick
- >
- <InlineAction
- aria-label={`Install ${skill.name}`}
- disabled={skillAction !== null}
- onClick={() => installSkill(skill.name)}
- renderAction={renderInstallAction}
- variant={null}
- />
- </ActionTooltip>
) : null}
+ <SegmentedButton segments={segments} style={null} />
</div>
);
};
@@ -203,9 +327,11 @@ export const SkillSettingsRow: React.FC<{
export const SkillsSettings: React.FC = () => {
const {error, remotionSkillsInfo, skillActionError} = useSettings();
const {previewServerState} = useContext(StudioServerConnectionCtx);
- const canInstall =
- !window.remotion_isReadOnlyStudio &&
- previewServerState.type === 'connected';
+ const canInstall = canEditStudioConfig({
+ isBrowserStudio: getBrowserStudioOperations() !== null,
+ previewServerConnected: previewServerState.type === 'connected',
+ readOnlyStudio: window.remotion_isReadOnlyStudio,
+ });
const {copied, markCopied} = useCopyFeedback();
const installedSkills = useMemo(() => {
return (
diff --git a/packages/studio/src/components/UpdateStatusContext.tsx b/packages/studio/src/components/UpdateStatusContext.tsx
index 3fbe0ce714..13d64c97b0 100644
--- a/packages/studio/src/components/UpdateStatusContext.tsx
+++ b/packages/studio/src/components/UpdateStatusContext.tsx
@@ -42,7 +42,8 @@ const UpdateStatusContext = createContext<UpdateStatusContextValue | null>(
export const UpdateStatusProvider: React.FC<{
readonly children: React.ReactNode;
-}> = ({children}) => {
+ readonly skillsRevision: number;
+}> = ({children, skillsRevision}) => {
const {previewServerState} = useContext(StudioServerConnectionCtx);
const [upgradeState, setUpgradeState] = useState<UpgradeState>('idle');
const [upgradeError, setUpgradeError] = useState<string | null>(null);
@@ -135,7 +136,7 @@ export const UpdateStatusProvider: React.FC<{
updateController.abort();
bugsController.abort();
};
- }, [showUpdates]);
+ }, [showUpdates, skillsRevision]);
const value = useMemo<UpdateStatusContextValue>(() => {
return {
diff --git a/packages/studio/src/components/UpdatesSettings.tsx b/packages/studio/src/components/UpdatesSettings.tsx
index 4be743fac4..0c80ca5f30 100644
--- a/packages/studio/src/components/UpdatesSettings.tsx
+++ b/packages/studio/src/components/UpdatesSettings.tsx
@@ -424,6 +424,35 @@ export const UpdatesSettings: React.FC = () => {
align="flex-start"
/>
) : null}
+ {info.skillsUpdateAvailable ? (
+ <>
+ <div style={title}>Remotion Agent Skills are out of date:</div>
+ {info.skillsUpdateDetails ? (
+ <ul
+ style={{
+ ...text,
+ listStyleType: 'disc',
+ margin: 0,
+ paddingLeft: 20,
+ }}
+ >
+ {info.skillsUpdateDetails.outdatedSkills.map((skill) => (
+ <li
+ key={skill.name}
+ style={{...text, display: 'list-item', listStyleType: 'disc'}}
+ >
+ {skill.name}:{' '}
+ {skill.reason === 'missing-version'
+ ? `The installed version is missing or could not be read. Update to match Remotion v${info.currentVersion}.`
+ : skill.reason === 'invalid-version'
+ ? `The installed version "${skill.installedVersion}" is invalid. Update to match Remotion v${info.currentVersion}.`
+ : `Installed v${skill.installedVersion} is older than Remotion v${info.currentVersion}.`}
+ </li>
+ ))}
+ </ul>
+ ) : null}
+ </>
+ ) : null}
{hasKnownBugs && info.updateAvailable ? (
<>
<div style={title}>
@@ -440,8 +469,8 @@ export const UpdatesSettings: React.FC = () => {
</div>
) : (
<div style={titleBeforeCommand}>
- Your Remotion Agent Skills are out of date. Run the following{' '}
- {updateActionType}:
+ Run the following {updateActionType} in this project to update your
+ skills:
</div>
)}
<div style={commandField}>