Private
Public Access
The service worker cached /api/rooms/mine, /api/rooms, .../messages, .../members, and /api/invites/mine with StaleWhileRevalidate: serve the previous cached response immediately, refresh the cache in the background for next time. That means every repeat visit showed content one visit behind -- reopening a room after someone messaged it, or checking a second device, both showed stale data until a manual reload (which finally picked up the now-revalidated cache). Only registers in a production build (vite dev never activates it), which is why this didn't surface during in-browser testing this session for #26/#27/#34. Switched all five routes to NetworkFirst: always prefer a live response, fall back to cache only when the network request itself fails or times out (genuinely offline), keeping the "readable while offline" behavior without the staleness. Verified against a real production build (`vite preview`, the only way the SW actually registers): sent a message from a second session against an already-cached room, and the very next fetch showed it immediately with no staleness. 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