Skip to content

feat(core): WebRTC TURN/ICE diagnostics and env-configurable Matrix VoIP#2218

Draft
webguru-hypha wants to merge 30 commits into
mainfrom
cursor/webrtc-turn-ice-telemetry-3c15
Draft

feat(core): WebRTC TURN/ICE diagnostics and env-configurable Matrix VoIP#2218
webguru-hypha wants to merge 30 commits into
mainfrom
cursor/webrtc-turn-ice-telemetry-3c15

Conversation

@webguru-hypha

Copy link
Copy Markdown
Contributor

Summary

Implements deployment-friendly tracing for Matrix group calls after gc.enter(): TURN credential / ICE server shape, optional STUN gather probe when no TURN is configured, and optional Matrix JS SDK summary WebRTC stats (privacy-safe aggregates).

Also wires Matrix createClient VoIP options from NEXT_PUBLIC_MATRIX_WEBRTC_* so infra can force relay, enable public STUN fallback when the HS returns no ICE servers, or bump ICE candidate pooling without code changes.

Env vars (optional)

Variable Effect
NEXT_PUBLIC_MATRIX_WEBRTC_FORCE_TURN forceTURN — relay-only peer connections (iceTransportPolicy: relay).
NEXT_PUBLIC_MATRIX_WEBRTC_FALLBACK_ICE_ALLOWED Allow matrix-js-sdk public STUN fallback when HS provides no ICE servers (default SDK behavior is false).
NEXT_PUBLIC_MATRIX_WEBRTC_ICE_POOL_SIZE iceCandidatePoolSize for faster first candidate gather.
NEXT_PUBLIC_MATRIX_WEBRTC_GROUP_STATS_MS If > 0, enables Matrix GroupCall periodic summary stats and logs hypha.group_call.webrtc_summary (dev console).

Telemetry events (development console, filter hypha.group_call)

  • hypha.group_call.turn_probecheckTurnServers() result, approximate TURN TTL, ICE entry/url counts, STUN/TURN/TURNS flags, short host hints (no URIs/passwords).
  • hypha.group_call.ice_gather_probe — only when no TURN/TURNS and no fallback: quick RTCPeerConnection gather smoke test (state or timeout).
  • hypha.group_call.webrtc_summary — when group stats interval > 0: SDK aggregate receive %, jitter, packet loss, peer connection counts vs opponents.

Notes

  • Hard requirement for reliable NAT traversal remains homework GET /voip/turnServer returning TURN URIs + credentials; client-side logging helps prove when that path is broken or empty.
  • Commit: feat(core): WebRTC diagnostics for Matrix group calls (TURN/ICE telemetry)
Open in Web Open in Cursor 

cursoragent and others added 30 commits April 27, 2026 20:41
…baseURL

Relative page.goto paths failed when tests ran without apps/web-e2e
playwright.config.ts (wrong CWD), yielding "Cannot navigate to invalid URL".
Centralize BASE_URL-aligned absolute URLs via resolveAppUrl/gotoApp.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Drop the second-line Matrix ID / technical handle from mention rows.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Insert `@` + zero-width space + Hypha/profile label when picking a member,
strip `@` from labels for stable tokens, and rewrite to MXIDs plus
explicit m.mentions user_ids before sendMessage/editRoomMessage so Matrix
notifications and interoperability stay correct.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
When AI + Human panels wrap the layout, the main scroll root allowed
overflow-x; panning revealed empty space beside the fixed chat rail.
Add overflow-x-hidden on the scrollport so content cannot shift sideways.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Replace Container max-width centering with full-width plus horizontal
padding so hero and secondary chrome span the scroll column when panels
narrow the viewport. Clip horizontal overflow on the dual-panel main
scroll root to avoid dead gaps next to fixed side rails.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Share Matrix→Privy→Person resolution between picker rows and composer:
insert the same resolved label as display tokens; merge overrides into
mention maps so wire send + timeline pills match the dropdown (not
shortened MXID fallbacks).

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
…ll guard

- Pass resolveMentionMemberLabel into HumanChatPanelCallStage for roster/Person
  labels on video tiles (not Matrix shortened MXIDs).
