gitdataai/libs/api/room
ZhenYi c89f01b718 feat(room): improve robustness — optimistic send, atomic seq, jitter reconnect
Backend:
- Atomic seq assignment via Redis Lua script: INCR + GET run atomically
  inside a Lua script, preventing duplicate seqs under concurrent requests.
  DB reconciliation only triggers on cross-server handoff (rare path).
- Broadcast channel capacity: 10,000 → 100,000 to prevent message drops
  under high-throughput rooms.

Frontend:
- Optimistic sendMessage: adds message to UI immediately (marked
  isOptimistic=true) so user sees it instantly. Replaces with
  server-confirmed message on success, marks as isOptimisticError on
  failure. Fire-and-forget to IndexedDB for persistence.
- Seq-based dedup in onRoomMessage: replaces optimistic message by
  matching seq, preventing duplicates when WS arrives before REST confirm.
- Reconnect jitter: replaced deterministic backoff with full jitter
  (random within backoff window), preventing thundering herd on server
  restart.
- Visual WS status dot in room header: green=connected, amber
  (pulsing)=connecting, red=error/disconnected.
- isPending check extended to cover both old 'temp-' prefix and new
  isOptimistic flag, showing 'Sending...' / 'Failed' badges.
2026-04-16 19:23:06 +08:00
..
ai.rs init 2026-04-15 09:08:09 +08:00
category.rs init 2026-04-15 09:08:09 +08:00
draft_and_history.rs init 2026-04-15 09:08:09 +08:00
member.rs init 2026-04-15 09:08:09 +08:00
message.rs init 2026-04-15 09:08:09 +08:00
mod.rs init 2026-04-15 09:08:09 +08:00
notification.rs init 2026-04-15 09:08:09 +08:00
pin.rs init 2026-04-15 09:08:09 +08:00
reaction.rs init 2026-04-15 09:08:09 +08:00
room.rs init 2026-04-15 09:08:09 +08:00
thread.rs init 2026-04-15 09:08:09 +08:00
ws_handler.rs init 2026-04-15 09:08:09 +08:00
ws_types.rs init 2026-04-15 09:08:09 +08:00
ws_universal.rs feat(room): improve robustness — optimistic send, atomic seq, jitter reconnect 2026-04-16 19:23:06 +08:00
ws.rs fix(ws): allow APP_DOMAIN_URL and APP_STATIC_DOMAIN origins 2026-04-16 18:51:52 +08:00