refactor(connect): one live connection, no token in any address (SSE removed)
Plan step 4.0. Owner (2026-11-17): no phone in use needs to keep working, so no
compatibility path.
- Removed the SSE channel: routers/sse.py (/api/sse/stream, which still accepted a JWT whose
session had ended — a signed-out phone could keep listening), services/sse_bus.py (every
backend module now calls services/ws_bus.broadcast_sync directly), waiter useSSE.js.
- Credentials only in the first frame: the waiter's useWebSocket and the manager's
LiveProvider send {token} there like the terminal; routers/ws.py no longer reads ?token=
(a token in a URL ends up in proxy and server logs).
- Waiter: SSEContext → LiveContext (LiveProvider, useLiveContext, liveAlive, the
'live-event' / 'live-reconnected' window events), dead SSE compat code removed.
- Tests: a token in the address is refused, /api/sse/stream is 404; e2e browser (3 delivery
modes) and manager assert no token in the live connection's address. Android taps now
wait for their element (the fixed sleeps made the suite flaky, KI-009).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,13 +19,13 @@ const FLASH_MS = 5 * 60 * 1000 // 5 minutes before bar starts flashing
|
||||
|
||||
const useConnectionStore = create((set, get) => ({
|
||||
status: 'online', // 'online' | 'reconnecting' | 'offline'
|
||||
sseAlive: false, // true when SSE stream is actively connected
|
||||
liveAlive: false, // true when the live connection is up
|
||||
lostAt: null, // Date when connection was first lost
|
||||
flashing: false, // true when offline > 5 min
|
||||
_graceTimer: null,
|
||||
_flashTimer: null,
|
||||
|
||||
setSseAlive: (alive) => set({ sseAlive: alive }),
|
||||
setLiveAlive: (alive) => set({ liveAlive: alive }),
|
||||
|
||||
setLost: () => {
|
||||
const { status, _graceTimer } = get()
|
||||
@@ -58,7 +58,7 @@ const useConnectionStore = create((set, get) => ({
|
||||
isOnline: () => get().status === 'online',
|
||||
isOffline: () => get().status === 'offline' || get().status === 'reconnecting',
|
||||
|
||||
// Legacy compat — SSEContext still calls these
|
||||
// Manual offline entry (immediate, no grace period)
|
||||
enterEmergency: () => {
|
||||
// treated as manual offline entry (immediate, no grace period)
|
||||
const { _graceTimer, _flashTimer } = get()
|
||||
|
||||
Reference in New Issue
Block a user