# Message search — handoff

## Summary

In-room and cross-room message search UI: query input, filters, result grouping, and navigation to found events. Uses Matrix `/search` or client-side APIs via `useMessageSearch`.

## User-facing behavior

- Search modal or page with text query
- Filters: room, sender, date (see SearchFilters)
- Results grouped by room/period
- Click result → jump to event in timeline

## Architecture

```
MessageSearch.tsx
  → useMessageSearch.ts
  → SearchInput, SearchFilters, SearchResultGroup
Router may mount search under client routes
```

## Key files

| Path | Role |
|------|------|
| `cinny/src/app/features/message-search/MessageSearch.tsx` | Main UI |
| `cinny/src/app/features/message-search/useMessageSearch.ts` | Search logic |
| `cinny/src/app/features/message-search/SearchInput.tsx` | Query field |
| `cinny/src/app/features/message-search/SearchFilters.tsx` | Filters |
| `cinny/src/app/features/message-search/SearchResultGroup.tsx` | Result list |

## Data model

Ephemeral search state in component hooks. No persistence.

## Dependencies

- `matrix-js-sdk` search API
- Homeserver must support message search (server-dependent)

## Integration points

- **routing-and-navigation**: search routes in home/space
- **room-timeline**: navigation to event id
- **global-search**: separate modal feature — see that handoff

## Testing

### Manual

1. Search known keyword; results appear.
2. Apply room filter; results scoped.
3. Click result; timeline scrolls to event.
4. Test on homeserver without search — expect graceful error.

### Automated

- None

## Known issues & gotchas

- Server-side search availability varies by deployment
- Encrypted room search limited by server/indexing policy
- Pagination in `useMessageSearch` — check for duplicate results

## Future work

- Client-side fallback search for small rooms
- Highlight match in timeline

## Related docs

- [global-search HANDOFF](../global-search/HANDOFF.md)
- [room-timeline HANDOFF](../room-timeline/HANDOFF.md)

## Add your extra things here

- Exported from `features/message-search/index.ts`
