Decouple bundled UI from runtime API and add remote instance tooling (#1228)

Add a packaged-client runtime boundary so the shared UI can talk to local,
desktop, remote, and VS Code runtimes through the right transport instead of
assuming one same-origin web server.

Centralize OpenChamber-owned API access behind RuntimeAPIs, runtimeFetch, and
runtime URL helpers, while keeping official OpenCode traffic on the SDK path.
Support runtime switching, remote host selection, desktop client credentials,
and headless connection links for pairing packaged clients with remote
OpenChamber servers.

Harden the new auth model by moving long-lived client tokens out of browser
URLs, introducing short-lived scoped URL tokens for browser-owned transports,
restricting URL-token access to explicit readable/realtime routes, and making
client-token management session-scoped or self-scoped as appropriate.

Update browser-owned assets and preview proxy flows to work with the split
runtime model, including authenticated project icons, preview token propagation,
CSP-safe preview bridge injection, and preview proxy auth that survives
short-lived URL-token expiry.

Tighten Electron security boundaries for packaged clients by gating privileged
preload state to trusted origins and requiring explicit confirmation before
connect deep-links import or switch remote runtimes.

Also refresh agent guidance and project skills so future runtime/API, auth,
preview, UI, CLI, settings, locale, and drag-to-reorder work follows the new
architecture.
This commit is contained in:
Bohdan Triapitsyn
2026-06-02 00:43:05 +03:00
committed by GitHub
parent a4314c189b
commit 2031e3b4a8
282 changed files with 16524 additions and 4259 deletions
+38
View File
@@ -0,0 +1,38 @@
/* eslint-disable react-refresh/only-export-components */
import React from 'react';
export type MobileAppActions = {
/** Open the Changes surface as a modal and (optionally) navigate it to a specific diff. */
openChanges: (options?: { diffPath?: string | null; staged?: boolean }) => void;
/** Open the Files surface as a modal. */
openFiles: () => void;
/** Open the Settings surface as a modal. */
openSettings: () => void;
};
const DedicatedMobileAppContext = React.createContext<MobileAppActions | null>(null);
export const DedicatedMobileAppProvider: React.FC<{
actions: MobileAppActions;
children: React.ReactNode;
}> = ({ actions, children }) => (
<DedicatedMobileAppContext.Provider value={actions}>{children}</DedicatedMobileAppContext.Provider>
);
/**
* Returns true when the surrounding tree is the dedicated MobileApp root
* (Capacitor or hosted /mobile.html), as opposed to the desktop responsive
* mobile path. Use this to suppress UI that exists only to bridge the
* desktop sidebar/layout into mobile, since the dedicated mobile root has
* its own native-feeling navigation and no sidebars to bridge into.
*/
export const useIsDedicatedMobileApp = (): boolean => React.useContext(DedicatedMobileAppContext) !== null;
/**
* Returns the dedicated mobile app's surface-opening actions, or null when
* not inside the dedicated mobile root. Components living in shared chat /
* input code can use this to route navigation to mobile-native surfaces
* (e.g. open the Changes diff for a file from PendingChangesBar) instead of
* desktop sidebars.
*/
export const useMobileAppActions = (): MobileAppActions | null => React.useContext(DedicatedMobileAppContext);