Repository navigation
fix(profiles): recover from access changes without failed loads - #440
Merged
Quick104 merged 26 commits intoOct 10, 2026
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge order: this change is backwards compatible and safe to merge before the server changes. Its access-change behavior takes effect once Silo-Server/silo-server#1780 ships (policy changes stop signing users out; the events socket sends an
access_changedsignal) and Silo-Server/silo-server#1781 ships (role changes force a token refresh instead of a sign-out). Against a server without them, the new frame, close code, and 401 type never arrive and that code does nothing.Problem
Related issue: Silo-Server/silo-server#1404
Validation tasks: changes #313 C3, #314 C3, #317 C5, #318 C5
Calendar and person detail are touched only in minor ways, but a re-test of those cases is worthwhile. A remembered PIN profile still opens without a prompt while the server accepts its token; the picker appears only after the server rejects it.
Silo is about to stop signing users out when an administrator moves them to another access group or changes their permissions or playback-quality override. Today those changes sign the user out, and Android handles that by returning to Login. After the server change:
profile_verification_required. Android has no general handling for that response, so every screen shows a failed load and the user has no way back except switching profile by hand. On phone, even that fails: the profile picker loads with the stale token still attached and gets the same 403.{"type":"access_changed"}and closes with code 4001. Android reconnects, but nothing outside Home refetches, so libraries, search, details, and collections keep showing what the old policy allowed.token_refresh_required. Android already refreshes on any 401; this needed confirming, not changing.The same 403 can already happen today, for example when another device changes a profile's restrictions or PIN, so the first fix also helps against current servers.
Approach
profile_verification_requiredalong with the profile id and token the refused request sent. A recovery clears the profile selection only if that is still the active profile and token on the active server; the account stays signed in. Phone and TV then open the profile picker. Reports for an identity that has since changed (another profile, a re-entered PIN, a server switch, a pinned background request from an earlier identity, a remote-playback overlay) are ignored, so repeated refusals cannot loop. Household-management calls (editing, creating, or deleting profiles) are excluded because the server uses the same problem type there for a missing permission.access_changedframe and the 4001 close once per connection. Home, the library lists and tabs (including the TV library page and its Collections pill), search, item details, and collections refetch on phone and TV; a detail page whose title the server now refuses shows the same error as a fresh load, and reloads the title if a later change restores access, coalesced so both sockets reporting the same change, up to a server check interval apart, cause one refresh. The socket then reconnects with a new ticket; if the profile token went stale, that ticket request triggers the profile recovery above.token_refresh_requiredrefreshes and retries once on both the active and the pinned background path without ending the session.The refreshed screens use their existing quiet refresh paths. Offline caches are keyed by the full profile identity, including its token, so a re-verified profile does not read entries written under the old token.
Validation
Commands assume the repository root is the cwd, with JDK 21.
shared: 1484 tests, 0 failures.android-shared: 1617, 0 failures.androidTvApp: 1159, 0 failures.androidApp: 694 tests, 1 failure:ReflowStyleTest > line height flows from settings. It fails on this machine because its locale formats1.9as1,9; it touches no code in this change.New tests cover: detection of the 403 with the presented identity, and no report for other problem types, household-management calls, or requests without a profile; the recovery clearing only the active identity, never signing out, ignoring stale, foreign, pinned-earlier, and overlay reports, clearing once for repeated refusals, surviving a failing clear, deferring behind playback and a remote-playback overlay, keeping the prompt through unrelated identity transitions, consuming it on the picker, and dropping it after a profile pick or sign-out; the notifications loop parking on an auth close, resuming after a reset, and reconnecting after a 4001-style close; Home refreshing once per burst of access changes and reconnecting after the close; the events socket against a MockWebServer that sends the frame and a 4001 close, only a 4001 close, or an ordinary close; and the 401
token_refresh_requiredrefresh on the active and pinned paths.Lint passed on all three modules with 0 errors and no warnings on changed lines (existing findings stay in each module's baseline). Both debug APKs built.
Review fixes (
7ddd8524,b120a00c): the phone detail tests (:androidApp:testDebugUnitTest --tests 'org.siloserver.silo.android.ui.screens.detail.*', 33 tests) and TV detail tests (:androidTvApp:testDebugUnitTest --tests 'org.siloserver.silo.tv.ui.screens.detail.*', 202 tests) pass on repeated runs. The new tests cover a refused title reloading once access returns and a still-refused title staying hidden instead of repainting its cached detail. Lint and the full module suites were not re-run for these two commits.Review fixes (
0b89049d,c921bf05)::shared:testDebugUnitTest --tests 'org.siloserver.silo.repository.PersonalDataRepositoryCacheTest'covers the foreground library-list comparison (a changed set, the same set in another order, and no cached list); the TV detail access-change and next-up tests pass; both apps compile.Maintainer review (
9025078fto5805bc62): mergedmain. The foreground library check now goes throughrecheckUserLibraries, so hidden libraries no longer count as an access change. The commits also fix Back from a picker opened while adding a server, older phone search and Collections loads overwriting the access-change refresh, and a pending facet load refilling Browse facets. The full unit suites pass on5805bc62(shared 1886, android-shared 1715, androidApp 830, androidTvApp 1255 tests, 0 failures), along with lint on all three modules and both debug builds.Not run:
lintVitalRelease, the supply-chain scripts, and a manual check on a device against a server running Silo-Server/silo-server#1780 and #1781 (they are not merged yet).Risks
Checklist
AI Disclosure
mainand fixed five more findings. One finding is still open: the profile prompt does not survive process death.Note
Recover from viewer access changes without failed loads
AccessChangeSignalscoordinator in AccessChangeSignals.kt. It collects stale-profile refusals from the v2 error decoder, access-change websocket frames, and close code 4001, and exposes cursor-based flows that coalesce duplicate reportsProfileVerificationRecoveryin ProfileVerificationRecovery.kt. A stale active profile is cleared while the account session is kept, and a pending prompt routes the user to profile selection (deferred on player, sign-in, and setup routes) in AppNavigation.kt and TvAppNavigation.ktNotificationsRepository.resetwakes the parked loop via aStateFlow-backed identity epoch and clearsrealtimeFatalOnViewerAccessChangedcomposable and refresh visible data when an access change is reported. Several ViewModels (e.g.HomeViewModel,CollectionsViewModel, TV library/search ViewModels) now track loadJobs and generations so stale responses from superseded or pre-change loads cannot overwrite newer resultsNotificationsRepository.connectRealtimechanges auth-failure behavior from permanent termination to a parked wait on the identity epoch — check that path andrealtimeFatalconsumers. Also,ApiResult.isAccessRefusalclassifies 403 as a refusal only when the problem code is notPROFILE_VERIFICATION_REQUIRED, so any code branching on refusal status should be reviewedMacroscope summarized 32e759c.