🎥 Make videos programmatically with React
Add agent guidance to the Studio disconnect banner
Jonny Burger22383733615d
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.tsindex aa23a4ef19..f05b01825c 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@@ -69,6 +69,11 @@ export const getRemotionSkillsInfo = ({};return {+ studioServerStartedByAgent: Boolean(+ process.env.CODEX_THREAD_ID ||+ process.env.CURSOR_AGENT ||+ process.env.CLAUDECODE === '1',+ ),remotionUpgradeSkillAvailable: isSkillAvailable('remotion-upgrade'),remotionInteractivitySkillAvailable: isSkillAvailable('remotion-interactivity',diff --git a/packages/studio-shared/src/api-requests.ts b/packages/studio-shared/src/api-requests.tsindex dc39d8eee3..e19dc6ebc4 100644--- a/packages/studio-shared/src/api-requests.ts+++ b/packages/studio-shared/src/api-requests.ts@@ -1340,6 +1340,7 @@ export type OpenRemotionSkillRequest = {scope: 'project' | 'global';};export type GetRemotionSkillsInfoResponse = {+ studioServerStartedByAgent: boolean;remotionUpgradeSkillAvailable: boolean;remotionInteractivitySkillAvailable: boolean;installations: {diff --git a/packages/studio/src/components/Notifications/ServerDisconnected.tsx b/packages/studio/src/components/Notifications/ServerDisconnected.tsxindex e4c179711c..f83e121ae4 100644--- a/packages/studio/src/components/Notifications/ServerDisconnected.tsx+++ b/packages/studio/src/components/Notifications/ServerDisconnected.tsx@@ -1,4 +1,4 @@-import React, {useContext} from 'react';+import React, {useCallback, useContext, useRef} from 'react';import {StudioServerConnectionCtx} from '../../helpers/client-id';import {SERVER_DISCONNECTED_BACKGROUND,@@ -6,6 +6,10 @@ import {TRANSPARENT,WHITE,} from '../../helpers/colors';+import {getCodexAnnotation} from '../../helpers/get-codex-annotation';+import {requestCodexAnnotation} from '../../helpers/request-codex-annotation';+import {Button} from '../Button';+import {useSettings} from '../SettingsContext';const container: React.CSSProperties = {position: 'fixed',@@ -31,6 +35,7 @@ const message: React.CSSProperties = {borderRadius: 4,boxShadow: SERVER_DISCONNECTED_SHADOW,lineHeight: 1.5,+ pointerEvents: 'auto',};const inlineCode: React.CSSProperties = {@@ -38,6 +43,11 @@ const inlineCode: React.CSSProperties = {fontFamily: 'monospace',};+const annotationButton: React.CSSProperties = {+ backgroundColor: TRANSPARENT,+ marginTop: 8,+};+let pageIsGoingToReload = false;window.addEventListener('beforeunload', () => {pageIsGoingToReload = true;@@ -45,6 +55,36 @@ window.addEventListener('beforeunload', () => {export const ServerDisconnected: React.FC = () => {const {previewServerState: ctx} = useContext(StudioServerConnectionCtx);+ const {remotionSkillsInfo} = useSettings();+ const annotationTarget = useRef<HTMLDivElement>(null);+ const canAnnotate = getCodexAnnotation() !== null;+ const isInAgent =+ canAnnotate || remotionSkillsInfo?.studioServerStartedByAgent;+ const restartSkill = isInAgent+ ? (['remotion-studio', 'remotion-best-practices'].find((skillName) =>+ remotionSkillsInfo?.skills.some(+ ({name, installedInProject, installedGlobally}) =>+ name === skillName && (installedInProject || installedGlobally),+ ),+ ) ?? null)+ : null;+ const restartCommand = restartSkill+ ? `/${restartSkill}`+ : window.remotion_studioServerCommand;+ const onSendToChatGPT = useCallback(() => {+ if (restartSkill === null) {+ return;+ }++ requestCodexAnnotation({+ target: annotationTarget.current,+ initialComment: `$${restartSkill} Restart the Remotion Studio server.`,+ metadata: {+ action: 'Restart Studio server',+ skill: restartSkill,+ },+ });+ }, [restartSkill]);const fav = document.getElementById('__remotion_favicon') as HTMLLinkElement;if (ctx.type !== 'disconnected') {@@ -63,19 +103,27 @@ export const ServerDisconnected: React.FC = () => {return (<div style={container} className="css-reset">- <div style={message}>+ <div ref={annotationTarget} style={message} role="alert">The studio server has disconnected. <br />- {window.remotion_studioServerCommand ? (+ {restartCommand ? (<span>- Run{' '}- <code style={inlineCode}>- {window.remotion_studioServerCommand}- </code>{' '}- to run it again.+ Run <code style={inlineCode}>{restartCommand}</code> to run it+ again.</span>) : (<span>Fast refresh will not work.</span>)}+ {canAnnotate && restartSkill ? (+ <div>+ <Button+ size="compact"+ style={annotationButton}+ onClick={onSendToChatGPT}+ >+ Send to ChatGPT+ </Button>+ </div>+ ) : null}</div></div>);