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:
committed by
GitHub
parent
a4314c189b
commit
2031e3b4a8
@@ -1,6 +1,9 @@
|
||||
import { useSessionUIStore } from '@/sync/session-ui-store';
|
||||
import { getSyncSessions } from '@/sync/sync-refs';
|
||||
import { useUIStore } from '@/stores/useUIStore';
|
||||
import { getRuntimeUrlResolver } from './runtime-url';
|
||||
import { opencodeClient } from './opencode/client';
|
||||
import { runtimeFetch } from './runtime-fetch';
|
||||
|
||||
declare const __APP_VERSION__: string | undefined;
|
||||
|
||||
@@ -57,7 +60,7 @@ const safeFetch = async (input: string, timeoutMs = 6000): Promise<ProbeResult>
|
||||
const startedAt = Date.now();
|
||||
|
||||
try {
|
||||
const resp = await fetch(input, {
|
||||
const resp = await runtimeFetch(input, {
|
||||
method: 'GET',
|
||||
headers: { Accept: 'application/json' },
|
||||
signal: controller.signal,
|
||||
@@ -152,14 +155,16 @@ export const buildOpenCodeStatusReport = async (): Promise<string> => {
|
||||
const directory = getCurrentDirectory();
|
||||
const eventStreamStatus = useUIStore.getState().eventStreamStatus;
|
||||
const origin = typeof window !== 'undefined' ? window.location.origin : '';
|
||||
const apiBase = origin ? `${origin.replace(/\/+$/, '')}/api/` : '';
|
||||
const urls = getRuntimeUrlResolver();
|
||||
const healthUrl = urls.health();
|
||||
const apiBase = urls.api('/api/');
|
||||
|
||||
const openChamberHealth: OpenChamberHealthSnapshot | null = await (async () => {
|
||||
if (!origin) return null;
|
||||
if (!healthUrl) return null;
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 5000);
|
||||
try {
|
||||
const resp = await fetch(`${origin.replace(/\/+$/, '')}/health`, {
|
||||
const resp = await runtimeFetch(healthUrl, {
|
||||
method: 'GET',
|
||||
headers: { Accept: 'application/json' },
|
||||
signal: controller.signal,
|
||||
@@ -180,11 +185,11 @@ export const buildOpenCodeStatusReport = async (): Promise<string> => {
|
||||
status: number | null;
|
||||
error: string | null;
|
||||
} = await (async () => {
|
||||
if (!origin) return null;
|
||||
if (!apiBase) return null;
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 7000);
|
||||
try {
|
||||
const resp = await fetch(`${origin.replace(/\/+$/, '')}/api/config/opencode-resolution`, {
|
||||
const resp = await runtimeFetch(urls.api('/api/config/opencode-resolution'), {
|
||||
method: 'GET',
|
||||
headers: { Accept: 'application/json' },
|
||||
signal: controller.signal,
|
||||
@@ -255,7 +260,8 @@ export const buildOpenCodeStatusReport = async (): Promise<string> => {
|
||||
const lines: string[] = [];
|
||||
lines.push(`Time: ${now.toISOString()}`);
|
||||
lines.push(`OpenChamber version: ${appVersion}`);
|
||||
lines.push(`Runtime: ${origin || '(unknown)'} (api=${origin ? origin + '/api' : '(unknown)'})`);
|
||||
lines.push(`Runtime: ${origin || '(unknown)'} (api=${apiBase || '(unknown)'})`);
|
||||
lines.push(`OpenCode SDK base: ${opencodeClient.getBaseUrl()}`);
|
||||
lines.push(`Event stream: ${eventStreamStatus}`);
|
||||
lines.push(`Directory: ${directory || '(none)'}`);
|
||||
lines.push(`Platform: ${platform}`);
|
||||
|
||||
Reference in New Issue
Block a user