Skip to content

Fix Webrtc connection errors#138

Merged
tleyden merged 2 commits into
mainfrom
webrtc_connection_errors
May 24, 2026
Merged

Fix Webrtc connection errors#138
tleyden merged 2 commits into
mainfrom
webrtc_connection_errors

Conversation

@tleyden
Copy link
Copy Markdown
Owner

@tleyden tleyden commented May 24, 2026

Fixes #137. Was using old deprecated endpoint.

Summary by CodeRabbit

  • Bug Fixes

    • Improved error messages for voice chat and real-time translation features, providing clearer feedback when sessions fail.
    • Enhanced error handling for API connection rejections with more informative error details.
  • Improvements

    • Optimized WebRTC connection initialization for voice and translation services.
    • Expanded error diagnostics for better troubleshooting capabilities.

Review Change Stack

@github-actions
Copy link
Copy Markdown

OSSF Scorecard (PR vs base)

  • Base score: 4.4
  • PR score: 4.4
  • Change: 0.00 (unchanged)

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bff3297b-d86e-4b37-951c-4cb24a3ac785

📥 Commits

Reviewing files that changed from the base of the PR and between c085c8d and a2bdf0c.

📒 Files selected for processing (9)
  • app/RealtimeTranslation.tsx
  • app/VoiceChat.tsx
  • lib/realtimeUserError.ts
  • modules/vm-webrtc/ios/OpenAIWebRTCClient.swift
  • modules/vm-webrtc/ios/OpenAIWebRTCCore.swift
  • modules/vm-webrtc/ios/OpenAIWebRTCTranslatorClient.swift
  • modules/vm-webrtc/ios/VmWebrtcModule.swift
  • modules/vm-webrtc/ios/WebRtcClientHelpers.swift
  • modules/vm-webrtc/src/VmWebrtcModule.ts

📝 Walkthrough

Walkthrough

This PR fixes WebRTC connection errors by introducing centralized error message handling, refactoring iOS session configuration to build and cache upfront before SDP exchange, switching to the /v1/realtime/calls endpoint, and expanding debug logging throughout the WebRTC negotiation flow with detailed SDP analysis and error details.

Changes

Realtime WebRTC Connection Error Handling and Session Configuration Refactor

Layer / File(s) Summary
User-facing error message utility
lib/realtimeUserError.ts, modules/vm-webrtc/ios/OpenAIWebRTCCore.swift
New getUserFacingRealtimeErrorMessage utility converts unknown errors to context-aware user strings (voice/translation). Updates OpenAIWebRTCError.openAIRejected to carry status and optional error details.
Error handling in React components
app/RealtimeTranslation.tsx, app/VoiceChat.tsx
RealtimeTranslation and VoiceChat replace inline error-message fallbacks with the new utility. VoiceChat updates debug logging to record resolved baseUrl/model values and adds hasMicPermission to connection startup logs.
WebRTC debug helper functions
modules/vm-webrtc/ios/WebRtcClientHelpers.swift
Adds utility functions for endpoint description (with legacy mode detection), SDP analysis, HTTP header summarization, JSON pretty-printing, and multipart request body construction to support rich debug logging.
Realtime endpoint and session configuration refactor
modules/vm-webrtc/ios/OpenAIWebRTCClient.swift
Switches to /v1/realtime/calls endpoint, builds and caches initial session configuration upfront during openConnection, refactors session structure to nest turn detection/transcription under audio.input, removes session.update over data channel, and delegates data channel open to handleDataChannelOpenAfterInitialSessionSetup().
Enhanced SDP offer and call exchange logging
modules/vm-webrtc/ios/WebRtcClientHelpers.swift, modules/vm-webrtc/ios/OpenAIWebRTCTranslatorClient.swift
Enriches SDP offer logging with full content and analysis; SDP exchange request/response logs now include endpoint and SDP summaries; realtime call exchange logs multipart structure with pretty-printed session JSON; all paths capture response headers/body on error and log detailed SDP analysis on success.
TypeScript bridge and native logging updates
modules/vm-webrtc/src/VmWebrtcModule.ts, modules/vm-webrtc/ios/VmWebrtcModule.swift
Passes concrete baseUrl and model string values (defaulting to "default") to native module instead of boolean flags. Expands native logging to include baseUrl, toolDefinitionCount, and transcriptionEnabled.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • tleyden/arty#128: Introduces realtime translation session start/stop logic that this PR enhances with centralized error messaging and improved session configuration handling.
  • tleyden/arty#77: Plumbs transcriptionEnabled into session configuration; this PR refactors session structure to nest transcription settings under audio.input.

Poem

🐰 A rabbit's cheer for clearer calls,
When WebRTC errors used to sprawl,
Now session configs build up front,
With endpoints switched—no more a hunt!
Detailed logs light up the way,
Voice and translation work today. 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main objective: fixing WebRTC connection errors by switching to a new endpoint and improving error handling.
Linked Issues check ✅ Passed The PR addresses the core requirement from issue #137 by switching from the deprecated /v1/realtime endpoint to /v1/realtime/calls and implementing comprehensive error handling.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing WebRTC connection errors: endpoint migration, error message conversion, enhanced logging, and session configuration restructuring.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch webrtc_connection_errors

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

@tleyden tleyden merged commit 223b22b into main May 24, 2026
9 checks 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.

Fix webrtc connection errors

1 participant