From 9072c567060a07c09f0570012a5765309386de32 Mon Sep 17 00:00:00 2001 From: BlitzOS Upstream Prep Date: Wed, 2 Sep 2026 00:25:16 +0000 Subject: [PATCH] feat(components): let a non-Electron host serve the local planes The local Machine RPC, local file preview, local project git state, local project control and local session-control planes all gate on `window.__LODY_ELECTRON__`. The transport behind them is `window.ipc`, which is not Electron-specific: `getIpcServices()` is a generic proxy and the local Loro data plane already gates on that alone. Declare `window.__LODY_LOCAL_BRIDGE__` and accept it beside the Electron flag, so a host that installs `window.ipc` by some other means can reach the same planes. Every predicate is widened by disjunction, so it can only become true where it was false; no Electron path changes. Model: claude-opus-5[1m] --- .../src/providers/create-workspace-runtime.ts | 2 +- .../src/providers/workspace-machine-rpc-facade.ts | 10 ++++++---- packages/components/src/window-globals.d.ts | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/components/src/providers/create-workspace-runtime.ts b/packages/components/src/providers/create-workspace-runtime.ts index 012d2c3e5..1d8f9cce6 100644 --- a/packages/components/src/providers/create-workspace-runtime.ts +++ b/packages/components/src/providers/create-workspace-runtime.ts @@ -2055,7 +2055,7 @@ export async function createWorkspaceRuntime(deps: RuntimeDeps): Promise { - const isElectron = typeof window !== 'undefined' && window.__LODY_ELECTRON__; + const isElectron = + typeof window !== 'undefined' && + (window.__LODY_ELECTRON__ || window.__LODY_LOCAL_BRIDGE__); if (isElectron) { // A local Electron file preview must never fall through to the // Streams RPC plane. Until the target router identifies the machine, @@ -996,7 +998,7 @@ export function createWorkspaceMachineRpcFacade(deps: WorkspaceMachineRpcFacadeD try { await waitForMachineRoute(machineId); if ( - window.__LODY_ELECTRON__ && + (window.__LODY_ELECTRON__ || window.__LODY_LOCAL_BRIDGE__) && getIpcServices() && targetRouter.getPlaneForMachine(machineId) === 'local' ) { @@ -1052,7 +1054,7 @@ export function createWorkspaceMachineRpcFacade(deps: WorkspaceMachineRpcFacadeD try { await waitForMachineRoute(request.machineId); if ( - window.__LODY_ELECTRON__ && + (window.__LODY_ELECTRON__ || window.__LODY_LOCAL_BRIDGE__) && getIpcServices() && targetRouter.getPlaneForMachine(request.machineId) === 'local' ) { diff --git a/packages/components/src/window-globals.d.ts b/packages/components/src/window-globals.d.ts index f4913873e..c08e60df5 100644 --- a/packages/components/src/window-globals.d.ts +++ b/packages/components/src/window-globals.d.ts @@ -28,6 +28,7 @@ declare global { __LODY_NATIVE__?: boolean; __LODY_CORDOVA_READY__?: boolean; __LODY_ELECTRON__?: true; + __LODY_LOCAL_BRIDGE__?: true; __LODY_PLATFORM__?: { os: string; homeDir: string;