Skip to content

feat(accounts): sign in to more than one account per server - #795

Merged
Quick104 merged 13 commits into
mainfrom
feat/multi-account
Nov 4, 2026
Merged

Quick104 merged 13 commits into
mainfrom
feat/multi-account

Conversation

@Quick104

@Quick104 Quick104 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: changes #332 and #333 (profile picker, PIN), #329 (downloads and offline), #336 and #337 (sign-in and onboarding), #346 (notifications)

Silo on Android keeps one signed-in account per server. Someone with two logins on one server, such as a parent and a teenager on the household server, has to sign out and back in to switch, and signing out used to leave the other person's downloads behind. This change lets each saved server hold several accounts and switch between them from the profile menu, on phone, tablet and Android TV. It follows the shared multi-account design and the owner's 2026-11-02 Change Account revision that Roku and Apple also ship.

Approach

  • Accounts in shared/. ServerRegistry and TokenManager gain an account dimension keyed by a device-made localAccountId, so phone and TV share it. The server's user ID only finds duplicates: signing in as a saved account refreshes it.
  • Migration. On first launch, each server's existing session becomes one account, offline. The old credential slots are deleted only after the new records read back. That account adopts the server's existing downloads, Room rows and preferences.
  • Local data per account. Room moves to schema 16, adding accountId to the eight tables keyed by server and profile (manual migration). Downloads go under <server>/acct-<id>/<profile>/. About fifteen preference and cache stores are now keyed by account, and push keeps one installation per server, handed to the account in use with the same key and the next generation.
  • Sign-out and expiry. Signing out of an account revokes its session and deletes its downloads, rows and preferences. An expired or revoked session is not a sign-out: the account and its downloads stay, marked Sign in again.
  • UI (owner revision).
    • Who's watching? shows the open account's profiles plus Add.
    • Add opens a sheet: Add a profile, Add an account, Add a server.
    • A new Change Account screen lists every saved server's accounts: a server rail and account pane on Android TV, a grouped list on phone and tablet. It is reached from the picker footer and from the profile menu, where Switch Server was.
    • Settings › Accounts replaces the server list.
    • The sign-out dialog is the app's own, with Cancel as the default, and offers Sign Out & Remove Server only when the server has no other account.
    • Server marks fall back to the Silo project icon.
  • Notifications. With more than one profile or account, the subtitle names the profile and server, and opening one switches to its account and profile.

Validation

  • :androidApp:assembleDebug and :androidTvApp:assembleDebug pass.
  • Unit tests: all four modules pass locally (shared, android-shared, androidApp, androidTvApp). Existing tests were updated to the account-scoped APIs; no new tests.
  • Release lint (lintVitalRelease) passes, and a minified release build was installed on a Pixel 11 Pro and an onn 4K TV.
  • Emulator runs against two isolated test servers passed:
    • Phone (Pixel 9): upgrading from main kept the account, profile and download.
    • Adding a second account on one server and a second server.
    • Switching accounts kept downloads per account.
    • Signing out deleted only that account's downloads.
    • An expired session showed Sign in again with the username filled in.
    • Change Account as the root screen when no account is open.
    • Tablet (Pixel Tablet): picker, Add sheet and Change Account.
    • Android TV (API 36): migration, rail and pane D-pad movement, Cancel focused in the sign-out dialog, expiry, and Watch Next following the switch.
    • The Room 15→16 migration was also run in SQLite on the real v15 schema with sample rows.
  • Not verified on a device: Remove server and Rename, replacing an expired account with a different one, the offline picker, push handover and opening a notification, a foldable, and a phone approving a TV sign-in for several accounts.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-android/pr-795/

Surface and build: debug builds of this branch and of main, on the Android phone, tablet and TV emulators. No foldable capture: the changed screens use the same compact and expanded layouts the phone and tablet captures show.

Risks

  • Migration. Every signed-in install rewrites its credentials and Room tables on first launch. It needs no network and retries on the next launch if a write fails, A build older than this one can't open the upgraded database (Room schema 16), so downgrading isn't supported.
  • Behaviour changes. Sign-out now deletes that account's downloads, which is new; the dialog states the count and size. With one profile and no PIN, the picker is skipped even under Every Time.
  • Sign-in identity. A sign-in refreshes a saved account only when its known server user ID matches. A migrated account whose user ID was never filled in becomes a separate account when signed in again; the phone offers Replace or Keep both.
  • Known gaps:
    • Revoking a session at sign-out is tried once, with no retry.
    • Two saved accounts later found to be the same server user are not merged.
    • On TV, removing a server you aren't using forgets its accounts without revoking their sessions.
    • When an account you aren't using expires, it is marked only once you choose it.
  • Size. This covers all four phases of the design in one pull request. It can be split into storage, phone UI, TV UI and notifications if reviewers prefer.

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: T3 Code running Claude Code
  • Tool(s): Claude Code subagents (general-purpose, code-simplifier), agent-device with the Fleet SimLock emulator pool, silo-dev-builder test servers
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated; verified on emulators by the agent, not yet by a human
  • Adversarial review: n/a, none run yet

🤖 Generated with Claude Code

Note

Add multi-account support: sign in to more than one account per server

  • Stores multiple saved accounts per server in AndroidServerRegistry, with account-scoped credentials, cached profiles, and an active-account selection. EncryptedTokenManagerImpl reads and writes tokens per account and migrates legacy per-server credentials on startup.
  • Adds account IDs to all local data scopes: Room tables (v15→16 migration in SiloDatabase.kt), download storage paths, DAO queries, DataStore settings files, and JSON state files.
  • Adds Change Account / Accounts UI on mobile and TV, including sign-out with optional server removal, expired-account replacement prompts, and account-scoped push notifications.
  • Adopts pre-account legacy data: files, rows, and JSON state move under an account token during a one-time adoption pass in OrphanedServerDataPurger and AccountLocalData; account-scoped purge runs when an account is removed.
  • Risk: database migration MIGRATION_15_16 rebuilds download, subscription, deletion, cache, and state tables with a new accountId primary-key column; existing installations should be checked for data loss. Legacy per-server credential migration in migrateAccountsIfNeededLocked copies tokens to account-scoped keys and should be verified on upgrade.

Macroscope summarized b897e3d.

Each saved server can now hold several accounts, keyed on the device by a
local account id. Credentials, Room rows, downloads, preferences, caches and
the push installation are kept per account. An existing signed-in install
migrates offline on first launch and keeps its downloads and profile.

Who's watching? shows the open account's profiles. A new Change Account
screen lists every saved server's accounts (a rail and pane on Android TV,
a grouped list on phone and tablet). Signing out of an account deletes its
downloads; an expired session keeps them and asks to sign in again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. label Nov 3, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 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 ⚠️ Failed 2026-11-04T04:13:56.422254Z
We couldn’t complete this review. Comment @codex review to try again.
b897e3d New commits
🔒 Security Review ✅ Completed 2026-11-03T03:26:48.702029Z b4d0c00 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.

@silo-kody

silo-kody Bot commented Nov 3, 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 Nov 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Walkthrough

The pull request adds saved accounts per server and extends account identity across credentials, local data, downloads, synchronization, and Android and Android TV navigation. It adds account-management flows and migration and adoption paths for existing account-less data.

Changes: Saved accounts and account-scoped data

