feat(rpc): add optional WebRTC fast path - #123
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b9a7b142f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (webRtcCooldown.isActive(connection.environmentId, nowMs)) { | ||
| fallbackReason = "cooldown"; | ||
| } else { | ||
| yield* selectWebRtc(config, webRtcPeerFactory, capability); |
There was a problem hiding this comment.
Do not gate readiness on optional WebRTC negotiation
When the server advertises this default-enabled capability but UDP/STUN traffic is blocked, selectWebRtc can run until its 10-second timeout, and session.ready waits for this call before ConnectionDriver publishes the already-authenticated WebSocket session. Users on restrictive firewalls therefore remain stuck in “synchronizing” for up to 10 seconds on every new session instead of receiving the promised immediate WebSocket fallback; negotiation failures also do not activate the cooldown. Run the upgrade without blocking WebSocket readiness, or apply a much shorter bounded selection window and cooldown failures.
AGENTS.md reference: AGENTS.md:L17-L19
Useful? React with 👍 / 👎.
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
What changed
WsRpcGroup, negotiated through the authenticated control WebSocket.T3CODE_WEBRTC_TURN_URLSis set. Optional TURN username and credential values are passed to Werift, browser WebRTC, and React Native WebRTC.Why
Remote clients currently send application RPC traffic through the WebSocket endpoint even when the client and environment can establish a faster WebRTC path. This adds an optional upgrade without changing authentication, relay bootstrap, or connection targets. If direct ICE cannot connect, operators can configure TURN. If WebRTC still fails, the existing WebSocket remains selected without a connection error.
An established RTC session no longer drops solely because its signaling WebSocket disconnects. The existing supervisor still reconnects after the selected DataChannel itself closes, without replaying in-flight mutations.
Verification
react-native-webrtc.Checklist
Model: GPT-5; harness: Codex.