Repository navigation
Route macOS beta to development backends - #7014
Conversation
Greptile SummaryThis PR introduces All findings are P2. The most actionable is Confidence Score: 4/5Safe to merge; all findings are non-blocking P2 style/quality concerns with no runtime breakage on the happy path No P0 or P1 issues found. The routing logic is correct, well-tested, and the initialization ordering in AppState.init guarantees UserDefaults is seeded before any backend URL is resolved at runtime. Score is 4 rather than 5 due to the environment-sensitive test and the static-let divergence in TranscriptionService. desktop/Desktop/Tests/APIClientRoutingTests.swift (environment-sensitive test) and desktop/Desktop/Sources/TranscriptionService.swift (static-let URL capture) Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[AppState.init] --> B[prepareUpdateChannelForBackendRouting]
B --> C{isProductionBundle?}
C -- No --> D[Skip — non-prod bundle]
C -- Yes --> E[migrateBetaChannelOverwrite]
E --> F[syncUpdateChannelOnFirstLaunch if nil]
F --> G[loadEnvironment]
G --> H[Load .env files via setenv]
H --> I[applyReleaseChannelDefaults]
I --> J{shouldUseDevelopmentBackends?}
J -- bundleId==prod AND channel==beta/staging --> K[setenv OMI_PYTHON_API_URL = api.omiapi.com]
J -- stable OR non-prod bundle --> L[No override — keep existing env vars]
K --> M[APIClient.baseURL computed each call]
L --> M
M --> N{shouldUseDevelopmentBackends?}
N -- Yes --> O[https://api.omiapi.com/]
N -- No --> P{OMI_PYTHON_API_URL set?}
P -- Yes --> Q[Use env var URL]
P -- No --> R[https://api.omi.me/]
TS[TranscriptionService] --> S[pythonBackendBaseURL static let captured ONCE]
S --> N
|
| } | ||
| return "https://api.omi.me/" | ||
| }() | ||
| private static let pythonBackendBaseURL: String = DesktopBackendEnvironment.pythonBaseURL() |
There was a problem hiding this comment.
Static-let URL is captured once and never refreshes
pythonBackendBaseURL is a static let, so it is evaluated lazily on first access and permanently cached for the process lifetime. APIClient.baseURL is a computed var that re-evaluates DesktopBackendEnvironment.pythonBaseURL() on every call, but TranscriptionService will silently keep whatever URL was resolved at first use. If anything accesses this property before AppBuild.prepareUpdateChannelForBackendRouting() writes to UserDefaults, the wrong backend URL is permanently baked in for the session. Consider making this a computed property to mirror APIClient.
| static func pythonBaseURL( | ||
| environmentValue: String? = currentEnvironmentValue("OMI_PYTHON_API_URL") | ||
| ) -> String { | ||
| pythonBaseURL( | ||
| useDevelopmentBackends: shouldUseDevelopmentBackends, | ||
| environmentValue: environmentValue | ||
| ) | ||
| } | ||
|
|
||
| static func pythonBaseURL(useDevelopmentBackends: Bool, environmentValue: String?) -> String { | ||
| if useDevelopmentBackends { | ||
| return developmentPythonAPIURL | ||
| } |
There was a problem hiding this comment.
Env-var override is silently ignored on beta builds
When useDevelopmentBackends == true, the environmentValue parameter is discarded before it is inspected. A developer running a production beta bundle who sets OMI_PYTHON_API_URL=http://localhost:8080 in .env will be silently routed to api.omiapi.com instead. The PR description says it "preserves local/dev env override behavior" but that only applies to stable builds. A log message when a non-empty env var is overridden would make this easier to diagnose.
## Summary - Add 5 env vars present in prod but missing from dev backend-listen - Variables: `GROQ_API_KEY`, `OPENROUTER_API_KEY`, `RAPID_API_HOST`, `RAPID_API_KEY`, `CONVERSATION_SUMMARIZED_APP_IDS` - Add secret key mappings to ExternalSecret values (backend-secrets chart) for GCP SM → K8s sync - Use `secretKeyRef` pattern in backend-listen chart (consistent with existing secret refs) ## GCP Secret Manager status (based-hardware-dev) | Secret | Status | |--------|--------| | GROQ_API_KEY | Created with `PLACEHOLDER_GROQ_API_KEY` value | | OPENROUTER_API_KEY | Already existed (real value, 73 chars) | | RAPID_API_HOST | Already existed (real value, 28 chars) | | RAPID_API_KEY | Already existed (real value, 50 chars) | | CONVERSATION_SUMMARIZED_APP_IDS | Created with `PLACEHOLDER_CONVERSATION_SUMMARIZED_APP_IDS` value | ## Context Beta users are routed to dev backends (PR #7014). Env var audit found these 5 vars exist in prod backend-listen but are absent in dev GKE deployment. ## Test plan - [ ] Deploy backend-secrets chart first (syncs new keys to K8s secret) - [ ] Deploy backend-listen chart (pods pick up new env vars) - [ ] Verify pods start without CrashLoopBackOff - [ ] Replace 2 placeholder values (GROQ_API_KEY, CONVERSATION_SUMMARIZED_APP_IDS) with real values when available 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…ase accounts (#7040) ## Problem Production-bundle macOS users on the `beta` update channel are landing in **fresh empty Firebase accounts** after sign-in. Concrete repro: signing in as `[email protected]` on build `0.11.365` creates new Firebase user `caLCFj7IisV85UX9XrrV1aVf3pk1` (no email, no providers, created today) instead of returning the existing `viUv7GtdoHXbK1UBCDlPuTDuPgJ2` that owns all of kodjima33's data. Reported as widespread across beta users. Both UIDs are in the same `based-hardware` Firebase project (`aud: based-hardware`, `iss: https://securetoken.google.com/based-hardware`), so it's not a project mismatch — the dev auth flow is minting tokens for new UIDs instead of linking to existing ones. ## Cause PR #7014 (`60046c19f`) routed `com.omi.computer-macos` clients on the `beta` channel to: - Python: `https://api.omiapi.com/` - Rust: `https://desktop-backend-dt5lrfkkoa-uc.a.run.app/` The `OMI_AUTH_URL` is unchanged (still prod `omi-desktop-auth`), but downstream calls through the dev Python backend during sign-in result in a different uid being returned to the client. The empty user record on the new uid (no email, no providers) indicates the path goes through `signInWithCustomToken` for a freshly-generated uid rather than `signInWithIdp` linking by email. ## Fix Surgical: `shouldUseDevelopmentBackends` now always returns `false`, so prod-beta clients keep talking to prod backends. The routing scaffolding (`DesktopBackendEnvironment`, env-var override paths, `applyReleaseChannelDefaults`) is left in place for when the auth-side issue is properly diagnosed and fixed — at that point this can be reverted. A full `git revert` of #7014 conflicts with newer changes to `TranscriptionService.swift` and others; this 1-line approach gets the same effect with no merge surgery. ## Verification - [ ] Codemagic build succeeds - [ ] Mac mini smoke test: sign in as kodjima33 on the new build, confirm uid = `viUv7GtdoHXbK1UBCDlPuTDuPgJ2` and data loads - [ ] Confirm `APIClient.baseURL` resolves to `https://api.omi.me/` for prod-beta - [ ] Confirm `rustBackendURL` resolves to the prod `desktop-backend-hhibjajaja-uc.a.run.app` (or the env-var override) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…irebase accounts PR BasedHardware#7014 routed prod-bundle beta-channel users to api.omiapi.com + the dev desktop-backend, with the assumption that both would still read prod Firestore. In practice, signing in via the dev path lands users in fresh empty Firebase accounts (e.g. caLCFj7… instead of viUv7Gtdo… for [email protected]) — so they sign in successfully but see zero data. Surgical fix: make `shouldUseDevelopmentBackends` always return false so prod-beta clients keep using prod backends. Routing scaffolding is left in place for when the auth-side issue is fixed. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…rdware#7029) ## Summary - Add 5 env vars present in prod but missing from dev backend-listen - Variables: `GROQ_API_KEY`, `OPENROUTER_API_KEY`, `RAPID_API_HOST`, `RAPID_API_KEY`, `CONVERSATION_SUMMARIZED_APP_IDS` - Add secret key mappings to ExternalSecret values (backend-secrets chart) for GCP SM → K8s sync - Use `secretKeyRef` pattern in backend-listen chart (consistent with existing secret refs) ## GCP Secret Manager status (based-hardware-dev) | Secret | Status | |--------|--------| | GROQ_API_KEY | Created with `PLACEHOLDER_GROQ_API_KEY` value | | OPENROUTER_API_KEY | Already existed (real value, 73 chars) | | RAPID_API_HOST | Already existed (real value, 28 chars) | | RAPID_API_KEY | Already existed (real value, 50 chars) | | CONVERSATION_SUMMARIZED_APP_IDS | Created with `PLACEHOLDER_CONVERSATION_SUMMARIZED_APP_IDS` value | ## Context Beta users are routed to dev backends (PR BasedHardware#7014). Env var audit found these 5 vars exist in prod backend-listen but are absent in dev GKE deployment. ## Test plan - [ ] Deploy backend-secrets chart first (syncs new keys to K8s secret) - [ ] Deploy backend-listen chart (pods pick up new env vars) - [ ] Verify pods start without CrashLoopBackOff - [ ] Replace 2 placeholder values (GROQ_API_KEY, CONVERSATION_SUMMARIZED_APP_IDS) with real values when available 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…irebase accounts PR BasedHardware#7014 routed prod-bundle beta-channel users to api.omiapi.com + the dev desktop-backend, with the assumption that both would still read prod Firestore. In practice, signing in via the dev path lands users in fresh empty Firebase accounts (e.g. caLCFj7… instead of viUv7Gtdo… for [email protected]) — so they sign in successfully but see zero data. Surgical fix: make `shouldUseDevelopmentBackends` always return false so prod-beta clients keep using prod backends. Routing scaffolding is left in place for when the auth-side issue is fixed. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ase accounts (BasedHardware#7040) ## Problem Production-bundle macOS users on the `beta` update channel are landing in **fresh empty Firebase accounts** after sign-in. Concrete repro: signing in as `[email protected]` on build `0.11.365` creates new Firebase user `caLCFj7IisV85UX9XrrV1aVf3pk1` (no email, no providers, created today) instead of returning the existing `viUv7GtdoHXbK1UBCDlPuTDuPgJ2` that owns all of kodjima33's data. Reported as widespread across beta users. Both UIDs are in the same `based-hardware` Firebase project (`aud: based-hardware`, `iss: https://securetoken.google.com/based-hardware`), so it's not a project mismatch — the dev auth flow is minting tokens for new UIDs instead of linking to existing ones. ## Cause PR BasedHardware#7014 (`60046c19f`) routed `com.omi.computer-macos` clients on the `beta` channel to: - Python: `https://api.omiapi.com/` - Rust: `https://desktop-backend-dt5lrfkkoa-uc.a.run.app/` The `OMI_AUTH_URL` is unchanged (still prod `omi-desktop-auth`), but downstream calls through the dev Python backend during sign-in result in a different uid being returned to the client. The empty user record on the new uid (no email, no providers) indicates the path goes through `signInWithCustomToken` for a freshly-generated uid rather than `signInWithIdp` linking by email. ## Fix Surgical: `shouldUseDevelopmentBackends` now always returns `false`, so prod-beta clients keep talking to prod backends. The routing scaffolding (`DesktopBackendEnvironment`, env-var override paths, `applyReleaseChannelDefaults`) is left in place for when the auth-side issue is properly diagnosed and fixed — at that point this can be reverted. A full `git revert` of BasedHardware#7014 conflicts with newer changes to `TranscriptionService.swift` and others; this 1-line approach gets the same effect with no merge surgery. ## Verification - [ ] Codemagic build succeeds - [ ] Mac mini smoke test: sign in as kodjima33 on the new build, confirm uid = `viUv7GtdoHXbK1UBCDlPuTDuPgJ2` and data loads - [ ] Confirm `APIClient.baseURL` resolves to `https://api.omi.me/` for prod-beta - [ ] Confirm `rustBackendURL` resolves to the prod `desktop-backend-hhibjajaja-uc.a.run.app` (or the env-var override) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
## Summary - Beta channel of the production bundle (`com.omi.computer-macos`) now routes to the dev backend (`api.omiapi.com` Python + dev Cloud Run desktop-backend), matching mobile's TestFlight → staging pattern. - Stable channel and non-prod bundles are unchanged. - New `OMI_FORCE_DEV_BACKENDS=1` env override lets a named test bundle opt into dev backends without flipping its channel — handy for side-by-side validation. ## Why this won't repeat the PR #7014 outage PR #7014 (April 2026) was reverted because the dev backend was wired to the `based-hardware-dev` Firebase project, so beta users signed in as fresh empty UIDs (e.g. `caLCFj7…` instead of prod's `viUv7Gtdo…`). The dev backend infra has since been moved onto prod Firebase. Verified against the live deployments: ``` $ gcloud run services describe backend --project=based-hardware-dev … FIREBASE_PROJECT_ID = based-hardware FIREBASE_AUTH_DOMAIN = based-hardware.firebaseapp.com GOOGLE_CLOUD_PROJECT = based-hardware FIREBASE_API_KEY = AIzaSyA88g… (matches prod) SERVICE_ACCOUNT_JSON.project_id = based-hardware client_email = [email protected] $ gcloud run services describe desktop-backend --project=based-hardware-dev … FIREBASE_PROJECT_ID = based-hardware FIREBASE_API_KEY = AIzaSyA88g… (matches prod) ``` So custom tokens minted by the dev backend resolve to the **same UID** the user has on prod, and reads/writes hit prod Firestore. ## Test plan - [x] `swift test --filter APIClientRoutingTests` (46/46 passing) - [ ] Codemagic builds Beta DMG from this branch on merge - [ ] Install Beta DMG on Mac mini, sign in with [email protected] - [ ] Confirm `auth_userId` defaults shows the prod UID (`viUv7Gtdo…`), not a fresh one - [ ] Confirm existing conversations + memories load - [ ] Record a new conversation; confirm it appears in prod Firestore for the prod UID - [ ] Confirm stable channel of the same prod bundle keeps using `api.omi.me` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Beta channel of the production bundle now routes to the development backend (api.omiapi.com + the dev Cloud Run desktop-backend). The dev backend is configured to use prod Firebase (project_id=based-hardware, prod service account, FIREBASE_API_KEY=AIzaSyA88g...), so custom tokens it mints resolve to the same UID users have on prod — reads/writes hit prod Firestore. Same pattern mobile TestFlight uses for staging. This redoes PR BasedHardware#7014, which was reverted in April because dev backend was on the based-hardware-dev Firebase project at the time, so beta users landed in fresh empty Firebase accounts. The dev backend's SERVICE_ACCOUNT_JSON, FIREBASE_API_KEY, FIREBASE_PROJECT_ID, and FIREBASE_AUTH_DOMAIN have all since been moved onto prod Firebase — verified via `gcloud run services describe backend --project=based-hardware-dev`. The Rust desktop-backend in the dev GCP project has the matching FIREBASE_PROJECT_ID=based-hardware and the same FIREBASE_API_KEY as prod. Also adds an OMI_FORCE_DEV_BACKENDS env override so a named test bundle (com.omi.omi-*) can opt into dev backends without flipping its channel or bundle ID — useful for validating routing on a side-by-side build before shipping to actual beta users. Stable channel and non-prod bundles still default to prod backends or their configured OMI_PYTHON_API_URL / OMI_DESKTOP_API_URL. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Verification
swift test --filter APIClientRoutingTests(43 tests, 0 failures)git diff --checkswift format lint desktop/Desktop/Sources/DesktopBackendEnvironment.swiftData stores
Dev backend deployments already point at production data stores:
GOOGLE_CLOUD_PROJECT=based-hardwarefor Python andFIREBASE_PROJECT_ID=based-hardwarefor Rust.