Skip to content

Add OTA update check and restart on cold start#14099

Open
dylanjeffers wants to merge 3 commits intomainfrom
claude/ota-auto-restart-app-o2Eov
Open

Add OTA update check and restart on cold start#14099
dylanjeffers wants to merge 3 commits intomainfrom
claude/ota-auto-restart-app-o2Eov

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

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 lifecycle

    • Checks for previously-downloaded pending updates and restarts immediately if found
    • Syncs with CodePush server to check/download/install new updates with a 10-second timeout
    • Restarts the app if an update completes within the timeout window
    • Stages updates as pending if sync exceeds timeout, applying them on next cold start
    • Exports otaStartupComplete promise that resolves when the OTA check finishes
  • Updated App.tsx: Calls useOtaStartupRestart() at the root level to ensure OTA checks run on every app launch

  • Updated RootScreen.tsx: Gates app initialization on otaStartupComplete

    • Adds isOtaReady state that waits for the OTA startup promise to resolve
    • Delays setting isLoaded until both account status is ready AND OTA check is complete
    • Ensures splash screen remains visible during any OTA restart

Implementation Details

  • The splash screen is held open by gating on otaStartupComplete, so restarts happen seamlessly while the splash is visible
  • Push notification deep links survive JS-only CodePush restarts because getInitialNotification() is held at the native layer
  • A safety net timeout (15 seconds) prevents the app from hanging if the hook never executes
  • Uses ON_NEXT_RESTART install mode to prevent CodePush from auto-restarting at unpredictable times
  • Comprehensive logging for debugging OTA sync status and timing

https://claude.ai/code/session_0185bgoxLSH5uxDpZbxhwmEN

claude added 3 commits April 10, 2026 18:20
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
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 10, 2026

⚠️ No Changeset found

Latest commit: 9e7e2cf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants