Skip to content

Conversation

@ben-kaufman
Copy link
Contributor

@ben-kaufman ben-kaufman commented Jan 16, 2026

Prevent node from stopping immediately when going to background and fix app getting stuck on app status

@claude

This comment has been minimized.

@claude

This comment has been minimized.

ovitrif
ovitrif previously approved these changes Jan 16, 2026
Copy link
Collaborator

@ovitrif ovitrif left a comment

Choose a reason for hiding this comment

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

utAck

maybe 1 little nit:
could use init instead of initialize/ initialization in fn names 🙏🏻

@claude

This comment has been minimized.

ovitrif
ovitrif previously approved these changes Jan 16, 2026
@claude

This comment has been minimized.

@claude

This comment has been minimized.

@claude

This comment has been minimized.

@claude

This comment has been minimized.

ovitrif
ovitrif previously approved these changes Jan 16, 2026
Copy link
Collaborator

@ovitrif ovitrif left a comment

Choose a reason for hiding this comment

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

re utAck

@claude

This comment has been minimized.

@claude

This comment has been minimized.

@ben-kaufman ben-kaufman requested a review from pwltr January 19, 2026 13:08
@jvsena42 jvsena42 requested a review from Copilot January 19, 2026 13:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR prevents the Lightning node from stopping immediately when the app goes to background and fixes the app status indicator from showing sync failures during app lifecycle transitions.

Changes:

  • Adds a 90-second delay before stopping the node when app goes to background
  • Introduces a cache layer in LightningService to avoid blocking UI thread with synchronous LDK calls
  • Updates test code to use async/await pattern with MainActor isolation

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Bitkit/Utilities/ScenePhase.swift Implements delayed node stop with cancellation logic for quick foreground returns
Bitkit/Services/LightningService.swift Adds MainActor-isolated cache for node state to prevent blocking UI thread
Bitkit/ViewModels/AppViewModel.swift Renames status initialization flag and adds reset method for background transitions
Bitkit/Components/AppStatus.swift Updates to use renamed status initialization flag
Bitkit/Utilities/AppStatusHelper.swift Changes stopped/stopping states to show pending instead of error
Bitkit/Views/Settings/AppStatusView.swift Switches from syncState to async syncStateAsync
Bitkit/ViewModels/WalletViewModel.swift Adds concurrent start guard and async state sync method
Bitkit/Utilities/StateLocker.swift Converts blocking Thread.sleep to async Task.sleep
BitkitTests/StateLockerTests.swift Updates tests to use async/await pattern
BitkitTests/UtxoSelectionTests.swift Wraps LightningService property access with MainActor.run
BitkitTests/ChannelPurchaseFlow.swift Wraps LightningService property access with MainActor.run
BitkitNotification/NotificationService.swift Wraps channel and peer access with MainActor.run
Bitkit/Services/TransferService.swift Wraps LightningService property access with MainActor.run
Bitkit/Services/CoreService.swift Wraps LightningService property access with MainActor.run
Bitkit/Managers/PushNotificationManager.swift Wraps status check with MainActor.run
Bitkit/Managers/BalanceManager.swift Wraps balance and channel access with MainActor.run
Bitkit/AppScene.swift Calls markAppStatusInit when node reaches running state

// Cancel any existing scheduled stop
stopNodeWorkItem?.cancel()

let workItem = DispatchWorkItem { [self] in
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The capture list [self] creates a strong reference which could lead to retain cycles if the work item outlives the view. Use [weak self] instead and add a guard statement to safely unwrap self.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@claude

This comment has been minimized.

pwltr
pwltr previously approved these changes Jan 19, 2026
Copy link
Contributor

@pwltr pwltr left a comment

Choose a reason for hiding this comment

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

Looks all good to me, briefly tested on simulator

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.

4 participants