Skip to content

fix: protect nostrconnect handshake from app backgrounding + paste/UX polish (build 62) - #26

Merged
DocNR merged 2 commits into
mainfrom
fix/nostrconnect-bg-task
May 7, 2026
Merged

fix: protect nostrconnect handshake from app backgrounding + paste/UX polish (build 62)#26
DocNR merged 2 commits into
mainfrom
fix/nostrconnect-bg-task

Conversation

@DocNR

@DocNRDocNR commented May 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Wraps the nostrconnect handshake Task in UIApplication.beginBackgroundTask so it survives the user swiping Clave away to launch the client app mid-flight. Previously the unguarded Task would get suspended by iOS within ~5–10s of backgrounding, freezing the URLSessionWebSocketTask mid-await; the critical 2–3s window of connect → publish ack → pair-client never 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.
  • Adds a "Paste Nostrconnect URI" button above the paste field — one tap instead of tap-field/long-press/paste.
  • Softens the connecting overlay copy to "Connecting... / Stay in Clave for a few seconds" rather than relying on the bg-task alone.
  • Fixes the "Connect as @..." approval button wrapping awkwardly for long emoji-decorated display names: 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.md

Test 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:

  • TestFlight install of build 62
  • Golden path: paste fresh nostrconnect:// URI → Approve → swipe Clave to app switcher and launch the client → client receives connect-ack and get_public_key round-trips
  • Stay-in-Clave control: repeat without swiping; no regression vs build 60
  • Paste button: clipboard contains valid URI → tap "Paste Nostrconnect URI" → ApprovalSheet presents directly
  • Paste button — empty clipboard: tap → "Clipboard is empty." inline error
  • Paste button — invalid URI: tap → "That doesn't look like a valid nostrconnect URI." inline error
  • Connect-as button: approve sheet for an account with a long emoji-decorated display name renders the button single-line with tail truncation, no wrap
  • Force-quit case (documented limitation): swipe Clave away from app switcher within 15s of Approve → handshake fails (UIBackgroundTask doesn't cover process termination); user sees error in Clave on next open
  • Bunker URI sanity: unchanged code path; existing bunker pairings + sign requests still work via NSE
  • Existing connections: build 60 era pairings still receive sign requests via the proxy/APNs/NSE pipeline

🤖 Generated with Claude Code

DocNRand others added 2 commits May 6, 2026 22:48
… 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>
@DocNRDocNR changed the title fix: protect nostrconnect handshake from app backgrounding + paste/UX polishfix: protect nostrconnect handshake from app backgrounding + paste/UX polish (build 62)May 7, 2026
@DocNR
DocNR marked this pull request as ready for review May 7, 2026 02:53
@DocNR
DocNR merged commit 1e081e7 into mainMay 7, 2026
@DocNR
DocNR deleted the fix/nostrconnect-bg-task branch May 7, 2026 02:53
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@DocNR