diff --git a/packages/app/src/app/host-runtime-bootstrap.test.ts b/packages/app/src/app/host-runtime-bootstrap.test.ts index 479ebae91..5eaf48288 100644 --- a/packages/app/src/app/host-runtime-bootstrap.test.ts +++ b/packages/app/src/app/host-runtime-bootstrap.test.ts @@ -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, diff --git a/packages/app/src/app/host-runtime-bootstrap.ts b/packages/app/src/app/host-runtime-bootstrap.ts index 8db0043fc..49f745bde 100644 --- a/packages/app/src/app/host-runtime-bootstrap.ts +++ b/packages/app/src/app/host-runtime-bootstrap.ts @@ -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) {