fix(app): restore mobile reconnect welcome

This commit is contained in:
Mohamed Boudra
2026-06-12 08:13:45 +07:00
parent 1b6f9300a7
commit cd0aaed1e2
2 changed files with 19 additions and 7 deletions
@@ -259,12 +259,13 @@ describe("resolveStartupRoute", () => {
).toEqual({ kind: "redirect", href: "/h/server-1/workspace/workspace-a" });
});
it("does not restore a workspace whose host is no longer saved", () => {
it("falls back to a saved host when the restored workspace host is no longer saved", () => {
expect(
resolveStartupRoute({
...baseIndexInput,
workspaceSelection: { serverId: "server-saved", workspaceId: "workspace-a" },
hosts: [{ serverId: "server-next" }],
hasGivenUpWaitingForHost: true,
}),
).toEqual({ kind: "redirect", href: "/h/server-next" });
});
@@ -278,17 +279,26 @@ describe("resolveStartupRoute", () => {
).toEqual({ kind: "redirect", href: "/h/srv-desktop" });
});
it("keeps a known connecting host in app-owned routing instead of showing welcome", () => {
it("keeps root startup on the splash while a saved host reconnects", () => {
expect(
resolveStartupRoute({
...baseIndexInput,
hosts: [{ serverId: "server-saved" }],
}),
).toEqual({ kind: "splash" });
});
it("shows welcome after root startup gives up waiting for a saved offline host", () => {
expect(
resolveStartupRoute({
...baseIndexInput,
hosts: [{ serverId: "server-saved" }],
hasGivenUpWaitingForHost: true,
}),
).toEqual({ kind: "redirect", href: "/h/server-saved" });
).toEqual({ kind: "redirect", href: "/welcome" });
});
it("shows welcome only after the host registry is ready and no host exists", () => {
it("shows welcome after root startup gives up and no host exists", () => {
expect(
resolveStartupRoute({
...baseIndexInput,
@@ -183,9 +183,11 @@ function resolveReadyIndexStartupRoute(input: ResolveIndexStartupRouteInput): St
return { kind: "redirect", href: buildHostRootRoute(input.anyOnlineHostServerId) };
}
const savedHostServerId = input.hosts[0]?.serverId ?? null;
if (savedHostServerId) {
return { kind: "redirect", href: buildHostRootRoute(savedHostServerId) };
if (workspaceSelection) {
const fallbackServerId = input.hosts[0]?.serverId ?? null;
if (fallbackServerId) {
return { kind: "redirect", href: buildHostRootRoute(fallbackServerId) };
}
}
if (input.hasGivenUpWaitingForHost) {