Skip to content

feat(desktop): route beta channel to dev backend#7224

Merged
kodjima33 merged 1 commit into
mainfrom
worktree-beta-dev-backend-v2
May 10, 2026
Merged

feat(desktop): route beta channel to dev backend#7224
kodjima33 merged 1 commit into
mainfrom
worktree-beta-dev-backend-v2

Conversation

@kodjima33
Copy link
Copy Markdown
Collaborator

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 = nik-164@based-hardware.iam.gserviceaccount.com

$ 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

  • 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 kodjima33@gmail.com
  • 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

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 #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) <noreply@anthropic.com>
@kodjima33 kodjima33 merged commit 7452e64 into main May 10, 2026
3 checks passed
@kodjima33 kodjima33 deleted the worktree-beta-dev-backend-v2 branch May 10, 2026 22:48
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 10, 2026

Greptile Summary

This PR re-enables beta-to-dev backend routing for the production macOS bundle (com.omi.computer-macos), which was previously locked to return false after the PR #7014 outage. It also introduces an OMI_FORCE_DEV_BACKENDS env override that lets any bundle opt into dev backends without changing its update channel.

  • Core routing logic: shouldUseDevelopmentBackends now returns true when the production bundle is on the beta channel, matching mobile's TestFlight → staging pattern. A new isAffirmative helper handles \"1\"/\"true\"/\"yes\" for the env override.
  • Safety rationale: The dev backend has since been migrated to the prod Firebase project, so custom tokens resolve to the same UID as prod and Firestore reads/writes hit prod data.
  • Test coverage: 46 routing tests updated; stable channel, non-production bundles, and the force override path all have dedicated assertions.

Confidence Score: 4/5

Safe to merge; the routing logic is correct, well-tested, and well-commented with the historical context needed for future maintainers.

The routing logic is narrowly scoped and all test cases pass. The only rough edges are a log message that now misfires under the force-override path, and a small gap in isAffirmative test coverage — neither affects correctness of the routing decisions.

desktop/Desktop/Sources/DesktopBackendEnvironment.swift — the applyReleaseChannelDefaults() log message should be updated to distinguish the force-override trigger path from the beta-channel path.

Important Files Changed

Filename Overview
desktop/Desktop/Sources/DesktopBackendEnvironment.swift Re-enables beta-to-dev backend routing for the production bundle and adds OMI_FORCE_DEV_BACKENDS env override; logic is correct but the log message in applyReleaseChannelDefaults() becomes inaccurate when routing is triggered by the override rather than the beta channel.
desktop/Desktop/Tests/APIClientRoutingTests.swift Well-structured test updates cover the main routing cases; missing coverage for the "yes" affirmative value and explicit rejection of "false"/"no" for the forceOverride parameter.
desktop/CHANGELOG.json Adds a user-facing changelog entry for the beta dev-backend routing change; no issues.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[shouldUseDevelopmentBackends called] --> B{OMI_FORCE_DEV_BACKENDS\nis affirmative?}
    B -- Yes --> C[return true\nRoute to dev backends]
    B -- No --> D{bundleIdentifier ==\ncom.omi.computer-macos?}
    D -- No --> E[return false\nRoute to prod backends]
    D -- Yes --> F{normalizedChannel ==\nbeta or staging?}
    F -- No --> E
    F -- Yes --> C
    C --> G[applyReleaseChannelDefaults:\nsets OMI_PYTHON_API_URL to api.omiapi.com\nsets OMI_DESKTOP_API_URL to dev Cloud Run]
    E --> H[pythonBaseURL to api.omi.me\nrustBackendURL to prod Cloud Run]
Loading

Comments Outside Diff (1)

  1. desktop/Desktop/Sources/DesktopBackendEnvironment.swift, line 93-99 (link)

    P2 Stale log message when force-override triggers dev routing

    applyReleaseChannelDefaults() logs "beta channel using development backends…" but will now also fire when OMI_FORCE_DEV_BACKENDS=1 is set on a non-beta or non-production bundle. If someone uses the override on a stable dev build to debug a specific issue and then checks the logs, the message will mislead them into thinking the routing was triggered by channel assignment rather than the env override. A simple conditional or a second log branch would keep the message accurate.

Reviews (1): Last reviewed commit: "feat(desktop): route beta channel to dev..." | Re-trigger Greptile

Comment on lines +189 to 205
func testForceOverrideEnablesDevelopmentBackendsForAnyBundle() {
XCTAssertTrue(DesktopBackendEnvironment.shouldUseDevelopmentBackends(
bundleIdentifier: "com.omi.desktop-dev",
updateChannel: "stable",
forceOverride: "1"
))
XCTAssertTrue(DesktopBackendEnvironment.shouldUseDevelopmentBackends(
bundleIdentifier: "com.omi.omi-beta-dev-test",
updateChannel: "stable",
forceOverride: "true"
))
XCTAssertFalse(DesktopBackendEnvironment.shouldUseDevelopmentBackends(
bundleIdentifier: "com.omi.computer-macos",
updateChannel: "stable",
forceOverride: "0"
))
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 isAffirmative "yes" branch and non-affirmative values are untested

isAffirmative accepts "yes" in addition to "1" and "true", but testForceOverrideEnablesDevelopmentBackendsForAnyBundle never exercises it. Likewise, "false" and "no" are silently rejected by the function but are never asserted as false in the test. A future refactor that trims the accepted set or changes the rejection logic would have no test catching the regression.

kodjima33 added a commit that referenced this pull request May 11, 2026
Reverts #7224. The change was merged before being validated locally; we
want to test the dev-backend routing on a named local bundle first
(using the `OMI_FORCE_DEV_BACKENDS` override I added in that PR — except
the env-var didn't actually reach the launched .app because `run.sh`
loads URLs via a baked `Contents/Resources/.env`, not shell env).
Reverting on `main`, validating locally, then redoing.

The diagnostic PR #7227 stays — that's an unrelated workflow hardening
that's useful regardless.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
kodjima33 added a commit that referenced this pull request May 11, 2026
Reapplies #7224 after the #7230 revert. Verified locally this time:

- Named bundle (`com.omi.omi-beta-dev-test`) launched with shell-bundled
dev URLs (`OMI_PYTHON_API_URL=https://api.omiapi.com/`,
`OMI_DESKTOP_API_URL=https://desktop-backend-dt5lrfkkoa-uc.a.run.app/`).
- Signed in with `kodjima33@gmail.com` — landed on **prod UID
`viUv7GtdoHXbK1UBCDlPuTDuPgJ2`** (not a ghost dev UID).
- Existing chat history and tasks loaded.
- New requests go through dev backend: `POST
https://api.omiapi.com/v2/desktop/messages`, `/v3/memories`,
`/v1/action-items` — all succeeding, AgentSync pushing rows.
- Confirms dev backend's `SERVICE_ACCOUNT_JSON`, `FIREBASE_API_KEY`,
`FIREBASE_PROJECT_ID` are all on prod Firebase (`based-hardware`), so
dev-issued custom tokens resolve to the same prod UID.

This time the change ships through the existing #7227 diagnostic patch
(already on main), so if Codemagic's universal-bundle step trips again
we'll get a real error instead of a 0.6s opaque failure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
pull Bot pushed a commit to codingwatching/omi that referenced this pull request May 11, 2026
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.

1 participant