diff options
Diffstat (limited to 'packages/app/src/components/dialog-select-server.tsx')
| -rw-r--r-- | packages/app/src/components/dialog-select-server.tsx | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/packages/app/src/components/dialog-select-server.tsx b/packages/app/src/components/dialog-select-server.tsx index b041bbab6..78f3189b2 100644 --- a/packages/app/src/components/dialog-select-server.tsx +++ b/packages/app/src/components/dialog-select-server.tsx @@ -5,28 +5,13 @@ import { Dialog } from "@opencode-ai/ui/dialog" import { List } from "@opencode-ai/ui/list" import { TextField } from "@opencode-ai/ui/text-field" import { Button } from "@opencode-ai/ui/button" -import { useServer } from "@/context/server" +import { normalizeServerUrl, serverDisplayName, useServer } from "@/context/server" import { usePlatform } from "@/context/platform" import { createOpencodeClient } from "@opencode-ai/sdk/v2/client" import { useNavigate } from "@solidjs/router" type ServerStatus = { healthy: boolean; version?: string } -function displayName(url: string) { - return url - .replace(/^https?:\/\//, "") - .replace(/\/+$/, "") - .split("/")[0] -} - -function normalize(input: string) { - const trimmed = input.trim() - if (!trimmed) return - const withProtocol = /^https?:\/\//.test(trimmed) ? trimmed : `http://${trimmed}` - const cleaned = withProtocol.replace(/\/+$/, "") - return cleaned.replace(/^(https?:\/\/[^/]+).*/, "$1") -} - async function checkHealth(url: string, fetch?: typeof globalThis.fetch): Promise<ServerStatus> { const sdk = createOpencodeClient({ baseUrl: url, @@ -87,7 +72,7 @@ export function DialogSelectServer() { async function handleSubmit(e: SubmitEvent) { e.preventDefault() - const value = normalize(store.url) + const value = normalizeServerUrl(store.url) if (!value) return setStore("adding", true) @@ -131,7 +116,7 @@ export function DialogSelectServer() { "bg-border-weak-base": store.status[i] === undefined, }} /> - <span class="truncate">{displayName(i)}</span> + <span class="truncate">{serverDisplayName(i)}</span> <span class="text-text-weak">{store.status[i]?.version}</span> </div> )} |
