diff options
Diffstat (limited to 'packages/app/src/components')
| -rw-r--r-- | packages/app/src/components/dialog-select-server.tsx | 21 | ||||
| -rw-r--r-- | packages/app/src/components/status-bar.tsx | 6 |
2 files changed, 7 insertions, 20 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> )} diff --git a/packages/app/src/components/status-bar.tsx b/packages/app/src/components/status-bar.tsx index bfc428fca..0ca403d72 100644 --- a/packages/app/src/components/status-bar.tsx +++ b/packages/app/src/components/status-bar.tsx @@ -34,10 +34,12 @@ export function StatusBar(props: ParentProps) { <div classList={{ "size-1.5 rounded-full": true, - "bg-icon-success-base": server.healthy(), - "bg-icon-critical-base": !server.healthy(), + "bg-icon-success-base": server.healthy() === true, + "bg-icon-critical-base": server.healthy() === false, + "bg-border-weak-base": server.healthy() === undefined, }} /> + <span class="text-12-regular text-text-weak">{server.name}</span> </Button> </div> |
