Skip to content

Ateam Go: recover faster from a dropped connection, and stop losing the prompt - #565

Merged
pallaoro merged 1 commit into
mainfrom
sometimes-it-is-not-possible-to
Nov 12, 2026
Merged

pallaoro merged 1 commit into
mainfrom
sometimes-it-is-not-possible-to

Conversation

@pallaoro

Copy link
Copy Markdown
Member

Why

After the phone wakes or changes network (Wi-Fi to 5G and back), its tunnel to a box takes from tens of seconds to a few minutes to settle. The box's Tailscale log showed that on every report: the phone asking for a direct path through the relay every 3 to 6 seconds, with the engine up the whole time. The app can't shorten that, but it made the outage longer and harder to read:

  • A box that timed out was retried at 5 s, 15 s, 30 s, 1 min, then every 2 min, so it stayed offline long after it could be reached. Reopening the app looked like the fix because that resets the pace.
  • A task screen sat on "resolving session…" behind a green dot.
  • A task sent into a dead socket failed with "RPC connection closed", shown in the same bar as "Started …" with the same Open button, and the prompt was gone.
  • The status dot was green if any box was up, even with the Run on box offline.

What changes

  • Retry pace (src/links.ts): a box that should be up is tried at least every 15 s (AWAY_RETRY_CAP_MS). A box that sleeps keeps the steady pace, and still only a tap wakes it.
  • Dead sockets (src/connection.ts): a call unanswered for 5 s has the socket probed there and then, not at the next keepalive. A socket judged dead is declared gone at once: closing a half-open socket starts a handshake nothing completes, so its close event can come much later or never, and the calls in flight kept waiting. A call made after that rejects.
  • Starting a task (App.tsx, src/Composer.tsx): the box is asked first (links.verify) and reached again if it doesn't answer. A task that couldn't start says why in the composer, in red, with the prompt and attachments back in the field. The "Started" bar no longer carries failures.
  • Status (src/boxes.ts fleetHealth): the dot is green only while every box that should be up is, amber while one is offline behind another that is up. Sleeping boxes don't count against green. Run on says "offline" or "asleep" next to the box, and its picker no longer calls every unreachable box "(asleep)".

Checked

  • bun test src in apps/mobile: 148 pass, including new tests for the retry pace (both kinds of box), verify, fleetHealth, and a half-open socket whose close never completes.
  • tsc --noEmit -p apps/mobile and biome check on the changed files: clean.

Not checked

  • Not run on a device. It needs an Ateam Go Dev build on an iPhone, with a network switch mid-session, to confirm the recovery and the composer's error state.

Known edge

If a task is created but its agent fails to launch, the message says so and the prompt comes back. Sending again then starts a second task.

…he prompt

A phone's tunnel takes from tens of seconds to minutes to settle after it
wakes or changes network. The app made that outage longer and harder to read.

- A box that should be up is retried at least every 15 s. Only a box that
  sleeps keeps the 5 s to 2 min pace, since no retry wakes it.
- A call unanswered for 5 s has the socket probed there and then, and a dead
  socket is declared gone at once: its own close event can come long after, or
  never, which left calls waiting behind a box still shown as connected.
- Starting a task asks the box first, and reaches it again if it doesn't
  answer. A task that couldn't start says why in the composer, with the prompt
  and files back in the field, rather than in the "Started" bar with Open.
- The status dot is amber while one box is offline behind another that is up,
  and Run on says offline or asleep for the box it names.
@pallaoro
pallaoro merged commit 13f9746 into main Nov 12, 2026
1 check passed
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.

1 participant