Skip to content

iOS Platform Detection Fix — `tauri-plugin-os` + shared helper

iOS Platform Detection Fix — tauri-plugin-os + shared helper

Status: Delivered
CAS: CAS-2516
Delivered: 2026-05-12
PRs: #646 (UA fallback), #645 (Cargo dep), #647 (shared helper)

What’s new

iOS bug-report submit now correctly routes through CloudBridge on every TestFlight build. Previously, every submit from an iPhone silently fell through to the desktop path and crashed with "gh not found" — the device has no gh binary. A missing Rust plugin registration caused the platform-detection function to always return “this is desktop” when running on iOS, making the months of CloudBridge work invisible to iPhone users.

How to use it

Nothing changes for the end user — the fix is automatic. On iOS, tapping the bug-report FAB, filling out the sheet, and submitting now reaches the CloudBridge daemon’s /v1/report-issue endpoint as intended. The existing CloudBridge pairing and submit flow (CAS-2381) now works end-to-end.

On macOS the submit path is unchanged: it still calls the local report_issue Tauri command which invokes gh.

What changed under the hood

  • tauri-plugin-os = "2" added to src-tauri/Cargo.toml and the plugin initialised in lib.rs. The JS-side @tauri-apps/plugin-os was already in package.json; the Rust side was the missing half — without it every platform() call threw and the catch block returned false (desktop).
  • src/utils/platform.ts — new shared platform helper exporting isMobilePlatform(), isDesktopPlatform(), and isApplePlatform(). Each tries the Tauri OS plugin first; if it throws (e.g., older bundle, stripped plugin), falls back to navigator.userAgent regex. Eliminates three duplicated detection snippets that each had slightly different failure modes.
  • Three call sites refactored to use the shared helper: useReportIssueStore.ts, FloatingReportButton.tsx, AISettingsPage.tsx.
  • userAgent defensive fallback (CAS-2518 / PR #646) landed first as an emergency hot-fix; the Cargo dep and shared helper (PRs #645 and #647) are the permanent fix.

Why we built it

CAS-2381 built the full iOS submit pipeline. CAS-2394 registered the cloud_bridge_report_issue Tauri command. Yet the 0.2.2 (14) TestFlight build still failed with the same gh not found error. Root-cause analysis on 2026-05-12 evening found that isNonDesktopPlatform() was calling @tauri-apps/plugin-os to detect iOS, but tauri-plugin-os was never added to Cargo.toml — so the IPC call threw, the catch returned false, and iOS was treated as desktop. Five months of mobile infrastructure work was one missing line in Cargo.toml away from being fully functional.

Known limitations / follow-on work

  • navigator.userAgent fallback is sufficient for a single-user app but is spoofable; acceptable here.
  • A post-fix iOS smoke test (CAS-2532) is queued to verify the end-to-end submit path on Simulator and confirm no regression on macOS.
  • The isApplePlatform() export (returns true on both iOS and macOS) is available for future use cases; not yet wired to any UI gate.