summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/context/server.tsx
diff options
context:
space:
mode:
authorBrendan Allan <[email protected]>2026-02-20 01:38:39 +0800
committerBrendan Allan <[email protected]>2026-02-20 01:38:39 +0800
commit50883cc1e995df3f14e31bdc1b5efa0d70b5ac51 (patch)
tree310ef8f67c09165f57f5990ab3892ef685f818f7 /packages/app/src/context/server.tsx
parentf2858a42ba17fba1e3376440e8f3aae2aa64ca61 (diff)
downloadopencode-50883cc1e995df3f14e31bdc1b5efa0d70b5ac51.tar.gz
opencode-50883cc1e995df3f14e31bdc1b5efa0d70b5ac51.zip
app: make localhost urls work in isLocal
Diffstat (limited to 'packages/app/src/context/server.tsx')
-rw-r--r--packages/app/src/context/server.tsx10
1 files changed, 7 insertions, 3 deletions
diff --git a/packages/app/src/context/server.tsx b/packages/app/src/context/server.tsx
index 389371702..3849bb6ae 100644
--- a/packages/app/src/context/server.tsx
+++ b/packages/app/src/context/server.tsx
@@ -24,11 +24,15 @@ export function serverDisplayName(conn?: ServerConnection.Any) {
function projectsKey(key: ServerConnection.Key) {
if (!key) return ""
if (key === "sidecar") return "local"
- const host = key.replace(/^https?:\/\//, "").split(":")[0]
- if (host === "localhost" || host === "127.0.0.1") return "local"
+ if (isLocalHost(key)) return "local"
return key
}
+function isLocalHost(url: string) {
+ const host = url.replace(/^https?:\/\//, "").split(":")[0]
+ if (host === "localhost" || host === "127.0.0.1") return "local"
+}
+
export namespace ServerConnection {
type Base = { displayName?: string }
@@ -197,7 +201,7 @@ export const { use: useServer, provider: ServerProvider } = createSimpleContext(
)
const isLocal = createMemo(() => {
const c = current()
- return c?.type === "sidecar" && c.variant === "base"
+ return (c?.type === "sidecar" && c.variant === "base") || (c?.type === "http" && isLocalHost(c.http.url))
})
return {