Skip to content

[Bug]: Mobile drops incoming links to new (uncached) threads when the environment is unreachable (e.g. Tailscale off) and does not open them after reconnecting #43661

Done

Description

@IlyaGulya

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/mobile

Steps to reproduce

  1. Pair the T3 Code mobile app (Android) with a remote T3 Code server over Tailscale (T3 Connect disabled).
  2. Turn Tailscale off on the phone (and optionally force-close T3 Code).
  3. On the remote server (or another client), create a new thread so the mobile app does not have it in its local cache yet.
  4. From another app (e.g. Telegram), tap the link to that new thread: https://app.t3.codes/threads/<environmentId>/<threadId>.
  5. Switch to Tailscale, turn VPN on, and return to T3 Code.

(Note: repeating the same steps for an already-cached thread works as expected — the cached thread opens immediately while showing a connecting state. The failure only happens for a new/uncached thread.)

Expected behavior

T3 Code should keep the target (environmentId, threadId) route alive while waiting for the environment to become reachable, instead of replacing it with an empty draft:

  • While connecting, show a clear loading/connecting state for that environment (e.g. "Opening thread on <environment>…" with a Cancel action).
  • If the environment is unreachable / offline / error (e.g. Tailscale is off), explain that the app cannot reach that environment yet — rather than discarding the route or showing a generic "not available in the current mobile snapshot" message — and provide Retry + a shortcut to Connections (similar to web PR fix(web): a thread link to an unconnected environment shows why instead of a blank pane #42048).
  • When the user turns Tailscale on and returns to T3 Code (AppState → active) or the environment transitions to connected, automatically retry and open the linked thread without requiring the user to go back and tap the link again.
  • Only show "Thread unavailable" if the environment is connected and the server confirms the thread does not exist or was deleted.

Actual behavior

For an uncached thread (selectedThread === null), once the local cache finishes reading (localCacheRead === true) while the environment is available, offline, or error:

  • threadRouteIsHydrating (apps/mobile/src/features/threads/thread-route-hydration.ts) returns false.
  • threadRouteOpensDraft returns true for any connection state other than connecting / reconnecting.
  • ThreadRouteScreen immediately mounts UnavailableThreadDraftRedirect, which dispatches StackActions.replace("Thread", { draft }).

The target (environmentId, threadId) is permanently dropped from the navigation stack. Turning Tailscale on afterwards and returning to T3 Code leaves the user on a new-thread draft and never opens the linked thread.

Related PRs:

Impact

Major degradation or frequent failure

Version or commit

T3 Code Mobile 2.3.0, T3 Code server 0.1.11, checked against main @ 28e9072095

Environment

Android 16, T3 Code Mobile 2.3.0, remote Linux server ([email protected]) accessed over Tailscale (T3 Connect disabled); App Link tapped from Telegram

Logs or stack traces

No crash or stack trace. Root cause observed in:
- apps/mobile/src/features/threads/thread-route-hydration.ts (`threadRouteIsHydrating`, `threadRouteOpensDraft`)
- apps/mobile/src/features/threads/ThreadRouteScreen.tsx (`UnavailableThreadDraftRedirect`, `ThreadUnavailableScreen`)

Workaround

Turn Tailscale on first, open T3 Code until the environment connects and syncs, then switch back to Telegram and tap the link a second time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions