# Lobby & forums — handoff

## Summary

Spaces in Paarrot can show a **Lobby** view: a card-based hierarchy of child rooms with drag-and-drop ordering, hero header, and category collapse. **Forum** spaces (`m.forum` room type or `im.paarrot.room.kind` = `forum_space`) use a post-feed style navigation instead of the standard lobby when opened.

## User-facing behavior

- Opening a space lands on lobby (or forum feed for forum spaces)
- Lobby: hero, categories, room cards, DnD reorder (with permissions)
- Forum spaces: routed to post feed per `getSpaceDefaultPath` / `shouldShowForumLobby`
- Category open/closed state persisted per space

## Architecture

```
Space route → Lobby.tsx (SpaceCardLobby)
  → LobbyHeader, LobbyHero, SpaceHierarchy
  → DnD reorder → m.space.child order updates
  → closedLobbyCategories atom (per-space category collapse)
  → shouldShowForumLobby(space) gates forum vs lobby behavior
```

## Key files

| Path | Role |
|------|------|
| `cinny/src/app/features/lobby/Lobby.tsx` | Main lobby view |
| `cinny/src/app/features/lobby/LobbyHeader.tsx` | Space header |
| `cinny/src/app/features/lobby/LobbyHero.tsx` | Hero banner area |
| `cinny/src/app/features/lobby/SpaceHierarchy.tsx` | Room tree/cards |
| `cinny/src/app/features/lobby/DnD.tsx` | Drag and drop |
| `cinny/src/app/features/lobby/RoomItem.tsx` | Room card |
| `cinny/src/app/state/closedLobbyCategories.ts` | Collapsed categories |
| `cinny/src/app/state/hooks/closedLobbyCategories.ts` | Jotai hook |
| `cinny/src/app/pages/pathUtils.ts` | `getSpaceLobbyPath`, forum routing |
| `cinny/src/app/utils/room.ts` | `shouldShowForumLobby`, `getStateEvent` |
| `cinny/src/types/matrix/room.ts` | `RoomType.Forum`, `PaarrotRoomKind` |

## Data model

| Event / field | Purpose |
|---------------|---------|
| `m.space.child` | Child room membership + `order` |
| `im.paarrot.sub_rooms` | Paarrot nested children (see sub-rooms handoff) |
| `im.paarrot.room.kind` | e.g. `forum_space` for forum behavior |
| `m.room.create` `type` | `m.forum` for forum rooms |
| Local: `closedLobbyCategories` | UI collapse state (not Matrix) |

## Dependencies

- Matrix space hierarchy events
- DnD library (see Lobby imports)
- Room power levels for reorder permission (`useCanDropLobbyItem`)

## Integration points

- **Sub-rooms**: `SpaceHierarchy` merges `im.paarrot.sub_rooms` children
- **Navigation**: `getSpaceDefaultPath` chooses lobby vs forum path
- **local-api**: `isSpaceLikeRoom` treats forum kind as space-like for channel API

## Testing

### Manual

1. Open a normal space → lobby with child rooms.
2. Collapse/expand category; reload — state should persist.
3. Drag reorder child (as admin); verify `m.space.child` order.
4. Open forum-type space; verify feed navigation not lobby cards.
5. Test with sub-rooms under a child space card.

### Automated

- None

## Known issues & gotchas

- Forum detection spans **two** signals: `m.forum` create type and `im.paarrot.room.kind`
- DnD permission logic is custom per `useCanDropLobbyItem` — read before changing
- `makeLobbyCategoryId(spaceId, childId)` keys collapse state

## Future work

- Unified hierarchy model (space.child + sub_rooms)
- Lobby theming from space avatar metadata

## Related docs

- [forum HANDOFF](../forum/HANDOFF.md) — post feed UI for forum spaces
- [sub-rooms HANDOFF](../sub-rooms/HANDOFF.md)

## Add your extra things here

- Route constant: `SPACE_LOBBY_PATH` in path utils
- `SpaceCardLobby` is the default export wrapper in `Lobby.tsx`
