fix: protect nostrconnect handshake from app backgrounding + paste/UX polish (build 62) - #26
Merged
Conversation
… polish The nostrconnect handshake was running in an unguarded Task — if the user swiped Clave to launch the client app mid-flight (the natural follow-up to tapping Approve), iOS would suspend the process within ~5-10s and freeze the URLSessionWebSocketTask. The critical 2-3s window of connect → publish ack → pair-client never completed, so the proxy never registered the URI relays for secondary subscription and the client's follow-up RPCs vanished into ephemeral kind:24133 events nobody was listening on. Wraps the handshake Task in beginBackgroundTask/endBackgroundTask with idempotent expiration handling to extend foreground execution to ~30s — comfortable margin over the ~15-20s handshake budget. Bunker flow is unaffected (NSE-owned via APNs, has its own background budget). While in this corner of the UI, also: - Added a "Paste Nostrconnect URI" button above the paste field so users don't have to tap the field, long-press, then paste. - Updated the connecting overlay to "Connecting... / Stay in Clave for a few seconds" to soften the foot-gun rather than rely on the bg-task alone. - Fixed the "Connect as @<displayLabel>" approval button wrapping awkwardly for long emoji-decorated display names — added lineLimit(1), truncationMode(.tail), and minimumScaleFactor(0.7). Build 60 → 61. Plan: ~/.claude/plans/run-bootstrap-i-m-gentle-fairy.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Archive in Xcode came out at build 62 (61 was burned in an earlier upload attempt that didn't ship). Sync git to match what's on ASC so the merge commit + tag reflect ship reality. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
DocNR
marked this pull request as ready for review
May 7, 2026 02:53
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TaskinUIApplication.beginBackgroundTaskso it survives the user swiping Clave away to launch the client app mid-flight. Previously the unguardedTaskwould get suspended by iOS within ~5–10s of backgrounding, freezing theURLSessionWebSocketTaskmid-await; the critical 2–3s window of connect → publish ack →pair-clientnever completed, so the proxy never registered URI relays for secondary subscription and the client's follow-up RPCs vanished into ephemeral kind:24133 events nobody was listening on. The 30s background budget is comfortable margin over the ~15–20s handshake.lineLimit(1)+truncationMode(.tail)+minimumScaleFactor(0.7).Bunker flow is unaffected (NSE-owned via APNs, has its own ~30s wake budget). Build 60 → 62 (61 was burned in an earlier archive that didn't ship).
Plan:
~/.claude/plans/run-bootstrap-i-m-gentle-fairy.mdTest plan
Local Debug confirmed the nostrconnect handshake works (Wisp client reported a fragile-connection issue resolved by the bg-task fix), but Debug uses sandbox APNs so the full sign-flow needs TestFlight:
nostrconnect://URI → Approve → swipe Clave to app switcher and launch the client → client receives connect-ack andget_public_keyround-trips🤖 Generated with Claude Code