Translation: change language output during call#136
Conversation
📝 WalkthroughWalkthroughThis PR adds the capability to change translation output language while a session is active. The native iOS implementation sends language updates via the Realtime API, the TypeScript bridge exposes this functionality to JavaScript, and the UI component is simplified by removing session-state guards from language selection. ChangesRuntime language update for active translation sessions
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
|
OSSF Scorecard (PR vs base)
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@modules/vm-webrtc/ios/OpenAIWebRTCTranslatorClient.swift`:
- Around line 146-149: Capture and check the Bool returned by sendEvent(...) for
the "session.update" call in OpenAIWebRTCTranslatorClient (currently invoked
with the session payload containing ["audio": ["output": ["language":
trimmed]]]); if the result is false, emit an explicit error log using the
existing logger (e.g., processLogger.error or the class's logger) that includes
operation-specific context such as "session.update", the role/caller (if
available at the call site), and the trimmed language value, and then take an
appropriate local action (e.g., return/fail fast or notify caller) to avoid
silent state desync.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 95c631ee-77ed-4bec-9c69-6e1f8a75f8a4
📒 Files selected for processing (5)
app/RealtimeTranslation.tsxcomponents/realtime/LanguagePickerRow.tsxmodules/vm-webrtc/ios/OpenAIWebRTCTranslatorClient.swiftmodules/vm-webrtc/ios/WebRTCTranslatorModule.swiftmodules/vm-webrtc/src/VmWebrtcTranslatorModule.ts
| _ = sendEvent([ | ||
| "type": "session.update", | ||
| "session": ["audio": ["output": ["language": trimmed]]] | ||
| ]) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Verify sendEvent signature/return type and current call patterns
rg -n 'func\s+sendEvent\s*\(' modules/vm-webrtc/ios -C3
rg -n '_ = sendEvent\(' modules/vm-webrtc/ios -C2Repository: tleyden/arty
Length of output: 2610
🏁 Script executed:
cat -n modules/vm-webrtc/ios/WebRtcClientHelpers.swift | sed -n '647,680p'Repository: tleyden/arty
Length of output: 1807
🏁 Script executed:
# Check if there are any places where sendEvent result IS used
rg 'sendEvent\(' modules/vm-webrtc/ios -B2 -A2 | grep -v '_ = sendEvent'Repository: tleyden/arty
Length of output: 7087
Add explicit failure handling for session.update with call-site context.
sendEvent() returns a Bool indicating success, but line 146 ignores it via _ =. Although sendEvent() logs internally, it lacks the operation-specific context (role, language) needed for observability. Similar critical operations elsewhere in the codebase (e.g., function call outputs, response.create in OpenAIWebRTCClient.swift) explicitly check the result and log context—this language update should follow the same pattern to prevent silent state desync.
Suggested fix
- _ = sendEvent([
+ let didSend = sendEvent([
"type": "session.update",
"session": ["audio": ["output": ["language": trimmed]]]
])
+ if !didSend {
+ logger.log(
+ "[VmWebrtc][Translator] Failed to send language update",
+ attributes: logAttributes(for: .warn, metadata: ["role": role, "language": trimmed])
+ )
+ }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@modules/vm-webrtc/ios/OpenAIWebRTCTranslatorClient.swift` around lines 146 -
149, Capture and check the Bool returned by sendEvent(...) for the
"session.update" call in OpenAIWebRTCTranslatorClient (currently invoked with
the session payload containing ["audio": ["output": ["language": trimmed]]]); if
the result is false, emit an explicit error log using the existing logger (e.g.,
processLogger.error or the class's logger) that includes operation-specific
context such as "session.update", the role/caller (if available at the call
site), and the trimmed language value, and then take an appropriate local action
(e.g., return/fail fast or notify caller) to avoid silent state desync.
Since #133 isn't working yet, this workaround will allow people to have bidirectional conversations by taking turns and manually switching languages.
Summary by CodeRabbit