Skip to content

feat(accounts): keep several accounts per server and add Change Account - #992

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

Quick104 merged 12 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: not yet checked against the v1.0 board

Silo on iPhone, iPad, Mac and Apple TV keeps only one signed-in account per server. A second person on the same server has to sign the first one out, and signing out on a shared device loses that person's downloads and settings. Saving the same server under two addresses (for example a LAN address and a domain) shows it twice.

This change lets each server hold several accounts, adds a Change Account screen to move between them, and merges duplicate addresses of one server.

Approach

  • Storage. Accounts are stored under a device-made ID (localAccountId); the server's user ID is only used to find a saved account again. A one-time migration at launch, with no network, turns each saved session into an account and moves its downloads, preferences, response snapshots, player settings, launch memory, watch party and push ownership under that account. Only the migration reads the old storage.
  • Screens. "Who's watching?" still shows the open account's profiles, and Add on it still creates a profile. Change Account lists saved accounts by server: a standard grouped list on iPhone, iPad and Mac (checkmark on the open account, Sign Out by swipe or long press, Add Account and Add Server rows; Settings › Accounts rows offer the same swipe and long-press sign-out), and a server rail with an accounts pane on Apple TV. It replaces Switch Server in the avatar menu and Change server on the picker's footer. The picker has no server pill. Server labels show the server's logo, or the Silo project icon when it has none.
  • Sign-out. Signing out of one account deletes that account's downloads and local data, after a confirmation: the system alert on iPhone, iPad and Mac, and the app's own dialog with Cancel focused on Apple TV, where a system dialog once caused an accidental sign-out. Signing out of a server's last account removes the server too, and servers left without an account from before the upgrade are removed at launch. An expired or revoked session keeps the account (and its server) and shows "Sign in again".
  • Push. Each server keeps one installation per device, owned by the account last used on that server, and is handed over on account switch through the existing re-registration path. No server change is needed.
  • Duplicate servers. Two saved addresses with the same server ID merge only after a login-session check proves they reach one backend. No account's token is sent to an unproven address.
  • Apple TV pairing. A phone can send several accounts to a TV that advertises support; older peers keep sending one account per server.

The design is in docs/superpowers/specs/2026-11-02-multi-account-design.md. Android and Roku are being implemented from the same spec in their own repositories.

