Skip to content

feat: connection issues view#878

Open
jvsena42 wants to merge 77 commits intomasterfrom
feat/connection-issues-view
Open

feat: connection issues view#878
jvsena42 wants to merge 77 commits intomasterfrom
feat/connection-issues-view

Conversation

@jvsena42
Copy link
Copy Markdown
Member

@jvsena42 jvsena42 commented Mar 31, 2026

Related to #873

Description

This PR adds a reusable connection issues overlay view and improves network recovery behavior across multiple flows.

Connection Issues Overlay

  • Adds ConnectionIssuesView composable with phone illustration, dashed gradient rings, and a loading spinner
  • Integrates the overlay into SendSheet, ReceiveSheet, ForceTransferSheet, SpendingAmountScreen, SpendingConfirmScreen, and SavingsConfirmScreen using AnimatedVisibility
  • Auto-dismisses when connectivity is restored, preserving the underlying flow state

canSend Refactor — Replace Cache with Flow-Based State

  • Removed cache fallback: canSend() no longer falls back to stale cached balance from DataStore when channels aren't usable — prevents false-positive unified invoices that would fail at payment time
  • Pure instant check: canSend() is now a non-suspend function that checks _lightningState.value.channels capacity directly
  • waitForUsableChannels() made public: Callers that need to wait for channel readiness (scan flows) call it explicitly before canSend()
  • Removed LightningService.canSend(): Logic inlined via totalNextOutboundHtlcLimitSats() extension on reactive state
  • Removed dead code: cachedLightningBalance(), CHANNELS_READY_TIMEOUT_MS

SyncNodeView on SendSheet

  • Displays SyncNodeView overlay on SendSheet when node is not running or lightning channels aren't usable yet (matching iOS shouldShowSyncOverlay behavior)
  • Opens SendSheet early when handling lightning-related deeplinks/scans, so the sync overlay is visible during channel reconnection
  • Navigates to Confirm screen before async fee estimation to avoid blocking

Network Recovery Improvements

  • SpendingAmountScreen refresh: Re-triggers updateLimits() when connectivity state changes, so the "Available" field updates after coming back online
  • IsOnlineTracker fix: Fixed isFirstEmission flag never being set to false, which prevented connectivity toasts from ever appearing
  • LightningRepo.awaitPeerConnected(): New method that polls for peer reconnection (up to 30s) before attempting cooperative channel close — prevents "Cannot begin shutdown while peer is disconnected" errors during transfer to savings after internet toggle
  • TransferViewModel.closeChannels(): Calls awaitPeerConnected() before attempting cooperative close, reducing unnecessary INTERRUPTED state in the savings progress screen

Preview

Send Sheet Sync View

send-sheet-sync-view.webm
Deeplink and QuickPay

deeplink-and-quickpay.webm
Receive Sheet

receive-sheet.webm
Transfer to Savings

transfer-to-savings.webm
Transfer to Spending

transfer-to-spending.webm
Scan Sheet (Zero Amount)

scan-sheet-zero-amount.webm
Scan Sheet (With Amount)

scan-sheet-with-amount.webm
Scan Sheet Sync View

scan-sheet-sync-view.webm
Send Sheet (Zero Amount)

send-sheet-zero-amount.webm
Send Sheet (With Amount)

send-sheet-with-amount.webm

QA Notes

Connection Issues Overlay

  1. Open the Send Bitcoin sheet, toggle airplane mode on
    • Connection Issues overlay should fade in over the send flow
    • Title should read "Send Bitcoin"
    • Dashed yellow rings and phone illustration should be visible
    • Spinner should be animating at the bottom
  2. Re-enable connectivity
    • Overlay should fade out
    • Send flow state should be preserved (no navigation reset)
  3. Repeat for Receive Bitcoin sheet (title: "Receive Bitcoin")
  4. Repeat for Force Transfer sheet (title: "Transfer Funds")
  5. Repeat for Transfer to Spending screens (amount + confirm)
  6. Repeat for Transfer to Savings confirm screen
  7. Verify the overlay does not appear when connectivity is stable

canSend / SyncNodeView

  1. With node starting, open send sheet → SyncNodeView overlay should show

    • Once node is running and channels usable, overlay fades out
  2. Paste BIP21 unified invoice while node is starting

    • SendSheet opens immediately with SyncNodeView visible
    • Once channels become usable, navigates to Confirm screen
  3. With node running and channels usable, paste BIP21 → should show both savings and spending options

Network Recovery — Send Flow

  1. With on-chain + lightning balance, enable airplane mode → open send sheet → disable airplane mode → paste unified zero-amount invoice
  • Both savings AND spending options should appear (not just savings)

Network Recovery — Transfer to Savings

  1. Toggle airplane mode off/on → immediately confirm transfer to savings
  • Progress screen should wait for peer reconnection and show SUCCESS (not INTERRUPTED)
  • Check logs for "Waiting for peer to reconnect" message

Connectivity Toasts

  1. Toggle airplane mode on → "Internet Connectivity Issues" warning toast should appear
  2. Toggle airplane mode off → "Internet Connection Restored" success toast should appear

@jvsena42 jvsena42 self-assigned this Mar 31, 2026
@jvsena42 jvsena42 marked this pull request as ready for review April 2, 2026 14:10
@jvsena42 jvsena42 added this to the 2.2.0 milestone Apr 2, 2026
@claude

This comment has been minimized.

@claude

This comment has been minimized.

jvsena42 and others added 3 commits April 2, 2026 13:25
@jvsena42

This comment was marked as resolved.

jvsena42 and others added 4 commits April 8, 2026 08:47
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
…oiceVM.kt

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review

@jvsena42

This comment was marked as resolved.

@jvsena42
Copy link
Copy Markdown
Member Author

jvsena42 commented Apr 9, 2026

Note: Small navigation delay when pasting unified invoices

During testing I noticed a ~5.8s delay navigating to SendAmountScreen after pasting a unified (BIP21 + Lightning) invoice. This is a pre-existing issue unrelated to this PR's changes.

Root cause

BlocktankService.info and CoreService.decode both run on ServiceQueue.CORE — a single-threaded queue. When a periodic BlocktankRepo.refreshInfo() coincides with a scan/paste, the slow network call to the Blocktank server (~5.8s) blocks decode from processing the invoice.

Why we can't just move BlocktankService to its own queue

Both services share native Rust state via bitkitcore FFI. The single-threaded CORE queue serializes access to that native database. Moving BlocktankService off it would create race conditions with initDb(), updateBlocktankUrl(), and cross-service calls from ActivityService.

Possible future fixes

This would need to be addressed at the bitkitcore/Rust level (e.g., making the native layer thread-safe so the queue constraint can be relaxed).

@jvsena42
Copy link
Copy Markdown
Member Author

jvsena42 commented Apr 9, 2026

Everything retested and polished as much as possible ✅

@jvsena42 jvsena42 requested a review from ovitrif April 9, 2026 12:00
Sign up for free to 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.

3 participants