From 0d4d449d5e2f07ef806b87e7bec9038136527f60 Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Mon, 9 Mar 2026 13:44:37 -0400 Subject: [PATCH] fix(notifications): use orphan parent space for deep-link navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit useNotificationJumper was using roomToParents.get(roomId) — the direct parent set — which could be a subspace rather than a root-level space. The router only recognises /space//room paths, so linking via a subspace ID would hit JoinBeforeNavigate instead of opening the room. Replace with the same logic as useRoomNavigate: getOrphanParents() walks the full hierarchy to find root-level spaces, guessPerfectParent() picks the best one to route through. --- src/app/hooks/useNotificationJumper.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/hooks/useNotificationJumper.ts b/src/app/hooks/useNotificationJumper.ts index 6f7c7768..2f121d9e 100644 --- a/src/app/hooks/useNotificationJumper.ts +++ b/src/app/hooks/useNotificationJumper.ts @@ -8,6 +8,7 @@ import { useSyncState } from './useSyncState'; import { useMatrixClient } from './useMatrixClient'; import { getCanonicalAliasOrRoomId } from '../utils/matrix'; import { getDirectRoomPath, getHomeRoomPath, getSpaceRoomPath } from '../pages/pathUtils'; +import { getOrphanParents, guessPerfectParent } from '../utils/room'; import { roomToParentsAtom } from '../state/room/roomToParents'; import { createLogger } from '../utils/debug'; @@ -62,12 +63,15 @@ export function NotificationJumper() { // If the room lives inside a space, route through the space path so // SpaceRouteRoomProvider can resolve it — HomeRouteRoomProvider only // knows orphan rooms and would show JoinBeforeNavigate otherwise. - const parents = roomToParents.get(pending.roomId); - const firstParentId = parents && [...parents][0]; - if (firstParentId) { + // Use getOrphanParents + guessPerfectParent (same as useRoomNavigate) so + // we always navigate to a root-level space, not a subspace — subspace + // paths are not recognised by the router and land on JoinBeforeNavigate. + const orphanParents = getOrphanParents(roomToParents, pending.roomId); + if (orphanParents.length > 0) { + const parentSpace = guessPerfectParent(mx, pending.roomId, orphanParents) ?? orphanParents[0]; navigate( getSpaceRoomPath( - getCanonicalAliasOrRoomId(mx, firstParentId), + getCanonicalAliasOrRoomId(mx, parentSpace), roomIdOrAlias, pending.eventId )