Repository navigation
app(local_dev): wait for the dev stack at launch instead of failing behind the Local Network prompt - #26672
Conversation
…ehind the Local Network prompt A freshly installed local_dev build on an iPhone makes its first requests to the Mac (backend health probe, Firebase Auth emulator token refresh, account deletion status) while iOS is still showing the Local Network prompt. Those requests fail, and the account check's failure leaves the user on an error with Try Again. - Startup (local_dev builds only) now waits for the backend's /v1/health and the Auth emulator before the first backend or Auth request. A dev-only screen names the unreachable host:port, retries every 2 s for 60 s, keeps a manual Retry, and continues on its own once the stack answers. When the stack answers at once, nothing is shown. - Try Again could stay broken because the local-dev session re-mint ran only from getIdToken(), which startup calls once. Authenticated requests refresh through refreshIdToken() and never re-minted. In a local_dev build, every transient refresh failure now schedules the re-mint (one at a time), and the re-mint keeps the signed-in uid. Gated on --dart-define=OMI_APP_PROFILE=local_dev (kLocalDevProfileBuild). Production, mobile_beta and real-server dev builds are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e reachability gate Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…xpiry, and backs off Review findings H1, H2 and L5 on the local-dev reachability change. - H1: the uid and session generation are captured when the re-mint is scheduled. They are re-checked after the harness round trip and again inside the account-mutation queue, right before signInWithCustomToken. A sign-out or account switch that lands while the request is in flight (up to 16 s) now wins, instead of the old uid being signed back in. - H2: a successful re-mint writes tokenExpirationTime from getIdTokenResult(), so the cached token no longer reads as expired and re-arms the refresh-then-re-mint cycle. Attempts are at most one per 10 s, so a stack that is down does not spin. - signInWithLocalDevToken and the re-mint share one harness step (_fetchLocalDevCustomToken). Tests inject that step and the Firebase sign-in step. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nyway, say when connected Review findings B1 and M1 on the local-dev reachability change. - B1: the wait now applies only to stack endpoints on a non-loopback host. iOS's Local Network prompt never applies to loopback. CI's Android emulator acceptance APK (local_dev, empty API_BASE_URL, so 127.0.0.1:8000 and emulator host 127.0.0.1) therefore boots straight to first-run as before. main.dart calls one guard, localDevEndpointsToAwait, and tests cover it with the profile and Env defaults that APK uses. - A "Continue anyway" action lets a local_dev phone install start with the Mac off. - M1: once the stack answers, or is skipped, the screen says "Starting Omi" for the rest of startup instead of "Can't reach". - Cleanups: the two probes run in parallel, the unused attempts counter is gone, and the `!` on Env.apiBaseUrl is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1168f50be5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| static String waiting(String hostPort) => | ||
| "Can't reach the local dev stack at $hostPort. Allow Local Network access if iOS asked; " | ||
| 'this retries automatically.'; |
There was a problem hiding this comment.
Localize the startup reachability screen
On a device configured for a non-English locale, this screen displays its connectivity instructions and recovery actions only in English. app/AGENTS.md requires all user-facing strings to use localization and provides no exception for local-dev builds. Add these messages through the localization tooling and resolve the device locale in this standalone startup surface; BootRecoveryApp already demonstrates localized copy before the main app's localization scope exists.
AGENTS.md reference: app/AGENTS.md:L121-L122
Useful? React with 👍 / 👎.
Summary
On a fresh local-dev install, the iPhone app's first launch failed while iOS showed the "find devices on your local network" prompt. Sometimes "Try again" never recovered. Everything here applies only to builds made with
--dart-define=OMI_APP_PROFILE=local_dev, through the newkLocalDevProfileBuildconstant. Release, production and normal dev-flavor builds are unchanged.Cause
The cause was worked out from the code; there is no device log.
/v1/health, the token refresh against the Auth emulator, and thenAccountDeletionGate's account-status request, which shows "Something went wrong".getIdToken()call. Normal requests refresh tokens on a different path. If Allow was tapped after that one attempt, every later request and every Try Again failed the same way.Change
lib/startup/local_dev_reachability.dart, called frommain.dartbefore the first backend or Auth request):/v1/healthand the Auth emulator.auth_service.dart): every failed token refresh now schedules local-dev recovery, one at a time. Recovery keeps the signed-in uid instead of always switching tolocal-dev-user.Tests
local_dev_reachability_test.dart: wait screen, retry window, manual Retry, and a plain build without the define.local_dev_reachability_probe_test.dart: loopback 200, 503 and connection refused.local_dev_request_recovery_test.dart: recovery after every failed refresh, serialized; non-local-dev builds never recover this way.flutter test: 11,094 passed, 13 skipped. Format, analyze on changed files, and the UX contract check are clean.Failure-Class: none
UI-Evidence: none -- the only new screen is a dev-only wait screen compiled into
OMI_APP_PROFILE=local_devbuilds; no production UI changesProduct invariants
INV-DATA-1 (production-family data-plane continuity).
app/lib/env/environment_profile.dartchanged. The only addition is a read-onlyconst bool kLocalDevProfileBuild = String.fromEnvironment('OMI_APP_PROFILE') == 'local_dev'.AppEnvironmentProfileresolution.Review
One round. Luna found nothing blocking:
local_devdefine.DeepSeek found one blocker and two high-severity issues. Commits
913085397dand1168f50be5fix them:local_devrelease APK on127.0.0.1, airplane mode) never reached first run. CI confirmed this on3093f15. Now the gate waits only for non-loopback hosts. Loopback builds never probe and never show the screen; the test "CI's Android acceptance APK … waits for nothing" covers it. The screen also has Continue anyway, and once the stack answers it switches to "Starting Omi".signInWithCustomToken.tokenExpirationTime, so it kept re-triggering itself. It now writes it fromgetIdTokenResult(), with at most one attempt every 10 s.After those fixes, the full hermetic
flutter testpasses: 11,108 passed, 13 skipped.🤖 Generated with Claude Code