Skip to content

Recipe/main - #47

Merged
MisterPapaye merged 9 commits into
mainfrom
recipe/main
Sep 19, 2026
Merged

MisterPapaye merged 9 commits into
mainfrom
recipe/main

Conversation

@MisterPapaye

Copy link
Copy Markdown
Member

No description provided.

MisterPapaye and others added 9 commits September 19, 2026 18:42
…planation popup

Same treatment as the ephemeral-session shield in PrivateMeetView.vue: the
"Chiffrement..."/"Appel sécurisé" text pill (fullscreen header and the
minimized floating window) is now an icon-only button. Clicking it opens
a popup explaining how DM calls are actually secured — direct P2P
connection (live direct/relay status via getConnectionType), the
DTLS-SRTP + ECDH session-key double encryption layer, and the SAS
anti-interception verification, with a button to start that verification
right from the popup (or a "code vérifié" confirmation once done) instead
of requiring a second click through a separate badge state.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ader

Same shield-button + explanation-popup pattern as DM calls (CallOverlay.vue)
and ephemeral sessions (PrivateMeetView.vue), added to ThreadLayout.vue's
shared header — covers both ThreadView.vue (text) and VoiceThreadView.vue
(voice) in one place, since neither owns its own header.

Content is accurate to this architecture specifically, not copy-pasted from
the P2P cases: threads are server-relayed and keep history (unlike a DM
call or an ephemeral session), so the popup explains per-thread key
distribution (RSA-wrapped per member) and that messages/voice are encrypted
client-side before ever reaching the server — never claims "peer-to-peer",
which wouldn't be true here. Voice thread encryption was verified against
useLiveKit.ts's ExternalE2EEKeyProvider/E2EEWorker setup (frame-level
encryption using the same unwrapped thread key) before writing the copy.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…, stop DM loading from hanging silently

Three issues diagnosed from a production console dump (app.synco.one):

1. Debug logging active in prod — App.vue's "[DEBUG]" console.log calls
   (health check, initKC, onMounted...), useWSocket.ts's routine connection
   status logs, useSecurePeer.ts's "[SECURE-PEER]" call-negotiation tracing
   (added during this session's call-redesign work, never stripped), and
   useNotification.ts's platform-init logs were all unconditional
   console.log/warn — visible verbatim in the pasted prod console. New
   debugLog()/debugWarn() (src/assets/utils/debugLog.ts) gate these behind
   import.meta.env.DEV — Vite's own automatic flag, not the project's
   hand-set VITE_DEV var (already proven fragile: found misconfigured in a
   local .env earlier this session). Genuine console.error/warn for real
   failures (connection errors, timeouts, security rejections) are left
   untouched — those are legitimate prod diagnostics, not "debug" noise.

2. "Le WS ne fonctionne plus parfois" — the production log showed both
   useSecurePeer.ts's and usePrivatMeet.ts's PeerJS Peer losing its
   connection to the signaling server ("Lost connection to server"), then
   nothing: neither file's 'disconnected' handler called peer.reconnect().
   Unlike the app's main socket.io connection (reconnection:true,
   configured in useWSocket.ts), PeerJS's Peer object never auto-reconnects
   its own signaling connection — confirmed via its source (close()/
   disconnect handling is local-only, no retry). A disconnected Peer can
   neither receive incoming calls/sessions nor place outgoing ones, with no
   recovery short of a full page reload. New shared
   src/assets/utils/peerReconnect.ts (createPeerReconnector) schedules
   peer.reconnect() with a capped backoff mirroring useWSocket.ts's own
   (1s up to 5s), reset on the peer's next 'open' and cancelled on
   intentional teardown — wired into both files' 'disconnected' handlers.

3. "Le chargement des DM est très long" — ChatView.vue's onMounted only
   waited for `socket.value` to be non-null before joining a DM, but
   useWSocket.ts assigns that ref as soon as the socket.io client object is
   constructed, well before the underlying WebSocket handshake actually
   completes — so on a slow/flaky connection (exactly what's in the prod
   log: repeated "Firefox can't establish a connection" / timeouts),
   join-dm fired on a not-yet-connected socket. socket.io queues it
   silently until connected, with no feedback or timeout — the view just
   sat on its loading skeleton for however long the handshake took. Now
   explicitly awaits waitForSocketConnection(socket, 15000) first and shows
   an error toast on timeout instead of hanging indefinitely, mirroring the
   pattern ThreadView.vue already used for workspace threads.

Also dropped a stray leftover console.log(targetEl) in
scrollToSelectedMessage (ChatView.vue) — pure debug scaffolding, no
purpose.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…sconnects

