Skip to content

The VS Code of video editing, built for agents.

TypeScript

Update context command to include workarea trim information in project overview

konstantin-paulusbf0ef2550603
diff --git a/apps/cli/src/index.ts b/apps/cli/src/index.ts
index 2619b2c1..0deb29d6 100644
--- a/apps/cli/src/index.ts
+++ b/apps/cli/src/index.ts
@@ -1110,7 +1110,7 @@ program
.command("context")
.alias("ctx")
.description(
- `Print essential context about the open project (project, entity count, scenes, active scene, playhead, font families); call this first to orient.`,
+ `Print essential context about the open project (project, entity count, scenes, active scene, playhead, workarea trim in seconds when set, font families); call this first to orient.`,
)
.action(() => context());
diff --git a/apps/web/src/context/editor-api/context.ts b/apps/web/src/context/editor-api/context.ts
index 19f8bfeb..a28ad6b6 100644
--- a/apps/web/src/context/editor-api/context.ts
+++ b/apps/web/src/context/editor-api/context.ts
@@ -24,6 +24,16 @@ export function handleContextGet(engine: Accessor<Engine>) {
const entityCount = getAllEntities(world).filter((eid) => !hasComponent(world, eid, c.Deleted)).length;
const activeSceneId = world.selection.scene !== null ? world.selection.scene : null;
const currentFrame = activeSceneId !== null ? (c.Computed.localTime[activeSceneId] ?? 0) : 0;
+
+ const fps = world.frameRate;
+ const workarea =
+ activeSceneId !== null && hasComponent(world, activeSceneId, c.Trim)
+ ? {
+ start: (c.Trim.start[activeSceneId] ?? 0) / fps,
+ end: (c.Trim.end[activeSceneId] ?? 0) / fps,
+ }
+ : null;
+
const fontFamilies = [...new Set(["Inter", ...world.fonts.map((f) => f.family)])];
const projectId = world.projectId;
const projectName = await getProjectName(projectId);
@@ -35,6 +45,7 @@ export function handleContextGet(engine: Accessor<Engine>) {
scenes,
activeSceneId,
currentFrame,
+ workarea,
fontFamilies,
};
}