import { atom } from 'jotai';

// Cross-route source of truth for "the room the user is currently looking at",
// independent of URL `roomIdOrAlias` params. Routes that don't carry the room
// id in the URL (e.g. /bots/:botId — the route key is a preset id, the room
// id is derived) write here so that consumers like ClientNonUIFeatures'
// notification suppression know which room is on screen.
//
// Existing /direct, /home, /:spaceId/* routes do NOT need to write here —
// `useSelectedRoom()` resolves their roomId from URL params already, and the
// atom is consulted only as a fallback. Keep writers narrow to avoid having
// two sources of truth racing for routes the URL already covers.
export const viewedRoomIdAtom = atom<string | undefined>(undefined);
