Bundle realtime initial state into livekit_join#17
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b5d6df8. Configure here.
| failHook = { resolve(Result.failure(it)) } | ||
| entry = PendingAckWaiter(matches = matches, onMatch = ::resolveAck) | ||
|
|
||
| synchronized(ackLock) { pendingAckWaiters.add(entry!!) } |
There was a problem hiding this comment.
Buffered acks ignore new waiters
High Severity
awaitAckMessage only scans bufferedAcks before registering a waiter. If a matching ack arrives on the WebSocket thread in that gap (or is dropped when connected is already true), it never pairs with the waiter, so bundled initial-state or legacy setImage/sendPrompt calls can time out despite a successful server ack and fail the session connect.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit b5d6df8. Configure here.


Summary
livekit_join.initial_state.prompt_ack/set_image_ackmessages until the post-livekit_room_infowaiter consumes them, keeping ack timeout timing after room info.setImage/sendPromptpath for legacy two-step updates.Test plan
./gradlew :sdk:testDebugUnitTestMade with Cursor
Note
Medium Risk
Changes the realtime connect handshake and ack timing on a critical path; mitigated by buffered early acks, unchanged legacy
setImage/sendPrompt, and unit tests, but still depends on server support forinitial_state.Overview
Bundles the first prompt / set_image payload into
livekit_join.initial_stateinstead of sending separate client messages after join, aligning Android realtime signaling with the cross-SDK change.RealtimeSessionManagerpassesinitialStateintosendLiveKitJoinand only awaits the matching ack viaawaitInitialStateAck(no duplicate sends).SignalingChannelreplaces SharedFlow ack listeners with a waiter/buffer model soprompt_ack/set_image_ackthat arrive beforelivekit_room_infoare held until the post–room-info waiter runs; post-connectsetImage/sendPromptstill send on the wire. Wire format updates:LiveKitJoinMessagecarries nestedinitial_state; serialization tests and newSignalingChannelTestcover bundled join, early ack buffering, and the legacy path.Reviewed by Cursor Bugbot for commit b5d6df8. Bugbot is set up for automated code reviews on this repo. Configure here.