Skip to content

Mobile: recover from wedged Tailscale tunnels + Tailscale-aware connection diagnostics - #7980

Merged
Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/mobile-connection-issues
Jul 9, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/mobile-connection-issues

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Users on Tailscale report two flavors of the same failure (#7824 + Discord reports):

  1. Hosts stuck on "Connecting…" with Troubleshooting showing Cannot reach 100.x.x.x:6768.
  2. Connection drops mid-typing (green → yellow) and "i have to force turn off tailscale and back on my phone for it to work again".

The root network fault is a known iOS Tailscale failure mode: the VPN tunnel silently stops passing traffic and only a manual toggle restarts it. But the app made it much worse:

  • A wedged tunnel produces no AppState change and no network-type change — the phone still reports "online, Wi-Fi" — so none of our connection-revival nudges ever fire.
  • The reconnect loop parked permanently after 12 attempts (~6 min). Even after Tailscale healed on its own, the app never re-dialed until a foreground/network event. Toggling Tailscale "worked" because the toggle forces exactly the transition that un-parks our loop.
  • The Troubleshooting screen's advice was LAN-era: its VPN section said "Disable the VPN" — which for a Tailscale-paired host destroys the only route to it.

Changes

Never park the reconnect loop (rpc-client.ts): past the give-up cap, the loop now drops to a 90s trickle dial instead of stopping. One TCP attempt per 90s, foreground-only (JS timers are suspended in background), so battery cost is negligible. A session on a wedged-then-healed tunnel now recovers by itself within ≤90s, no toggle required. RPC callers past the cap still fail fast ("Connection retry limit reached").

Nudge on host focus (h/[hostId]/index.tsx): opening a host resets a backed-off/trickling loop and probes a possibly half-open socket immediately, instead of waiting out the timer. Empty deps so it fires per focus transition, not per connection-state flip (which would defeat backoff).

Say "check Tailscale" when it's the likely culprit (connection-health.ts): classifyConnection now accepts the host endpoint; warning/unreachable verdicts on 100.64/10 or *.ts.net endpoints carry a check Tailscale hint, rendered on the home host list and the in-session status line ("Can't connect — check Tailscale — tap to retry") after ~3 failed attempts (~15s). Reuses isTailscaleEndpoint from src/shared (#6637).

Tailscale-aware Troubleshooting (troubleshoot.tsx): unreachable tailnet hosts read Cannot reach 100.x.x.x:6768 — check Tailscale; new "Tailscale Host Unreachable" section documents the toggle workaround and desktop-awake check; the VPN section now scopes "disable it" advice to non-Tailscale VPNs. Static sections extracted to troubleshoot-common-issues.tsx (max-lines ratchet, no bump).

Testing

  • New: trickle-retry regression test (loop keeps dialing past the cap; a healed tunnel reconnects with no user action), connection-health hint tests, unreachableHostDetail tests (incl. non-CGNAT 100.x negative case).
  • Updated: the former "parked loop never retries" repro now asserts the fixed behavior; runAllTimersAsync uses replaced with bounded advances (an endless trickle timer would spin them forever).
  • Full mobile suite: 1278 passed / 2 skipped; tsc --noEmit, oxlint, oxfmt, and the max-lines ratchet all clean.

Fixes #7824

Made with Orca 🐋

…e' when it's the likely culprit

A wedged Tailscale tunnel (known iOS failure mode) produces no AppState
or network-type transition, so no revival nudge ever fires and the
reconnect loop parked permanently at its give-up cap — users had to
toggle Tailscale off/on just to force a transition (#7824).

- rpc-client: past the give-up cap, drop to a 90s trickle dial instead
  of parking so the session self-heals once the tunnel recovers.
- host screen: nudge the shared client on focus so opening the host
  retries immediately instead of waiting out a backoff/trickle timer.
- connection-health: warning/unreachable verdicts on 100.64/10 or
  *.ts.net endpoints now carry a 'check Tailscale' hint, shown on the
  home host list and the in-session status line after ~3 failed
  attempts.
- troubleshoot: 'Cannot reach <tailnet-ip>' now says to check
  Tailscale, adds a dedicated Tailscale section, and stops telling
  Tailscale users to disable their VPN (that advice killed their only
  route to the host); sections extracted to
  troubleshoot-common-issues.tsx to stay under the max-lines cap.

Co-authored-by: Orca <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The mobile app now detects Tailscale endpoints when classifying connection health and displays contextual hints in host and session screens. Troubleshooting content moved into a shared module, while unreachable-host diagnostics provide Tailscale-specific guidance. RPC reconnects continue at a slower cadence after the retry cap, pending waiters fail fast, and foreground focus restarts reconnect handling. Tests cover endpoint classification, display labels, diagnostic details, and reconnect behavior.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed, but it misses required template sections like Screenshots, AI Review Report, Security Audit, and Notes. Add the missing template sections, including Screenshots or 'No visual change', an AI Review Report, a Security Audit, and Notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: Tailscale tunnel recovery plus Tailscale-aware diagnostics.
Linked Issues check ✅ Passed The PR addresses [#7824] by keeping retries alive, retrying on focus, and adding Tailscale-specific diagnostics and troubleshooting.
Out of Scope Changes check ✅ Passed The tests, diagnostics refactor, and max-lines extraction are all directly tied to the Tailscale recovery and troubleshooting work.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
mobile/src/diagnostics/host-reachability.ts (1)

62-70: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider sharing the "check Tailscale" hint text with connection-health.ts.

This hardcodes "— check Tailscale" while connection-health.ts defines TAILSCALE_HINT = 'check Tailscale' for the same concept. Extracting a shared constant (e.g. alongside isTailscaleEndpoint in src/shared/remote-runtime-tailscale-hint.ts) would prevent the two messages drifting apart later.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c207f02e-c5da-41bc-887b-835a2c89dc4d

📥 Commits

Reviewing files that changed from the base of the PR and between e537953 and 537f1f1.

📒 Files selected for processing (11)
  • mobile/app/h/[hostId]/index.tsx
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/app/index.tsx
  • mobile/app/troubleshoot.tsx
  • mobile/src/diagnostics/host-reachability.test.ts
  • mobile/src/diagnostics/host-reachability.ts
  • mobile/src/diagnostics/troubleshoot-common-issues.tsx
  • mobile/src/transport/connection-health.test.ts
  • mobile/src/transport/connection-health.ts
  • mobile/src/transport/rpc-client.test.ts
  • mobile/src/transport/rpc-client.ts

@Jinwoo-H
Jinwoo-H merged commit 73f1bbf into main Jul 9, 2026
3 checks passed
Jinwoo-H added a commit that referenced this pull request Jul 10, 2026
Clean auto-merge, no conflicts (109 files, +7490 from main). Brought in:
- Codex WSL runtime status hooks (#7969); WSL/SSH agent path resolution past
  shell aliases (#7867); WSL source-control path separators (#7966); WSL
  GitLab-auth wake fix (#7967); WSL Codex usage RPC refresh (#7567/#7658)
- Improve workspace cleanup list (#7053) + background removal
- mobile: per-host connection log + Tailscale wedge recovery (#7984/#7980),
  wake slept agents on mobile worktree open (#7906)
- Harden layout validation, watcher lifecycle, connection robustness (#7924)
- Disable experimental worktree card style by default (#7977)

Perf-branch structure preserved (clean auto-merge). typecheck 0 errors; lint 0
errors. CI is the release gate (local runs skipped per env lag).

Co-authored-by: Orca <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…e' when it's the likely culprit (stablyai#7980)

A wedged Tailscale tunnel (known iOS failure mode) produces no AppState
or network-type transition, so no revival nudge ever fires and the
reconnect loop parked permanently at its give-up cap — users had to
toggle Tailscale off/on just to force a transition (stablyai#7824).

- rpc-client: past the give-up cap, drop to a 90s trickle dial instead
  of parking so the session self-heals once the tunnel recovers.
- host screen: nudge the shared client on focus so opening the host
  retries immediately instead of waiting out a backoff/trickle timer.
- connection-health: warning/unreachable verdicts on 100.64/10 or
  *.ts.net endpoints now carry a 'check Tailscale' hint, shown on the
  home host list and the in-session status line after ~3 failed
  attempts.
- troubleshoot: 'Cannot reach <tailnet-ip>' now says to check
  Tailscale, adds a dedicated Tailscale section, and stops telling
  Tailscale users to disable their VPN (that advice killed their only
  route to the host); sections extracted to
  troubleshoot-common-issues.tsx to stay under the max-lines cap.

Co-authored-by: Orca <[email protected]>
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.

[Bug] Lose connection mid typing to host on tailscale

1 participant