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
parent 51835ecf90
commit b76ead3fe8
19 changed files with 404 additions and 588 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)
}