Repository navigation
feat(accounts): keep several accounts per server and add Change Account - #992
Conversation
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
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. View limit details
Walkthrough
Merge Risk:
|
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
| #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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 } |
There was a problem hiding this comment.
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-149iosApp/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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
| if temporaryScope == nil, let expectedAccount = expected.localAccountId, | ||
| account.localAccountId != expectedAccount { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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() } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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-320iosApp/iosApp/Screens/Auth/AccountSessions.swift:79-79iosApp/iosApp/Networking/TokenStore.swift:360-360iosApp/iosApp/Shared/AccountStore.swift:551-551iosApp/iosApp/Networking/TokenStore.swift:1276-1276iosApp/iosApp/Shared/AccountStore.swift:567-567docs/superpowers/specs/2026-11-02-multi-account-design.md:289-289iosApp/iosApp/Shared/AccountStore.swift:651-651iosApp/iosApp/Shared/AccountStore.swift:618-618iosApp/iosApp/Shared/AccountStore.swift:747-747iosApp/iosApp/Networking/TokenStore.swift:1224-1224iosApp/iosApp/Networking/TokenStore.swift:1170-1170iosApp/iosApp/Networking/AccountMigration.swift:103-103iosApp/iosApp/Networking/AccountMigration.swift:107-107iosApp/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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
legacySessionsMigratedbefore 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
| private func value(for account: SavedAccountSummary) -> String? { | ||
| if account.needsSignIn { return "Sign in again" } | ||
| return ChangeAccountList.profileCount(account.cachedProfiles.count) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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?
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]>
8e30e0b to
ace7e7d
Compare
|
Re CodeRabbit's outside-diff finding on 🤖 Claude Code (claude-opus-5-5) |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 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".
… 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 — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
| // 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) |
There was a problem hiding this comment.
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-473iosApp/iosApp/Shared/SharedStorage.swift:468-468iosApp/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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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:
deleteLegacyignoresSecItemDelete’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,
runIfNeededretries 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
maindoes 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.
There was a problem hiding this comment.
💡 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 — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
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
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.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
CalendarTimeZoneTests.testLoadAfterATimeZoneChangeRequestsTheSameWeekInTheNewZone, depends on today's date and also fails on the commit before this branch.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).mainbuild 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.main; cold-launch focus, Add sheet, Change Account rail and pane focus, PIN focus return, profile menu, sign-out dialog, expired session, Settings › Accounts.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.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
Checklist
AI Disclosure
silo-buildservice, Fleet SimLock simulators🤖 Generated with Claude Code
Note
Add multi-account support per server and Change Account UI
AccountStoreas the source of truth for saved accounts, credentials, and selection, replacing per-server session persistence inTokenStoreandAuthService(TokenStore.swift, AccountStore.swift)acct=1capability so one pairing run can send every signed-in accountAccountScopedKeyAdoption.adoptValue,PlayerSettings.currentScopeIdentifier(returns nil without an active account), andDownloadStore.loadScope(rejects empty account IDs and failed adoptions).Macroscope summarized 052c1d5.