Add OTA update check and restart on cold start#14099
Open
dylanjeffers wants to merge 3 commits intomainfrom
Open
Add OTA update check and restart on cold start#14099dylanjeffers wants to merge 3 commits intomainfrom
dylanjeffers wants to merge 3 commits intomainfrom
Conversation
When the app launches (including from a push notification), check for a previously-downloaded CodePush update and restart immediately — while the native splash screen is still visible — so users always open into the latest JS bundle. Push notification deep links survive the JS-only restart because getInitialNotification() is held at the native layer. https://claude.ai/code/session_0185bgoxLSH5uxDpZbxhwmEN
Instead of only checking for pending (already-downloaded) updates, now also runs a full CodePush sync on cold start to download new updates. If the download completes within a 10s timeout window (while the splash screen is still visible), restarts immediately to apply it. If it takes longer, the update is staged as pending for the next cold start or the banner's Restart button. Uses ON_NEXT_RESTART install mode so we control restart timing rather than letting CodePush auto-restart at an unpredictable moment. https://claude.ai/code/session_0185bgoxLSH5uxDpZbxhwmEN
Export an `otaStartupComplete` promise from the OTA hook that resolves when the sync finishes, times out, or OTA is disabled. RootScreen now gates the `isLoaded` transition on this promise, keeping the native splash screen visible during any OTA download + restart. This guarantees the user never sees the old bundle flash before a restart. If the sync takes longer than 10s the timeout fires, the promise resolves, and the app loads normally with the update staged for the next cold start. Also adds a 15s safety-net timeout at module level so the app can never hang on the splash screen even if the hook fails to execute. https://claude.ai/code/session_0185bgoxLSH5uxDpZbxhwmEN
|
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 free
to 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
Implements automatic OTA (Over-The-Air) update checking and application on app cold start. The feature checks for pending updates and syncs with the server to download/install new updates, with intelligent restart timing that keeps the splash screen visible during the process.
Key Changes
New hook
useOtaStartupRestart: Manages the cold-start OTA update lifecycleotaStartupCompletepromise that resolves when the OTA check finishesUpdated
App.tsx: CallsuseOtaStartupRestart()at the root level to ensure OTA checks run on every app launchUpdated
RootScreen.tsx: Gates app initialization onotaStartupCompleteisOtaReadystate that waits for the OTA startup promise to resolveisLoadeduntil both account status is ready AND OTA check is completeImplementation Details
otaStartupComplete, so restarts happen seamlessly while the splash is visiblegetInitialNotification()is held at the native layerON_NEXT_RESTARTinstall mode to prevent CodePush from auto-restarting at unpredictable timeshttps://claude.ai/code/session_0185bgoxLSH5uxDpZbxhwmEN