🎥 Make videos programmatically with React
Simplify WebMCP outline metadata
JonnyBurger76e9a98ece64
diff --git a/packages/docs/docs/ai/webmcp.mdx b/packages/docs/docs/ai/webmcp.mdxindex 00631ace57..922f6a2ce5 100644--- a/packages/docs/docs/ai/webmcp.mdx+++ b/packages/docs/docs/ai/webmcp.mdx@@ -181,11 +181,13 @@ Returns the measurable selectable component outlines active at the current framecurrentComposition: string | null;currentFrame: number | null;outlines: Array<{- outlineId: string;sequenceId: string;name: string | null;depth: number;- context: string | null;+ location: {+ filename: string;+ line: number;+ } | null;geometry: {points: [{x: number; y: number},diff --git a/packages/example/e2e/studio.test.mts b/packages/example/e2e/studio.test.mtsindex 84fac30431..37fb6491e5 100644--- a/packages/example/e2e/studio.test.mts+++ b/packages/example/e2e/studio.test.mts@@ -2320,8 +2320,10 @@ test.describe('visual mode', () => {readonly outlines: readonly {readonly name: string | null;readonly sequenceId: string;- readonly outlineId: string;- readonly context: string | null;+ readonly location: {+ readonly filename: string;+ readonly line: number;+ } | null;readonly geometry: {readonly points: readonly {readonly x: number;@@ -2343,11 +2345,13 @@ test.describe('visual mode', () => {outlines: expect.any(Array),});expect(gridlineOutline).toEqual({- outlineId: expect.any(String),sequenceId: selectedSequence.sequenceId,name: '0% gridline',depth: expect.any(Number),- context: contextForAgents,+ location: {+ filename: 'src/BarChart.tsx',+ line: expect.any(Number),+ },geometry: {points: expect.arrayContaining([expect.objectContaining({diff --git a/packages/studio/src/components/WebMcp.tsx b/packages/studio/src/components/WebMcp.tsxindex 466a463ae3..0d1b38f477 100644--- a/packages/studio/src/components/WebMcp.tsx+++ b/packages/studio/src/components/WebMcp.tsx@@ -9,7 +9,10 @@ import {play} from '../api/play';import {seek} from '../api/seek';import {calculateTimeline} from '../helpers/calculate-timeline';import {createFolderTree} from '../helpers/create-folder-tree';-import {formatContextForAgents} from '../helpers/format-file-location';+import {+ formatContextForAgents,+ getRelativeFileLocation,+} from '../helpers/format-file-location';import {clampTimelineZoom,TIMELINE_MIN_ZOOM,@@ -518,7 +521,7 @@ export const WebMcp: FC = () => {name: 'get_outlines',title: 'Get Studio canvas outlines',description:- 'Read the active selectable component outlines in the current Remotion Studio canvas, including sequence identity, source-code context, and geometry in composition pixels.',+ 'Read the active selectable component outlines in the current Remotion Studio canvas, including sequence identity, source-code location, and geometry in composition pixels.',inputSchema: {type: 'object',properties: {},@@ -620,13 +623,11 @@ export const WebMcp: FC = () => {const bottom = Math.max(...yValues);return {- outlineId: outline.key,sequenceId: outline.sequence.id,name,depth: outline.depth,- context: formatContextForAgents({+ location: getRelativeFileLocation({location,- name,root: window.remotion_cwd,}),geometry: {diff --git a/packages/studio/src/helpers/format-file-location.ts b/packages/studio/src/helpers/format-file-location.tsindex 9132275532..d967bcc1db 100644--- a/packages/studio/src/helpers/format-file-location.ts+++ b/packages/studio/src/helpers/format-file-location.ts@@ -3,19 +3,24 @@ type FileLocation = {readonly line: number | null;};+export type RelativeFileLocation = {+ readonly filename: string;+ readonly line: number;+};+const normalizeSlashes = (path: string) => path.replace(/\\/g, '/');const stripTrailingSlashes = (path: string) => path.replace(/\/+$/, '');const stripLeadingDotSlash = (path: string) => path.replace(/^\.\/+/, '');-export const formatFileLocation = ({+export const getRelativeFileLocation = ({location,root,}: {readonly location: FileLocation | null;readonly root: string;-}) => {+}): RelativeFileLocation | null => {if (!location?.source || location.line === null) {return null;}@@ -37,7 +42,25 @@ export const formatFileLocation = ({? source.slice(normalizedRoot.length + 1): source;- return `${stripLeadingDotSlash(relativeSource)}:${location.line}`;+ return {+ filename: stripLeadingDotSlash(relativeSource),+ line: location.line,+ };+};++export const formatFileLocation = ({+ location,+ root,+}: {+ readonly location: FileLocation | null;+ readonly root: string;+}) => {+ const relativeLocation = getRelativeFileLocation({location, root});+ if (relativeLocation === null) {+ return null;+ }++ return `${relativeLocation.filename}:${relativeLocation.line}`;};export const formatContextForAgents = ({