Private
Public Access
refreshHistory() fires twice in quick succession on a fresh load -- once on mount, again when the WS 'joined' envelope arrives shortly after (for the #37 rejoin-resync case) -- with nothing preventing a slower/stale response (e.g. the service worker's NetworkFirst cache falling back on a delayed request) from resolving last and overwriting a newer, correct one. Track the latest-initiated request and drop any response that isn't from it. Confirmed via a production DB check that there are no duplicate created_at timestamps, ruling out the timestamp-precision theory -- the actual scrambling was two competing fetches racing, not a data problem. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
DS Chat frontend (Phase 1)
React + Vite PWA. Login, room list, and chat views wired to the backend's
REST API and /ws/chat WebSocket endpoint. See ../README.md
and ../backend/README.md for full local setup.
Dev
npm install
npm run dev
The dev server proxies /api and /ws to http://localhost:8000 (see
vite.config.ts), so the backend must be running for anything beyond the
login page to work.
Build
npm run build
Generates the PWA manifest and service worker via vite-plugin-pwa into dist/.
Layout
src/
main.tsx, App.tsx routes: /login, /rooms, /rooms/:roomId
api/ fetch wrappers (client, auth, rooms)
ws/useChatSocket.ts WebSocket hook (join/send/receive)
context/AuthContext.tsx current-user state, hydrated via GET /api/auth/me
components/ ProtectedRoute, RoomListItem, MessageList, MessageInput
pages/ LoginPage, RoomListPage, ChatRoomPage