desktop: fetch defaultServer at top level

This commit is contained in:
Brendan Allan
2026-02-19 21:14:59 +08:00
parent d07f09925f
commit 885d71636f
3 changed files with 17 additions and 7 deletions

View File

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

View File

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

View File

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