- Auto-leave after 5 minutes when connected solo (othersInRoom === 0).
- Abort hung GroupCall.enter() after 90s with recoverable error + telemetry.
- i18n for idle-leave banner (en, de, es, fr, pt).

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Clear mention display overrides after roomId is declared. Widen
resolveMemberLabel typing to accept undefined for call tiles.
Gate keyboard mention pick until Hypha name resolution completes.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Avoid redirect-dependent navigation per CodeRabbit review on PR #2209.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Align baseURL parsing with resolveBaseUrl() for consistent navigation.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Person lookup uses usePersonBySub which does not fetch until JWT exists;
keep busy until auth finishes loading the token when a privySub path is active.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
When sanitized labels collide, map keys and composer tokens include a shortened
MXID suffix so wire send resolves to the intended user.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Cold loads map history before `getUserId()` is available, so own rows were
stored as member with technical display labels. Reconcile role, senderName,
and avatar when currentUserId or profile avatar resolves.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Message body used synchronous resolveMatrixMemberLabel only; Matrixoften
shows bridged Privy MXIDs until roster/Hypha hydrate. Mirror sender pills:
use matrix_user_links + Person when label still looks technical.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
…s lag

Emit connected/media_snapshot/remote_media_stall telemetry in dev; detect
when participants exist without remote userMedia feeds for 45s and show an
inline banner with dismiss. Periodic snapshots every 12s while connected.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Prefer roster merge over raw Matrix member displaynames; resolve Person via
matrix_user_links when labels still look bridged. Apply same logic to
connecting placeholders.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Remove ring outline; use minimal horizontal padding and smaller corner radius
so the background sits close to the @ name.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Parse http(s) URLs in plaintext bodies, trim trailing punctuation from
hrefs, and wrap with anchor target _blank rel noopener noreferrer.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Copy link now omits redundant chat param (?msg only). Resolve msg-only deep
links when viewing the same space. Render Hypha chat URLs as compact # slug
chips instead of raw long URLs.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
CodeQL flagged repeated regex tests on user-controlled chat text.
Strip trailing URL punctuation with a constant-time character set and
scan http(s) URLs without a nested-quantifier regex.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
The first-unread marker used accent-tinted backgrounds that read as a
green strip next to messages (including reply context). Use neutral
border and muted row tint instead, aligned with mention-highlight styling.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Address known advisories: bump hono to a patched 4.12.x, ensure
@hono/node-server stays on the 1.19.x line >=1.19.13 for static
middleware fixes, enforce dompurify >=3.4.0 for transitive mermaid
chains, and pin @xmldom/xmldom >=0.9.9 under mathjax tooling.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
String index can be undefined under strict indexing; guard before Set.has
so web deploy check-types passes.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
…wing t

CodeRabbit: inner variable shadowed useTranslations('HumanChatPanel') t.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
CodeRabbit: wirePlain substitutes MXIDs; keep user-facing preview as typed text.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Horizontally scroll the tab rail so Chat, Members, and Mentions stay fully
visible when the panel is narrow or the rail was scrolled. Runs on active
tab change and after tab clicks (including re-selecting the same tab).

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
- Use distinct other-Matrix-user count for onlyLocalInRoomCall (not device
  count) so one person on two devices no longer mis-labels Start vs Join.
- When remote media stall is detected, show stall copy and stop the
  infinite spinner on remote placeholder tiles; pass remoteMediaStall from
  useSpaceGroupCall into the call stage.
- i18n: add callRemoteParticipantMediaStalled in all HumanChatPanel locales.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Export renderTextWithMentions for the mention inbox excerpt: MXID tokens
get the same pills and async Person resolution as the timeline. Add
MentionInboxSenderName for senders whose Matrix display is still technical
(Privy-bridged) so the header line uses Person after load.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
Sum unread @-mentions across joined Matrix rooms for bell and Chat/Mentions
tabs. Mentions tab lists mentions from all rooms with room labels; selecting
another space’s mention navigates via ?msg= when slug is known from session or
storage. Persist room→space slug in sessionStorage for routing.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
…etry)

Wire createClient VoIP options from NEXT_PUBLIC_MATRIX_WEBRTC_* env vars,
log privacy-safe turn_probe / ice_gather_probe / webrtc_summary events after
gc.enter(), and optionally enable Matrix SDK summary stats collection.

Co-authored-by: webguru-hypha <webguru-hypha@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e9dd26c5-f8c9-432c-8d10-8e1628f05655

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/webrtc-turn-ice-telemetry-3c15

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

2 participants