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
Hosting pre-selects the title, so a new room is playing-and-selected the instant it exists — and every routing decision keyed on exactly that. Creating a room therefore flashed the invite code for a fraction of a second and replaced it with the player, leaving nothing on screen to read out to the person you were inviting. A host who is still alone now stays in the lobby, where the code is shown large, and the lobby hands off by itself once the member count rises. A guest is unaffected: they join a room that is already running and should land in it rather than be stranded behind a code they just used. Applied at both decision points on both platforms — the entry routing (TvAppNavigation, watchTogetherDestination) and the lobby's own auto hand-off (shouldEnterSyncedPlayer, lobbyPlayerDestinationOrNull) — since either alone would still skip past the code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
The QR had no quiet zone at all. MARGIN was set to 0 with a comment saying the surrounding Box supplied padding instead, but the canvas was the same size as the box, so the modules ran edge to edge — and a 16dp rounded clip then cut the corners off the finder patterns, the three squares a scanner locks onto. Against a dark TV background there was nothing separating the code from the wall either. Square corners now, with the spec's clear border. The lobby was a single non-scrolling Column. The host block alone — code, QR, two cycler rows, close button — is taller than a 1080p panel once the suggestion list sits under it, so "Guest controls" and everything below it were drawn past the bottom edge and could not be reached at all. It scrolls now, with bottom padding for a focused row's scale inside the overscan-safe area. The suggestion list moves out of a LazyColumn while I am here: a lazy list nested in a scrolling column is measured with an unbounded height and crashes. A room's suggestions are few enough that laziness bought nothing. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
Making the lobby scroll fixed the unreachable controls but broke the one thing the screen exists for: moving focus down to the cycler rows scrolled the join code off the top, so a host looking at the controls could no longer read the code out to the person they were inviting. Split into two columns. The invite — code and QR — is pinned on the left and never scrolls. Everything focusable lives in the right column, which scrolls on its own, so the code stays put however far down the list you go. The right half of the screen was empty before this. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
|
Warning Review limit reached
Next review available in: 7 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughWatch Together now uses shared room sessions and delivery-aware realtime commands across Android and TV. Vote-room hosting and winner promotion are added, Android TV entry and suggestion flows are exposed, lobby navigation is refined, and QR rendering gains quiet-zone padding. ChangesWatch Together runtime
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ 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 |
The server now decides vote rooms by the tally, but nothing on the client could create one or act on it: both apps called createRoom with no mode, so every room came back host_pick, and the lobby showed vote counts that changed nothing. Hosting now offers "Host a vote room" alongside the ordinary one — selection_mode is fixed at creation server-side, so it has to be chosen there rather than switched on later. In a vote room the lobby marks the leading suggestion WINNING and gives the host a single "Start winner" action above the list, labelled with the title it will start. It is disabled until something has a vote, because the server refuses that start and a button that can only fail is worse than one visibly not ready. The per-row "Pick" is hidden in vote rooms. The server promotes only the winner, so offering it on every row would be an action that fails on all but one of them. roomVoteWinner lives in shared and mirrors the server's rule exactly — head of the vote-ordered list, nothing when no votes are cast — so the client's idea of who is winning cannot drift from the server's and leave a host staring at a refusal they cannot explain. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
Both clients created a room and immediately set the title the host was looking at as its selection. In a vote room that sets the room playing before anyone can suggest anything: everyone is thrown into the player and the vote never happens, so the mode was dead on arrival. A vote room now opens with no selection and lands the host in the lobby, where suggestions and votes are collected. host_pick is unchanged — it still pre-selects, because there the host's choice IS the selection. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
|
Pushed the voting client work onto this branch, paired with Silo-Server/silo-server#486:
Full unit suites and |
A vote room had no way to acquire candidates. addSuggestion existed on the repository and the API and was called from nowhere on either platform, so the lobby sat on "No suggestions yet" permanently and the host's Start winner action could never leave its disabled state. The mode was unusable end to end. The TV detail overflow now offers "Suggest to Watch Together" whenever the viewer is actually in a room. Suggesting belongs on item detail rather than in the lobby: you choose something to suggest by browsing for it, and the lobby has no catalogue in it. The room comes from the repository's live snapshot, which outlives any one screen, so the action follows you around the app while a room is open. The result is confirmed with a toast — the dialog closes on selection, so without one the action is indistinguishable from having missed it. Movies previously had no overflow at all; being in a room now brings one, same as the Watch Together entry does. Phone has no equivalent yet. This is also the narrow version of a bigger gap: Watch Together is reachable only from a title, which assumes a room is always about the title in front of you — true for host_pick, wrong for a vote room, where you are deciding what to watch in the first place. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
Scaffolding for making a room outlive the screen that opened it. NOT yet wired: the four existing connect() call sites still own their own connections, so behaviour is unchanged by this commit. The connection currently lives in screen scope — the lobby's viewModelScope and, separately, the player controller's scope. Leaving the lobby closes the socket, the server sees the host disconnect, and the room is closed for everyone shortly after. That makes "stay in the room while you browse for something to suggest" impossible, which is exactly what a vote room needs its members to do. It also removes a latent bug rather than only enabling a feature: because both scopes call connect(), navigating lobby -> player runs two reconnect loops racing over the repository's single realtime field. A single owner fixes that by construction instead of by timing. Next: register it on an application scope in both apps' DI, then change the lobby view models and both RoomSyncControllers to observe it rather than connect themselves. That step needs a two-device test before anything is built on top of it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
Wires the holder added in 864de27. All four screen-scoped connections are gone: the lobby view models and both RoomSyncControllers now adopt the app-scoped session instead of opening their own. Two things this fixes. A room survives leaving the lobby. The connection used to live in viewModelScope, so backing out closed the socket, the server saw the host disconnect, and the room was closed for everyone. Browsing for something to suggest — the whole point of a vote room — took the room down with it. And a lobby -> player hand-off no longer runs two reconnect loops. Both scopes called connect(), racing over the repository's single realtime field; whichever lost left a dead client believing it was connected. One owner removes that by construction rather than by timing. Leaving is now explicit: only the lobby's leave() drops the connection, never composition ending. The server's host-disconnect grace was raised to two minutes in parallel, so a genuine drop costs a reconnect rather than the room. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
|
Pushed three more commits, which together make a room something you stay in rather than a screen you are on. Suggesting. One owner for the connection. All four screen-scoped connections are gone — the lobby view models and both
Leaving is explicit now: only the lobby's Paired with Silo-Server/silo-server#487, which raises the server's host-disconnect grace from 15s to two minutes. They cover different failure modes — this stops us reporting "host left" when the host merely navigated; that one covers drops the client cannot prevent (backgrounding, connectivity, process death). Unit suites and |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 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
`@androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherLobbyScreen.kt`:
- Line 70: Update the LaunchedEffect key list in WatchTogetherLobbyScreen to
include room?.selectedFileId alongside the existing room state keys, ensuring
file-only content re-picks trigger the existing auto-navigation logic.
In
`@androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherLobbyViewModel.kt`:
- Around line 83-85: Update the teardown launched at
WatchTogetherLobbyViewModel’s explicit-departure path and the corresponding
TvWatchTogetherLobbyViewModel path so roomSession.leave() is executed in an
app-scoped or RoomSession-owned scope rather than the clearing viewModelScope,
or is awaited before navigation. Apply this change in
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherLobbyViewModel.kt
lines 83-85 and
androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/watchtogether/TvWatchTogetherLobbyViewModel.kt
lines 77-79, preserving the behavior that leaving composition alone does not
disconnect.
In
`@androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/auth/QrCodePanel.kt`:
- Around line 36-37: Update QrCodePanel’s quiet-zone calculation to derive the
surrounding padding and drawing offset from matrix.width, ensuring at least four
QR modules of clear space per side when EncodeHintType.MARGIN is zero. Remove
the fixed quietZone default or replace it with a computed minimum based on the
rendered size and matrix.width, and keep the QR content correctly centered.
In
`@androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/detail/TvItemDetailScreen.kt`:
- Around line 1001-1007: Update the suggestViewModel.suggest call in
TvItemDetailScreen so that when playContentId refers to the next-up episode,
playType and the associated title, subtitle, and poster metadata are sourced
from that same episode rather than the series or season detail. Preserve the
existing metadata behavior for items where playContentId already represents the
displayed detail entity.
In
`@androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvRoomSyncController.kt`:
- Around line 137-140: Update the leave/exit flow in TvRoomSyncController to
route explicit room departure through RoomSession: after any host close request,
call roomSession.leave() instead of repository.reset(). Ensure the session job
is stopped and no reconnect occurs with reset credentials.
In
`@shared/src/commonMain/kotlin/org/siloserver/silo/watchtogether/RoomSession.kt`:
- Around line 54-58: Update the connection replacement logic in RoomSession’s
mutex.withLock block to await the existing job’s cancellation with
cancelAndJoin() before launching the new repository.connect(roomId) job; apply
the same cancellation-and-join ordering before invoking reset() in the related
flow. Preserve the existing connectedRoomId and active-job guard.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 86b86c93-78f6-427a-856c-5c7475ad0635
📒 Files selected for processing (31)
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/di/AndroidModule.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerScreen.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/RoomSyncController.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/RoomSyncStateReportGate.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherEntrySheet.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherEntryViewModel.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherLobbyScreen.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherLobbyViewModel.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/di/AndroidTvModule.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvAppNavigation.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/auth/QrCodePanel.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/detail/TvItemDetailScreen.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerScreen.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvRoomSyncController.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/watchtogether/TvSuggestToRoomViewModel.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/watchtogether/TvWatchTogetherEntryDialog.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/watchtogether/TvWatchTogetherLobbyScreen.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/watchtogether/TvWatchTogetherLobbyViewModel.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/watchtogether/TvWatchTogetherViewModel.ktandroidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/watchtogether/LobbyNavigationDecisionTest.ktandroidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/watchtogether/TvWatchTogetherSurfaceSourceTest.ktshared/src/commonMain/kotlin/org/siloserver/silo/di/RepositoryModule.ktshared/src/commonMain/kotlin/org/siloserver/silo/model/feature/ClientSurfacePolicy.ktshared/src/commonMain/kotlin/org/siloserver/silo/network/WatchTogetherRealtimeClient.ktshared/src/commonMain/kotlin/org/siloserver/silo/repository/WatchTogetherRepository.ktshared/src/commonMain/kotlin/org/siloserver/silo/watchtogether/RoomSession.ktshared/src/commonMain/kotlin/org/siloserver/silo/watchtogether/RoomStateReportGate.ktshared/src/commonMain/kotlin/org/siloserver/silo/watchtogether/RoomVote.ktshared/src/commonTest/kotlin/org/siloserver/silo/model/feature/ClientSurfacePolicyTest.ktshared/src/commonTest/kotlin/org/siloserver/silo/repository/WatchTogetherRepositoryTest.ktshared/src/commonTest/kotlin/org/siloserver/silo/watchtogether/RoomStateReportGateTest.kt
💤 Files with no reviewable changes (1)
- androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/RoomSyncStateReportGate.kt
|
|
||
| // Auto-navigate into the synced player when the room starts playing. | ||
| LaunchedEffect(room?.phase, room?.selectedContentId) { | ||
| LaunchedEffect(room?.phase, room?.selectedContentId, room?.memberCount, room?.selfRole) { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Repo files matching WatchTogetherLobbyScreen:"
fd -a 'WatchTogetherLobbyScreen\.kt$' . || true
echo
echo "Android and TV lobby file outlines:"
for f in $(fd 'WatchTogetherLobbyScreen\.kt$' .); do
echo "--- $f"
wc -l "$f"
ast-grep outline "$f" --match 'LaunchedEffect' --view expanded || true
done
echo
echo "Relevant LaunchedEffect and lobbyPlayerDestinationOrNull usages:"
for f in $(fd 'WatchTogetherLobbyScreen\.kt$' .); do
echo "--- $f"
rg -n "LaunchedEffect\\(|lobbyPlayerDestinationOrNull|selectedFileId|selectedContentId|shouldEnter|destination|navigate\\(" "$f" -C 4 || true
done
echo
echo "Diff stat/name for context:"
git diff --stat || true
git diff -- 'androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherLobbyScreen.kt' | sed -n '1,220p' || trueRepository: Silo-Server/silo-android
Length of output: 4301
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Locate lobby and route-related files:"
fd -i '(\bwatch|lobby|player|route)\b.*\.kt$|.*Route\.kt$' androidApp androidTvApp | sed -n '1,200p'
echo
echo "Search lobbyPlayerDestinationOrNull and related symbols:"
rg -n "fun lobbyPlayerDestinationOrNull|fun .*Destination|class .*Destination|sealed .*Destination|data class .*Route|Player\\(" androidApp src -S || true
echo
echo "Inspect android lobby surrounding LaunchedEffect and helper definitions:"
sed -n '1,240p' androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherLobbyScreen.kt
echo
echo "Inspect TV route construction near effect:"
sed -n '1,155p' androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/watchtogether/TvWatchTogetherLobbyScreen.ktRepository: Silo-Server/silo-android
Length of output: 23454
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Show the destination helpers and routes:"
sed -n '1,80p' androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherLobbyViewModel.kt
echo "---"
sed -n '24,42p' androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherEntryViewModel.kt
echo "---"
sed -n '136,160p' androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/Routes.kt
echo "---"
sed -n '38,70p' androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/LobbyAutoNavigateTest.kt
echo
echo "Search RoomSnapshot selectedFileId usages in watchtogether files:"
fd -i '\.kt$$' androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether . androidApp/src/commonTest/kotlin/org/siloserver/silo/android . | xargs -r rg -n "selectedFileId|selectedContentId|lobbyPlayerDestinationOrNull|Route.Player" || trueRepository: Silo-Server/silo-android
Length of output: 50380
Add room?.selectedFileId to the LaunchedEffect keys.
lobbyPlayerDestinationOrNull() builds Route.Player with room.selectedFileId, so a re-pick that changes only the file ID can produce a different player route without triggering auto-navigation. Mirror the TV lobby pattern here.
🎯 Proposed fix
- LaunchedEffect(room?.phase, room?.selectedContentId, room?.memberCount, room?.selfRole) {
+ LaunchedEffect(room?.phase, room?.selectedContentId, room?.selectedFileId, room?.memberCount, room?.selfRole) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| LaunchedEffect(room?.phase, room?.selectedContentId, room?.memberCount, room?.selfRole) { | |
| LaunchedEffect(room?.phase, room?.selectedContentId, room?.selectedFileId, room?.memberCount, room?.selfRole) { |
🤖 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
`@androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherLobbyScreen.kt`
at line 70, Update the LaunchedEffect key list in WatchTogetherLobbyScreen to
include room?.selectedFileId alongside the existing room state keys, ensuring
file-only content re-picks trigger the existing auto-navigation logic.
| // Explicit departure is the only thing that drops the connection now; | ||
| // leaving composition must not. | ||
| viewModelScope.launch { roomSession.leave() } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== files =="
git ls-files | rg 'WatchTogetherLobbyViewModel\.kt|RoomSession|RoomSessionWrapper|WatchTogether' || true
echo "== phone ViewModel =="
cat -n androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherLobbyViewModel.kt
echo "== tv ViewModel =="
cat -n androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/watchtogether/TvWatchTogetherLobbyViewModel.kt
echo "== watchtogether related files =="
for f in $(git ls-files | rg 'watchtogether|WatchTogether' | head -80); do
echo "--- $f"
ast-grep outline "$f" --view compact 2>/dev/null || true
doneRepository: Silo-Server/silo-android
Length of output: 15073
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== phone callers of leave/onBack navigation =="
rg -n "leave\(|onBack|WatchTogetherLobbyScreen|Pop |popBackStack|navigate\(" androidApp/src/androidMain/kotlin -g '*.kt' || true
echo "== tv callers of leave/onBack navigation =="
rg -n "leave\(|onDismiss|onBack|TvWatchTogetherLobbyScreen|Pop |popBackStack|navigate\(" androidTvApp/src/androidMain/kotlin -g '*.kt' || true
echo "== RoomSession implementation =="
cat -n shared/src/commonMain/kotlin/org/siloserver/silo/watchtogether/RoomSession.kt
echo "== RoomTransportAuthority implementation sections =="
wc -l shared/src/commonMain/kotlin/org/siloserver/silo/watchtogether/RoomTransportAuthority.kt
sed -n '1,220p' shared/src/commonMain/kotlin/org/siloserver/silo/watchtogether/RoomTransportAuthority.ktRepository: Silo-Server/silo-android
Length of output: 50381
Schedule watch-together teardown outside viewModelScope.
In androidApp, the back handler runs viewModel.leave() then immediately calls onBack(), and in androidTvApp the equivalent back/cancel path can also dispose the lobby. Since roomSession.leave() is launched from the clearing viewModelScope, it can be cancelled before the room disconnects and shared repo state is reset. Move this teardown to the app-scoped/RoomSession-owned scope, or await it before navigation.
📍 Affects 2 files
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherLobbyViewModel.kt#L83-L85(this comment)androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/watchtogether/TvWatchTogetherLobbyViewModel.kt#L77-L79
🤖 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
`@androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherLobbyViewModel.kt`
around lines 83 - 85, Update the teardown launched at
WatchTogetherLobbyViewModel’s explicit-departure path and the corresponding
TvWatchTogetherLobbyViewModel path so roomSession.leave() is executed in an
app-scoped or RoomSession-owned scope rather than the clearing viewModelScope,
or is awaited before navigation. Apply this change in
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/watchtogether/WatchTogetherLobbyViewModel.kt
lines 83-85 and
androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/watchtogether/TvWatchTogetherLobbyViewModel.kt
lines 77-79, preserving the behavior that leaving composition alone does not
disconnect.
| /** Clear border around the modules; four modules' worth is the spec minimum. */ | ||
| quietZone: Dp = 12.dp, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "## locate QrCodePanel.kt"
fd -a 'QrCodePanel.kt$' . || true
echo "## file locations"
for f in $(fd 'QrCodePanel.kt$' .); do
echo "--- $f"
wc -l "$f"
ast-grep outline "$f" || true
done
echo "## relevant QrCodePanel.kt contents"
f=$(fd 'QrCodePanel.kt$' androidTvApp 2>/dev/null | head -n1 || true)
if [ -n "${f:-}" ]; then
cat -n "$f"
fi
echo "## usages of QrCodePanel"
rg -n "QrCodePanel|QrCodePanel\(" androidTvApp || trueRepository: Silo-Server/silo-android
Length of output: 5327
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "## TvLoginScreen QrCodePanel call"
sed -n '590,625p' androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/auth/TvLoginScreen.kt | cat -n
echo "## TvWatchTogetherLobbyScreen call context"
sed -n '240,265p' androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/watchtogether/TvWatchTogetherLobbyScreen.kt | cat -n
echo "## search for QR size / padding usages"
rg -n "QrCodePanel\(|content = snapshot\.code|snapshot\.code|join code|WatchTogether|watchtogether" androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv -S || trueRepository: Silo-Server/silo-android
Length of output: 20160
🌐 Web query:
Google ZXing QRCodeWriter encode result width barcode matrix width Margin 0 8 modules quiet zone
💡 Result:
In the Google ZXing library, the QRCodeWriter automatically includes a quiet zone around the generated barcode [1]. The default size of this quiet zone is 4 modules [2][3]. You can control this margin by passing an EncodeHintType.MARGIN entry in the hints Map passed to the encode method [4][3]. While setting this value to 0 aims to remove the quiet zone, the resulting image may still contain a small margin due to the way ZXing calculates the final matrix [3]. Technical Breakdown of Matrix Calculation: 1. Encoding: The library first generates the raw QR code matrix [4][2]. 2. Scaling: It then calculates a scaling factor (multiple) to fit the QR code into your requested width and height [2][5]. The multiple is determined by the integer division of the available output space by the total number of modules (including the quiet zone) [2][5]. 3. Padding: Because the library enforces integer scaling (a whole number of pixels per module), any remaining pixels that cannot form a complete module are distributed as padding, often resulting in residual white space even if MARGIN is set to 0 [2][3][5]. To achieve a truly precise output size with no extra padding, advanced users often bypass the standard encode method and manually construct the image from the underlying encoder's output [3].
Citations:
- 1: https://groups.google.com/g/zxing/c/MN8mmvJDjbg
- 2: https://fossies.org/dox/zxing-zxing-3.5.4/QRCodeWriter_8java_source.html
- 3: https://stackoverflow.com/questions/10142748/reduce-border-width-on-qr-codes-generated-by-zxing
- 4: https://github.com/zxing/zxing/blob/master/core/src/main/java/com/google/zxing/qrcode/QRCodeWriter.java
- 5: https://github.com/zxing-js/library/blob/master/src/core/qrcode/QRCodeWriter.ts
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
p = Path("androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/auth/QrCodePanel.kt")
text = p.read_text()
checks = {
"default_margin_hint_is_zero": 'EncodeHintType.MARGIN to 0' in text,
"default_quiet_zone_dp_is_12": 'quietZone: Dp = 12.dp' in text,
"box_pads_quiet_zone": ".padding(quietZone)" in text,
"canvas_draws_from_zero": "topLeft = Offset(x * modulePx, y * modulePx)" in text,
"module_px_from_total_size": "this.size.minDimension / moduleCount" in text,
}
for name, ok in checks.items():
print(f"{name}={ok}")
# Geometric probe for the lobby 140.dp short-code call with a 21-module version-1 matrix.
size = 140.0
margin = 0
module_count = 21
assert margin == 0, "probe assumes EncodeHintType.MARGIN is zero"
canvas_size = size - 2 * margin
# Actual rendering in QrCodePanel: modules occupy the whole canvas; padding is separate around canvas.
module_px = canvas_size / module_count
pad_quiet_zone = 12.0
quiet_zone_in_modules = pad_quiet_zone / module_px
print(f"\nlobby_140px_21_module_geometry:")
print(f"canvas_size={canvas_size}")
print(f"module_px={module_px}")
print(f"modules_rendered_width={module_count * module_px}")
print(f"quiet_zone_per_side_dp={pad_quiet_zone}")
print(f"quiet_zone_per_side_modules={quiet_zone_in_modules:.3f}")
print(f"quiet_zone_meets_four_module_minimum={quiet_zone_in_modules >= 4.0}")
# Minimal formula for four-module minimum given requested size and matrix width when ZXing margin is zero.
required = 4
quiet_zone_px = required * size / (module_count + 2 * required)
print(f"\nrequired_quiet_zone_dp_for_four_modules={quiet_zone_px:.3f}")
print(f"corresponding_canvas_size={size - 2 * quiet_zone_px:.3f}")
print(f"corresponding_module_px={(size - 2 * quiet_zone_px) / module_count:.3f}")
PYRepository: Silo-Server/silo-android
Length of output: 637
Compute the QR quiet zone from matrix.width.
With EncodeHintType.MARGIN = 0, the surrounding .padding(quietZone) is the only quiet-zone boundary. At size = 140.dp with a 21-module matrix, each module is ~6.67.dp, so the default 12.dp is only ~1.8 modules per side, not the documented four-module minimum. Derive the padding/draw offset from matrix.width, or enforce a minimum padding that preserves 4 modules.
Also applies to: 50-63
🤖 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
`@androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/auth/QrCodePanel.kt`
around lines 36 - 37, Update QrCodePanel’s quiet-zone calculation to derive the
surrounding padding and drawing offset from matrix.width, ensuring at least four
QR modules of clear space per side when EncodeHintType.MARGIN is zero. Remove
the fixed quietZone default or replace it with a computed minimum based on the
rendered size and matrix.width, and keep the QR content correctly centered.
| suggestViewModel.suggest( | ||
| contentId = playContentId, | ||
| contentType = detail.type, | ||
| title = detail.title, | ||
| subtitle = detail.seriesTitle.takeIf { !it.isNullOrBlank() }, | ||
| posterUrl = detail.posterUrl, | ||
| ) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Keep suggestion metadata aligned with the suggested item.
For series and seasons, playContentId is the next-up episode, while contentType = detail.type remains series or season. Send playType and metadata for that same episode; otherwise the suggestion can be interpreted or displayed as the wrong entity.
🤖 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
`@androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/detail/TvItemDetailScreen.kt`
around lines 1001 - 1007, Update the suggestViewModel.suggest call in
TvItemDetailScreen so that when playContentId refers to the next-up episode,
playType and the associated title, subtitle, and poster metadata are sourced
from that same episode rather than the series or season detail. Preserve the
existing metadata behavior for items where playContentId already represents the
displayed detail entity.
| // Adopt the app-scoped connection. Both this and the lobby used to call | ||
| // connect() in their own scopes, so a lobby -> player hand-off ran two | ||
| // reconnect loops racing over the repository's single realtime field. | ||
| scope.launch { roomSession.enter(roomId) } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Route explicit leave through RoomSession.
This adopts an app-scoped connection, but leave() still calls repository.reset() rather than roomSession.leave(). The session job remains active after exit and can reconnect using reset credentials. Replace the repository reset with roomSession.leave() after any host close request.
🤖 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
`@androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvRoomSyncController.kt`
around lines 137 - 140, Update the leave/exit flow in TvRoomSyncController to
route explicit room departure through RoomSession: after any host close request,
call roomSession.leave() instead of repository.reset(). Ensure the session job
is stopped and no reconnect occurs with reset credentials.
| mutex.withLock { | ||
| if (connectedRoomId == roomId && job?.isActive == true) return | ||
| job?.cancel() | ||
| connectedRoomId = roomId | ||
| job = scope.launch { repository.connect(roomId) } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Wait for cancellation before replacing or resetting the connection.
cancel() is asynchronous. The old connect() job can clear the repository’s shared realtime field after the replacement job has installed its client, causing all later sends to report undelivered. Use cancelAndJoin() before launching the next connection and before reset().
Also applies to: 69-73
🤖 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
`@shared/src/commonMain/kotlin/org/siloserver/silo/watchtogether/RoomSession.kt`
around lines 54 - 58, Update the connection replacement logic in RoomSession’s
mutex.withLock block to await the existing job’s cancellation with
cancelAndJoin() before launching the new repository.connect(roomId) job; apply
the same cancellation-and-join ordering before invoking reset() in the related
flow. Preserve the existing connectedRoomId and active-job guard.
Brings the phone to parity with TV. addSuggestion was called from nowhere on either platform, so a vote room could not acquire candidates; TV got its entry point first and mobile was left without one, which meant a phone participant could vote but never nominate. "Suggest to Watch Together" now appears in the movie and series detail overflow whenever the viewer is in a room, and the result is confirmed with a toast — the menu closes on selection, so otherwise the action is indistinguishable from having missed the item. The room comes from the repository's live snapshot, which since the session hoist outlives any single screen, so the action is available wherever you wander while a room is open. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
|
Added the mobile half of suggesting, so the phone is no longer a second-class member of a vote room — it could vote but never nominate. Suggest to Watch Together now appears in the phone's movie and series detail overflow whenever the viewer is in a room, with the same toast confirmation as TV. Two composables needed it — This only works because of the session hoist earlier in this branch: the room is read from the repository's live snapshot, which now outlives any single screen. Before that, the action could only have appeared while the lobby was composed — i.e. never, since you are on a detail page when you want it. Full unit suites plus both One cherry-pick conflict resolving onto this branch, worth naming since it is the kind of thing that hides a mistake: an import block where |
Follows the server: the tally is advisory, so the host may start something other than the winner. The per-row "Pick" returns in vote rooms, where it had been hidden precisely because the server used to refuse it. "Start winner" stays as the one-press path to the tally's answer, and the WINNING badge still shows what the room chose — the host now simply is not bound by it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
|
Closing as superseded by the reviewed Watch Together work that has since landed through the forward-split stack and subsequent profile-entry changes. Retaining this PR and its branch as historical reference; it is not being merged. |
Why
Watch Together was fully built and completely unreachable. Create/join, suggestions and voting, the WebSocket transport,
RoomSyncEngine— all 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 nobody could reach it, none of this code had ever run. Opening the door turned up six defects, four of which broke every room.
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 as the phone does. 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. Movies had no overflow button at all, so the action brings one with it.
What was broken underneath
1. Frames sent before the socket was up vanished silently.
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 — impossible for a session the server never had.This is worse 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 retry at 1s until the socket is up and an offset exists.4. Room-scoped calls addressed an empty room id, turning "there is no room" into a request against a malformed path whose 404/405 surfaced as a rejected action. They fail fast now, and fall back to the id
connect()was called with, so voting still works before the first snapshot arrives and after a transient close.5. The invite code was unreadable. Hosting pre-selects the title, so a new room is playing-and-selected the instant it exists — and every routing decision keyed on that, so creating a room flashed the code for a fraction of a second before the player replaced it. A host who is still alone now stays in the lobby; it hands off once the member count rises. Guests are unaffected.
6. The lobby could not reach its own controls. A single non-scrolling column, taller than a 1080p panel, so "Guest controls", "Close room" and the suggestion list were drawn past the bottom edge. It is now two columns: the invite (code + QR) pinned left and never scrolling, everything focusable in a right column that scrolls — the code has to stay on screen while you read it out.
Also: the QR had no quiet zone (
MARGINwas 0, and the promised padding did not exist — the canvas matched the box), and a rounded clip cut the corners off the finder patterns. Squared, with the spec's clear border.votedIdswas an unsynchronisedMutableSetwritten from an IO dispatcher and the WebSocket fold at once. The state-report cadence gate had been hand-copied into the TV controller with a comment asking the copies be kept in lockstep — it moves tosharedbesideroomTransportAuthorized.Testing
assembleDebugand the full unit suites green onshared,androidAppandandroidTvApp, from this branch based onupstream/main.New tests:
TvWatchTogetherSurfaceSourceTest(the TV failure was absence of wiring, which nothing behavioural could catch — the dialog was not reachable to observe); repository tests that sends report undelivered before the socket is up; lobby hand-off tests for host-alone / host-with-guest / guest, verified to fail when the guard is removed.Not exercised end to end against a live server. The TV build is installed on hardware and the lobby, invite code and QR were checked visually, but a room needs two participants and I have not run one. 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 — and no server changes were needed.Worth flagging: 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, reviewed it, and did the on-device checks. The defects were found by reading the code, not by running it.
Summary by CodeRabbit