diff options
| author | Brendan Allan <[email protected]> | 2026-01-12 17:58:13 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-01-12 17:58:13 +0800 |
| commit | ebbb4dd88a55a69ea1722eb0622b91d697acf507 (patch) | |
| tree | f58ecab8b64f0a2abc4ce725b0073ab6e42e935d /packages/app/src | |
| parent | 087473be6ec4ad21220752de2391e8b882f7058f (diff) | |
| download | opencode-ebbb4dd88a55a69ea1722eb0622b91d697acf507.tar.gz opencode-ebbb4dd88a55a69ea1722eb0622b91d697acf507.zip | |
fix(desktop): improve server detection & connection logic (#7962)
Diffstat (limited to 'packages/app/src')
| -rw-r--r-- | packages/app/src/app.tsx | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/packages/app/src/app.tsx b/packages/app/src/app.tsx index 91e4ae39b..5dfc59a4e 100644 --- a/packages/app/src/app.tsx +++ b/packages/app/src/app.tsx @@ -33,7 +33,7 @@ const Loading = () => <div class="size-full flex items-center justify-center tex declare global { interface Window { - __OPENCODE__?: { updaterEnabled?: boolean; port?: number; serverReady?: boolean; serverUrl?: string } + __OPENCODE__?: { updaterEnabled?: boolean; } } } @@ -65,19 +65,18 @@ function ServerKey(props: ParentProps) { ) } -export function AppInterface() { - const defaultServerUrl = iife(() => { +export function AppInterface(props: { defaultUrl?: string }) { + const defaultServerUrl = () => { + if (props.defaultUrl) return props.defaultUrl; if (location.hostname.includes("opencode.ai")) return "http://localhost:4096" - if (window.__OPENCODE__?.serverUrl) return window.__OPENCODE__.serverUrl - if (window.__OPENCODE__?.port) return `http://127.0.0.1:${window.__OPENCODE__.port}` if (import.meta.env.DEV) return `http://${import.meta.env.VITE_OPENCODE_SERVER_HOST ?? "localhost"}:${import.meta.env.VITE_OPENCODE_SERVER_PORT ?? "4096"}` return window.location.origin - }) + }; return ( - <ServerProvider defaultUrl={defaultServerUrl}> + <ServerProvider defaultUrl={defaultServerUrl()}> <ServerKey> <GlobalSDKProvider> <GlobalSyncProvider> |
