Repository navigation
fix: flag session restore on pubky init fail - #1305
Conversation
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
jvsena42
left a comment
There was a problem hiding this comment.
Approved — no HIGH/MEDIUM findings at head d303825e4. (Posted as a comment because GitHub does not allow approving your own PR.)
Checked: Traced the new flag path in PubkyRepo.initialize (line 186) end to end: on an identity error the code only flips _sessionRestorationFailed; no keychain delete, no signOut, no clearLocalState runs on that path, and the only consumer (AppViewModel.kt:503-510) shows the toast and clears the flag, so nothing is discarded for transient failures. Offline/transport failures are a separate PaykitException.Transport class in the rc55 bindings and are excluded by isPaykitIdentityError, so a network outage cannot trigger the toast (the Rust-side mapping itself is not checked out locally and was not verified). The deferred stale-session branch in PaykitSdkService.initialize (lines 235-251) resumes stored session access in finally before rethrowing, so a non-deferrable identity error still leaves the saved session intact. The flag is set before initializationReady completes, but it is a StateFlow so a late AppViewModel subscriber still sees it; the second initialize caller (WalletViewModel.kt:243, restore path) hits isServiceInitialized=true when the SDK started, and when it did not the toast repeats only in that restore run. Re-auth after this toast still fails because startAuth awaits the poisoned isSetup, and the toast repeats every launch; both are stated as accepted limitations in the PR body and #1275 scopes the fix to setting the flag, so not raised. The path is only reachable for wallets that created a Pubky session through the dev-gated Paykit UI. No iOS twin PR found.
There was a problem hiding this comment.
Verdict: ✅ Approve
Review: diff 5 files.
Findings:
1 inline (non-blocking)
Audit:
Awaits QA.
Coverage:
QA: journeys and manual tests queued
Reviewed by claude-opus-5-xhigh via gh-pr-review-loop skill
Commands: @ovi-reviewer review · test · retest · audit (author or owner)
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jvsena42
left a comment
There was a problem hiding this comment.
Approved — no blocking HIGH/MEDIUM findings at head 8f47f9fc2. (Posted as a comment because GitHub does not allow approving your own PR.)
Checked: Follow-up: Follow-up on 8f47f9f (test only). The new case builds the repo with createSut(), whose init launches initialize(), and awaitInitialization waits for that job, so it runs the production path. It throws the same AppError(PaykitException.Identity(...)) that the sibling case uses to prove isPaykitIdentityError() is true, and it stubs PAYKIT_SESSION to null. hasSavedSession() (PubkyRepo.kt:231) is therefore false and the flag must stay false. Removing && hasSavedSession() from PubkyRepo.kt:186 sets _sessionRestorationFailed to true and fails the new assertFalse. The commit touches only PubkyRepoTest.kt.
Refs #1093
Related to #1275
This PR shows the "Session expired" toast when Paykit fails to start because the saved Pubky session is rejected.
Description
Out of Scope
PubkyRepo: clearing the stale saved session automatically, and widening the cases where a stale session can be deferred. Both need input from the Paykit SDK owner. Until that is decided, the toast shows again on every launch, because the stale session stays saved and re-auth cannot re-initialize the service. For that reason this PR references Paykit: recover stale sessions and harden coroutine error handling #1093 and does not close it.PubkyRepo: removing the saved credentials when Paykit is turned off (Paykit: recover stale sessions and harden coroutine error handling #1093 item 1).Design
N/A — no UI changes.
Preview
N/A. The toast and its text already exist; only the condition that shows it changed. No device run was done: a stale session cannot be forced on the shared emulator without tampering with its real Paykit session.
QA Notes
Manual Tests
regression:Wallet that never enabled Paykit → force-stop → launch app: no "Session expired" toast.regression:Wallet with a valid Paykit session → force-stop → launch app: no toast; Profile and Contacts load.Automated Checks
PubkyRepoTest.ktchecks that an identity error with a saved session sets the flag without calling session import or deleting keychain entries, and that a storage error with a saved session does not set it.PubkyRepoTest.ktstartup-failure test now also checks the flag stays unset when no session is saved.PaykitExceptionExtTest.ktcovers wrapped identity, storage and generic errors.PubkyRepoTest.ktpins the saved-session half of the guard — an identity error with no saved session leaves the flag unset and does not import a session.just compile,just test,just lint, all green. Negative controls: with the fix removed, the identity-error test failed; with&& hasSavedSession()dropped from the guard, exactly the new no-saved-session test failed (1 of 104 inPubkyRepoTest.kt).