Root cause of the "socket.io disconnects randomly" reports: the server
revalidates each socket's token every 60s (ws.ts) and disconnects
immediately if it's expired at that instant. Client-side, keycloak-js's
onTokenExpired fires via a single setTimeout scheduled for exactly
(exp - now) — zero margin — so the refresh round-trip (updateToken() +
the auth:refresh emit that pushes the new expiry to the server) always
starts strictly after the token has already expired. Any of: normal
network latency, or a backgrounded tab (browsers throttle setTimeout/
setInterval there, delaying this precisely-timed callback) could make the
server's next tick win the race and kill an otherwise-healthy connection.

keycloak.ts now also refreshes proactively: a 20s-interval check requesting
a refresh whenever less than 90s of validity remains, independent of (and
well ahead of) the exact-expiry callback, which stays as a fallback. Refactored
the refresh logic (token/localStorage bookkeeping) into a shared
doTokenRefresh() used by both paths.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
useWSocket.ts now tracks isConnected (true on 'connect', false on any
'disconnect'/'connect_error'/explicit disconnectSocket()) and
connectionAttempted (true once useWSocket() has been called at least
once — avoids the banner flashing before login even starts trying to
connect).

New ConnectionStatusBanner.vue, mounted globally in App.vue: a small
pill at the top of the screen reading "Connexion au serveur perdue —
reconnexion en cours…" whenever the socket is down. Delayed 1.5s before
showing, so a normal, fast reconnect (socket.io's own reconnection is
already near-instant — 1s initial delay) doesn't cause a flash for every
brief, silently-recovered blip.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… dash

Simplified the show/hide logic to a single derived computed (isDown)
instead of watching two separate refs together — removes any ambiguity
around how a multi-source watch's values line up, and makes "reconnected"
hide the banner immediately and unconditionally rather than depending on
how isConnected/connectionAttempted happened to change relative to each
other.

Also reworded the banner text to use a period instead of an em dash, and
plain "..." instead of the single-character ellipsis — no stylized
punctuation in user-facing copy.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- peerReconnect.ts: createPeerReconnector took a `Peer | null` typed via
  `import type Peer from 'peerjs'`, but its two callers import Peer
  differently (useSecurePeer.ts: named `{ Peer }`, usePrivatMeet.ts:
  default `Peer`) — vue-tsc stopped treating these as the same type once a
  THIRD import of it was in the mix, failing on protected members like
  _serializers that are compared nominally. Replaced with a local
  structural interface (just the 3 members actually used: destroyed,
  disconnected, reconnect()), sidestepping the cross-import identity issue
  entirely regardless of which import style a caller uses.

- ChatView.vue: waitForSocketConnection(socket, ...) failed the same way —
  `socket` was a locally re-declared `ref<Socket | null>` (from a separate
  `import type { Socket } from 'socket.io-client'`) copied from
  useWSocket()'s return value, rather than that return value itself.
  Passing `wsRef` (the actual Ref<Socket | null> returned by useWSocket(),
  exact matching type) instead fixes it — and matches the pattern already
  used everywhere else in the codebase (useNotifications.ts, ThreadBtn.vue,
  VoiceThreadBtn.vue, VoiceInviteModal.vue all pass useWSocket()'s return
  value directly rather than re-declaring their own ref). ThreadView.vue
  has the same pattern as ChatView.vue's old code but never errored only
  because its socket ref is typed `any`.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…he token

Root cause of "stuck showing disconnected even after reconnecting" —
traced through socket.io-client's own source (node_modules/socket.io-client/
build/cjs/socket.js): when a connect_error is caused by the server sending
a CONNECT_ERROR packet (our io.use() middleware rejecting a stale token at
the exact instant of a (re)connection attempt — the residual race the
server-side fixes already reduce but can't fully eliminate, e.g. a tab left
suspended across several token lifetimes), socket.io-client calls
this.destroy() BEFORE emitting connect_error. destroy() permanently
unsubscribes that Socket from its Manager's events "to avoid
reconnections" — the Manager keeps retrying the underlying transport in
the background (reconnection:true still runs), but nothing is listening
for that success anymore on our namespace. Without calling connect()
ourselves afterward, the connection stays broken for good after a single
rejected auth attempt, even once the token is fixed — 'connect' (and
therefore isConnected) never fires again. This was never a bug in
ConnectionStatusBanner.vue; the underlying connection state itself was
truly stuck.

The existing 'disconnect' handler already understood and worked around
this exact destroy() behavior for "io server/client disconnect" (its
comment says so) — connect_error just needed the same treatment.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@MisterPapaye
MisterPapaye merged commit c5f3c40 into main Sep 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant