From c234f9f198c0e7fb61ba06868a3354b6e93268a5 Mon Sep 17 00:00:00 2001 From: Coracle-Bot Date: Wed, 16 Sep 2026 15:37:02 +0000 Subject: [PATCH] Enter a space on the page it was left on or its details page --- e2e/specs/routing.spec.ts | 22 +++++++++++++++++++++- src/app/routes.ts | 17 +++-------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/e2e/specs/routing.spec.ts b/e2e/specs/routing.spec.ts index a5c9a8e6..bce050a8 100644 --- a/e2e/specs/routing.spec.ts +++ b/e2e/specs/routing.spec.ts @@ -1,7 +1,7 @@ import {spec} from "@welshman/lib" import type {TrustedEvent} from "@welshman/util" import {RelayMessageType} from "@welshman/net" -import {expect, getTranscript, roomPath, spacePath, test, users} from "../harness" +import {expect, getTranscript, pathPattern, roomPath, spacePath, test, users} from "../harness" test("keeps two spaces' contents on their own relays", async ({seed, as}) => { const scenario = await seed(({relay, user}) => { @@ -182,3 +182,23 @@ test("switches spaces inside the space menu without closing it", async ({seed, a await expect(page).toHaveURL(new RegExp(`${roomPath(other.url, "garden")}$`)) await expect(drawer).toHaveCount(0) }) + +test("enters a space on its details page whatever its relay advertises", async ({seed, as}) => { + const scenario = await seed(({relay, user}) => { + const space = relay("space") + + space.room("lounge", {name: "Space Lounge"}) + space.join(user.alice, "lounge") + }) + + const space = scenario.space("space") + + // A relay whose document claims no nip-29. The entry path used to read that as "open the chat + // page", which a cold load could never get right: the document arrives after the first + // navigation, so a space opened on chat and corrected itself to about a moment later. + const relayInfo = {[space.url]: {supported_nips: [1, 11, 42]}} + const page = await as(users.alice, spacePath(space.url), {relayInfo}) + + await expect(page).toHaveURL(pathPattern(spacePath(space.url) + "/about")) + await expect(page.locator('[data-component="PageBar"]')).toContainText("Space Details") +}) diff --git a/src/app/routes.ts b/src/app/routes.ts index 0481b61a..9e13ca60 100644 --- a/src/app/routes.ts +++ b/src/app/routes.ts @@ -18,7 +18,7 @@ import { tagValue, tagValues, } from "@welshman/util" -import {app, messagingRelayLists, relays, user} from "@app/core" +import {app, messagingRelayLists, user} from "@app/core" import {makeChatId} from "@app/chats" import {entityLink, PLATFORM_URL, PLATFORM_RELAYS} from "@app/env" import {decodeRelay, encodeRelay} from "@app/relays" @@ -95,19 +95,8 @@ export const makeSpacePath = (url: string, ...extra: (string | undefined)[]) => export const forgetSpacePage = (url: string) => lastPageBySpaceUrl.delete(url) -export const makeSpaceEntryPath = (url: string) => { - const prevPath = lastPageBySpaceUrl.get(url) - - if (prevPath) { - return prevPath - } - - if (!relays.get().get(url)?.hasNip(29)) { - return makeSpaceChatPath(url) - } - - return makeSpacePath(url, "about") -} +export const makeSpaceEntryPath = (url: string) => + lastPageBySpaceUrl.get(url) ?? makeSpacePath(url, "about") export const goToSpace = (url: string, options: {replaceState?: boolean} = {}) => navigate(makeSpaceEntryPath(url), options)