Repository navigation
Conversation
Watch Together has been fully built and completely unreachable. The room machinery — create/join, suggestions and voting, the WebSocket transport, RoomSyncEngine — compiled, and both apps routed to the lobby and the synced player, but nothing could open either. Phone was one const: CLIENT_WATCH_TOGETHER_SURFACE_ENABLED gated an entry sheet that was already wired into AppNavigation. TV had no entry point at all. TvItemDetailScreen declared an onWatchTogether callback and TvAppNavigation wired it to the lobby and synced-player routes, but no code path ever invoked it and TvWatchTogetherEntryDialog was never instantiated anywhere. This adds the missing half: a "Watch Together" action in the detail overflow that opens the entry dialog, hands off to the join-code dialog, and routes on the resolved room the same way the phone does — host with a selection goes straight to the synced player, everything else to the lobby. Hosting targets whatever Play would launch, so a series or season hosts its next-up episode rather than the container, which cannot be a room selection. Audiobooks are excluded: a room's transport drives a video player and the lobby's "now playing" has nothing to show for one. Movies previously had no overflow button at all, so the action brings one with it. Worth noting there is no Apple counterpart to mirror — silo-apple has no Watch Together whatsoever — so the shape here is Android's own. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
WatchTogetherRealtimeClient.sendText was `session?.send(...)` — every
client to server frame silently vanished if the socket had not finished
connecting, with no error and no retry. The interface even documented the
opposite ("repository gates on connection"); nothing did.
Two consequences, both on phone and TV, and both in the first seconds of
a room:
attach_session was lost for the life of the room. Both controllers set
the sent-latch BEFORE awaiting the send, and the only path that re-arms
it is a server-had-our-session to hasn't transition — which cannot happen
for a session the server never had. So a room could run with a member's
playback session permanently unknown to it.
The clock stayed unsynced for up to 15s. The ping loop fires immediately,
races the handshake, and on a dropped first ping no pong arrives until
the next interval. RoomSyncEngine's documented fallback with no offset is
to apply commands immediately, which discards the scheduled-execute
barrier that keeps members in step — during exactly the window where
someone presses play.
Sends now report whether they reached an open session. The latch is set
only on a delivered frame, and pings retry at 1s until the socket is up
and an offset exists, then settle to the normal interval.
Found by reading the code, not by running it: this feature has never been
reachable by a user, so none of it has ever been exercised.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
…ting Four follow-ups from reading the sync path. Room-scoped calls resolved their room id as `roomId ?: ""`, turning "there is no room" into a request against a malformed path. It is reachable — the snapshot is cleared on close and on losing the connection, and the UI can still have an action in flight — and the 404/405 surfaced to the user as though the server had rejected what they did. All nine call sites now return a no_active_room error without touching the API. votedIds was an unsynchronised MutableSet written from two directions at once: REST completions on an IO dispatcher and the websocket fold. It is a StateFlow of an immutable Set now, so updates are atomic and readers always see a whole set. The state-report cadence gate was hand-copied into the TV controller with a comment asking the two copies to be kept in lockstep. It now lives in shared next to roomTransportAuthorized, for the same reason that is shared: a room is one protocol, and two platforms disagreeing about when to report is a desync that only appears with two devices in a room. Its test moves to commonTest with it. MAX_RECONNECT_ATTEMPTS documented the opposite of what the code does — failures reset on a clean connection end, not on any healthy event, which is deliberate and load-bearing (a server emitting one good frame per attempt would otherwise reconnect forever). The code was right; the comment is now too. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
Room-scoped calls resolve their id from the room snapshot, which is null until the first frame arrives over the socket and is cleared again on a transient close. The lobby lets you vote, promote and change policy in both of those windows, so those actions failed for a room the caller is demonstrably connected to. connect() knows the id; remember it and fall back to it. The snapshot stays the preferred source. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (12)
📝 WalkthroughWalkthroughThe PR exposes Watch Together on Android TV, adds room-resolution dialog wiring and navigation, reports websocket send delivery status, centralizes state-report suppression, and retries synchronization pings until server time is established. ChangesWatch Together and room synchronization
Sequence Diagram(s)sequenceDiagram
participant Viewer
participant TvItemDetailScreen
participant WatchTogetherViewModel
participant TvAppNavigation
Viewer->>TvItemDetailScreen: select Watch Together
TvItemDetailScreen->>WatchTogetherViewModel: host or join room
WatchTogetherViewModel-->>TvItemDetailScreen: resolved RoomSnapshot
TvItemDetailScreen->>TvAppNavigation: open WatchTogetherLobby
Possibly related PRs
Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Closing — opened against the wrong remote. This work lives on the RXWatcher fork. |
Why
Watch Together was fully built and completely unreachable. The room machinery — create/join, suggestions and voting, the WebSocket transport,
RoomSyncEngine— compiled, and both apps routed to the lobby and the synced player, but nothing could open either.CLIENT_WATCH_TOGETHER_SURFACE_ENABLED = false, with the entry sheet already wired intoAppNavigation.TvItemDetailScreendeclared anonWatchTogethercallback andTvAppNavigationwired it to the lobby and synced-player routes, but no code path ever invoked it andTvWatchTogetherEntryDialogwas never instantiated anywhere.Because no user could reach any of it, none of this code had ever run. Reading it turned up four defects, two of which would have broken every room in its first seconds.
The entry points
TV gets the missing half: a Watch Together action in the detail overflow that opens the entry dialog, hands off to the join-code dialog, and routes on the resolved room exactly as the phone does — host with a selection goes straight to the synced player, everything else to the lobby.
Hosting targets whatever Play would launch, so a series or season hosts its next-up episode rather than the container, which cannot be a room selection. Audiobooks are excluded: a room's transport drives a video player and the lobby's "now playing" has nothing to show for one. Movies previously had no overflow button at all, so the action brings one with it.
CLIENT_WATCH_TOGETHER_SURFACE_ENABLEDnow gates both platforms together, so the surface can still be withdrawn in one edit.The four defects
1. Frames sent before the socket was up vanished silently.
WatchTogetherRealtimeClient.sendTextwassession?.send(...)— no error, no queue, no retry. The interface documented the opposite ("repository gates on connection"); nothing did. Sends now report whether they reached an open session.2.
attach_sessioncould be lost for the life of the room. Both controllers set the sent-latch before awaiting the send, and the only path that re-arms it is a server-had-our-session → hasn't transition, which cannot happen for a session the server never had. The latch is now set only on a delivered frame.This one matters more than it looks. The server's readiness barrier keys entirely on the attached session —
activeParticipantCountLocked,allParticipantsReadyLockedandhandleWaitingDeadlineall skip members withsessionID == "". A member whose attach was dropped isn't someone the room waits for; it's someone the room doesn't know is watching. Playback starts without them and nothing logs an error.3. The clock stayed unsynced for up to 15s. The ping loop fires immediately and races the handshake; on a dropped first ping no pong arrives until the next interval.
RoomSyncEngine's documented fallback with no offset is to apply commands immediately, discarding the scheduled-execute barrier that keeps members in step — during exactly the window where someone presses play. Pings now retry at 1s until the socket is up and an offset exists, then settle to the normal interval.4. Room-scoped calls addressed an empty room id. They resolved
roomId ?: "", turning "there is no room" into a request against a malformed path whose 404/405 surfaced as though the server had rejected the user's action. They now fail fast withno_active_room— and fall back to the idconnect()was called with, so voting still works in the windows where the snapshot is legitimately absent (before the first frame, and after a transient close).Also
votedIdswas an unsynchronisedMutableSetwritten from an IO dispatcher and the WebSocket fold at once; it is aStateFlow<Set<String>>updated atomically now.sharedbesideroomTransportAuthorized— a room is one protocol, and two platforms disagreeing about when to report is a desync that only appears with two devices in a room. Its test moves tocommonTest.MAX_RECONNECT_ATTEMPTSdocumented the opposite of the code. The behaviour is deliberate and load-bearing (there is a test for it); only the comment changed.Testing
assembleDebugand the full unit suites green onshared,androidAppandandroidTvApp, from a clean--rerun-tasksrun on this branch based onmain.New tests:
TvWatchTogetherSurfaceSourceTest— the TV failure mode was absence of wiring, which nothing behavioural could catch, because the dialog was not reachable to observe.RoomStateReportGateTestmoves tocommonTestwith the gate.Not yet exercised against a live server. The TV build is installed on an emulator, but a room needs two participants and I have not run one end to end. The server side was read closely — transport authority mirrors the client's shared
roomTransportAuthorized, the waiting deadline is epoch-guarded, persist conflicts restore and re-arm rather than dropping the transition — and no server changes were needed.Worth flagging for whoever picks this up: there is no Apple counterpart.
silo-applehas no Watch Together at all, so this surface has no gold-standard client to mirror and anything ambiguous about its shape is a product decision rather than a parity bug.AI-use disclosure
Written by Claude Opus 5 (Claude Code) working with @RXWatcher, who directed the work and reviewed it. The defects were found by reading the code, not by running it.
Summary by CodeRabbit