Repository navigation
feat(profiles): ask who's watching at launch on Android phones and tablets - #543
Conversation
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 16 minutes. View limit details
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
| val cast = get<SiloCastSessionManager>() | ||
| org.siloserver.silo.common.profiles.ProfileAwayTracker(get(), get(), isCasting = { cast.castState.value.isConnected }) |
There was a problem hiding this comment.
Incorrect Cast activity tracking treats cast.castState.value.isConnected as active playback and does not notify ProfileAwayTracker of Cast state changes, so paused or idle connected sessions suppress Every Time and disconnects after onStop leave timed selections without an away marker. Use playback-aware Cast activity and observe background transitions so stopping or disconnecting starts the away interval even when no local Player emits an event.
Prompt for LLM
File androidApp/src/androidMain/kotlin/org/siloserver/silo/android/di/AndroidModule.kt:
Line 546 to 547:
Incorrect Cast activity tracking treats cast.castState.value.isConnected as active playback and does not notify ProfileAwayTracker of Cast state changes, so paused or idle connected sessions suppress Every Time and disconnects after onStop leave timed selections without an away marker. Use playback-aware Cast activity and observe background transitions so stopping or disconnecting starts the away interval even when no local Player emits an event.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Confirmed. isConnected stays true for a paused or finished session, so Every Time never asks while a session is connected. A session that stops while Silo is hidden never starts the away clock, so the next return doesn't ask either. Apple counts only playback that is running.
I'm fixing this in a commit on this branch, so there's no need to change it yourself. Casting now counts only while the receiver is playing, and any change in that while Silo is hidden moves the away clock, as a local player's events do.
Silo Cast to a Silo TV still isn't counted. Leaving it out means Silo asks rather than skips the picker, and its controller drops unengaged sessions in the background, so it needs its own design. I've left it as a follow-up.
There was a problem hiding this comment.
Thanks for confirming. The fix you describe addresses both parts of the finding: only receiver playback counts as active use, and playback-state changes while Silo is hidden update the away interval without relying on local player events.
The key regression cases are pausing, finishing, or disconnecting a Cast session while backgrounded, then returning with Every Time or a timed selection enabled.
Keeping Silo Cast to a Silo TV as a separate follow-up makes sense given its background-session behavior. I haven’t reviewed the new commit, but the described approach addresses this suggestion.
There was a problem hiding this comment.
Fixed in 2c2ff75. Casting counts only while isConnected && isPlaying. A collector on the Cast state calls the new ProfileAwayTracker.onRemotePlaybackChanged(), which moves the away clock only while Silo is hidden. Two new tests in ProfileLaunchPreferencesTest cover it: a Cast stop while hidden makes Every Time ask on return, and a change while Silo is in use starts no clock. No Cast receiver was available, so this wasn't walked on a device. Unit tests (android-shared, phone, TV), lint, and both debug builds pass at this commit.
There was a problem hiding this comment.
Thanks for the update. Based on your description, 2c2ff75a0 addresses both parts of the finding: only connected, playing Cast sessions count as active use, and Cast-state changes update the away clock while Silo is hidden without relying on local player events.
The two new tests cover the background-stop behavior and ensure foreground changes don’t start an away interval. The passing tests, lint, and builds are reassuring; end-to-end behavior with a Cast receiver remains unverified.
I haven’t independently reviewed the commit, but the reported fix addresses this suggestion.
| if (action != ProfileLaunchAction.AskWhoIsWatching) { | ||
| profileAwayTracker.onSelectionHandled() | ||
| return@collect |
There was a problem hiding this comment.
Missing reachability-triggered reevaluation allows KeepProfileOffline to clear selectionRequired despite its contract to ask once the server returns; if connectivity recovers while Downloads remains open, the collector receives neither a new selection request nor a navigation event, leaving the retained profile open. Preserve a deferred-selection flag and reevaluate it on server recovery before exposing online profile screens.
Prompt for LLM
File androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt:
Line 424 to 426:
Missing reachability-triggered reevaluation allows KeepProfileOffline to clear selectionRequired despite its contract to ask once the server returns; if connectivity recovers while Downloads remains open, the collector receives neither a new selection request nor a navigation event, leaving the retained profile open. Preserve a deferred-selection flag and reevaluate it on server recovery before exposing online profile screens.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
This is the same defect as the thread on MainActivity.kt line 595. I'm fixing it there in a commit on this branch.
There was a problem hiding this comment.
Understood—this duplicates the finding on MainActivity.kt line 595. No separate fix is needed for this thread, provided that commit also handles server recovery while Downloads remains open and triggers the deferred profile selection before online profile screens become accessible.
| // launch, so a protected profile there needs its PIN. Cleared | ||
| // before navigating, so the picker loads under the new server. | ||
| profileLaunchPreferences?.requiresSelectionAtLaunch() == true -> { | ||
| activeProfileReset?.clearActiveProfile() |
There was a problem hiding this comment.
Race condition identified in overlapping server selections allows an older onSelect coroutine to call activeProfileReset?.clearActiveProfile() after a newer selection activates another server, clearing the replacement server's active profile because the reset lacks requested-server or selection-generation ownership checks. Capture an ownership generation when admitting the selection, revalidate it and the active server before resetting, coordinate reset with server switching to prevent ownership changes during suspending cleanup, and recheck ownership before publishing the destination.
Also found in:
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/MainActivity.kt:590-590androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/profiles/TvProfileSelectionViewModel.kt:423-423androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/profiles/TvProfileSelectionViewModel.kt:412-412androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt:435-435androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt:431-431androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt:443-443androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt:425-425
Kody rule violation: Revalidate asynchronous ownership before publication, launch, and cleanup
Prompt for LLM
File androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/servers/ServerListViewModel.kt:
Line 93:
Race condition identified in overlapping server selections allows an older onSelect coroutine to call activeProfileReset?.clearActiveProfile() after a newer selection activates another server, clearing the replacement server's active profile because the reset lacks requested-server or selection-generation ownership checks. Capture an ownership generation when admitting the selection, revalidate it and the active server before resetting, coordinate reset with server switching to prevent ownership changes during suspending cleanup, and recheck ownership before publishing the destination.
**Also found in:**
- `androidApp/src/androidMain/kotlin/org/siloserver/silo/android/MainActivity.kt:590-590`
- `androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/profiles/TvProfileSelectionViewModel.kt:423-423`
- `androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/profiles/TvProfileSelectionViewModel.kt:412-412`
- `androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt:435-435`
- `androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt:431-431`
- `androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt:443-443`
- `androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt:425-425`
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
I don't think this one holds. Navigating to the switch destination pops the server list, which cancels its viewModelScope, so an older onSelect can't reset after the newer switch has landed. If both coroutines do get that far, the reset clears the profile on whichever server ends up active, and that server's switch would ask anyway.
A related case is real: pressing Back while the switch's probe runs cancels the gate, but AuthRepository finishes the switch in its background scope. I've raised that separately on line 92.
There was a problem hiding this comment.
Agreed—the specific race I reported is not established, and the critical classification is not justified.
The switch destination clears the navigation stack (androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt:999–1002), which removes the server-list ViewModel and cancels its scope. An older selection still waiting on the probe cannot then resume normally into the reset. If both selections reach the reset before navigation, clearing the currently active profile is not by itself evidence of incorrect behavior: that server is subject to the same device-level selection preference.
Cancellation is cooperative, so popping the screen is not a universal guarantee against every already-running operation. But that caveat alone does not establish the harmful interleaving claimed in this comment. I should have demonstrated one rather than treating missing ownership checks as proof.
The Back-during-probe case is distinct and supported by the implementation: AuthRepository.switchToServer() runs activation in backgroundScope while the caller waits on ready.await() (shared/src/commonMain/kotlin/org/siloserver/silo/repository/AuthRepository.kt:344–362). Back can cancel the caller’s wait—and therefore skip the subsequent selection gate—without canceling activation.
I no longer stand by this suggestion as written. Your separate line-92 report is the appropriate place to address that cancellation boundary.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f820e91a0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| profileLaunchPreferences?.requiresSelectionAtLaunch() == true -> { | ||
| activeProfileReset?.clearActiveProfile() | ||
| ServerSwitchDestination.ProfileSelection |
There was a problem hiding this comment.
Apply profile selection to every server switch
When Every Time is active and another saved server has a remembered PIN-protected profile, this new gate protects only onSelect. onRemove still promotes and calls switchToServer at lines 115-132 without resolving a destination, and the wrong-server pairing flow switches at AppNavigation.kt:887 before pairingAuthRouteOrNull (lines 1973-1979), which checks only token/profile presence. Backing out of either flow can therefore reopen the target server's protected profile without Who's Watching, so route every server activation through this same clear-and-picker decision.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed, on both paths. TvServerListViewModel.onRemove applies the rule through switchDestination(). The phone's onRemove promotes and switches without it, so Back from the list reopens the promoted server's saved profile without its PIN. The wrong-server pairing switch checks only whether a token and profile exist.
I'm fixing both in a commit on this branch, so there's no need to change them yourself. ActiveProfileReset.clearIfSelectionRequired() now runs after all three switches: removing the active server then goes to Who's Watching, and the pairing switch goes through the picker with its link re-queued.
There was a problem hiding this comment.
Fixed in 2c2ff75. onRemove and the wrong-server pairing switch now call ActiveProfileReset.clearIfSelectionRequired() after switching, as onSelect does. Removing the active server sends the list to Who's Watching when that server has a saved profile. Not walked on a device: it needs two saved servers, and I had one sandbox. Unit tests (android-shared, phone, TV), lint, and both debug builds pass at this commit.
| kotlinx.coroutines.flow.combine( | ||
| profileAwayTracker.selectionRequired, | ||
| navController.currentBackStackEntryFlow, |
There was a problem hiding this comment.
Defer external routes until profile selection finishes
When a notification or silo:// content intent resumes a stopped activity whose policy now requires selection, route delivery is still gated only by the current destination in consumeExternalRouteOnce (lines 519-560). The old authenticated destination can therefore let the request navigate and become consumed before this collector finishes its download/reachability decision; lines 431-435 then replace that route with the picker and clear the identity. The requested target is lost after profile choice, and a play link can begin loading under the previous profile, so include the pending profile-selection state in the external-route wait.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed. The TV app already holds a launcher link while selection is pending (TvAppNavigation checks requiresSelectionAfterBackground() before delivering), but the phone's consumeExternalRouteOnce waits only for a route outside the sign-in screens. On a warm return under Every Time, a notification tap can open the link (or start a play link) under the profile that is about to be cleared, then popUpTo(0) wipes it.
I'm fixing this in a commit on this branch, so there's no need to change it yourself: the external-route wait also waits while profileAwayTracker.selectionRequired is up. After that, Who's Watching holds the link the same way it does at launch.
There was a problem hiding this comment.
Fixed in 2c2ff75: consumeExternalRouteOnce now waits while profileAwayTracker.selectionRequired is up.
On the emulator, with Every Time on, I left Silo and delivered a silo://item link. At both 7f820e9 and 2c2ff75, Who's Watching showed and the server got no item request before the pick, so the race didn't trigger in my runs. After the pick, both builds land on Home: a content link is pinned to the identity it arrived under, and the reset changes that identity, as at launch. The change matters when the race does trigger, and for notification links, which are scoped to a server and profile only and can now open after that profile is picked again. I couldn't send a notification intent on the emulator, so that part comes from the source, not a device. Unit tests (android-shared, phone, TV), lint, and both debug builds pass at this commit.
| } | ||
| // The away interval stays recorded, so Silo asks once the server | ||
| // can be reached again. | ||
| ProfileLaunchAction.KeepProfileOffline -> Unit |
There was a problem hiding this comment.
Re-run deferred selection when the server reconnects
When the policy requires a picker but launch is allowed offline because the profile has downloads, this branch only preserves the away timestamp. ServerReachabilityMonitor keeps probing in the foreground, but its reconnect callback only refreshes config (PlayerInfraModule.kt:261-276), while the return effect observes only the tracker and back stack (AppNavigation.kt:398-401; its offline branch clears the tracker at lines 424-426). If connectivity returns without the app leaving the foreground, the previous profile remains usable until another stop/start instead of asking once the server is reachable as this comment promises, so observe reconnection and re-run the profile decision.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed. Nothing re-runs the decision on reconnect, so this comment's promise only holds at the next return. There is a second gap: at launch, Every Time can ask with no away interval recorded, so that later return wouldn't ask either. Apple has no offline exception, so this contract is Android's own.
I'm fixing it in a commit on this branch, so there's no need to change it yourself. When the launch path keeps a profile offline, it records an interval if none exists. AppNavigation raises the request when the reachability monitor reports the server reachable while that interval is still recorded. Like the profile-verification prompt, it waits until the user leaves playback, reading, or the Cast remote.
There was a problem hiding this comment.
Fixed in 2c2ff75. When the launch path keeps a profile offline, it records an away interval if none exists. AppNavigation requests the picker when the reachability monitor reports Reachable while that interval is still recorded and a profile is in use, waiting behind the routes the profile-verification prompt waits behind. Not walked on a device (it needs downloads and a connectivity toggle). The normal launches and returns I walked never raised it. Unit tests (android-shared, phone, TV), lint, and both debug builds pass at this commit.
Quick104
left a comment
There was a problem hiding this comment.
Adversarial review of 7f820e9, this PR's own commit on top of #542. Where a bot had already raised a defect, I answered in its thread instead of opening a new one.
Confirmed. I'll push fixes to this branch:
- High: removing the active server, or a pairing link's server switch, skips the rule (Codex thread on
ServerListViewModel.kt). - High: a connected but idle Cast session holds the profile, and Cast that stops while Silo is hidden never starts the away clock (Kody thread on
AndroidModule.kt). - Medium: a notification or link can open under the profile being cleared, then gets lost (Codex thread on
AppNavigation.ktline 400). - Medium: the offline exception never asks once the server is reachable again (Codex thread on
MainActivity.kt). - Medium: the restore check looks only at the top entry (inline).
- Medium: pending setting writes can be lost on a return (inline).
- Low: the launch rule ignores playback that is already running (inline).
Needs your call: pressing Back during a server switch (inline).
Not a defect: Kody's overlapping-selection race (answered in its thread).
These findings come from the source. I haven't reproduced them on a device yet, and the summary comment will report the live check.
Review by Claude Code (claude-opus-5-5) with review subagents, plus one cross-provider pass by Codex (gpt-6.1-sol).
| // Profile Selection asks on a server switch as it does at | ||
| // launch, so a protected profile there needs its PIN. Cleared | ||
| // before navigating, so the picker loads under the new server. | ||
| profileLaunchPreferences?.requiresSelectionAtLaunch() == true -> { |
There was a problem hiding this comment.
Medium, needs your call: pressing Back during a server switch skips the rule.
onSelect applies the rule only after authRepository.switchToServer(serverId) returns. That switch finishes in the repository's background scope even when its caller is cancelled, and Back stays enabled while it probes, for up to 6 s. Back pops the list and cancels viewModelScope. The server still changes, and its saved, possibly PIN-protected profile reopens behind the list without the picker.
The old shell staying behind after a cancelled switch predates this PR; the PIN bypass is new. I haven't changed this, because the fix belongs in the switch path. Options:
- (a) Block Back on the list while
pendingSwitchToIdis set. - (b) Apply the rule inside the switch operation itself, and have the list observe the destination.
- (c) Have
AppNavigationre-check the rule wheneveractiveServerIdchanges.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
| // The flusher drops a write once its profile is no longer active, and | ||
| // onStop's flush may still be in flight; push pending writes first, | ||
| // bounded, as Switch Profile does (ProfileSwitchTeardown). | ||
| withTimeoutOrNull(FLUSH_TIMEOUT_MS) { playerSettingsStore.flushPendingDeviceSettings() } |
There was a problem hiding this comment.
Race condition identified in androidApp/src/androidMain/kotlin/org/siloserver/silo/android/auth/ActiveProfileReset.kt: the new suspending flush runs after AppNavigation navigates to ProfileSelection but before clearProfile changes the identity generation, allowing ProfileSelectionViewModel to load its grid under the identity being cleared; if the load completes after clearing, loadProfiles discards the response and leaves an empty grid without retrying. Complete the reset before creating the picker, or explicitly reload the picker after the reset completes.
Prompt for LLM
File androidApp/src/androidMain/kotlin/org/siloserver/silo/android/auth/ActiveProfileReset.kt:
Line 35:
Race condition identified in androidApp/src/androidMain/kotlin/org/siloserver/silo/android/auth/ActiveProfileReset.kt: the new suspending flush runs after AppNavigation navigates to ProfileSelection but before clearProfile changes the identity generation, allowing ProfileSelectionViewModel to load its grid under the identity being cleared; if the load completes after clearing, loadProfiles discards the response and leaves an empty grid without retrying. Complete the reset before creating the picker, or explicitly reload the picker after the reset completes.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c2ff75a07
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| navController.currentBackStackEntryFlow, | ||
| profileAwayTracker.selectionRequired, | ||
| ) { entry, selectionRequired -> entry.destination.route to selectionRequired } | ||
| .filter { (_, selectionRequired) -> !selectionRequired } |
There was a problem hiding this comment.
Preserve content intents through the picker
When a silo://item or silo://play intent arrives while this policy requires Who's Watching, waiting here still cannot preserve it: delivery later compares the request's captured identityGeneration at lines 582-596, but the forced clear and subsequent profile selection advance that generation, so even reselecting the same profile fails validation and consumeExternalRouteOnce consumes the request without navigating. The fresh evidence after the earlier report is that the new filter now reaches this unchanged generation mismatch; preserve or rebuild the intended scope across the forced picker.
Useful? React with 👍 / 👎.
| navController.navigate(Route.ProfileSelection.route) { | ||
| popUpTo(0) { inclusive = true } | ||
| launchSingleTop = true | ||
| } | ||
| activeProfileReset.clearActiveProfile() |
There was a problem hiding this comment.
Reset identity before the picker loads
When a return has pending device-setting writes, this ordering composes Profile Selection before clearActiveProfile() finishes its up-to-5-second flush. ProfileSelectionViewModel.loadProfiles captures the old auth scope and, after the reset changes identity, discards its response at lines 147-173 without scheduling another load; Who's Watching can therefore settle on an empty grid, or reject the first unprotected tap if the response won the race. Reset before starting the picker or explicitly reload it after the transition.
Useful? React with 👍 / 👎.
| Box( | ||
| modifier = Modifier | ||
| .fillMaxSize() | ||
| .background(Color.Black) | ||
| .pointerInput(Unit) { |
There was a problem hiding this comment.
Make the profile cover modal for all input
While the return check or reset is pending on a device with TalkBack or a hardware keyboard, this overlay only consumes pointer events. It leaves the underlying AppNavigation semantics, focus, and non-pointer keys active, so a user can still discover or invoke controls from the prior protected profile during the seconds the black cover is shown; remove the underlying semantics and intercept key/accessibility input at the parent as a modal privacy gate.
Useful? React with 👍 / 👎.
| // Profile Selection asks on a server switch as it does at | ||
| // launch, so a protected profile there needs its PIN. Cleared | ||
| // before navigating, so the picker loads under the new server. | ||
| activeProfileReset.clearIfSelectionRequired() -> ServerSwitchDestination.ProfileSelection |
There was a problem hiding this comment.
Retain offline profiles during server switches
When the user selects a saved server that is unreachable but has downloads for its remembered profile, with Every Time or an expired timeout active, this branch clears the target identity and routes to the network-only profile picker. Unlike the launch and return paths, it never applies the download/reachability profileLaunchAction, so the picker cannot list profiles or verify a PIN and Downloads is no longer available because there is no active profile; preserve the target profile offline and request selection on reconnect. The mobile navigation invariant says Downloads appears only for an active profile with downloads.
AGENTS.md reference: AGENTS.md:L10-L10
Useful? React with 👍 / 👎.
…blets Phones and tablets get the Profile Selection setting Android TV already has: Automatic (the default), Every Time, After 1 Hour, and After 12 Hours, under Settings > Preferences. The choice stays on the device. The timing rules, the device-local store, and the away tracker move to android-shared so both apps use the same code. The TV keeps its existing preferences file, so choices made there survive. When the setting asks, Silo clears the active profile and opens Who's Watching, so a protected profile needs its PIN again. Playback that keeps going in the background counts as still in use. If the server cannot be reached and the profile has downloads, Silo keeps the profile so downloads stay playable, and asks once the server is back. Switching servers follows the launch rule, as on TV.
…d reconnect Review fixes for the phone's Profile Selection: - Removing the active server and a pairing link's server switch now apply the rule, as selecting a server does (the TV already did on removal). - Cast counts as use only while the receiver plays, and a Cast stop while Silo is hidden starts the away clock. - Links wait while Who's Watching replaces the previous profile's screens, instead of opening under the profile being cleared. - When the offline exception keeps a profile, Silo asks once the server is reachable again, and the launch path records an interval to ask about. - The restore check covers the whole restored stack, not just its top. - The reset flushes pending setting writes first, as Switch Profile does. - The launch rule leaves a profile whose playback is already running. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2c2ff75 to
534c3e9
Compare
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
| ProfileLaunchAction.AskWhoIsWatching -> { | ||
| // Cleared before the picker loads; losing its PIN proof makes | ||
| // a protected profile ask for its PIN again. | ||
| get<ActiveProfileReset>(ActiveProfileReset::class.java).clearActiveProfile() |
There was a problem hiding this comment.
Race condition in the startup decision captures activeEntry and profileId before suspending contract, download, and reachability checks, but clearActiveProfile() resets whichever identity is current afterward, allowing an obsolete decision to clear a replacement profile and its PIN proof. Capture a startup ownership generation and identity scope before asynchronous work, reject obsolete decisions, pass the expected ownership into a reset serialized with identity transitions, and recheck ownership after the suspending reset before publishing the startup destination.
Also found in:
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt:437-437androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt:441-441
Kody rule violation: Revalidate asynchronous ownership before publication, launch, and cleanup
Prompt for LLM
File androidApp/src/androidMain/kotlin/org/siloserver/silo/android/MainActivity.kt:
Line 594:
Race condition in the startup decision captures activeEntry and profileId before suspending contract, download, and reachability checks, but clearActiveProfile() resets whichever identity is current afterward, allowing an obsolete decision to clear a replacement profile and its PIN proof. Capture a startup ownership generation and identity scope before asynchronous work, reject obsolete decisions, pass the expected ownership into a reset serialized with identity transitions, and recheck ownership after the suspending reset before publishing the startup destination.
**Also found in:**
- `androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt:437-437`
- `androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt:441-441`
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
I don't think this one holds in practice. During cold-start resolution the splash covers the app, and during the return path the cover swallows input, so the user can't switch profile or server in that window. The changes that can happen there are a session expiry or a rejected PIN proof, and both already drop the profile and lead to the same picker. In that case the reset clears a profile that is already being dropped, and the destination is still Who's Watching. Leaving this open for a maintainer if you'd still like an explicit generation check.
There was a problem hiding this comment.
That’s a fair challenge. My original finding assumes that a replacement profile or server can become active during the suspended checks. The splash and return-path cover rule out user-driven transitions; the session-expiry and rejected-PIN paths you describe invalidate the existing profile rather than replace it.
Given those constraints, I haven’t established a reachable case where this reset clears a newly selected profile or its PIN proof. Suspension alone isn’t enough to substantiate the race.
An ownership-generation check could still provide defensive protection against future background identity transitions, but I would not treat it as a critical fix required for this PR without identifying a concrete replacement-identity path that can run under the cover.
Maintainer review can remain the deciding step; no issue or rule changes have been made.
| val processStart = !hasResolvedLaunchProfile | ||
| hasResolvedLaunchProfile = true |
There was a problem hiding this comment.
Race condition in cold-start resolution sets the process-wide launch flag before the suspending launch policy finishes: device rotation triggers configuration-change destruction, which cancels the resolution coroutine without calling onBackground, and the replacement Activity takes the warm branch with selectionRequired=false, bypassing Every Time and retaining the previous profile's PIN proof. Commit the flag only after the launch decision and any required profile reset complete.
Prompt for LLM
File androidApp/src/androidMain/kotlin/org/siloserver/silo/android/MainActivity.kt:
Line 503 to 504:
Race condition in cold-start resolution sets the process-wide launch flag before the suspending launch policy finishes: device rotation triggers configuration-change destruction, which cancels the resolution coroutine without calling onBackground, and the replacement Activity takes the warm branch with selectionRequired=false, bypassing Every Time and retaining the previous profile's PIN proof. Commit the flag only after the launch decision and any required profile reset complete.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Rotation can't trigger this: MainActivity declares configChanges for orientation, screen size, smallest screen size, screen layout, keyboard, and UI mode, so those don't recreate it (the emulator check rotated nothing, but the manifest settles it). Other recreations, such as a locale or density change during the splash, could, and #542's final TV version already sets its flag only after settling. Fixed in 60ef558: the phone now sets hasResolvedLaunchProfile only once the launch rule has been applied, including after the reset in the Who's Watching branch. Phone unit tests, lint, and assembleDebug pass.
There was a problem hiding this comment.
You're right—the rotation scenario in my original suggestion was incorrect because MainActivity handles those configuration changes itself.
The underlying cancellation risk still applies to an unhandled recreation during splash, such as a locale or density change. Based on your description, 60ef558 addresses that risk: committing hasResolvedLaunchProfile only after the launch policy and any required profile reset complete prevents a replacement Activity from treating an interrupted cold start as resolved.
The reported passing phone unit tests, lint, and assembleDebug support the fix. I consider this suggestion addressed, with the rotation claim corrected.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 534c3e9e22
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fun SiloCastState.castPlaying() = isConnected && isPlaying | ||
| org.siloserver.silo.common.profiles.ProfileAwayTracker( | ||
| get(), | ||
| get(), | ||
| isCasting = { cast.castState.value.castPlaying() }, |
There was a problem hiding this comment.
Treat all ongoing remote playback as profile use
When a phone-controlled SiloCast TV keeps playing after the phone is backgrounded, this predicate observes only the Chromecast SiloCastSessionManager; the separate SiloCastController that drives Route.SiloCastRemote is not in ActivePlayerHolder either. Chromecast rebuffering is also reported as isPlaying == false by SiloCastSessionManager.syncCastState. Consequently, Every Time starts an away interval and returning during an active SiloCast title or a Cast rebuffer opens Who's Watching and clears the profile mid-session; merge both remote play-intent signals and feed their transitions to the tracker.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The rebuffer part was real: SiloCastSessionManager reports isPlaying == false while buffering. Fixed in 60ef558. SiloCastState gains isPlaybackActive (playing, buffering, or loading), and the tracker counts Cast as use on that.
Silo Cast to a Silo TV is a known follow-up, listed in the review summary. Leaving it out means Silo asks rather than skips the picker. SiloCastController drops unengaged sessions when the app backgrounds, so a background transition would start the away interval even while the TV keeps playing. Counting it correctly needs that controller's own design, so I've kept it out of this PR.
…h rule after recreation - A Cast receiver that is buffering or loading still counts as use of the profile, so returning during a rebuffer no longer asks who's watching. - The phone sets its launch-rule flag only once the rule has been applied, as the TV does, so an Activity recreated during startup still applies it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60ef558296
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Profile Selection asks on a server switch as it does at | ||
| // launch, so a protected profile there needs its PIN. Cleared | ||
| // before navigating, so the picker loads under the new server. | ||
| activeProfileReset.clearIfSelectionRequired() -> ServerSwitchDestination.ProfileSelection |
There was a problem hiding this comment.
Keep the profile reset alive across Back
When Every Time (or an expired timer) applies to a saved target with a protected profile, pressing Back while switchToServer or this reset is suspended pops ServerList and cancels its viewModelScope. AuthRepository.switchToServer deliberately leaves the activation running in its background scope (AuthRepository.kt:322-328), but the reset and destination update die with the entry, so the restored shell is switched to the target server's remembered profile without Who's Watching. Fresh evidence after the earlier server-switch fix is that clearIfSelectionRequired() now adds an up-to-5-second settings flush before clearProfile(); make the policy reset durable or block Back until it finishes.
Useful? React with 👍 / 👎.
| // can ask with none recorded, so start one. | ||
| ProfileLaunchAction.KeepProfileOffline -> | ||
| if (launchPreferences.state.value.backgroundedAtMs == null) launchPreferences.markBackgrounded() | ||
| ProfileLaunchAction.KeepProfile -> if (processStart) launchPreferences.clearBackgroundedAt() |
There was a problem hiding this comment.
Preserve background markers written during startup
When a timed policy is active and the user presses Home while resolveStartDestination() is still suspended, onStop() writes a fresh away timestamp, but the startup coroutine keeps running while stopped and clears that newer value here whenever its result is KeepProfile. Returning after the 1/12-hour limit then sees no interval and reopens the previous profile instead of Who's Watching. Clear only the timestamp observed by this launch decision, or guard the update with a foreground/generation check.
Useful? React with 👍 / 👎.
Review summaryReviewed head: Fit: 8/10 · Readiness: 7/10 — conditional Addressed (commits 534c3e9 and 60ef558)
Remaining
Verification
Validated featuresUnavailable: I couldn't read the validation board. Issue #332 lists C2 and C4 for Android phone and tablet as not run, so no passed case can regress. The body's User manualSilo-Server/siloserver.org#156 already covers this PR: the Android phone and tablet Profile Selection row on the Profiles page. Two suggestions for it: mention that with downloads and no connection, Silo keeps the profile until the server is reachable, and fix the line "The Android apps and the web app have no such setting." No new docs issue is needed. Apple/Android parityiPhone, iPad and Apple TV already have Profile Selection, and Android TV got it in #542. One divergence: the offline-with-downloads exception is Android-only; silo-apple asks on return regardless of connectivity. That's reasonable for an app with offline downloads, but it should be recorded as a deliberate difference. Why these scores
Review by Claude Code (claude-opus-5-5) with review subagents and one cross-provider pass by Codex (gpt-6.1-sol). |
…) rebranded; keep fork-local silo scheme/identifier conventions
…to sync branch; content adopted rebranded in 7fb9e06
…to sync branch; content adopted rebranded in 7fb9e06
…to sync branch; content adopted rebranded in 7fb9e06
Problem
Closes #518
Related issue: Silo-Server/silo-server#1179
Validation tasks: unblocks #332 C2
On Android phones and tablets, Silo always reopens the last profile used on the device. On a family tablet, a child who opens Silo lands in a parent's profile unless every adult profile has a PIN. The 1.0 criteria (silo-server#1179, AC2) ask that on any client the user can choose between remembering a profile and asking who is watching at launch. iPhone, iPad, Apple TV and Android TV already have this setting.
This change adds Profile Selection to the phone and tablet app, with the same four choices and Automatic as the default.
Approach
android-shared, and both apps use them. The TV keeps its stored choices.Validation
android-shared, the TV app and the phone app, exceptReflowStyleTest, which fails the same way on main with this machine's locale. After the rebase onto main: android-shared 1766, phone 845, TV 1270 tests, no failures.Evidence
Evidence: https://evidence.siloserver.org/r/silo-android/pr-543/
Surface and build: phone emulator (API 36), Settings as the same profile. Before (main): no Profile Selection row. After (this branch): the row, and its page with the four choices.
Risks
Checklist
AI Disclosure
/code-review) found that casting from the phone counted as leaving Silo, so Every Time could clear the profile mid-cast. A Cast session now counts as using the profile.