Fix removed host routes getting stuck connecting

This commit is contained in:
Mohamed Boudra
2026-06-09 18:06:48 +07:00
parent c5bcec5c71
commit e53d26699f
6 changed files with 115 additions and 12 deletions
+21
View File
@@ -355,6 +355,27 @@ export function buildHostOpenProjectRoute(serverId: string) {
return `${base}/open-project` as const;
}
export type KnownHostRouteResolution =
| { kind: "render" }
| { kind: "redirect"; href: ReturnType<typeof buildHostOpenProjectRoute> | "/welcome" };
export function resolveKnownHostRoute(input: {
routeServerId: string | null | undefined;
hosts: readonly { serverId: string }[];
}): KnownHostRouteResolution {
const routeServerId = trimNonEmpty(input.routeServerId);
if (routeServerId && input.hosts.some((host) => host.serverId === routeServerId)) {
return { kind: "render" };
}
const fallbackServerId = input.hosts[0]?.serverId;
if (fallbackServerId) {
return { kind: "redirect", href: buildHostOpenProjectRoute(fallbackServerId) };
}
return { kind: "redirect", href: "/welcome" };
}
export function buildHostNewWorkspaceRoute(
serverId: string,
sourceDirectory?: string,