Skip to content

Bundle realtime initial state into livekit_join#17

Merged
AdirAmsalem merged 1 commit into
mainfrom
feat/bundle-initial-state-livekit-join
Jun 15, 2026
Merged

Bundle realtime initial state into livekit_join#17
AdirAmsalem merged 1 commit into
mainfrom
feat/bundle-initial-state-livekit-join

Conversation

@VerioN1

@VerioN1 VerioN1 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Bring Android realtime signaling to parity with feat(realtime): bundle initial_state into livekit_join sdk#155 by bundling the first prompt/set_image payload into livekit_join.initial_state.
  • Buffer early prompt_ack / set_image_ack messages until the post-livekit_room_info waiter consumes them, keeping ack timeout timing after room info.
  • Preserve the post-room-info setImage / sendPrompt path for legacy two-step updates.

Test plan

  • ./gradlew :sdk:testDebugUnitTest

Made 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 for initial_state.

Overview
Bundles the first prompt / set_image payload into livekit_join.initial_state instead of sending separate client messages after join, aligning Android realtime signaling with the cross-SDK change.

RealtimeSessionManager passes initialState into sendLiveKitJoin and only awaits the matching ack via awaitInitialStateAck (no duplicate sends). SignalingChannel replaces SharedFlow ack listeners with a waiter/buffer model so prompt_ack / set_image_ack that arrive before livekit_room_info are held until the post–room-info waiter runs; post-connect setImage / sendPrompt still send on the wire. Wire format updates: LiveKitJoinMessage carries nested initial_state; serialization tests and new SignalingChannelTest cover 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.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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!!) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b5d6df8. Configure here.

@AdirAmsalem AdirAmsalem merged commit 7bbfec7 into main Jun 15, 2026
1 check passed
@AdirAmsalem AdirAmsalem deleted the feat/bundle-initial-state-livekit-join branch June 15, 2026 08:17
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