Skip to content

feat(profiles): ask who's watching at launch on Android phones and tablets - #543

Merged
Quick104 merged 3 commits into
Silo-Server:mainfrom
Rhainland:fix/518-phone-profile-selection
Oct 11, 2026
Merged

Quick104 merged 3 commits into
Silo-Server:mainfrom
Rhainland:fix/518-phone-profile-selection

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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

  • The Profile Selection rules and the device-only store move from the TV app to android-shared, and both apps use them. The TV keeps its stored choices.
  • Settings → Preferences gets a Profile Selection row with Automatic, Every Time, After 1 Hour and After 12 Hours. The choice stays on the device.
  • When the setting asks, at launch or on returning to Silo, the active profile is cleared (so a PIN profile needs its PIN again) and Silo opens at Who's Watching. Playback that keeps going while Silo is hidden, including a Cast session that is playing or rebuffering, counts as still using the profile, as on Apple. Cast that stops while Silo is hidden starts the away interval then.
  • Switching servers applies the same rule, as on the TV: picking a server, removing the active one (which promotes another), and a pairing link's server switch.
  • Links that arrive while Who's Watching is replacing the previous profile's screens wait for it instead of opening under the profile being cleared.
  • With downloads and no connection to the server, Silo keeps the current profile so its downloads stay usable, and asks as soon as the server is reachable again (after leaving any playback).

