Repository navigation
Conversation
An identity that never restored is forgotten on this device, as on Android, and other sign-out errors show plain text. Verified: xcodebuild test (unit-tests.yml skips), swiftformat --lint
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The changes affect profile Disconnect and its error messages. The PR appears safe to merge, with a non-blocking gap in testing the real Disconnect path. Findings
SummaryDisconnect now forgets an identity locally when its session has not restored.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Disconnect] --> B{Profile session restored?}
B -->|No| C[Forget local session access]
C --> D[Drop pending public cleanup]
B -->|Yes| E[Remove endpoints and sign out]
D --> F[Clear local app and profile state]
E --> F
Reviews (1) · Last reviewed commit: "fix: disconnect a profile that newer pay..." · Reviewed by Greptile |
talosmachina
left a comment
There was a problem hiding this comment.
1 finding (1 P1). Disconnect on a profile that never restored now forgets the identity on this device instead of failing on newer Paykit state, drops the pending public endpoint cleanup, and the sign-out toasts show the update message instead of the raw storage error. Reviewed 2c99657, full tier.
The P1: the restored/unrestored decision is taken before an in-flight session restore settles, so a Disconnect that races a successful restore takes the forget-only branch for an identity that did restore.
QA: static review. Not built: an auto-review never builds a Bitkit branch, and iOS does not build on this Linux host.
What I checked, and 3 candidates I ruled out
Read in full: PubkyProfileManager.swift (sign-out, session mutation, initializeSessionState, clearLocalAppState, endpoint removal), ProfileView.swift, EditProfileView.swift, PaykitError+NewerState.swift; PaykitSdkService.signOut, forgetSessionAccess, restorePersistedSession in PubkyService.swift.
Parity: PubkyRepo.forgetUnrestoredIdentity() and ProfileViewModel.signOut() on bitkit-android master.
Paykit: forget_session_access at the pinned paykit-rs 0b9c63d clears local session access only, takes no storage read, so it does not hit the newer-state error.
CI at review time: SwiftFormat, validate, build-local green; Run Tests, Run Integration Tests and e2e still pending.
Ruled out
- Private contact-sharing cleanup flag left set:
clearLocalAppStatealready clears it viaclearPublicPaykitSharingState. - Profile deletion taking the forget-only branch:
deleteProfilerequirescurrentSession, sopublicKeyis set there. profileErrorDescriptionmasking a different storage error: it matches only the two newer-state contexts, other errors keeplocalizedDescription.- Cold reader: the finding stood; it rated it P2. I kept P1 because the outcome is a silent regression of Disconnect for a restorable identity, which Android guards with a dedicated test.
Merge confidence: 3/5, one P1 on the Disconnect-during-restore race.
Reviewer model: claude-opus-5-5, with xiaomi/mimo-v2.6-pro as the cold reader
Reasoning effort: Not exposed (the run metadata names the models only)
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR diff against its merge base, at 2c99657.
No new actionable code findings.
This pass found no new actionable code findings. Disconnect on a profile that never restored now forgets the identity on this device instead of failing on newer Paykit state. The pinned paykit-rs forget_session_access at 0b9c63d clears local session access with no storage read, so this path avoids the newer-state error. It also deletes the saved session and secret key (PubkySessionAccessTeardown), so a forgotten identity does not come back through restoreSessionIfNeeded. Profile deletion still takes the restored path because it requires currentSession. clearLocalAppState already clears the private contact-sharing cleanup flag. The toast change only swaps the text for the two newer-state errors.
Existing unresolved concern (verified at this head). talosmachina's thread on the restore race holds against the pinned source. While a restore is in flight from Try Again or retrySessionRestoration, the cached header still shows Disconnect (ProfileView.swift#L327-L337). isRestored is read before anything waits for that restore (PubkyProfileManager.swift#L1633). restorePersistedSession and forgetSessionAccess both serialize on operationLock (PubkyService.swift#L559-L572, #L1696-L1702). The result: a successful restore is followed by an unrevoked local forget, the pending public cleanup is dropped, and initializeSessionState discards the restore on the revision check. The identity's endpoints and grant stay on the homeserver with no retry. At base, the same race ran private and public endpoint removal and PubkyService.signOut() after the restore. Android master checks _publicKey inside initializeMutex and has a regression test for this case. The basis is source analysis; I did not run anything. The thread is open and needs a fix or an evidence-backed rebuttal.
Greptile's test-gap thread is also accurate. testDisconnectOnlyForgetsAnIdentityThatNeverRestored supplies isRestored itself, so nothing covers how signOut() derives it from manager state, including the in-flight restore case above.
Parity: compared with bitkit-android master 791d51b (PubkyRepo.forgetUnrestoredIdentity, ProfileViewModel.signOut). Both platforms forget whenever the public key is null, which includes deferred (offline) and generic failed restores, not only the newer-state case. Both leave homeserver endpoints and the grant in place, as the PR's Out of Scope states. The only material difference is Android's lock-guarded check described above.
Validation: on PR CI, SwiftFormat, validate and build-local pass. Run Tests, Run Integration Tests and e2e were pending at review time, so unit test execution is not yet confirmed.
Recommended before device testing: resolve the restore-race thread, and wait for Run Tests to finish on this head.
Device testing: not performed in this review. Author cases 1 and 2 remain unrun. They need Paykit state written by a newer SDK.
Suggested additional test cases
- iOS, regtest, connected profile: turn off networking and relaunch so restoration is deferred (cached header with Try Again). Tap Disconnect and confirm. Expected: Profile offers to connect a profile. On reconnecting the same identity, note whether its old endpoints still resolve; that is the accepted residue.
- iOS, same deferred state: restore connectivity, tap Try Again, and confirm Disconnect while the spinner is showing. Expected: the profile is fully signed out and its public endpoints no longer resolve. Today the race above predicts they stay.
Reviewer model: claude-opus-5-5
Reasoning effort: high
Verified: xcodebuild test (unit-tests.yml skips), swiftformat --lint
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: changes since 2c99657, including affected code paths and prior findings, at e018ea9. Baseline: previous QA review. The previous head is an ancestor of the current head, and the merge base is unchanged. This pass re-read the one new commit, the Disconnect branching it changes, the profile-deletion caller and the new tests. Coverage of the error toasts, changelog, paykit-rs forget_session_access contract and the original signOutCleanup unit test carries over from the baseline.
No new actionable code findings.
No new actionable code findings in the follow-up.
Prior concern, fixed in the code. talosmachina's restore-race thread is marked resolved, and the code at this head supports that. The baseline QA review listed it as an existing concern. signOutOrForget now waits for every running initializationTask before it reads publicKey (PubkyProfileManager.swift#L1648-L1651). An identity that restores while Disconnect waits therefore takes the full sign-out path instead of the forget-only path. Nothing can start a new restore between the end of the wait and beginSessionMutation. The while loop also catches a restore that starts while Disconnect waits. The profile-deletion caller cannot wait: performProfileDeletion requires initializationTask == nil, and initialize refuses to start while a deletion is running. testDisconnectSignsOutAProfileRestoredWhileItWaits would fail without the wait, because it expects ["signOut"] and would get ["forget"].
Test-coverage thread, partly addressed. Greptile's thread is marked resolved. The new testDisconnectForgetsAProfileThatNeedsAnUpdate goes through the manager after .restorationNeedsUpdate. It checks that only the forget step runs and that the displayed key and the update flag are cleared. It still injects forgetSessionAccess, so the deletion of the saved session and secret key and the dropped pending-cleanup flag are not asserted. This is a coverage gap only, not a defect.
Android parity. Compared with bitkit-android master 791d51b. There, PubkyRepo.forgetUnrestoredIdentity() and signOut() both run under initializeMutex, so they also wait for a running restore before choosing a path. iOS now matches that behaviour.
Validation and limits. This is a source-only review. No Swift toolchain was available, so I did not compile or run anything. When I checked, the PR's unit-tests and integration-tests runs for e018ea9 were still in progress, so there is no CI result yet for the two new tests. Device testing was not performed in this review.
Suggested additional test cases
- iOS, restore-race Disconnect: start with a saved profile whose restore was deferred (for example, open Profile while offline). Tap Try Again, or bring connectivity back, and confirm Disconnect while the restore is still running. Expected: the button stays disabled until the restore finishes. The identity is then signed out (its session ends and its endpoints are removed). Profile then offers a fresh connection, and the old identity does not come back after the app restarts.
Reviewer model: claude-opus-5-5
Reasoning effort: high
Closes #1427
Description
PaykitError.Storagetext and left the profile in place, because sign-out first removes Paykit endpoints, which needs that state. A profile whose session never restored is now forgotten on this device only, as on Android (PubkyRepo.forgetUnrestoredIdentity()); the shared Paykit state on the homeserver stays untouched.Out of Scope
Design
N/A — no UI changes.
Preview
N/A
QA Notes
Setup
As in #1427: connect a Paykit profile on regtest, stop Bitkit, write version 6 shared state for the same identity with a newer Paykit SDK, then relaunch this build.
Journeys
N/A — not drivable; see Manual Tests.
Manual Tests
Automated Checks
PubkyProfileManagerTests.swift— Disconnect only forgets an identity that never restored and drops its pending endpoint cleanup; a restored one signs out as before; through the manager, a profile that needs an update is forgotten, and one restored while Disconnect waits is signed outEvidence
xcodebuild testwith theunit-tests.ymlskips andswiftformat --lintpass on this change over master 325b409. Device cases not run.Gaps
Models used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium)gemini-4-neon-high(reasoning:high)