Repository navigation
fix(mobile): connect reliably over tailscale and explain failures - #361
Merged
Merged
Conversation
nixuuu
marked this pull request as ready for review
November 8, 2026 17:20
nixuuu
added a commit
that referenced
this pull request
Nov 9, 2026
The phone now keeps a verified route until transport failure, network change, return from background, Reconnect, or removal of that address. Long-lived streams and quiet periods no longer cause a new race after 30 seconds, so normal requests keep their connection and Details keeps its route results. - Response headers and stream data/heartbeats confirm the current selection. Late responses or failures from an abandoned selection cannot restore or demote a newer one, including a new selection of the same address. RPCs that may have reached the computer are never replayed. - Added/reordered addresses retain the working route and live streams. There are no background upgrade probes. The phone drops private IPv4 `.0` candidates from old pairings and persists the sanitized list even when its last working address stays the same. - Gateway advertisements exclude virtual/container/macOS bridge adapters, unrelated utun interfaces, non-unicast/link-local/loopback addresses, and subnet network/broadcast endpoints using the actual mask. /31 and /32 host routes, Tailscale IP/MagicDNS, physical LAN and configured public addresses remain supported. Pairing, overview announcements and UpdateNetworkAccess use the existing shared address list. The 30-second cache was introduced by #324 and retained by #361, verified in git history. The gateway change ships with the desktop/server update; mobile changes are TS only and remain compatible with OTA. Validation: - 47 distinct focused tests pass: route policy without networking, real pinned-TLS streaming/recovery/no-replay, macOS/Linux/Windows interface samples and subnet boundaries, network access, phone port changes/address propagation and Tailscale advertisement ordering. - Passed: frozen-lockfile install, root typecheck, root lint, format:check, gen:check, web build and ESLint for all changed mobile transport files. Full local check:tmp was intentionally omitted as requested; CI remains the full-suite gate. - EAS CLI 27.4.1 production fingerprints match the starting dev commit 5e07154 on both platforms: iOS `6ddec9ef559ee0095ac33e94ff9418a942053b17`, Android `5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. No native/config/dependency changes or OTA publication. - Extra whole-app Expo lint reports 36 errors and 3 warnings in unchanged React UI files; none are in the changed transport files. Physical-phone QA and E2E were not run. The defensive private IPv4 `.0` filter is a documented heuristic because pairing routes carry no subnet mask; it can omit a valid `.0` host in a larger private subnet. Gateway filtering uses the actual mask. Polish network/mobile documentation is updated. Copy audit (docs/copy.md §8): no UI text or layout changes; existing English route/result labels are preserved. Fixes: #324 Related: #361
nixuuu
added a commit
that referenced
this pull request
Nov 10, 2026
Repeated failures against an unreachable paired gateway made the mobile sheet alternate between “Reconnecting…” and “Gateway unavailable”. Route probes erased their previous results, the sheet changed height, and the sidebar banner could unmount an open sheet. Independent requests could also start another failed route race as soon as the preceding race finished. Availability and retry activity now use one shared domain state machine across mobile and web/desktop. After 3 failures or 12 seconds without success, “Gateway unavailable” stays until a successful stream snapshot/resynchronization. Retry activity appears in a reserved line. Retries use 1/2/4/8/16/30-second backoff with 80–100% jitter; network/foreground/manual reconnect reset the delay without clearing unavailable. - Mobile route rows retain their last result while checking, use fixed heights and a bounded scroll area. All requests share the failed route race’s cooldown; no sent RPC is replayed. - The mobile sheet remains mounted through retries, manual reconnect and recovery. The sidebar banner overlays the list. Web/desktop has a matching status popover, manual reconnect and an overlay banner below the header. - Documented states, transitions, route cooldown and lifecycle resets in `docs/mobile.md` and `docs/ui-api.md`. No native, dependency or protocol changes. ## Validation - Passed: `bun install`, `bun run gen:check`, `bun run typecheck`, root `bun run lint`, `bun run format:check`, and the production web build. - Focused domain/transport/route tests: 32 passed, 333 assertions, 0 failed. Coverage includes sticky unavailable, hanging opens, exponential backoff/cap/jitter, lifecycle/manual resets, late callbacks, linked-computer outages, diagnostics retention and independent-request cooldown. - Browser: stopped and restarted a disposable gateway; sampled title, open state, panel/button geometry and content positions every 200 ms. No unavailable-to-reconnecting bounce, sheet closure or content movement; automatic recovery succeeded. Checked light/dark and desktop/phone widths with short and long thread names. Measured retry intervals grew exponentially to the capped range; manual reconnect restarted immediately without clearing unavailable. - Both production fingerprints generated with `[email protected]` are unchanged: iOS `6ddec9ef559ee0095ac33e94ff9418a942053b17`, Android `5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. Limitations: native iOS/Android visual QA was unavailable. Full `check:tmp` was not run; this task’s verification scope permits focused tests. Additional Expo ESLint reports existing errors in unchanged files; changed mobile UI files have no ESLint errors (the keyed recovery memo has one dependency warning). Root oxlint and all requested checks above pass. Evidence is kept outside the repository. ## Copy audit — docs/copy.md §8 1. “No route in use” / “Checking routes…” → “Routes”; per-route replacement status → last result plus “Checking route” activity. These distinguish availability from an attempt without rewriting the heading. Added “Retrying in N s” / “Retrying…” in a reserved line; digits are localized, units spaced, sentence case retained. 2. Glossary unchanged. “Reconnect now”, “Copy details” and “Open Tailscale” name actions. The web popover explains the last known state and automatic reconnect; technical failures remain in Details. Tailscale guidance stays in the description while the availability title remains stable. 3. No new empty states, duplicated availability heading, optional-dependency warning or expressive sentence. Existing failure copy retains its automatic resolution/manual reconnect action. 4. Short, typical and long thread titles checked at desktop and phone widths in both themes; route hosts keep middle truncation and results have a fixed row. Native text sizing/layout remains unverified as noted above. 5. Availability and countdown have text labels; checking activity has an accessible label. Color is supplementary and spinners respect reduced motion. ## Regression attribution The merged diff for #361 explicitly introduced `down && stale === subscriptionKey && !routes.pending`, which returns the availability presentation to reconnecting whenever a new probe begins. This fixes that condition and the resulting presentation instability. #366’s Tailscale hint and fixed retry interval were checked as context; they did not introduce that condition. Fixes: #361 Related: #366
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cause and evidence
A gateway can be reachable while every phone route is rejected by the fixed 2 s TLS probe deadline. This reproduces hypothesis (a); it does not establish that a real phone's Tailscale radio/tunnel was the source of the delay.
The isolated Bun client fixture uses the actual pinned TLS listener, a TCP proxy delaying the first TLS reply by 3.5 s on every connection, one DNS failure and one blackholed route. Before the change, the request failed after 2.26 s despite the healthy listener. After the change, it connects in about 9.3 s, including a second probe and a separately delayed RPC connection. The gateway receives exactly one RPC. Ordinary dead-first-route selection still completes in about 0.5 s.
The combined error hid which address failed (hypotheses b/c). There is no evidence of excessive route counts, a per-device limit or a listener concurrency problem. Source review also found that Android's reset only evicted idle sockets; an active, half-open HTTP/2 connection could still be reused. Slow-pong integration coverage demonstrates why a short pong deadline can close an otherwise healthy session; it does not prove that this happened on the maintainer's phones.
The original 2 s probe is from #61, before #324 (
4f3f1c55, checked against #324's parent). #324 reworked the race, added liveness limits and introduced the pool reset being corrected here.Change
Diagnostics
Details now shows each route's kind, truncated host/port and result: DNS failed, timed out with elapsed milliseconds, TLS pin mismatch, connection refused or OK with latency. It marks the route in use, distinguishes request failures from probe results and offers Copy details with full hosts and timestamps. Diagnostics stay in memory and exclude tokens, fingerprints and payloads.
Desktop/server gateway logs record timestamped TLS/session starts, protocol, listener port, session ID, close reason/duration and liveness timeouts. They contain no peer addresses, certificates, credentials, headers or payloads.
pin_check=client_sideis deliberate: the gateway cannot attest that its client checked the server pin. The phone's successful probe confirms that comparison.Verification
bun install,bun run gen:check, root/mobile typecheck, root lint/format check, web build and mobilebunx expo lint.bun run check:tmp: 1808 pass, 161 skip, 0 fail (1969 tests across 323 files, 942.46 s); temp check passed. Temp data stayed under the worktree;GIT_CEILING_DIRECTORIESprevented empty test directories from inheriting its enclosing repository. An initial run exposed that environment issue; the complete run passed with the boundary set.:canopy-pinned-fetch:compileDebugKotlinpassed on Linux with a private SDK/JDK, no daemon, 2 workers, in-process Kotlin and a 2 GB Gradle heap. CNG prebuild and Gradle clean passed; generated native output was removed. Swift's native parser passed on macOS over stdin, without producing files or launching an app. No EAS/store builds or publication.Unverified: iOS compilation and native device/visual QA (light/dark, phone/tablet and clipboard interaction). The reproducible measurement uses the authorized Bun client-library alternative, not a physical radio or the maintainer's running apps. Native changes require new builds; the existing fingerprint runtime policy prevents an OTA update from calling the new native API on old binaries.
Copy audit — docs/copy.md §8
Fixes: #61
Related: #324