From 00381fa7b2cb52d443d848904a617aed8d10687c Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 12 Mar 2026 13:54:18 +0100 Subject: [PATCH] frontend-app-api: add session boundary app initialization Instantiate the app shell up to app/root.children during sign-in, then rebuild the full tree after sign-in without cloning the app tree. Signed-off-by: Patrik Oldsberg Made-with: Cursor --- .../frontend-app-api/src/tree/instantiateAppNodeTree.ts | 6 ++++++ plugins/app/src/extensions/AppRoot.tsx | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/frontend-app-api/src/tree/instantiateAppNodeTree.ts b/packages/frontend-app-api/src/tree/instantiateAppNodeTree.ts index 3de09acf41..85a7baa11c 100644 --- a/packages/frontend-app-api/src/tree/instantiateAppNodeTree.ts +++ b/packages/frontend-app-api/src/tree/instantiateAppNodeTree.ts @@ -509,6 +509,9 @@ export function instantiateAppNodeTree( apis: ApiHolder, collector: ErrorCollector, extensionFactoryMiddleware?: ExtensionFactoryMiddleware, + options?: { + stopAtAttachment?(ctx: { node: AppNode; input: string }): boolean; + }, ): boolean { function createInstance(node: AppNode): AppNodeInstance | undefined { if (node.instance) { @@ -521,6 +524,9 @@ export function instantiateAppNodeTree( const instantiatedAttachments = new Map(); for (const [input, children] of node.edges.attachments) { + if (options?.stopAtAttachment?.({ node, input })) { + continue; + } const instantiatedChildren = children.flatMap(child => { const childInstance = createInstance(child); if (!childInstance) { diff --git a/plugins/app/src/extensions/AppRoot.tsx b/plugins/app/src/extensions/AppRoot.tsx index 07fd3aa4a0..a970ae4463 100644 --- a/plugins/app/src/extensions/AppRoot.tsx +++ b/plugins/app/src/extensions/AppRoot.tsx @@ -73,6 +73,7 @@ export const AppRoot = createExtension({ }), children: createExtensionInput([coreExtensionData.reactElement], { singleton: true, + optional: true, }), elements: createExtensionInput([coreExtensionData.reactElement]), wrappers: createExtensionInput( @@ -105,9 +106,7 @@ export const AppRoot = createExtension({ }); } - let content: ReactNode = inputs.children.get( - coreExtensionData.reactElement, - ); + let content = inputs.children?.get(coreExtensionData.reactElement); for (const wrapper of inputs.wrappers) { const Component = wrapper.get(AppRootWrapperBlueprint.dataRefs.component);