Layer / File(s) Summary
Account identity and authentication
shared/src/commonMain/kotlin/org/siloserver/silo/model/server/*, shared/src/commonMain/kotlin/org/siloserver/silo/network/*, shared/src/commonMain/kotlin/org/siloserver/silo/repository/*, shared/src/androidMain/kotlin/org/siloserver/silo/network/*
Shared models and registry APIs add account state and account switching. Credential storage, sign-in, sign-out, profile refresh, and account identity migration are updated.
Database and synchronization scopes
android-shared/schemas/*, android-shared/src/androidMain/kotlin/org/siloserver/silo/common/data/db/*, android-shared/src/androidMain/kotlin/org/siloserver/silo/common/data/sync/*, shared/src/commonMain/kotlin/org/siloserver/silo/repository/*
Room advances to version 16 and adds account IDs to scoped keys and queries. Cache, user-state, download-deletion, and outbox operations include account scope.
Local data and downloads
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/store/*, android-shared/src/androidMain/kotlin/org/siloserver/silo/common/settings/*, android-shared/src/androidMain/kotlin/org/siloserver/silo/common/downloads/*
Local files, settings, bookmarks, caches, download metadata, workers, locks, and storage paths use account-aware scope. Legacy data adoption and account cleanup are added.
Android account journeys
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/*, androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/servers/*, androidApp/src/androidMain/kotlin/org/siloserver/silo/android/auth/*, androidApp/src/androidMain/kotlin/org/siloserver/silo/android/push/*
Android adds account-list, account-detail, and Change Account flows. Sign-in, sign-out, pairing, notification routing, and profile selection use saved account identity.
TV account journeys
androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/*, androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/profiles/*, androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/data/preferences/*
TV adds Accounts and Change Account screens. Routes, profile selection, launch-tile restoration, sign-in, and preference files use account scope.

Estimated code review effort: 5 (Critical) | ~120 minutes

Change: Feature

Suggested reviewers: rxwatcher, rhainland

Merge Risk: Low · previous review 1e3d9

Signed-out downloads may remain until a later cleanup, and an old TV PIN prompt can remain after an account switch.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 44.26% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title "feat(accounts): sign in to more than one account per server" matches the main change in the changeset. The raw summary and objectives show account-scoped sessions, storage, and UI across th…
Description check Passed The description is directly related to the changeset. It explains the multi-account-per-server goal, the device-local account ID design, the Room 15→16 migration, account-scoped downloads and preferen…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(accounts): sign in to more than one account per server" matches the main change in the changeset. The raw summary and objectives show account-scoped sessions, storage, and UI across the shared, android-shared, androidApp, and androidTvApp modules, with multi-account sign-in per server as the central goal. The title is concise, specific, and follows a conventional commit style.

Full details: Description check

Explanation

The description is directly related to the changeset. It explains the multi-account-per-server goal, the device-local account ID design, the Room 15→16 migration, account-scoped downloads and preferences, sign-out and expiry behavior, the phone and TV UI changes, notifications, validation steps, and risks. It matches the file-level summaries and the PR objectives.

Full details: Docstring Coverage

Explanation

Docstring coverage is 44.26% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 122 functions across 104 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@macroscopeapp

macroscopeapp Bot commented Nov 3, 2026

Copy link
Copy Markdown

Evidence is missing: the Evidence section still contains EVIDENCE_LINK, not a published evidence URL, and the PR body has no attached screenshots or recording. Emulator test notes do not let reviewers see the change.

  • The account/profile picker, Add choices, Change Account, Settings › Accounts, sign-out/sign-in screens, and account-specific visible profile/download state (androidApp/src/androidMain/.../ProfileSelectionScreen.kt, AccountsScreen.kt, ChangeAccountScreen.kt, AccountDialogs.kt; shared account-scoped state in android-shared/) reach Android phone, tablet, foldable, and Android TV. Before/after captures are missing for phone, tablet, and TV; the foldable omission cites equivalent compact/expanded layouts, but the referenced phone/tablet captures are absent. Provide the captures (foldable folded and open, or a reason for omitting it supported by the actual captures) and a recording of the multi-step account flow.
  • TV-specific account rail/pane, Add sheet, and D-pad focus behavior (androidTvApp/.../TvChangeAccountScreen.kt, TvChoiceSheet.kt) lack Android TV before/after captures and a recording showing focus movement and the flow.
  • Notification account attribution and opening a notification switching to its account/profile (androidApp/.../PushNotificationPresenter.kt, NotificationTileSwitch.kt) reach Android phone, tablet, and foldable; no captures or recording of the notification-opening flow are provided.

Suggested fix: No diff applies; publish the evidence and replace EVIDENCE_LINK with its URL, or attach the captures and recording.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@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: fe39445cd3

ℹ️ 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".

@silo-triage silo-triage Bot added enhancement New feature or request needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. priority: P2 Limited scope, workaround exists, or polish labels Nov 3, 2026
- Copy, move and delete account files with java.io.File instead of java.nio.file.Files
- Detect real directories with Os.lstat so a symlink isn't followed
- Fall back to the Silo icon in the marquee server chip when the server has no mark
@silo-kody

silo-kody Bot commented Nov 3, 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 ❌

@silo-kody

silo-kody Bot commented Nov 4, 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 ❌

// Nothing else reloads this picker on an account
// change, so load the open account then (or reach
// NoAccountOpen if it was removed).
gridScope = null

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

A discarded grid leaves its PIN verification active

An old account's PIN prompt can remain usable after an account change, or a queued verification can commit the old profile to the new account. When discarding the grid, invalidate the PIN attempt, close the dialog, and bind verification to the captured gridScope.

Kody rule violation: Revalidate asynchronous ownership before publication, launch, and cleanup

Prompt for LLM
File androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/profiles/TvProfileSelectionViewModel.kt, line 288:

A discarded grid leaves its PIN verification active

Invalidate the outstanding PIN attempt and close the PIN dialog when discarding the old grid. Also bind PIN verification to the grid's captured scope rather than capturing the current scope after the verification coroutine starts. Otherwise, an old account's PIN prompt can remain usable after the account changes, or a queued verification can capture the new account's identity and commit the old profile there.

Kody rule violation: [Revalidate asynchronous ownership before publication, launch, and cleanup](https://kodus.siloserver.org/settings/code-review/1247142403/kody-rules/8ee8ffaf-7856-4c08-a084-f52e4c5e5f57?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)

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 Author

Choose a reason for hiding this comment

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

Fixed in 7fdb87c. When the post-record check discards the grid, it now bumps pinAttempt, clears addAfterUnlock, and closes the PIN dialog (pinProfile, pinForManagement, pinError, isVerifyingPin). A verification still in flight drops its answer, and the old prompt can no longer be submitted.

I left onPinEntered capturing the scope when it runs instead of binding it to gridScope. That is how main and the phone picker already work, so it is outside this PR. The pre-record identity check above it has the same PIN-dialog gap on main, and I left that unchanged here too.

🤖 Claude Code (claude-opus-5-5)

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 addressing the post-record discard path. The original issue is only partially resolved, though: matching main does not make the remaining race safe for multi-account switching.

In TvProfileSelectionViewModel.kt:521–529, onPinEntered takes the profile from the existing dialog but captures the identity inside the launched coroutine. If the account changes before that capture, verification can use the new account’s scope with the old grid’s profile. The later scope check would not detect that mismatch. The pre-record discard path at lines 253–269 also leaves the old PIN dialog and attempt active.

Please bind the PIN flow to the scope associated with the displayed grid, reject a missing or stale scope rather than treating it as unguarded, and invalidate the attempt and close the dialog on every path that discards that grid. Regression tests should cover an account change before the verification coroutine runs and during each discard path, including management PINs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Leaving the rest out of this PR. Capturing the scope when onPinEntered runs, and the pre-record discard branch, both work this way on main, and the phone picker does the same. Binding verification to the grid scope changes both pickers and has to be checked against the TV remote-playback identity overlay that capture-at-answer guards against.

An account can now change while the TV picker is alive (launcher tiles call switchToAccount). In that case an old prompt verifies another account's profile ID, which the server is expected to reject, so the likely result is a PIN error, not a wrong selection. That isn't confirmed against the server.

Follow-up with the full fix and regression tests: #804. I'm leaving this thread open for a human reviewer.

🤖 Claude Code (claude-opus-5-5)

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. The post-record discard path is partially addressed, but the scope-binding race and pre-record discard path remain unresolved in this PR. I agree the proposed fix needs to account for the TV remote-playback identity overlay.

Because server-side rejection of a profile ID from another account has not been confirmed, the impact remains uncertain; we should not assume it is limited to a PIN error. Follow-up #804 covers the full fix and regression tests, and the thread remains open for human review.

When a profile load finds the account changed while it recorded the list,
it now also voids any PIN check in flight and closes the PIN dialog, so an
old account's prompt can't verify or commit after the switch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@silo-kody

silo-kody Bot commented Nov 4, 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 ❌
⚠️ 4 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Validate download ownership before publishing subtitle bytes
  • Bind playback markers to the actual playing file
  • Share route-aware audio decisions and preserve original-format decoder fallback
  • Apply playback route eligibility consistently at admission and media loading

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (2)

Major · Bind cached-profile taps to the cached account. · ProfileSelectionViewModel.kt:590

androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/profiles/ProfileSelectionViewModel.kt:590
Major · Data Integrity & Integration · Heavy lift

Bind cached-profile taps to the cached account.

openCachedProfile bypasses the displayed grid's gridScope and captures the current scope after scheduling work. If the account changes before or during that capture, the old cached profile ID can be committed under the new account. Capture the active account ID at tap time, capture the scope, and reject the tap if the account changed before the capture completes. Pass that captured scope to selectProfile so the repository also rejects a transition after capture.

Major · Skip row adoption when file adoption returns false. · OrphanedServerDataPurger.kt:190-191

android-shared/src/androidMain/kotlin/org/siloserver/silo/common/downloads/OrphanedServerDataPurger.kt:190-191
Major · Data Integrity & Integration · Quick win

Skip row adoption when file adoption returns false.

storage.adoptLegacyFiles returns false when the owner marker cannot be written or when another account already owns the server's legacy files. The code ignores that result and still relabels the Room rows to this account. Account-scoped lookups and deletes include the legacy files only for the recorded owner. The relabeled rows can then point to files that this account cannot read. Sign-out does not delete those files.

Checking the result lets a later purge pass retry adoption and relabel the rows only after the owner is recorded.

Suggested fix
-                    storage.adoptLegacyFiles(account.serverId, account.localAccountId)
-                    purgeDao.adoptLegacyRows(account.serverId, account.localAccountId)
+                    if (storage.adoptLegacyFiles(account.serverId, account.localAccountId)) {
+                        purgeDao.adoptLegacyRows(account.serverId, account.localAccountId)
+                    }
Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9a42427c-013f-46d3-8f10-5bbb0291b32d
Commits

Reviewing files that changed from the base of the PR and between cdc870a and 4fb9d99.

Files selected for processing: 11
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/downloads/DownloadWorker.kt
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/downloads/OrphanedServerDataPurger.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/auth/LoginScreen.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/profiles/ProfileSelectionViewModel.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/components/TvSignOutDialog.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/TvAccountsScreen.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/servers/TvChangeAccountScreen.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/TvSettingsScreen.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/theme/TvTypographyReadabilityTest.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/repository/AuthRepository.kt

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

…ed taps to the account

- Legacy adoption relabels Room rows only once the account is recorded as
  the owner of the server's legacy files, so rows never point at files the
  account can't see. A failed marker write leaves them for a later pass.
- A cached profile tile on phone commits only while its account is still
  the open one, checked before and after the identity scope is read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Quick104

Quick104 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Both outside-diff findings from the latest CodeRabbit review are fixed in 7da7845:

  • OrphanedServerDataPurger.kt:190: adoptLegacyRows now runs only when adoptLegacyFiles returns true. A failed marker write, or another owner, leaves the rows unadopted for a later pass to retry.
  • ProfileSelectionViewModel.kt:590: openCachedProfile checks that the tile is in the open account's cached list. It records that account ID at tap time, reads the scope, and drops the tap if the account changed in between. The captured scope still goes to selectProfile, so a later change is rejected there. A cached tile with a PIN goes through onPinEntered, whose scope timing fix(tv): profile picker PIN prompt can outlive its grid after an account change #804 tracks.

🤖 Claude Code (claude-opus-5-5)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@silo-kody

silo-kody Bot commented Nov 4, 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 ❌

if (registry != null && openAccountCached.orEmpty().none { it.id == profile.id }) return
viewModelScope.launch {
val scope = profileRepository.captureIdentityScope()
if (registry?.activeAccountId?.value != accountId) return@launch

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

Cached profile selection does not validate the displayed identity generation

An obsolete tap can select a profile under a replacement identity because activeAccountId alone cannot detect server changes, identity transitions, or overlapping profile IDs. Bind displayed profiles to their server, account, and identity generation, then revalidate ownership after capturing the scope and before selection.

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/profiles/ProfileSelectionViewModel.kt, line 598:

Cached profile selection does not validate the displayed identity generation

Bind the displayed cached profiles to a captured server/account authority and identity generation, then revalidate that ownership after capturing the scope and before selecting the profile. Comparing only the account ID cannot detect a server change or an account transition away and back while capture is suspended; it also does not prove that the tapped tile belongs to the currently displayed account when profile IDs overlap. An obsolete tap can therefore select a profile under a replacement identity.

Kody rule violation: [Revalidate asynchronous ownership before publication, launch, and cleanup](https://kodus.siloserver.org/settings/code-review/1247142403/kody-rules/8ee8ffaf-7856-4c08-a084-f52e4c5e5f57?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)

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 Author

Choose a reason for hiding this comment

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

Not changing this. The cases are covered by guards that are already here:

  • Server change: localAccountId is a UUID made on the device for each saved account (AndroidServerRegistry.kt:312). A different server means a different account ID, so the account check after capture drops the tap.
  • Away and back while the scope is read: the captured scope goes to selectProfile, which re-checks it inside the profile-switch transition (ProfileRepository.kt:143). isSameIdentityAs compares server, account, identityGeneration and credentialEpoch (AuthScopeSnapshot.kt:67). A scope read under another account, or under this one before it switched away and back, has an older generation and returns ScopeChanged. If the whole round trip finishes before the read, the scope and the tile both belong to the open account, which is correct.
  • Tile ownership: when the tap is handled, the profile must be in the open account's cached list in the registry, not just the drawn list. A tile from another account could pass only if that account had a profile with the same server-made ID.

The ownership check runs on both sides of the capture, and the repository enforces the generation at the write. Leaving this open for a human reviewer.

🤖 Claude Code (claude-opus-5-5)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The existing guards address part of the concern, but they do not establish the identity that produced the tapped tile.

  • After scope capture: I agree that selectProfile revalidates the captured scope inside the profile-switch transition. That protects against a subsequent identity change before the write. See ProfileRepository.kt:117–155.
  • Before scope capture: The account ID is checked before and after capture, but not the identity generation. If an account transitions away and back before capture finishes, the same account ID can pass the check while the captured scope reflects the later generation. The repository then validates that later scope—not the identity under which the tile was displayed.
  • Tile ownership: The registry check tests profile ID membership, not the tile’s provenance. As you note, an overlapping profile ID can pass. Also, the cached PIN path returns before that registry check (ProfileSelectionViewModel.kt:582–595).

The UUID argument reduces the ordinary cross-server risk, and the write-time guard is valuable. But neither proves that the displayed profile belongs to the captured identity. I’d keep the finding open for human review, with the qualification that the cross-account case depends on overlapping profile IDs and a stale tap. The practical likelihood and severity of that case still need assessment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fair point on the PIN path. In 1e3d9ba the open-account check runs before the PIN branch, so a cached tile with a PIN can't open its prompt unless it's in the open account's cached list. That PIN answer still captures its scope when it runs, which #804 tracks.

On the away-and-back case: the check is that the account ID is the same, and a cached tile is that account's profile. So committing it under the account's newer generation selects the right profile. The remaining case needs two accounts with the same server-made profile ID and a stale tap. I agree that's for a human reviewer to weigh, so I'm leaving this open.

🤖 Claude Code (claude-opus-5-5)

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. With the open-account membership check before the PIN branch, my earlier PIN-path objection no longer applies; the later PIN scope-capture concern is tracked in #804.

For the non-PIN path, selecting the same account’s cached profile under a newer generation can be correct, assuming the account and profile still represent the same identity. The remaining provenance concern is narrower: a stale tile could pass the current account’s membership check if the profile IDs overlap.

Leaving the finding open for a human reviewer to assess that scenario’s likelihood and severity is reasonable.

…rompt

A cached profile with a PIN opened its dialog before the open-account
check, so a tile drawn for another account could still prompt. The check
now runs first for both paths.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Nov 4, 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 ❌
⚠️ 4 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Validate download ownership before publishing subtitle bytes
  • Bind playback markers to the actual playing file
  • Share route-aware audio decisions and preserve original-format decoder fallback
  • Apply playback route eligibility consistently at admission and media loading

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Retry deferred account cleanup after playback teardown. · OrphanedServerDataPurger.kt:199-225

android-shared/src/androidMain/kotlin/org/siloserver/silo/common/downloads/OrphanedServerDataPurger.kt:199-225
Minor · Data Integrity & Integration · Quick win

Retry deferred account cleanup after playback teardown.

If the user signs out while ActivePlaybackFile belongs to that account, purgeAccount retains the files and rows. Playback teardown only clears ActivePlaybackFile; it does not trigger another purge pass. The signed-out account's data can therefore remain until another registry change or an app restart.

Make playback teardown notify the purger and invoke purgeOnce() after the active file clears.

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e50dbc1b-f92c-417d-b4a9-9e68895ddbe8
Commits

Reviewing files that changed from the base of the PR and between 4fb9d99 and 1e3d9ba.

Files selected for processing: 3
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/downloads/OrphanedServerDataPurger.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/profiles/ProfileSelectionViewModel.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/profiles/TvProfileSelectionViewModel.kt

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Signing out of an account while one of its downloads plays defers the
purge, and nothing ran it again until the next launch. The purger now
notes the deferral and runs a pass once the player releases its file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Quick104

Quick104 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

The outside-diff finding from the latest CodeRabbit review (OrphanedServerDataPurger.kt:199-225) is fixed in 3de4442. When purgeAccount defers because one of the account's files is playing, it records that. start() now watches ActivePlaybackFile.fileId and runs purgeOnce() when the file clears, if a purge was deferred.

purgeServer defers the same way on main, with no retry when playback ends. This PR leaves that unchanged.

🤖 Claude Code (claude-opus-5-5)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@silo-kody

silo-kody Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Code Review Completed, but its comments could not be posted ⚠️

The review produced 1 comment(s), but none could be posted to this pull request (for example, the platform rejected them with a rate limit). This is not a clean review: comment @kody review on this PR to run it again.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Access your configuration settings here.

​

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. priority: P2 Limited scope, workaround exists, or polish size/XXXL 3000+ added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant