Explorar o código

desktop: fetch defaultServer at top level

Brendan Allan hai 1 mes
pai
achega
885d71636f

+ 2 - 2
packages/app/src/context/platform.tsx

@@ -1,5 +1,5 @@
 import { createSimpleContext } from "@opencode-ai/ui/context"
-import { AsyncStorage, SyncStorage } from "@solid-primitives/storage"
+import type { AsyncStorage, SyncStorage } from "@solid-primitives/storage"
 import type { Accessor } from "solid-js"
 
 type PickerPaths = string | string[] | null
@@ -58,7 +58,7 @@ export type Platform = {
   fetch?: typeof fetch
 
   /** Get the configured default server URL (platform-specific) */
-  getDefaultServerUrl?(): Promise<string | null> | string | null
+  getDefaultServerUrl?(): Promise<string | null>
 
   /** Set the default server URL to use on app startup (platform-specific) */
   setDefaultServerUrl?(url: string | null): Promise<void> | void

+ 13 - 3
packages/desktop/src/index.tsx

@@ -426,6 +426,12 @@ void listenForDeepLinks()
 render(() => {
   const platform = createPlatform()
 
+  const [defaultServer] = createResource(() =>
+    platform.getDefaultServerUrl?.().then((url) => {
+      if (url) return ServerConnection.key({ type: "http", http: { url } })
+    }),
+  )
+
   function handleClick(e: MouseEvent) {
     const link = (e.target as HTMLElement).closest("a.external-link") as HTMLAnchorElement | null
     if (link?.href) {
@@ -466,9 +472,13 @@ render(() => {
             }
 
             return (
-              <AppInterface defaultServer={ServerConnection.key(server)} servers={[server]}>
-                <Inner />
-              </AppInterface>
+              <Show when={defaultServer.loading ? false : defaultServer.latest}>
+                {(defaultServer) => (
+                  <AppInterface defaultServer={defaultServer() ?? ServerConnection.key(server)} servers={[server]}>
+                    <Inner />
+                  </AppInterface>
+                )}
+              </Show>
             )
           }}
         </ServerGate>

+ 2 - 2
packages/opencode/package.json

@@ -55,7 +55,6 @@
     "@actions/core": "1.11.1",
     "@actions/github": "6.0.1",
     "@agentclientprotocol/sdk": "0.14.1",
-    "@aws-sdk/credential-providers": "3.993.0",
     "@ai-sdk/amazon-bedrock": "3.0.79",
     "@ai-sdk/anthropic": "2.0.62",
     "@ai-sdk/azure": "2.0.91",
@@ -75,6 +74,7 @@
     "@ai-sdk/togetherai": "1.0.34",
     "@ai-sdk/vercel": "1.0.33",
     "@ai-sdk/xai": "2.0.51",
+    "@aws-sdk/credential-providers": "3.993.0",
     "@clack/prompts": "1.0.0-alpha.1",
     "@gitlab/gitlab-ai-provider": "3.6.0",
     "@gitlab/opencode-gitlab-auth": "1.3.3",
@@ -107,8 +107,8 @@
     "diff": "catalog:",
     "drizzle-orm": "1.0.0-beta.12-a5629fb",
     "fuzzysort": "3.1.0",
-    "gray-matter": "4.0.3",
     "google-auth-library": "10.5.0",
+    "gray-matter": "4.0.3",
     "hono": "catalog:",
     "hono-openapi": "catalog:",
     "ignore": "7.0.5",