Validation

  • Build (MacDev build service, build-only): iOS, tvOS and macOS succeed on the final source.
  • Tests: existing tests updated to the account-keyed APIs (cases covering the removed per-server session slots deleted). Silo 3703 passed, SiloTV 3366 passed; the one failure on each, CalendarTimeZoneTests.testLoadAfterATimeZoneChangeRequestsTheSameWeekInTheNewZone, depends on today's date and also fails on the commit before this branch.
  • Review findings from Kody, Codex and CodeRabbit: 29 fixed over two rounds (including one the updated tests caught: a token rotation path dropped the account ID), the rest answered in their threads. Full suites rerun after each round; signing out of a selected expired account checked on the iPhone simulator.
  • CI regression: the only failure is CalendarTimeZoneTests, which hard-codes the current week and fails on main too ([bug] CalendarTimeZoneTests fails while its hard-coded week is the current week #989).
  • iPhone simulator (iOS 27): upgrade from a signed-in main build kept both servers, the profile and a downloaded clip, with no sign-in prompt. The picker, Add sheet, adding a second account, Change Account, switching (including a PIN profile), sign-out deleting only that account's downloads, the sign-out dialog, expired session, and Settings › Accounts all pass.
  • iPad simulator: picker and Change Account in landscape.
  • Add opening profile creation and the system sign-out alert: iPhone and Apple TV simulators, before the rebase onto the latest tvOS commits; the rebased tree was compiled only.
  • Apple TV simulator: upgrade from main; cold-launch focus, Add sheet, Change Account rail and pane focus, PIN focus return, profile menu, sign-out dialog, expired session, Settings › Accounts.
  • Revoked session and duplicate-server merge (including offline, where entries stay separate): iPhone simulator.
  • Native Change Account (default and accessibility text sizes, swipe and long-press Sign Out, cross-server switch with no reorder), account-less server removal (upgrade from main, last-account sign-out, backing out of Add Server, expired account keeps its server) and the picker without the server pill: iPhone simulator. A behavior-preserving cleanup pass after those runs was compiled only.
  • Physical iPhone: installed and its metadata verified; launch was not verified because the phone was locked.
  • Not verified: Mac at runtime, Top Shelf, phone-assisted multi-account pairing, push on a device, several Apple TV users, an interrupted merge, and a behavior-preserving cleanup pass made after the simulator runs (it was compiled only).

Evidence

Evidence: https://evidence.siloserver.org/r/silo-apple/pr-992/

Surface and build: iPhone 17 Pro and iPad Pro 11-inch (iOS 27.0) and an Apple TV simulator, running signed Debug builds of this branch against two test servers. The before captures come from main (0480748) with the same servers and accounts. Mac was compiled but not run. iPhone Duo uses the iPhone layout and wasn't run separately.

Risks

  • Migration is one-way. After upgrading, older builds can't read the moved sign-ins or downloads; going back means signing in again.
  • Size. This is one large change across storage, push, routing and both UIs, not the phased PRs the spec proposed.
  • Known gaps:
    • After signing out and back in, the server's download list restores the account's downloads.
    • An expired account's downloads are kept but can't be played until it signs in again.
    • The Settings account row can show the server address instead of its name.
    • The sign-in username is empty when the only remaining account needs to sign in again.
    • On Apple TV, the picker still shows when there is a single profile without a PIN, so each Apple TV user's own choice is kept.
    • There is no local Rename Server; it was removed earlier in Refine tvOS settings, servers, authentication, and content interactions #90.

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, running in T3 Code
  • Tool(s): Claude Code subagents (implementation, simulator verification, simplification), MacDev silo-build service, Fleet SimLock simulators
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: n/a; no independent or adversarial review was run

🤖 Generated with Claude Code

Note

Add multi-account support per server and Change Account UI

  • Introduces AccountStore as the source of truth for saved accounts, credentials, and selection, replacing per-server session persistence in TokenStore and AuthService (TokenStore.swift, AccountStore.swift)
  • Adds account switching, per-account sign-out, and account-scoped local data: player settings, downloads, response snapshots, preference caches, push targets, and remembered profiles are all keyed by local account ID, with one-time legacy-data adoption for each account designated as a server's legacy-data owner
  • Adds a Change Account screen on iOS/macOS and tvOS plus Accounts settings screens, and replaces Switch Server actions with Change Account throughout (ChangeAccountView.swift, TVChangeAccountView.swift)
  • Supports duplicate-server detection and merging: candidate servers with a verified shared ID are proven via login-session comparison and merged, moving downloads, snapshots, and local data to the survivor (ServerRegistry.swift, ServerMerge.swift)
  • Companion TV pairing advertises and uses an acct=1 capability so one pairing run can send every signed-in account
  • Behavioral Change: request identity, profile memory, and caches are scoped by local account ID; legacy values move only for the designated legacy owner. Pre-account server/profile keys are read for that owner until adopted. Check AccountScopedKeyAdoption.adoptValue, PlayerSettings.currentScopeIdentifier (returns nil without an active account), and DownloadStore.loadScope (rejects empty account IDs and failed adoptions).

Macroscope summarized 052c1d5.

@silo-triage silo-triage Bot added the size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. label Nov 3, 2026
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 20 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 80 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

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: 03f3392e-be40-4a9b-9d12-a80d3417b551
Commits

Reviewing files that changed from the base of the PR and between 8e30e0b and 052c1d5.

Files ignored due to path filters: 3
  • iosApp/iosApp/Assets.xcassets/SiloProjectIcon.imageset/silo-project-icon-128.png is excluded by !**/*.png
  • iosApp/iosApp/Assets.xcassets/SiloProjectIcon.imageset/silo-project-icon-256.png is excluded by !**/*.png
  • iosApp/iosApp/Assets.xcassets/SiloProjectIcon.imageset/silo-project-icon-512.png is excluded by !**/*.png
Files selected for processing: 136
  • docs/superpowers/specs/2026-11-02-multi-account-design.md
  • iosApp/Tests/APIv2SubtitleTests.swift
  • iosApp/Tests/AccountSessionPersistenceTests.swift
  • iosApp/Tests/ApplePushNotificationSyncTests.swift
  • iosApp/Tests/ApplePushOrderedRegistrationTests.swift
  • iosApp/Tests/ApproverBearerTests.swift
  • iosApp/Tests/CatalogV2Tests.swift
  • iosApp/Tests/CollectionsV2Tests.swift
  • iosApp/Tests/CredentialIdentityTests.swift
  • iosApp/Tests/DiagnosticsCapabilitiesV2Tests.swift
  • iosApp/Tests/DiagnosticsUploadV2Tests.swift
  • iosApp/Tests/DownloadStorageReclaimTests.swift
  • iosApp/Tests/EpisodeSpoilerTests.swift
  • iosApp/Tests/ExternalSignInTests.swift
  • iosApp/Tests/HostedDiagnosticsAPITests.swift
  • iosApp/Tests/LegacyDownloadStorageTests.swift
  • iosApp/Tests/OnboardingInvitationTests.swift
  • iosApp/Tests/PairingCoordinatorTests.swift
  • iosApp/Tests/ProfileLaunchPolicyTests.swift
  • iosApp/Tests/ProfileVerificationSignalTests.swift
  • iosApp/Tests/ProgressSyncV2Tests.swift
  • iosApp/Tests/RequestsV2Tests.swift
  • iosApp/Tests/ResponseSnapshotStoreTests.swift
  • iosApp/Tests/ServerIdentityResolverTests.swift
  • iosApp/Tests/TVSignInTests.swift
  • iosApp/Tests/TopShelfHTTPClientTests.swift
  • iosApp/Tests/UICustomizationPreferencesTests.swift
  • iosApp/TopShelf/ContentProvider.swift
  • iosApp/iosApp/Assets.xcassets/SiloProjectIcon.imageset/Contents.json
  • iosApp/iosApp/Components/AccountRemovalConfirmation.swift
  • iosApp/iosApp/Components/TabTopBarActions.swift
  • iosApp/iosApp/ContentView.swift
  • iosApp/iosApp/DesignSystem/Marquee/MarqueeControls.swift
  • iosApp/iosApp/Downloads/AutoDownloadSchedule.swift
  • iosApp/iosApp/Downloads/DownloadFilePaths.swift
  • iosApp/iosApp/Downloads/DownloadManager.swift
  • iosApp/iosApp/Downloads/DownloadModels.swift
  • iosApp/iosApp/Downloads/DownloadSessionDelegate.swift
  • iosApp/iosApp/Downloads/DownloadStorageReclaim.swift
  • iosApp/iosApp/Downloads/DownloadStore.swift
  • iosApp/iosApp/Downloads/DownloadsSettingsView.swift
  • iosApp/iosApp/Navigation/AppNavPreferences.swift
  • iosApp/iosApp/Navigation/AppRouter+Accounts.swift
  • iosApp/iosApp/Navigation/AppRouter.swift
  • iosApp/iosApp/Navigation/MacSidebarSections.swift
  • iosApp/iosApp/Navigation/Route.swift
  • iosApp/iosApp/Navigation/UICustomizationPreferences.swift
  • iosApp/iosApp/Networking/APIv2/APIv2Client.swift
  • iosApp/iosApp/Networking/APIv2/APIv2PushModels.swift
  • iosApp/iosApp/Networking/AccountLocalData.swift
  • iosApp/iosApp/Networking/AccountMigration.swift
  • iosApp/iosApp/Networking/AdvisoryAgePreferenceStore.swift
  • iosApp/iosApp/Networking/HTTPClient.swift
  • iosApp/iosApp/Networking/HiddenLibraryPreference.swift
  • iosApp/iosApp/Networking/LoginSessionProof.swift
  • iosApp/iosApp/Networking/OnboardingModels.swift
  • iosApp/iosApp/Networking/ResponseCache.swift
  • iosApp/iosApp/Networking/ResponseSnapshotStore.swift
  • iosApp/iosApp/Networking/ServerMerge.swift
  • iosApp/iosApp/Networking/ServerRegistry.swift
  • iosApp/iosApp/Networking/ThemeMusicPreferences.swift
  • iosApp/iosApp/Networking/TitleArtPreferences.swift
  • iosApp/iosApp/Networking/TokenStore.swift
  • iosApp/iosApp/Notifications/ApplePushDeepLinkCoordinator.swift
  • iosApp/iosApp/Notifications/ApplePushDisplayTargets.swift
  • iosApp/iosApp/Notifications/ApplePushInstallationJournal.swift
  • iosApp/iosApp/Notifications/ApplePushRegistration.swift
  • iosApp/iosApp/Notifications/ApplePushRegistrationChannel.swift
  • iosApp/iosApp/Pairing/Approver/SignInTVView.swift
  • iosApp/iosApp/Pairing/Approver/TVApprovalCard.swift
  • iosApp/iosApp/Pairing/Approver/TVApprovalModel.swift
  • iosApp/iosApp/Pairing/Companion/CompanionPairingCard.swift
  • iosApp/iosApp/Pairing/Companion/CompanionPairingCoordinator.swift
  • iosApp/iosApp/Pairing/Companion/TVPairingBrowser.swift
  • iosApp/iosApp/Pairing/PairingProtocol.swift
  • iosApp/iosApp/Pairing/Receiver/ReceiverPairingCoordinator.swift
  • iosApp/iosApp/Pairing/Receiver/TVPairingAdvertiser.swift
  • iosApp/iosApp/Pairing/Receiver/TVPairingReceiverView.swift
  • iosApp/iosApp/Screens/Accounts/AccountDirectory.swift
  • iosApp/iosApp/Screens/Accounts/AddChoice.swift
  • iosApp/iosApp/Screens/Accounts/ChangeAccountModel.swift
  • iosApp/iosApp/Screens/Accounts/ChangeAccountView.swift
  • iosApp/iosApp/Screens/Auth/AccountSessions.swift
  • iosApp/iosApp/Screens/Auth/AuthService.swift
  • iosApp/iosApp/Screens/Auth/LoginView.swift
  • iosApp/iosApp/Screens/Auth/QRLoginViewModel.swift
  • iosApp/iosApp/Screens/Auth/RestoredSessionValidator.swift
  • iosApp/iosApp/Screens/Auth/ServerSetupView.swift
  • iosApp/iosApp/Screens/Auth/SystemWebAuthenticationRunner.swift
  • iosApp/iosApp/Screens/Auth/TVLoginView.swift
  • iosApp/iosApp/Screens/Auth/TVServerSetupView.swift
  • iosApp/iosApp/Screens/Browse/Filtering/BrowsePrefsStore.swift
  • iosApp/iosApp/Screens/Browse/LibrariesTabView.swift
  • iosApp/iosApp/Screens/Calendar/CalendarView.swift
  • iosApp/iosApp/Screens/Detail/EpisodeSpoilerPreferences.swift
  • iosApp/iosApp/Screens/Detail/TrailerReturnPolicy.swift
  • iosApp/iosApp/Screens/Home/HomeView.swift
  • iosApp/iosApp/Screens/Onboarding/OnboardingTourGate.swift
  • iosApp/iosApp/Screens/Onboarding/OnboardingTourViewModel.swift
  • iosApp/iosApp/Screens/Player/PlayerSettings.swift
  • iosApp/iosApp/Screens/Player/PlayerSettingsFlusher.swift
  • iosApp/iosApp/Screens/Player/SeekIntervalPreferences.swift
  • iosApp/iosApp/Screens/Profiles/ProfileLaunchPreferences.swift
  • iosApp/iosApp/Screens/Profiles/ProfileModels.swift
  • iosApp/iosApp/Screens/Profiles/ProfileSelectionView.swift
  • iosApp/iosApp/Screens/Profiles/ProfileSelectionViewModel.swift
  • iosApp/iosApp/Screens/Profiles/ProfileTile.swift
  • iosApp/iosApp/Screens/Recommendations/RecommendationsView.swift
  • iosApp/iosApp/Screens/Servers/ServerListView.swift
  • iosApp/iosApp/Screens/Settings/AccountsSettingsView.swift
  • iosApp/iosApp/Screens/Settings/IOSSettingsOverview.swift
  • iosApp/iosApp/Screens/Settings/SettingsView.swift
  • iosApp/iosApp/Shared/Account.swift
  • iosApp/iosApp/Shared/AccountScopedKeyAdoption.swift
  • iosApp/iosApp/Shared/AccountSessionPersistence.swift
  • iosApp/iosApp/Shared/AccountStore.swift
  • iosApp/iosApp/Shared/Diagnostics/DiagnosticsCoordinator.swift
  • iosApp/iosApp/Shared/EpisodeSpoilerCache.swift
  • iosApp/iosApp/Shared/ProfileLaunchState.swift
  • iosApp/iosApp/Shared/SharedStorage.swift
  • iosApp/iosApp/Shared/TopShelfHTTPClient.swift
  • iosApp/iosApp/Shared/TopShelfProfilePolicy.swift
  • iosApp/iosApp/WatchParty/WatchPartyRecentStore.swift
  • iosApp/iosApp/iOS/OnboardingTourPresentation+iOS.swift
  • iosApp/iosApp/macOS/MacSidebar.swift
  • iosApp/iosApp/macOS/OnboardingTourPresentation+macOS.swift
  • iosApp/iosApp/tvOS/Navigation/TVLibraryScopeStore.swift
  • iosApp/iosApp/tvOS/Navigation/TVMainTabView.swift
  • iosApp/iosApp/tvOS/Navigation/TVTopMenuBar.swift
  • iosApp/iosApp/tvOS/Navigation/TVTrailerReturnStore.swift
  • iosApp/iosApp/tvOS/Screens/Auth/TVChangeAccountView.swift
  • iosApp/iosApp/tvOS/Screens/Components/TVProfileTile.swift
  • iosApp/iosApp/tvOS/Screens/Settings/TVAccountsSettingsView.swift
  • iosApp/iosApp/tvOS/Screens/Settings/TVGeneralSettingsView.swift
  • iosApp/iosApp/tvOS/Screens/Settings/TVSettingsComponents.swift
  • iosApp/iosApp/tvOS/Screens/Settings/TVSettingsView.swift
Walkthrough

This change adds multiple saved accounts per server across Apple clients. It introduces account-scoped credentials and local data, migration and duplicate-server merging, account-management screens and routing, and account-aware download, pairing, and push behavior.

Changes: Apple multi-account support

Layer / File(s) Summary
Account model and persistence
iosApp/iosApp/Shared/Account.swift, AccountStore.swift, AccountScopedKeyAdoption.swift, SharedStorage.swift, AccountSessionPersistence.swift, docs/superpowers/specs/*
Adds account records, account selection, account-scoped key formats, migration, and account-store persistence.
Authentication and server merging
iosApp/iosApp/Networking/AccountMigration.swift, ServerRegistry.swift, ServerMerge.swift, TokenStore.swift, HTTPClient.swift, AuthService.swift
Migrates legacy sessions into account records and uses account records for credentials and profile proofs. The registry verifies and merges duplicate server entries.
Account-scoped data and downloads
iosApp/iosApp/Downloads/*, iosApp/iosApp/Networking/*, iosApp/iosApp/Screens/Player/*, iosApp/iosApp/Shared/Diagnostics/*
Scopes downloads, caches, preferences, snapshots, player settings, onboarding state, and diagnostics to accounts. Adds legacy-data adoption, account removal, and merge handling.
Account navigation and management
iosApp/iosApp/Navigation/*, iosApp/iosApp/Screens/Accounts/*, iosApp/iosApp/Screens/Auth/*, iosApp/iosApp/Screens/Profiles/*, iosApp/iosApp/Screens/Settings/*, iosApp/iosApp/tvOS/*
Adds account routes, account-management screens, account switching, sign-in, sign-out, server removal, and shared confirmation flows.
Pairing and push ownership
iosApp/iosApp/Pairing/*, iosApp/iosApp/Notifications/*
Adds account-specific pairing targets for multi-account TVs. Push ownership, registration handover, and deep-link matching include local account identity.

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ChangeAccountView
  participant ChangeAccountModel
  participant AccountSessions
  participant AccountStore
  User->>ChangeAccountView: Select saved account
  ChangeAccountView->>ChangeAccountModel: choose(account)
  ChangeAccountModel->>AccountSessions: switchTo(account)
  AccountSessions->>AccountStore: Select account
  AccountStore-->>AccountSessions: Account state
  AccountSessions-->>ChangeAccountModel: Switch result
  ChangeAccountModel-->>ChangeAccountView: Update account state
Loading

Possibly related PRs

  • Silo-Server/silo-apple#981 — Both changes modify the profile-menu action and callback contract.
  • Silo-Server/silo-apple#906 — Both changes modify phone-to-TV pairing; this change adds account-specific pairing targets while retaining Roku’s single-server behavior.
  • Silo-Server/silo-apple#977 — Both changes use login-session proof and shared push records while adding duplicate-server merging and account-aware ownership.

Suggested labels: api-v2, impact: usability, impact: security, impact: playback, impact: polish, needs-review, evidence-required

Suggested reviewers: zzebrahz

Merge Risk: Moderate · previous review 8e30e

Upgrading users with credentials in older Keychain locations could lose their saved sign-in during migration and have to sign in again. Some users could also see previously deleted downloads or monitors reappear after the account-scoped download migration. Both fixes are small and should be made before merging.

Security architecture risk: High · up to 8e30e

A previously trusted server address can reuse an old identity proof after being re-added, potentially redirecting saved credentials if that address has changed ownership. Migration recovery also has a conditional gap that can leave private local data without a cleanup owner.

Retained concerns

  • High · security · inferred: Re-adding a previously merged HTTPS address can reuse an old backend-equivalence proof without authenticating its current ownership. If the original server is not in use, the newly added address can become the preferred survivor and receive existing accounts with their access tokens, refresh tokens, and rewritten origins. An attacker controlling that former alias and advertising the matching deployment ID could consequently receive credentials on subsequent authenticated requests. The initial proof is strong, but its cached lifetime is not bound to the address-registration lifecycle.
  • Medium · security · inferred: If sign-in creates an account while legacy migration is deferred, the later migration excludes the legacy account because that server is already listed, marks migration complete, and deletes the old credential slots without establishing a legacy-data owner. Legacy preferences and response snapshots can then remain outside account sign-out cleanup. Ownership-gated readers prevent this from establishing cross-account disclosure, but the conditional transition breaks data ownership and privacy cleanup. Production reachability of the full sequence was not completely verified.
Security review details

Security Blast Radius

  • inferred — The stale-proof path affects saved accounts consolidated from the affected server on this device, rather than only the account that originally supplied the proof. Merge commit preserves each moved account's tokens and profile data while changing its origin. Local-data relocation is demonstrated; automatic upload of those local files is not.

Security Findings and Attack Paths

  • inferred — A former HTTPS alias changes ownership, advertises the original deployment ID, and is re-added while the affected account is not in use. Its old proof still matches a surviving account epoch, so preference for the new entry can authorize origin rebinding without a fresh backend proof. Subsequent authenticated use can disclose the moved credentials to the alias operator. This conditional path is introduced by the new consolidation flow.

Trust Boundaries and Controls

  • observed — Initial merge proof uses each account's own origin and bearer, uses a redirect-refusing session, and does not send one account's token to the other address. HTTPS is preferred and HTTPS-to-HTTP consolidation is refused. These controls narrow the concern to reuse of previously established trust, not arbitrary merging from a public identity claim alone.

Resilience and Maintainability Implications

  • observed — Legacy data adoption and deletion depend on explicit ownership. Download adoption refuses to give another account the legacy scopes, while preference and snapshot cleanup includes legacy entries only for their recorded owner. This limits cross-account access but makes preservation of the ownership mapping essential throughout migration recovery.

Hardening Proposals

  • proposed — Bind merge authorization to the address-registration lifecycle and require fresh backend proof after an address is re-added. Treat migration completion as requiring an explicit disposition for every legacy account and its data owner, including when a new account already exists on the same server.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 71.00% 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): keep several accounts per server and add Change Account" matches the main change in the changeset. The raw summary and PR objectives both center on multiple accounts per ser…
Description check Passed The description states the problem, the approach (account-keyed storage, migration, Change Account screens, sign-out, push handover, duplicate-server merging, Apple TV pairing), validation steps, evid…
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): keep several accounts per server and add Change Account" matches the main change in the changeset. The raw summary and PR objectives both center on multiple accounts per server, account-keyed storage, and a Change Account screen. The title is specific, short, and does not describe anything absent from the changeset.

Full details: Description check

Explanation

The description states the problem, the approach (account-keyed storage, migration, Change Account screens, sign-out, push handover, duplicate-server merging, Apple TV pairing), validation steps, evidence, and risks. It directly describes the changes in the changeset, so it is on-topic and specific.

Full details: Docstring Coverage

Explanation

Docstring coverage is 71.00% 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 269 functions across 86 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

@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-triage silo-triage Bot added enhancement New feature or request priority: P2 Limited scope, workaround exists, or polish labels Nov 3, 2026
#endif
let requestAccountId = await TokenStore.shared.requestAccountId(onServer: serverId)
let wasInUse = ServerRegistry.shared.activeServerId == serverId && requestAccountId == localAccountId
let outcome = await AccountSessions.signOut(account: localAccountId, onServer: serverId)

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 critical

A refused sign-out can still delete the account's downloads

A refused sign-out can leave the account signed in after its downloads and settings have been deleted. Complete the identity transition in AccountSessions.signOut before cleanup, preserving the ownership information needed to delete local data.

Prompt for LLM
File iosApp/iosApp/Navigation/AppRouter+Accounts.swift, line 376:

A refused sign-out can still delete the account's downloads

This call deletes the account's downloads and local settings before `AuthService.signOut()` acquires its identity-transition lease, so a refused sign-out leaves the account signed in after irreversibly losing its data. Authorize and complete the sign-out transition before deleting account-local data, preserving the ownership information needed for cleanup.

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.

The order is deliberate. Downloads and local data go first because the account record decides which pre-accounts data the account owns, and AccountStore.signOut clears that ownership along with the record. The person has already confirmed deleting those downloads, so a refused sign-out loses nothing they meant to keep, and the error asks them to try again. The likeliest refusal, an account switch while the data was being deleted, is now handled: the sign-out re-checks which account is in use and pins AuthService.signOut to the confirmed account (see the thread on line 79).

🤖 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 ownership dependency explains why cleanup currently comes first, and pinning sign-out to the confirmed account addresses the risk of signing out the wrong account.

I’d still keep the concern, though not necessarily at critical severity. Confirming sign-out and download deletion doesn’t make the partial-failure state harmless: if sign-out is refused, the person can be left with a signed-in account whose local data is gone. An error and retry path make that state visible, but they don’t restore the data.

A safer approach would be to capture the ownership information needed for cleanup, then acquire and complete the identity transition before deleting data—or hold the transition lease across both operations. Either approach needs to ensure cleanup still targets the confirmed account and its legacy-owned data. The excerpt alone doesn’t establish which is feasible, so I’d verify the current AccountSessions and AccountStore implementations before prescribing a specific fix.

let task = Task { await renewInactiveServer(serverId, stored: stored, access: access, refresh: refresh, origin: origin) }
inactiveServerRenewals[key] = (refresh, task)
let bearer = await task.value
if inactiveServerRenewals[key]?.refreshToken == refresh {

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 high

An older renewal can remove a newer flight with the same refresh token

A recurring refresh token can let an older task remove a newer entry from inactiveServerRenewals, allowing duplicate renewals. Give each flight a unique ID and remove the entry only if that ID still matches.

Kody rule violation: Scope single-flight work to session identity and required freshness

Prompt for LLM
File iosApp/iosApp/Networking/HTTPClient.swift, line 2502:

An older renewal can remove a newer flight with the same refresh token

Give each renewal flight a unique ID and remove the registry entry only when that ID still matches. A refresh token can recur after an intervening replacement flight, so an older task can otherwise remove a newer task's entry and allow duplicate renewals.

Kody rule violation: [Scope single\-flight work to session identity and required freshness](https://kodus.siloserver.org/settings/code-review/1247142423/kody-rules/9c21cfde-5ecb-4810-b60c-eaa17ba38383?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.

For this, a stored refresh token would have to come back after it had already been rotated away. Rotation issues a new random token and nothing writes an old one back, so a newer flight can't have the same token as an older one. The same compare-on-token cleanup exists on main for the server-keyed path.

🤖 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.

That reasoning addresses the reported race: if a refresh token cannot recur for the same account while an older renewal is still in flight, the older task cannot mistake a newer flight for its own. Under that invariant, a separate flight ID is not necessary.

I haven’t independently verified every path that can write or restore a refresh token, so my conclusion depends on that invariant holding—including across sign-out and sign-in. The same pattern on main is useful context, though it doesn’t by itself prove the race is impossible. Given the stated rotation behavior, I would withdraw the suggestion.

guard let id = try? await own(nil).currentSession?.id, !id.isEmpty else { return .unavailable }
var cursor: String?
for _ in 0..<maximumSessionPages {
guard let page = try? await holder(cursor) else { return .unavailable }

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 high

Session proof pagination is not fenced against owner changes

An account or scope switch can combine sessions from different owners and produce an invalid proof. Validate captured owners, scopes, and applicable generations after own and every holder page, returning .unavailable if any changed.

Also found in:

  • iosApp/iosApp/Networking/ServerMerge.swift:149-149
  • iosApp/iosApp/Networking/ServerMerge.swift:103-103

Kody rule violation: Fence asynchronous results by scope and invalidation generation

Prompt for LLM
File iosApp/iosApp/Networking/LoginSessionProof.swift, line 37:

Session proof pagination is not fenced against owner changes

Fence the proof against the captured authentication owners, scopes, and applicable generations for both session readers. Verify those identities after the `own` read and after every `holder` page before using the result; return `.unavailable` if any identity changed. Otherwise, an account or scope switch during pagination can combine sessions from different owners and produce an invalid server-identity proof.

**Also found in:**
- `iosApp/iosApp/Networking/ServerMerge.swift:149-149`
- `iosApp/iosApp/Networking/ServerMerge.swift:103-103`

Kody rule violation: [Fence asynchronous results by scope and invalidation generation](https://kodus.siloserver.org/settings/code-review/1247142423/kody-rules/ce041253-02ac-48cb-9576-81de9b2f41ef?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.

Each Sessions closure is bound to a fixed address and localAccountId (ServerMerge.sessions(of:)), so every page comes from that account at that address, whatever is selected in the app. The proof shows that the holder address's backend knows a random session ID issued at the other address, and that conclusion holds whichever session of that account read a page. Changed sign-in epochs are handled by the stored proof's epoch check in cachedProof.

🤖 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 fixed address and localAccountId make the original concern about switching the selected account unsubstantiated for ServerMerge.sessions(of:). A selection change alone does not change which account or address its closures use.

There is still a narrower race worth checking: prove captures the accounts’ epochs before awaiting the network reads, but then stores and returns the outcome directly, without checking those epochs again. cachedProof checks epochs on a later lookup; it does not validate that immediate result. Also, each page fetches a fresh token, so whether a sign-out or re-sign-in can change the credentials during pagination depends on freshAccessToken and the account lifecycle.

I would revise the suggestion rather than assert that selection changes invalidate the proof: verify the captured account identities, epochs, and address bindings before accepting or using the result, if those can change during the read. A test that pauses pagination, changes a sign-in epoch, and then resumes would clarify the behavior. The push registrar’s separate use of LoginSessionProof should be assessed independently.

Comment on lines +140 to +143
let target = self.directory(for: scope, in: root)
if !fm.fileExists(atPath: target.path), (try? fm.moveItem(at: directory, to: target)) != nil { continue }
}
try? fm.removeItem(at: directory)

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 critical

Snapshot move failures delete the only cached copy

A failed move can permanently delete the only cached responses. Remove directory only if target already exists or the move succeeds.

Prompt for LLM
File iosApp/iosApp/Networking/ResponseSnapshotStore.swift, lines 140-143:

Snapshot move failures delete the only cached copy

A failed snapshot move falls through to deleting the source directory, permanently losing its offline cached responses even when no destination exists. Delete the source only when the destination already exists or the move succeeds.

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.

These directories are a refetchable response cache. After the merge commits, no reader resolves the dropped server's ID, so keeping a directory whose move failed would only leave unreachable files on disk. The survivor refetches on its next online load.

🤖 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.

That makes sense. If the snapshots are refetchable and the dropped server ID is no longer reachable after the merge, retaining the source directory after a failed move would not preserve usable cache data. I’d withdraw the suggestion as a critical data-loss issue.

There is still a temporary offline availability tradeoff: if the move fails and the destination doesn’t exist, those responses won’t be available until they can be refetched. That may be acceptable for a best-effort cache.

Comment on lines +669 to +670
if temporaryScope == nil, let expectedAccount = expected.localAccountId,
account.localAccountId != expectedAccount {

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

Temporary handoffs bypass account-bound request authorization

Queued work for a saved account can run under temporary credentials when server and profile IDs match. Reject requests with localAccountId while temporaryScope is active.

Prompt for LLM
File iosApp/iosApp/Networking/TokenStore.swift, lines 669-670:

Temporary handoffs bypass account-bound request authorization

An account-bound request can execute with temporary handoff credentials when the handoff uses the same server and profile IDs, allowing queued work from the saved account to run under a different account. Reject requests carrying `localAccountId` while a temporary scope is active rather than bypassing the account check.

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.

This also happens on main, which has no account check in captureRequestAuth: a temporary handoff for the same server and profile ID already ran queued work under the handoff's credentials, even when the handoff came from a different server user. This PR adds the account check outside temporary scopes and leaves that behavior unchanged. Rejecting account-bound requests during remote playback would change tvOS handoff behavior and belongs in its own change.

🤖 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.

That distinction makes sense: if temporary handoffs already allowed this on main, the bypass is a pre-existing issue rather than a regression introduced by this PR. I’d withdraw the suggestion as a PR-blocking finding on that basis.

The cross-account authorization risk is still worth tracking separately, with a fix that preserves or deliberately revises tvOS handoff behavior. Would you like me to create a follow-up issue?

.truncationMode(.middle)
.fixedSize(horizontal: false, vertical: true)
if let accounts = accountNames(on: server) {
Text(accounts)

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 high

Account rows can push pairing actions beyond the available screen

Multiple servers or large accessibility text can push Continue and Cancel beyond the available height. Keep the normal layout when it fits and add a vertically scrollable fallback for the card content.

Also found in:

  • iosApp/iosApp/Components/MarqueeDialog.swift:27-27

Kody rule violation: Keep SwiftUI actions reachable at accessibility sizes and during loading

Prompt for LLM
File iosApp/iosApp/Pairing/Companion/CompanionPairingCard.swift, line 188:

Account rows can push pairing actions beyond the available screen

The added account-name row makes each server choice taller, but the pairing card has no scrolling fallback. With multiple servers or large accessibility text, the Continue and Cancel actions can extend beyond the available height. Keep the normal layout when it fits and provide a vertically scrollable fallback for the card content when it does not.

**Also found in:**
- `iosApp/iosApp/Components/MarqueeDialog.swift:27-27`

Kody rule violation: [Keep SwiftUI actions reachable at accessibility sizes and during loading](https://kodus.siloserver.org/settings/code-review/1247142423/kody-rules/b6dbc964-8e7c-41ab-bcf7-b0b98b84f2ae?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.

The pairing card has no scroll fallback on main either, and its server list could already outgrow the screen with many servers or large text. This PR adds one single-line caption per server, and only when the TV keeps several accounts and the server has more than one. MarqueeDialog.swift, named under 'Also found in', was deleted in a094b67. Leaving the scroll fallback for a separate change.

🤖 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.

That’s a reasonable distinction. The lack of a scrolling fallback predates this PR, although the new captions can make the existing height constraint easier to hit in the multi-account case.

Deferring the fallback to a separate change is reasonable; it should cover multiple servers and accessibility text sizes. The reference to the deleted MarqueeDialog.swift is also not applicable to the current tree.

private func approveCurrent(_ target: PairingTarget) async {
let server = target.server
state = .working(progress: "Approving \(target.displayName)…")
let approver = await bearer(for: target)

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 high

Approval can be sent after the pairing session is canceled

Cancellation during bearer resolution can still result in an approval being sent. Capture the request code and approval identity before the await, then recheck the session, target, request, and authorization before calling api.approve.

Kody rule violation: Validate consent at the side-effect boundary

Prompt for LLM
File iosApp/iosApp/Pairing/Companion/CompanionPairingCoordinator.swift, line 449:

Approval can be sent after the pairing session is canceled

Capture the request code and approval identity before resolving the bearer, then recheck immediately after the await that the session has not concluded, the same target and request are still current, and the approval is still authorized before calling `api.approve`. The user can cancel while bearer renewal is suspended, but the current code can still send the approval after cancellation.

Kody rule violation: [Validate consent at the side\-effect boundary](https://kodus.siloserver.org/settings/code-review/1247142423/kody-rules/b5abde6d-aedc-4a8c-9965-03cdadc5eb36?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.

Real, but not new: on origin/main, approveCurrent also awaits accessToken(server.id) and then calls api.approve without checking concluded again. This PR only swapped in the per-account bearer. Leaving it for a separate fix.

🤖 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 cancellation race appears to predate this PR, so it makes sense to address it separately rather than treat it as a regression introduced here.

Would you like to track it as a separate issue? No changes have been made.

Comment on lines +108 to +111
let accounts = (try? AccountStore.shared.accounts(onServer: serverId)) ?? []
for account in accounts { await deleteLocalData(of: account) }
let wasActive = ServerRegistry.shared.activeServerId == serverId
let removed = await ServerRegistry.shared.remove(serverId: serverId, resolveFallbackProfile: wasActive)

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 critical

Failed server removal permanently deletes account data

If removal fails, the server and accounts remain signed in after their downloads and settings are deleted. Make deleteLocalData conditional on successful removal or include it in a recoverable transaction.

Prompt for LLM
File iosApp/iosApp/Screens/Auth/AccountSessions.swift, lines 108-111:

Failed server removal permanently deletes account data

A server removal that fails to acquire the identity transition or purge diagnostics leaves the server and accounts signed in after their downloads and local settings have already been deleted. Make local-data deletion conditional on a successful removal or include it in a recoverable transaction.

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.

This order is deliberate too. Each account's data has to go before ServerRegistry.remove deletes the records that say which pre-accounts data the account owns. Removing a server is a confirmed choice to delete those downloads. If the removal fails (for example, the diagnostics purge fails), the person sees "couldn't remove the saved server" and can try again, and the retry finishes the removal.

🤖 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 ordering constraint is valid: deleting the ownership records first could make legacy data impossible to identify. The confirmation also makes deletion intentional.

The remaining concern is partial failure. If diagnostics purging or transition acquisition fails, the server and accounts remain usable, but their downloads and settings are already gone. Retrying may finish removing the server; it cannot restore that data if the user cannot or chooses not to retry. The error message alone may not make that outcome clear.

I’d keep the finding, but distinguish it from an unconfirmed deletion. A possible fix is to capture the ownership information first, then perform fallible removal checks before deleting local data, while retaining enough information to clean up afterward. If that cannot be made reliable, an explicitly recoverable removal process would address the partial-failure case.

await viewModel.loadProfiles()
await skipPickerIfSingleProfile()
#if !os(tvOS)
if !requestedByPerson { await openOnlyProfileIfNeeded() }

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 medium

Single-profile auto-open bypasses the configured launch policy

People who selected Every Time or a timed Who's Watching policy can have the required picker bypassed. Check the launch preference before calling openOnlyProfileIfNeeded.

Prompt for LLM
File iosApp/iosApp/Screens/Profiles/ProfileSelectionView.swift, line 87:

Single-profile auto-open bypasses the configured launch policy

On iOS and macOS, a single unprotected profile opens automatically even when the person selected Every Time or a timed Who's Watching policy, bypassing the picker those settings require. Honor the launch preference's selection requirement before automatically selecting the profile.

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.

This is intended. Spec §4.2 says "If the open account has a single profile without a PIN, the picker never appears," whatever Profile Selection says, and Android and Roku route it the same way (commit 38dcbe9). The picker still shows when the person asks for it (pickerRequestedByPerson).

🤖 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 the clarification. The suggestion is not valid: per spec §4.2, a single profile without a PIN should open automatically regardless of the Profile Selection policy. An explicitly requested picker remains accessible through pickerRequestedByPerson.

Would you like me to preserve this exception as a repository memory for future reviews?

func forget(_ serverID: String) -> Bool {
/// Removes the record and its adoption marker. Migration calls this only
/// after the account made from the record has been committed.
func delete(_ serverID: String) -> Bool {

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

Legacy session deletion can remove newer credentials or revive old tokens

A concurrent replacement can be deleted by delete, and removing the adoption marker can make old tokens authoritative again. Retire only the captured record and ownership, including account, origin, and epoch, and preserve the marker until token sources are consumed and retirement is durable.

Also found in:

  • iosApp/iosApp/Networking/ServerRegistry.swift:320-320
  • iosApp/iosApp/Screens/Auth/AccountSessions.swift:79-79
  • iosApp/iosApp/Networking/TokenStore.swift:360-360
  • iosApp/iosApp/Shared/AccountStore.swift:551-551
  • iosApp/iosApp/Networking/TokenStore.swift:1276-1276
  • iosApp/iosApp/Shared/AccountStore.swift:567-567
  • docs/superpowers/specs/2026-11-02-multi-account-design.md:289-289
  • iosApp/iosApp/Shared/AccountStore.swift:651-651
  • iosApp/iosApp/Shared/AccountStore.swift:618-618
  • iosApp/iosApp/Shared/AccountStore.swift:747-747
  • iosApp/iosApp/Networking/TokenStore.swift:1224-1224
  • iosApp/iosApp/Networking/TokenStore.swift:1170-1170
  • iosApp/iosApp/Networking/AccountMigration.swift:103-103
  • iosApp/iosApp/Networking/AccountMigration.swift:107-107
  • iosApp/iosApp/Networking/AccountMigration.swift:105-105

Kody rule violation: Make authenticated Keychain migration ownership-checked and fail-closed

Prompt for LLM
File iosApp/iosApp/Shared/AccountSessionPersistence.swift, line 59:

Legacy session deletion can remove newer credentials or revive old tokens

Make legacy session retirement conditional on the exact record and ownership captured by migration, including its account, origin, and epoch. The current deletion is keyed only by server ID, so a concurrent refresh or binding can replace the record before this method removes it. Also preserve the adoption marker until legacy token sources have been consumed and retirement is durable; removing it can otherwise make those sources authoritative again.

**Also found in:**
- `iosApp/iosApp/Networking/ServerRegistry.swift:320-320`
- `iosApp/iosApp/Screens/Auth/AccountSessions.swift:79-79`
- `iosApp/iosApp/Networking/TokenStore.swift:360-360`
- `iosApp/iosApp/Shared/AccountStore.swift:551-551`
- `iosApp/iosApp/Networking/TokenStore.swift:1276-1276`
- `iosApp/iosApp/Shared/AccountStore.swift:567-567`
- `docs/superpowers/specs/2026-11-02-multi-account-design.md:289-289`
- `iosApp/iosApp/Shared/AccountStore.swift:651-651`
- `iosApp/iosApp/Shared/AccountStore.swift:618-618`
- `iosApp/iosApp/Shared/AccountStore.swift:747-747`
- `iosApp/iosApp/Networking/TokenStore.swift:1224-1224`
- `iosApp/iosApp/Networking/TokenStore.swift:1170-1170`
- `iosApp/iosApp/Networking/AccountMigration.swift:103-103`
- `iosApp/iosApp/Networking/AccountMigration.swift:107-107`
- `iosApp/iosApp/Networking/AccountMigration.swift:105-105`

Kody rule violation: [Make authenticated Keychain migration ownership\-checked and fail\-closed](https://kodus.siloserver.org/settings/code-review/1247142423/kody-rules/feb1a346-d507-492b-bbb2-f6348c6069b4?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.

After this PR the legacy record is never written: only AccountMigration reads it and only cleanUpLegacySlots deletes it, so no concurrent refresh or binding can replace it. Deletion runs only after the index with legacySessionsMigrated has been committed and read back, and after that runIfNeeded returns before loading any legacy record, so removing the marker can't make old tokens authoritative again.

🤖 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.

Given those invariants, I agree that the suggestion’s two stated failure scenarios do not apply to this PR:

  • If no post-upgrade path can replace the legacy record, deleting it by server ID cannot race with a refresh or binding that writes a newer record.
  • If migration durably commits and verifies legacySessionsMigrated before cleanup, and all subsequent launches check that flag before reading legacy credentials, removing the marker cannot make those credentials authoritative again.

I would withdraw the suggestion provided those assumptions hold for every process that shares the storage, including extensions and any interrupted-migration paths. I haven’t independently verified the full call graph or persistence behavior from the supplied diff. The non-compiling test target also means those guarantees are not currently covered by runnable tests.

apply(entry)
Task { @MainActor in
await Task.yield()
apply(entry)

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 high

Deferred focus can restore a stale pane entry

A removed server or newer user selection can be followed by a stale focus assignment. Bind the deferred apply to the current selection identity, invalidate it when selection or focus changes, and apply the current pane entry.

Kody rule violation: Bind delayed presentation work to selection identity and current content

Prompt for LLM
File iosApp/iosApp/tvOS/Screens/Auth/TVChangeAccountView.swift, line 280:

Deferred focus can restore a stale pane entry

The yielded task reapplies a captured pane entry without checking whether the selected server or focus has changed. A removed server or a newer user selection can therefore be followed by a stale focus assignment. Bind the deferred assignment to the current selection identity and invalidate it when selection or user focus changes; then apply the current pane entry.

Kody rule violation: [Bind delayed presentation work to selection identity and current content](https://kodus.siloserver.org/settings/code-review/1247142423/kody-rules/673418ad-ff18-488b-87df-0e75d4252f1e?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.

focusEntry runs only to seed the screen (on appear and when the splash lifts). The second apply runs one Task.yield() after the first, before a remote press can arrive. A removed server reselects through onChange(of: model.servers), not through this path, and setting a @FocusState value for a card that is no longer shown does nothing.

🤖 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 finding overstates what the code establishes. The deferred assignment runs only during focus seeding, and the diff does not demonstrate that it actually overrides a newer selection or causes a visible focus error. Server removal is handled separately by the model.servers change handler.

That said, Task.yield() does not guarantee that no other main-actor work or input can run before the task resumes. The captured entry could become stale, but whether that produces an observable tvOS focus problem is not established here.

I’d withdraw the high-severity claim unless there’s a reproducible sequence. Guarding the deferred assignment against a changed selection could still be a defensive improvement, rather than a confirmed fix for this behavior.

@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 ❌

Comment on lines +169 to +171
private func value(for account: SavedAccountSummary) -> String? {
if account.needsSignIn { return "Sign in again" }
return ChangeAccountList.profileCount(account.cachedProfiles.count)

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 medium

Account settings no longer identifies the active account

Users with multiple signed-in accounts cannot tell which account is active before signing one out. Restore the active-account status in the row and its accessibility value in value(for:).

Prompt for LLM
File iosApp/iosApp/tvOS/Screens/Settings/TVAccountsSettingsView.swift, lines 169-171:

Account settings no longer identifies the active account

The new account value omits the previous `In use` indicator, so users with multiple signed-in accounts cannot tell which account is active before signing one out. Restore the active-account status in the row and its accessibility value.

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.

Intentional. bef09dc redrew this screen with Roku's Settings › Accounts rows, which show only the profile count or "Sign in again". On Apple TV, Change Account marks the open account with its Current badge, and the sign-out dialog names the account and server.

🤖 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. I’d withdraw the suggestion: the omission is intentional and matches Roku’s Accounts settings design. On Apple TV, users can identify the active account in Change Account, and the sign-out dialog names the account and server.

Would you like me to preserve this design decision for future reviews?

Quick104 and others added 3 commits November 3, 2026 21:45
Tests now save and select accounts, use account-scoped keys and download
paths, and expect push owners with a local account ID. Cases that covered
the removed per-server session slots and mirrors are deleted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A selected account that needs to sign in again can be signed out: only a
  loaded session signs out through AuthService, and the inactive path
  refuses only the loaded account and clears a selection pointing at it.
- An unreadable account list never counts as "the server's last account",
  so one sign-out can't remove the whole server.
- Background removal of account-less servers re-checks that the server is
  still inactive and empty right before committing.
- Migration reads every older Keychain location strictly, deferring on a
  read failure instead of treating it as absent.
- Download store merges keep pending legacy cleanup flags.
- A failed server switch clears only the TV approval that started it.
- Merging a legacy settings queue keeps an unfinished device clear.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Moving a credential from an older Keychain location writes it only into
  an empty slot and deletes the old copy from the one group it was found
  in, so a search without a group can no longer delete the new copy.
- Duplicate-server merges record which account kept a removed account's
  downloads, and background download tags resolve to it, so a transfer
  that outlives the merge finds its record.
- A store holding only pending legacy cleanup isn't discarded as empty.
- A merged settings write keeps the older write's stored profile value
  for display unless it owes a newer one.

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

Quick104 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Re CodeRabbit's outside-diff finding on DownloadStore.swift:411-416 (review 5762430336): Fixed in ace7e7d.

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

@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 ❌

Comment thread iosApp/iosApp/Shared/AccountStore.swift Resolved

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

ℹ️ 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 thread iosApp/iosApp/Shared/Account.swift Resolved
… Keychain moves

- A saved selection that names an account a duplicate-server merge removed
  resolves to the account kept in its place, so another Apple TV user
  isn't silently switched to a different person on that server.
- The merge records which survivor account took a dropped server's data
  from before accounts, and background download tags from before accounts
  resolve through it.
- Moving a credential forward from an older Keychain location deletes the
  old copy even when the destination already holds a newer value, so it
  can't be moved forward again later.

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 ❌
⚠️ 3 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:

  • Centralize server-relative authentication path validation
  • Enforce latest-link-wins centrally across deferred deep links
  • Rank subtitles using container capabilities and one stable cross-client policy

// from the group it was found in: a query without one would match
// the shared copy too. An item whose group isn't known stays.
if let found = result.accessGroup {
deleteLegacy(account: account, accessGroup: found)

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

Older-group retirement can delete a replacement credential

A concurrent replacement can be deleted, while a failed deletion can leave credentials available for resurrection. Make deleteLegacy conditional on the captured record and ownership, and propagate deletion failures before returning success.

Also found in:

  • iosApp/iosApp/Shared/SharedStorage.swift:473-473
  • iosApp/iosApp/Shared/SharedStorage.swift:468-468
  • iosApp/iosApp/Shared/SharedStorage.swift:443-443

Kody rule violation: Make authenticated Keychain migration ownership-checked and fail-closed

Prompt for LLM
File iosApp/iosApp/Shared/SharedStorage.swift, line 474:

Older-group retirement can delete a replacement credential

Make source retirement conditional on the exact captured record and ownership, and propagate deletion failures before returning success. A concurrent writer can replace the source after it was read, while an unsuccessful deletion can leave credentials available for later resurrection.

**Also found in:**
- `iosApp/iosApp/Shared/SharedStorage.swift:473-473`
- `iosApp/iosApp/Shared/SharedStorage.swift:468-468`
- `iosApp/iosApp/Shared/SharedStorage.swift:443-443`

Kody rule violation: [Make authenticated Keychain migration ownership\-checked and fail\-closed](https://kodus.siloserver.org/settings/code-review/1247142423/kody-rules/feb1a346-d507-492b-bbb2-f6348c6069b4?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 a defect in this build. Nothing writes these older locations any more: credentials are saved as per-account records (signIn.v1.<server>.<account>), and the old per-server item names in the older groups and the tvOS per-user location are only read and retired. The sole caller of getCheckedIncludingOlderLocations is AccountMigration (plus its own tvOS recursion), so there is no concurrent writer whose replacement the delete could remove. If a delete fails, the old item stays where it was; migration commits once and does not run this path again, and the remaining get fallback behaves as it already did on main.

🤖 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 rebuttal is persuasive about the concurrent-replacement scenario within this build: the checked older-location read is used by AccountMigration, and the legacy session slots are migrated to account-scoped records. I don’t see evidence in the inspected code that this build writes replacement credentials to those old slots. That conclusion assumes no older app version or other process sharing the Keychain can write them concurrently. See iosApp/iosApp/Networking/AccountMigration.swift:120–166.

The failed-deletion concern is narrower, but not fully disproved:

  • deleteLegacy ignores SecItemDelete’s status, and the tvOS retirement call also ignores the result (iosApp/iosApp/Shared/SharedStorage.swift:441–447, 473–474, 752–755).
  • Once session migration is marked complete, runIfNeeded retries cleanup of pending legacy slots rather than re-reading them (AccountMigration.swift:50–59, 169–187). So a failed older-group deletion does not, by itself, demonstrate that this build will resurrect a signed-out account.
  • However, a stale credential may remain in the Keychain. Whether cleanup removes every older-location copy, and whether a downgrade or another entitled process can later read it, needs separate verification. The fact that fallback behavior existed on main does not establish that retirement succeeded.

I would therefore not treat the replacement race as a demonstrated defect under the stated single-build assumption, but I would avoid dismissing the failed-deletion concern outright without checking those cleanup and cross-process assumptions.

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

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

Switching to another account on the same server cleared every account's
saved Home and library snapshots. Snapshots are kept per server, account and
profile, so the switch now clears only what is in memory and leaves each
account its saved content for offline fallback. A server switch still
clears everything, as before.

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 ❌

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

Labels

api-v2 API v2 / Huma program (epic silo-server#135) enhancement New feature or request evidence-required Needs before-and-after evidence before the Evidence check passes impact: playback Can't play, stalls, or wrong media impact: polish Annoyance, cosmetic, or nice-to-have impact: security Auth, privacy, or permission boundary impact: usability Core flow broken or severely blocked 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