The VS Code of video editing, built for agents.
TypeScript
Focus camera on newly mounted scenes
konstantin-paulusdd1d7646419c
diff --git a/apps/cli/src/index.ts b/apps/cli/src/index.tsindex 10b5c0fd..f6466c27 100644--- a/apps/cli/src/index.ts+++ b/apps/cli/src/index.ts@@ -1087,7 +1087,7 @@ programprogram.command("mount").description(- `Compile a Solid JSX project module and mount its roots into the canvas. Re-mounting reconciles rather than duplicates: each top-level element carries a \`key\`, and a root replaces the node with that key or creates it (a new <scene key> becomes the active scene). Long-running when the module declares AI assets (blocks until generation finishes). Compile errors fail before the app is contacted; on success, inspect the result with \`dapi context\` or \`dapi node tree\`.`,+ `Compile a Solid JSX project module and mount its roots into the canvas. Re-mounting reconciles rather than duplicates: each top-level element carries a \`key\`, and a root replaces the node with that key or creates it (a new <scene key> becomes the active scene and the camera focuses it). Long-running when the module declares AI assets (blocks until generation finishes). Compile errors fail before the app is contacted; on success, inspect the result with \`dapi context\` or \`dapi node tree\`.`,).argument("[path]", "path to a .tsx / .jsx / .ts / .js entry module").option("--code <str>", "inline module source; export default wrapper optional for bare JSX")diff --git a/apps/web/src/context/editor-api/mount.ts b/apps/web/src/context/editor-api/mount.tsindex b0004f15..23de95ad 100644--- a/apps/web/src/context/editor-api/mount.ts+++ b/apps/web/src/context/editor-api/mount.ts@@ -50,6 +50,7 @@ export function handleMount(engine: Accessor<Engine>) {if (document.rootEid && hasComponent(world, document.rootEid, c.Scene)) {switchActiveScene(world, document.rootEid);+ if (document.rootCreated) e.camera.fitToActiveScene();}} catch (error) {return { status: "rejected", error: error instanceof Error ? error.message : String(error) };diff --git a/apps/web/src/utils/jsx.ts b/apps/web/src/utils/jsx.tsindex c80c3abf..5eb1e591 100644--- a/apps/web/src/utils/jsx.ts+++ b/apps/web/src/utils/jsx.ts@@ -199,6 +199,8 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {public promises: Promise<void>[] = [];public stage: DocumentNode;public rootEid: number | null = null;+ /** Whether the root was created fresh rather than reconciled onto an existing keyed node. */+ public rootCreated = false;public engine: Engine;private queue: GenaiQueueItem[] = [];@@ -822,6 +824,8 @@ export class WorldDocument implements ProjectDocument<DocumentNode> {const existing = query(this.world, [c.Key, Not(c.Deleted)]).find((eid) => eid !== node.eid && c.Key[eid] === key);+ this.rootCreated = existing === undefined;+if (existing === undefined) {const width = c.Computed.width[node.eid] ?? 0;const height = c.Computed.height[node.eid] ?? 0;