hoangsonww / hoangsonww/Threadline-RealTime-Collab
Add a shared client-side identity cache
- Dominant language
- TypeScript
- Stars
- 3
- Forks
- 1
- Avg merge
- 6h 39m
- Merged PRs (30d)
- 4
Description
## Problem
`WorkspaceSidebar`, `WorkspaceTopbar`, and the body of every `/app/**` page each independently call `GET /v1/auth/me` on the same page load. It works — each component is self-contained and doesn't rely on props being threaded down — but it's redundant: a single page load can fire three near-identical identity requests.
## Proposed solution
- Introduce a small React context (e.g. `IdentityProvider`) mounted once in `apps/app/layout.tsx`, alongside or just above `WorkspaceGate`, that fetches `/v1/auth/me` once and exposes the result to descendants.
- Migrate `WorkspaceSidebar`, `WorkspaceTopbar`, and the page bodies that currently call `apiFetch("/v1/auth/me")` directly to read from the context instead.
- Keep `WorkspaceGate`'s own boundary behavior unchanged — it should stay the single place that blocks rendering and redirects on `401`, per its documented role.
## References
- [`docs/roadmap.md`](https://github.com/hoangsonww/Threadline-RealTime-Collab/blob/main/docs/roadmap.md) — "No shared identity cache"
- [`docs/frontend.md#shell-composition`](https://github.com/hoangsonww/Threadline-RealTime-Collab/blob/main/docs/frontend.md)
Contributor guide
Assessment
This issue has not been assessed yet.