Repository navigation
feat(mobile): tell Android users when their build is out of date - #11825
AboveColin wants to merge 5 commits into
Conversation
A single 'Not a valid pairing code' covered a wrong link, a truncated paste and an app too old to understand the offer, so an out-of-date app looked like a bad paste. parsePairingInput/parsePairingUrl now return the reason, and the unsupported-version case reports both the offer version and the version this app supports. The QR and deep-link paths stay strict about the orca://pair route; only a deliberate paste may be a bare base64 code.
Android ships as a sideloaded APK on GitHub Releases, so nothing ever tells the user their app is out of date — an app too old to pair just failed with a blank error. On startup the app now resolves the newest mobile-android-v tag and offers the release page. Not /releases: desktop publishes hourly releases and the Android lane publishes with --prerelease --latest=false, so /releases/latest names a desktop build and a /releases page can hold zero Android entries (measured 2026-08-01: newest Android at index 9, gaps of 37 between entries). The git/matching-refs tag endpoint filters by prefix server-side instead. Checked at most once per 24h, aborted after 5s, silent on every failure, and Android-only — iOS updates arrive through TestFlight.
Default-on, unlike push notifications: a sideloaded APK has no store to announce a new build, so staying silent is the harmful default here. Turning it off skips the request itself rather than just the prompt, so the app stops contacting GitHub entirely. Android-only in the UI too — an iOS toggle would control nothing, since the check never runs there.
Greptile SummaryThis PR adds startup update notifications for sideloaded Android APKs and improves pairing error messages. Because the Android app is distributed outside any store, there was previously no signal to the user that their build was stale — a version mismatch silently presented as "Not a valid pairing code".
Confidence Score: 5/5Safe to merge. All new code is Android-only, opt-out, and resolves silently on every failure path; pairing changes are backward-compatible. The update-check path is purely additive and fails silently in every error case (offline, rate-limited, malformed body, timeout). The pairing refactor preserves the old null-returning wrappers for any callers not yet on the typed API, so existing behaviour is unchanged. The About screen toggle correctly defers rendering until the stored preference is loaded. No data is written to external services and no auth credentials are involved. Files Needing Attention: No files require special attention. android-release-feed.ts has a minor edge case in its catch block noted in the inline comment.
|
| Filename | Overview |
|---|---|
| mobile/src/updates/android-release-feed.ts | New module fetching latest Android release from GitHub's matching-refs API. Well-designed with timeout, pagination, and silent-failure semantics; one edge case where accumulated results from completed pages are discarded on timeout mid-pagination. |
| mobile/src/updates/use-app-update-check.ts | React hook orchestrating the update check: loads preferences, runs shouldCheckForUpdate, fetches the feed, calls evaluateUpdate, and surfaces a prompt. Correctly uses disposed flag and re-reads storage state in dismiss to avoid stale closure issues. |
| mobile/src/updates/app-update-check.ts | Pure logic for shouldCheckForUpdate and evaluateUpdate. Correctly handles 24h throttle, clock regression, platform guard, and per-version dismissal. Well-tested. |
| mobile/src/updates/update-check-store.ts | AsyncStorage wrapper for update check state. Defensive parsing and silent error handling are appropriate for a non-critical preference store. |
| mobile/src/transport/pairing.ts | Refactored to return typed PairingParseResult/PairingRejection. Version check before schema validation cleanly separates out-of-date app from malformed input. Old null-returning wrappers preserved for callers not yet migrated. |
| mobile/src/transport/pairing-rejection-message.ts | Maps PairingRejection reason + input source to actionable user messages. The unsupported-version case correctly identifies which side needs updating based on version comparison direction. |
| mobile/app/about.tsx | Adds Android-only update check toggle. Properly initializes state to null and conditionally renders the Switch only once the stored value is known. |
| mobile/src/components/UpdateAvailableDrawer.tsx | New drawer component presenting the update prompt. Simple and correct; opens GitHub release URL on Get the APK and calls onDismiss in both paths. |
| mobile/src/storage/preferences.ts | Adds loadAutomaticUpdateCheckEnabled/saveAutomaticUpdateCheckEnabled. Silent error handling matches existing preference patterns. |
| mobile/app/_layout.tsx | Wires useAppUpdateCheck into the root layout and renders UpdateAvailableDrawer at the top level. |
Sequence Diagram
sequenceDiagram
participant App as RootLayout (mount)
participant Hook as useAppUpdateCheck
participant Prefs as AsyncStorage
participant GH as api.github.com
participant Store as update-check-store
App->>Hook: mount (useEffect)
Hook->>Prefs: loadAutomaticUpdateCheckEnabled()
Hook->>Store: loadUpdateCheckState()
Prefs-->>Hook: enabled (bool)
Store-->>Hook: "{ lastCheckedAtMs?, dismissedVersion? }"
Hook->>Hook: shouldCheckForUpdate(platform, enabled, state, now)
alt skip (iOS / disabled / checked recently)
Hook-->>App: "prompt = null"
else check
Hook->>GH: GET matching-refs/tags/mobile-android-v (paginated)
GH-->>Hook: "AndroidRelease | null"
Hook->>Store: "saveUpdateCheckState({ lastCheckedAtMs })"
Hook->>Hook: evaluateUpdate(currentVersion, release, dismissedVersion)
alt update-available
Hook-->>App: "prompt = { release, currentVersion }"
App->>App: UpdateAvailableDrawer visible
App->>Hook: dismiss()
Hook->>Store: "saveUpdateCheckState({ dismissedVersion })"
else up-to-date / dismissed
Hook-->>App: "prompt = null"
end
end
Reviews (2): Last reviewed commit: "fix(mobile): address review on pairing m..." | Re-trigger Greptile
📝 WalkthroughWalkthroughThe PR adds structured pairing parsers and source-specific rejection messages for QR, pasted, and deep-link inputs. It adds Android release discovery, version comparison, update-check policy, persisted check state, and automatic-update preferences. The root layout now displays an update drawer with release details and APK actions. The About screen exposes the Android update preference. Tests cover pairing failures, release fetching, update decisions, and preference persistence. Priority: ➖ Normal Merge Risk: 🔵 Low · up to Android screen-reader users may encounter the update preference switch without knowing what setting it controls. Add an accessible name before merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is detailed and relevant, but it does not follow the required template. It omits the required linked issue, required template headings, completed checklist items, and visual proof for the new drawer and About toggle. Resolution Add the required template sections and headings. Provide a valid linked issue after “Fixes #”. Attach before-and-after screenshots or a video for the UI changes. Complete the Testing, Review, Agent skill upstream boundary, Notes, and Checklist sections, including the build status and manual testing details.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
mobile/src/updates/use-app-update-check.ts (1)
68-78: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winMove the persistence side effect out of the
setPromptupdater.State updater functions must be pure. React double-invokes updater functions in development Strict Mode, so this async
loadUpdateCheckState/saveUpdateCheckStateside effect can run twice. The updater also depends onloadUpdateCheckStatewithout it being a dependency ofdismiss.Read
promptdirectly, add it to the dependency array, and callsetPrompt(null)after scheduling the persistence update.♻️ Proposed fix to keep the updater pure
const dismiss = useCallback(() => { - setPrompt((current) => { - if (current) { - void (async () => { - const state = await loadUpdateCheckState() - await saveUpdateCheckState({ ...state, dismissedVersion: current.release.version }) - })() - } - return null - }) - }, []) + if (prompt) { + const dismissedVersion = prompt.release.version + void (async () => { + const state = await loadUpdateCheckState() + await saveUpdateCheckState({ ...state, dismissedVersion }) + })() + } + setPrompt(null) + }, [prompt])
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 99d13e2d-dff1-487d-ae00-4b833f8eed8b
📒 Files selected for processing (18)
mobile/app/_layout.tsxmobile/app/about.tsxmobile/app/pair-scan.tsxmobile/src/components/UpdateAvailableDrawer.tsxmobile/src/storage/preferences.test.tsmobile/src/storage/preferences.tsmobile/src/transport/pair-confirm-state.test.tsmobile/src/transport/pair-confirm-state.tsmobile/src/transport/pairing-rejection-message.tsmobile/src/transport/pairing.test.tsmobile/src/transport/pairing.tsmobile/src/transport/types.tsmobile/src/updates/android-release-feed.test.tsmobile/src/updates/android-release-feed.tsmobile/src/updates/app-update-check.test.tsmobile/src/updates/app-update-check.tsmobile/src/updates/update-check-store.tsmobile/src/updates/use-app-update-check.ts
| import { PAIRING_OFFER_VERSION, PairingOfferSchema, type PairingOffer } from './types' | ||
|
|
||
| // Why: this file mirrors src/shared/pairing.ts (which is covered by CI | ||
| // vitest) but uses atob/btoa because Metro/Hermes don't ship Node's | ||
| // Buffer. Keep the parsing semantics in sync — when one changes, update | ||
| // the other. | ||
| // the other. The rejection reasons below are mobile-only and add no | ||
| // accept/reject difference: they explain a refusal the shared copy states | ||
| // as null. | ||
|
|
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Locate the shared pairing parser and compare its accept/reject logic to mobile/src/transport/pairing.ts.
fd -HI 'pairing.ts' src/shared
cat -n src/shared/pairing.ts 2>/dev/nullRepository: stablyai/orca
Length of output: 3916
🏁 Script executed:
#!/bin/bash
# Description: Inspect the updated mobile pairing parser implementation around the cited functions.
cat -n mobile/src/transport/pairing.ts | sed -n '1,180p'Repository: stablyai/orca
Length of output: 6495
Synchronize src/shared/pairing.ts route and version handling.
Mobile now rejects non-orca://pair routes before decoding and rejects unsupported v versions before schema parsing. src/shared/pairing.ts only rejects non-pair hostnames inside extractPairingCodeFromUrl and parses through PairingOfferSchema.parse in both decoded paths. Apply the same matchPairRouteRest-style route check and pre-schema v rejection in the shared parser so both sides make the same accept/reject decisions.
- The unsupported-version message always told the user to update their phone. That is only right when the offer is newer; an older offer means the desktop is behind, and pointing at the wrong machine is worse than saying nothing. - saveAutomaticUpdateCheckEnabled is called without await from About, so a failing write became an unhandled rejection. Swallow it like the other writes. - The About toggle rendered default-on before the stored value loaded, flashing ON for opted-out users and letting a quick tap be reverted by the load. - Update-check storage key now follows the 'orca:camelCaseKey' convention. Adds a parity test pinning the mobile parser's accept/reject set to the shared one across 29 inputs, including the one pre-existing divergence (mobile matches the scheme and host case-insensitively for QR alphanumeric mode).
|
Thanks both — four of five points were right and are fixed in 78dcbeb. The fifth I measured, and it does not hold. Fixed
Not reproduced: shared/mobile parser divergence @coderabbitai asked to apply the route check and pre-schema Rather than assert that, I ran both parsers over 29 inputs (valid URL, bare code, hash form, wrong route, extra path, truncated code, junk base64, wrong That one pre-dates this PR: Not addressed: docstring coverage Deliberate. PR description now follows the template. |
|
Tip For best results, initiate chat on the files or code changes.
The direction-aware version message and the handled preference write address the valid findings. I withdraw the shared/mobile parser-divergence finding. The new parsing branches change rejection reporting, not acceptance. The parity test also records the pre-existing uppercase-host difference. I also withdraw the docstring-coverage finding. The 🐇 ✓ ✏️ Learnings added
You are interacting with an AI system. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2b094274-fcb0-47ef-bcdf-1c87b41eb29f
📒 Files selected for processing (6)
mobile/app/about.tsxmobile/src/storage/preferences.tsmobile/src/transport/pairing-rejection-message.test.tsmobile/src/transport/pairing-rejection-message.tsmobile/src/transport/pairing-shared-parity.test.tsmobile/src/updates/update-check-store.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- mobile/src/updates/update-check-store.ts
- mobile/app/about.tsx
- mobile/src/storage/preferences.ts
| // Why: a newer offer means this app is behind; an older one means the | ||
| // desktop is. Naming the wrong side sends the user to update a machine | ||
| // that is already current. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Shorten or remove the multi-line comments.
The code and test names already state the behavior. Keep only a single line when non-obvious context is necessary.
mobile/src/transport/pairing-rejection-message.ts#L24-L26: remove the implementation walkthrough or replace it with one concise rationale.mobile/src/transport/pairing-rejection-message.test.ts#L5-L6: remove the rationale because the test name is sufficient.mobile/src/transport/pairing-shared-parity.test.ts#L6-L8: reduce the mirror-contract explanation to one line.mobile/src/transport/pairing-shared-parity.test.ts#L73-L76: reduce the divergence explanation to one line.
As per coding guidelines, comments must be concise, limited to non-obvious information, and preferably one line.
📍 Affects 3 files
mobile/src/transport/pairing-rejection-message.ts#L24-L26(this comment)mobile/src/transport/pairing-rejection-message.test.ts#L5-L6mobile/src/transport/pairing-shared-parity.test.ts#L6-L8mobile/src/transport/pairing-shared-parity.test.ts#L73-L76
Source: Coding guidelines
|
All four fixes look correct in 78dcbeb:
On the parser divergence: the parity test is the right call. Pinning the uppercase case as a documented, named divergence ( No further concerns. Tip: You can customize Greptile's behavior for this repo with |
# Conflicts: # mobile/app/about.tsx
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 0ec46f3b-61f7-4f07-8462-28ab97825b62
📒 Files selected for processing (5)
mobile/app/_layout.tsxmobile/app/about.tsxmobile/app/pair-scan.tsxmobile/src/settings/about-screen.tsxmobile/src/transport/types.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| <View style={styles.updateSection}> | ||
| <View style={styles.row}> | ||
| <Text style={styles.rowLabel}>Check for updates</Text> | ||
| <Switch |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions
Length of output: 39498
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- mobile/app/about.tsx ---'
sed -n '1,130p' mobile/app/about.tsx
printf '%s\n' '--- related accessibility and switch usage ---'
rg -n -S --glob '*.{tsx,ts,js,jsx}' 'accessibility(Label|LabelledBy)|<Switch|Switch' mobile | head -200Repository: stablyai/orca
Length of output: 26698
🏁 Script executed:
#!/bin/bash
set -eu
sed -n '1,130p' mobile/app/about.tsx
printf '\n--- switch/accessibility references ---\n'
rg -n -S --glob '*.{tsx,ts,js,jsx}' 'accessibility(Label|LabelledBy)|<Switch|Switch' mobile | head -200Repository: stablyai/orca
Length of output: 25504
🌐 Web query:
site:reactnative.dev/docs/0.78 accessibilityLabelledBy Switch accessibilityLabel React Native Android
💡 Result:
In React Native, the Switch component inherits View props [1], and since the View component supports accessibilityLabelledBy [2][3], the Switch component can technically accept this prop. accessibilityLabelledBy allows you to associate a component with another element's nativeID to provide an accessible label for screen readers [2]. This is useful for complex forms where you want the screen reader to announce a label associated with the control [2]. To use this with a Switch on Android: 1. Assign a unique nativeID to the Text component serving as the label. 2. Pass that nativeID as the string value to the accessibilityLabelledBy prop on the Switch. Example: Enable Notifications When the Switch is focused by a screen reader (such as TalkBack on Android), it will announce the Switch's state along with the text provided by the element referenced by the nativeID [2]. Ensure that your implementation testing on Android accounts for specific OS versions, as accessibility behavior can vary across different TalkBack releases.
Citations:
- 1: https://reactnative.dev/docs/0.78/switch
- 2: https://reactnative.dev/docs/0.78/accessibility
- 3: https://reactnative.dev/docs/0.78/view
Add an accessible name to the update switch.
The Android Switch has no accessibilityLabel or accessibilityLabelledBy association. The neighboring Text does not label it automatically, so TalkBack users can reach the switch without its setting name. Add accessibilityLabel="Check for updates".
Proposed fix
<Switch
+ accessibilityLabel="Check for updates"
value={updateCheckEnabled}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <Switch | |
| <Switch | |
| accessibilityLabel="Check for updates" |
|
Closing this. It has fallen behind main and I'm not able to keep it current. Thanks for the reviews. |
Summary
The mobile app is distributed as a sideloaded APK on GitHub Releases (
.github/workflows/mobile-android-release.yml) — there is no store to announce a new build. An out-of-date app therefore fails silently, and it surfaces in the worst place: pairing rejects the desktop's offer with a bare "Not a valid pairing code", which reads like a bad paste rather than "this app is old".That is how this was found: a stale APK refused a valid
orca://pair?code=…offer, by QR and by paste, with no hint that the app was the problem.1. Pairing rejections name their reason.
parsePairingInput/parsePairingUrlreturn a typedPairingRejectioninstead ofnull. The offer version is read before schema validation, which is what makes an out-of-date app distinguishable from bad input, and the message names the side that is behind:QR and deep-link paths stay strict about the
orca://pairroute; only a deliberate paste may be a bare base64 code.parsePairingCode/decodePairingUrlstay as wrappers, so existing callers are untouched.2. Startup update check (Android). On launch the app resolves the newest
mobile-android-vtag and offers the release page.Source of truth, measured rather than assumed:
/releases/latestis unusable — the Android lane publishes with--prerelease --latest=false, so it names a desktop build (v1.4.162)./releases?per_page=30would be a landmine: desktop publishes hourly, so Android entries sit deep and far apart. Measured 2026-08-01 on page 1 of 100: Android at indices 9, 26, 63, 64, 88, 89 — a gap of 37. A 30-item page can hold zero Android releases.git/matching-refs/tags/mobile-android-v, which filters by tag prefix server-side. One request, every Android tag, no desktop noise.Budgets: at most one check per 24h, 5s abort, and every failure — offline, rate limited, malformed body — resolves silently with no prompt.
3. "Check for updates" toggle on About. Default-on, unlike push notifications: silence is the harmful default when nothing else can tell you. Off skips the request itself, not just the prompt.
Screenshots
No screenshots. The two new surfaces are a bottom drawer ("Update available", Get the APK / Later) and a Switch row on About, both built from the existing
BottomDrawerand theSwitchrow pattern already used on the Notifications screen, with existing theme tokens only. Happy to attach captures from an emulator if a reviewer wants them.Testing
pnpm lint— oxlint clean (mobile/)pnpm typecheck—tsc --noEmitexit 0 (mobile/)pnpm test— 380 files, 2829 passed, 3 skipped (mobile/)pnpm build— not run; this PR touches onlymobile/, which is built by the Expo/Gradle release workflow rather than the desktop buildNew tests: release-tag parsing and numeric semver ordering; pagination (refs are oldest-first, so a full page must be followed); silent failure on rate limit, network error, malformed body and a stalled request; throttle window, backwards clock, opt-out and per-version dismissal; default-on preference and its opt-out round-trip; every pairing rejection reason; and a parity test pinning the mobile parser's accept/reject set to
src/shared/pairing.tsacross 29 inputs.Also verified live against the real GitHub API: resolves
0.0.36, silent on0.0.36, prompts on0.0.30, honors dismissal.AI Review Report
Reviewed with Claude. Risks checked: the update check's failure modes (offline, HTTP error, malformed body, hang, clock skew), whether an opt-out truly stops the network call, whether the pairing refactor changes what gets accepted, and the drawer's behavior when the release URL is missing.
What it flagged and what changed:
saveAutomaticUpdateCheckEnabledhad no try/catch while being called withvoid— a failing write would surface as an unhandled rejection. Now swallowed like the neighbouring writes.orca:camelCaseKeyconvention. Renamed.mainalready matched case-insensitively and had a test for it, because QR alphanumeric mode encodes uppercase). Pinned in the parity test rather than silently changed — see Notes.Cross-platform: this PR touches only
mobile/, so no desktop macOS/Linux/Windows surface, no shortcuts, labels, shell behavior, or Electron paths are involved. Within mobile, the platform split is explicit: the check and its toggle are gated onPlatform.OS === 'android', since iOS updates arrive through TestFlight. Nopathhandling is introduced.Security Audit
orca://pairroute before decoding, so a bare base64 blob is only trusted from a deliberate paste. The parity test pins the accept/reject set against the shared implementation so a future edit cannot quietly widen it. All parsing stays inside try/catch with schema validation viaPairingOfferSchema.api.github.comover HTTPS, no credentials, no request body, no device identifier. The response is only read forrefstrings matched againstmobile-android-v<semver>; the opened URL is built from that validated tag, not from a server-supplied link, so a compromised or spoofed response cannot redirect the user to an arbitrary URL. Aborted after 5s.Notes
ORCA://PAIR?code=…whilesrc/shared/pairing.tsrejects it (URL.hostnameis case-sensitive for non-special schemes). Mobile is right — QR alphanumeric mode encodes uppercase — so the shared/web copy is the one that should probably change. That is out of scope for this PR; it is pinned inpairing-shared-parity.test.tsso it stays visible.AGENTS.mdmandates concise, non-obvious comments only ("DO NOT be verbose, explain the obvious"). Adding docstrings to satisfy the ratio would contradict the repo's own style rule.