# Create flows — handoff

## Summary

UI for creating rooms, spaces, direct chats, and adding existing rooms to spaces. Includes modal renderers mounted at client root and join/create page routes.

## User-facing behavior

- Create room modal (optionally as sub-room of parent)
- Create space modal
- Create DM / group DM
- Add existing room to space
- Create tab in sidebar for quick actions

## Architecture

```
CreateRoomModalRenderer → CreateRoomModal.tsx
CreateSpaceModalRenderer → CreateSpaceModal.tsx
create-chat/ — DM creation
add-existing/ — pick room to add to space
pages/client/create/Create.tsx — create hub
pages/client/direct/DirectCreate.tsx
State: createRoomModal.ts, createSpaceModal.ts
```

## Key files

| Path | Role |
|------|------|
| `cinny/src/app/features/create-room/CreateRoomModal.tsx` | Room create + sub-room parent update |
| `cinny/src/app/features/create-space/CreateSpaceModal.tsx` | Space create |
| `cinny/src/app/features/create-chat/` | DM flows |
| `cinny/src/app/features/add-existing/AddExisting.tsx` | Add to space |
| `cinny/src/app/features/create-room/CreateRoom.tsx` | Standalone create page |
| `cinny/src/app/features/create-space/CreateSpace.tsx` | Standalone space create |
| `cinny/src/app/state/createRoomModal.ts` | Modal state + parent room id |
| `cinny/src/app/state/createSpaceModal.ts` | Space modal state |
| `cinny/src/app/pages/client/create/Create.tsx` | Create hub route |
| `cinny/src/app/pages/client/home/CreateRoom.tsx` | Home create entry |

## Data model

Creates standard Matrix rooms/spaces. Sub-room creation also updates `im.paarrot.sub_rooms` on parent.

## Dependencies

- matrix-js-sdk `createRoom` APIs
- Space parent/child events

## Integration points

- **sub-rooms**: parent id in create room modal
- **room-nav**: opens create sub-room modal
- **routing-and-navigation**: Create routes, modal renderers

## Testing

### Manual

1. Create public room; verify join.
2. Create sub-room under parent; appears in home tree.
3. Create space; add existing room.
4. Start DM from DirectCreate.

### Automated

- None

## Known issues & gotchas

- Sub-room failure after room created leaves orphan — see sub-rooms handoff
- `CreateRoomKindSelector` for room type variants
- Forum room type may need specific create options

## Future work

- Create forum space template
- Batch add rooms to space

## Related docs

- [sub-rooms HANDOFF](../sub-rooms/HANDOFF.md)
- [routing-and-navigation HANDOFF](../routing-and-navigation/HANDOFF.md)

## Add your extra things here

- `useOpenCreateSubRoomModal` hook opens modal with `parentRoomId`
