refactor(desktop): rework default server initialization and connection handling (#16965)

This commit is contained in:
Brendan Allan 2026-03-12 16:10:52 +08:00 committed by GitHub
commit b76ead3fe8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 400 additions and 584 deletions

View file

@ -1,3 +1,4 @@
import { usePlatform } from "@/context/platform"
import type { ServerConnection } from "@/context/server"
import { createSdkForServer } from "./server"
@ -81,3 +82,10 @@ export async function checkServerHealth(
.catch((error) => next(count, error))
return attempt(0).finally(() => timeout?.clear?.())
}
export function useCheckServerHealth() {
const platform = usePlatform()
const fetcher = platform.fetch ?? globalThis.fetch
return (http: ServerConnection.HttpBase) => checkServerHealth(http, fetcher)
}