Validation

  • Unit tests pass for android-shared, the TV app and the phone app, except ReflowStyleTest, 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.
  • Phone and TV debug builds and the CI lint tasks pass.
  • On a phone emulator against a local server: Automatic reopens the last profile; with Every Time a relaunch shows Who's Watching and a PIN profile asks for its PIN; switching back to Automatic reopens a remembered PIN profile without its PIN.
  • Not walked on a tablet emulator; tablets use the same code path.
  • Review fixes (534c3e9, rebased onto main after feat(tv): ask who's watching on a new Android TV and offer to remember #542 merged), on a phone emulator against a sandbox server: with Every Time, Silo restored after process death with Manage Servers over Home now opens at Who's Watching (before, Back reached Home with no profile). New unit tests cover a Cast stop while Silo is hidden. Not walked on a device: Cast, removing the active server, reconnecting after offline, and media resumption.

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

  • Offline with downloads, the current profile stays open even when the setting asks, so someone else can open that profile's downloads until the server is reachable.
  • The per-profile cache clearing now runs from both the existing switch path and the new reset helper.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code (in T3 Code)
  • Tool(s): Claude Code with subagents, adb
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, human verified
  • Review fixes: commits 534c3e9 and 60ef558 by Claude Code (claude-opus-5-5) from a maintainer review, with a cross-provider pass by Codex (gpt-6.1-sol); see the review threads.
  • Adversarial review: an independent review pass (Claude Code /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.

@silo-kody

silo-kody Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: eae85104-3acc-47e1-9cc3-c8e0962c8d5d

📥 Commits

Reviewing files that changed from the base of the PR and between 78f554c and 60ef558.


📒 Files selected for processing (27)
  • FEATURES.md
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/profiles/ProfileAwayTracker.kt
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/profiles/ProfileLaunchPreferences.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/profiles/ProfileLaunchPreferencesTest.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/MainActivity.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/auth/ActiveProfileReset.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/cast/SiloCastSessionManager.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/di/AndroidModule.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/profiles/ProfileLaunchAction.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/Routes.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/servers/ServerListViewModel.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/SettingsPages.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/SettingsScreen.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/profiles/ProfileLaunchActionTest.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/MainTvActivity.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/di/AndroidTvModule.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvAppNavigation.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/profiles/TvProfileSelectionViewModel.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/servers/TvServerListViewModel.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/TvSettingsScreen.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/TvSettingsViewModel.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/watchnext/TvWorkerFactory.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/watchnext/WatchNextProfileExpiryReceiver.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/watchnext/WatchNextSyncWorker.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/profiles/InMemoryPrefs.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/profiles/TvProfileRememberOfferTest.kt

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T05:02:31.485176Z 60ef558 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment on lines +546 to +547
val cast = get<SiloCastSessionManager>()
org.siloserver.silo.common.profiles.ProfileAwayTracker(get(), get(), isCasting = { cast.castState.value.isConnected })

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug high

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.

​

​

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment on lines +424 to +426
if (action != ProfileLaunchAction.AskWhoIsWatching) {
profileAwayTracker.onSelectionHandled()
return@collect

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug high

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.

​

​

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the same defect as the thread on MainActivity.kt line 595. I'm fixing it there in a commit on this branch.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules critical

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

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.

​

​

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +92 to +94
profileLaunchPreferences?.requiresSelectionAtLaunch() == true -> {
activeProfileReset?.clearActiveProfile()
ServerSwitchDestination.ProfileSelection

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +398 to +400
kotlinx.coroutines.flow.combine(
profileAwayTracker.selectionRequired,
navController.currentBackStackEntryFlow,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 Quick104 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.kt line 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 -> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 pendingSwitchToId is set.
  • (b) Apply the rule inside the switch operation itself, and have the list observe the destination.
  • (c) Have AppNavigation re-check the rule whenever activeServerId changes.

@silo-kody

silo-kody Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

// 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() }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug high

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.

​

​

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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 }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +437 to +441
navController.navigate(Route.ProfileSelection.route) {
popUpTo(0) { inclusive = true }
launchSingleTop = true
}
activeProfileReset.clearActiveProfile()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment on lines +259 to +263
Box(
modifier = Modifier
.fillMaxSize()
.background(Color.Black)
.pointerInput(Unit) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Rhainland and others added 2 commits October 11, 2026 00:37
…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]>
@Quick104
Quick104 force-pushed the fix/518-phone-profile-selection branch from 2c2ff75 to 534c3e9 Compare October 11, 2026 04:39
@silo-kody

silo-kody Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules critical

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

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.

​

​

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment on lines +503 to +504
val processStart = !hasResolvedLaunchProfile
hasResolvedLaunchProfile = true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Security critical

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.

​

​

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +556 to +560
fun SiloCastState.castPlaying() = isConnected && isPlaying
org.siloserver.silo.common.profiles.ProfileAwayTracker(
get(),
get(),
isCasting = { cast.castState.value.castPlaying() },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

silo-kody Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@Quick104

Copy link
Copy Markdown
Contributor

Review summary

Reviewed head: 60ef558: the phone commit plus two review-fix commits, rebased onto main after #542 merged. Rebasing only touched TV startup, where it keeps #542's final first-launch rule, and one #542 TV test, which now uses the shared preferences type.

Fit: 8/10 · Readiness: 7/10 — conditional

Addressed (commits 534c3e9 and 60ef558)

  • High: removing the active server and a pairing link's server switch now apply the rule, as picking a server does.
  • High: Cast counts as use only while the receiver plays or rebuffers, and a Cast stop while Silo is hidden starts the away interval.
  • Medium: links that arrive while Who's Watching replaces the previous profile's screens wait for it, instead of opening under the profile being cleared.
  • Medium: after the offline-with-downloads exception, Silo asks once the server is reachable again (after leaving playback), and the launch path records an interval to ask about.
  • Medium: the process-death restore check looks beneath the top entry, so Manage Servers over Home can't leave Back at a Home with no profile.
  • Medium: the reset pushes pending setting writes (bounded) before clearing, as Switch Profile does.
  • Low: the launch rule leaves a profile whose playback is already running (media resumption).
  • Low: the phone sets its launch-rule flag only after the rule is applied, as the TV does, so an Activity recreated during startup still applies it.

Remaining

  • Needs your call: pressing Back during a server switch still skips the rule (thread on ServerListViewModel.kt). Options are in that thread.
  • Follow-up: Silo Cast to a Silo TV isn't counted as use. That errs toward asking, and its controller drops unengaged sessions in the background, so it needs its own design.
  • Follow-up: a paused audiobook stays loaded behind Who's Watching, so its media notification still shows the previous profile's title. silo-apple closes the audio player before it clears the profile on return.
  • Kody's overlapping-selection race and its startup-ownership race: answered in their threads as not defects.

Verification

  • Phone emulator (Android 14) against a sandbox server built from silo-server main, with Profile Selection set to Every Time. Same steps before (7f820e9) and after (2c2ff75; the phone code later changed only in the Cast rebuffer check and the launch flag's placement):
    • Process death with Manage Servers over Home: before, Silo reopened on the server list and Back reached Home with no profile ("Sign in to load Home"). After, it reopens at Who's Watching.
    • Relaunch: shows Who's Watching, and the PIN profile asks for its PIN.
    • silo://item link on a return: both builds showed the picker with no item request first, so the race didn't trigger here. After the pick, both land on Home, because content links are pinned to the identity they arrived under.
  • Unit tests at 534c3e9: android-shared 1766, androidApp 845, androidTvApp 1270, no failures. At 60ef558 (phone-only change): androidApp tests, lint and assembleDebug pass.
  • Lint (lintDebug for all three modules, lintVitalRelease for both apps): no new issues. Both apps' assembleDebug and the supply-chain scripts pass.
  • Not walked on a device: Cast, removing the active server, reconnecting after offline, the settings flush, and media resumption.
  • CI on 60ef558: all checks pass (Android CI, Lint, Unit tests, Release readiness, Evidence, Kody). The earlier Unit tests failure on 2c2ff75 was DiagnosticsCoordinatorTest, unrelated to this PR, and it passed locally and on the next run.

Validated features

Unavailable: 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 Validation tasks: unblocks #332 C2 line is unchanged and unconfirmed.

User manual

Silo-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 parity

iPhone, 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

  • Fit 8: the change closes a published 1.0 criterion ("On any client, the user can choose to remember a profile or ask who is watching at launch") with the same four choices as Apple, kept on the device. The setting is the criterion, so it isn't extra surface. The Android-only offline exception holds the score down until the divergence is recorded.
  • Readiness 7: the verified defects are fixed and the main paths were walked on an emulator. What holds it at conditional: the open Back-during-switch case and several fixes checked only from source and unit tests.

Review by Claude Code (claude-opus-5-5) with review subagents and one cross-provider pass by Codex (gpt-6.1-sol).

@Quick104
Quick104 merged commit 538aa09 into Silo-Server:main Oct 11, 2026
9 checks passed
JonahMMay added a commit to Prairie-Server/prairie-android that referenced this pull request Oct 11, 2026
…) rebranded; keep fork-local silo scheme/identifier conventions
JonahMMay added a commit to Prairie-Server/prairie-android that referenced this pull request Oct 11, 2026
JonahMMay added a commit to Prairie-Server/prairie-android that referenced this pull request Oct 11, 2026
JonahMMay added a commit to Prairie-Server/prairie-android that referenced this pull request Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact: usability Core flow broken or severely blocked priority: P2 Limited scope, workaround exists, or polish

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] Ask who's watching at launch on the Android phone and tablet app

2 participants