Skip to content

fix(relay): keep an idle phone's live page open with server pings - #4622

Open
icedevera wants to merge 1 commit into
mainfrom
fix/relay-phone-keepalive
Open

icedevera wants to merge 1 commit into
mainfrom
fix/relay-phone-keepalive

Conversation

@icedevera

Copy link
Copy Markdown
Member

A phone's open page drops to Read-only after it sits idle for one idle period. The relay now pings phone owner sockets, as it already pings desktops, so an idle phone page stays live.

Cause

Every live connection has an idle timer (namedLiveRoutes.ts, setTimeout(stop, limits.idleTimeoutMs)). When the timer fires, stop() terminates the socket. On a phone owner socket, only frames restart that timer:

  • the relay's keepalive ping loop ran only if (desktop);
  • a phone's own ping restarts the timer only for connections through the share gateway.

A phone that sits on a page without editing for the idle period (60 s on the self-host profile) has its socket terminated. Its next keystroke then finds the connection closed, and the page shows Read-only with "dohc could not reach the server." A Gemini 4 Neon test on Drive hit this on the first Return after about 1–2 minutes without edits. With the idle limit set to 1 s, a relay test reproduced it: the socket closed after 1 s, even when the phone pinged every 200 ms.

Change

  • The owner branch records ownerPhone, replacing a local phone used by ticketed and the Show on phone guard.
  • The keepalive loop runs for desktops and phone owner sockets.
  • The desktop sign-in checks in the pong handler stay desktop-only. The host checks run for phones too, so a stale binding, account fence, ownership change or Show on phone turned off closes the socket on the next pong.
  • A phone that stops answering pings still closes after one idle period.
  • Share gateway routes, named and link, are unchanged.

There's no config, protocol or client change. Phones answer pings automatically: SocketRocket on iOS, OkHttp on Android. Each open phone page costs one 8-byte ping every half idle period.

Verification

  • namedLiveRoutes.test.ts gains one test. An idle phone owner socket stays open through 5 pings past the idle limit, and a phone that answers with wrong pongs closes within 2× the limit. It fails on main and passes with the fix.
  • sync-relay typecheck passes. namedLiveRoutes and ownerLiveTransport: 158 pass. liveAuthorityWrites, personalLiveRoutes, selfHostLiveProfile: 33 pass.
  • pnpm verify:pr results go in a comment.

Review

GPT Sol: ACCEPT 9/10.

  • Pong host checks are right for phones.
  • Relay revocation and Show on phone still close the socket at once.
  • A session deleted by another process is still closed by the existing session poll.
  • Reservation accounting holds.
  • Pong replies are automatic in both phone transports.

Deploying this to Drive needs Ice's OK.

🤖 Generated with Claude Code

A phone's owner socket restarted its idle timer only on frames, and the relay
pinged desktop sockets alone, so a page left open on a phone for one idle
period (60 s in the self-host profile) closed without a close frame. The
phone then showed Read-only with "dohc could not reach the server." on its
next edit.

The relay now runs its keepalive ping loop for phone owner sockets too. Each
answered ping restarts the idle timer, and a phone that stops answering still
closes after one idle period. Desktop session checks stay behind
trackedDesktop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T08:21:37.209918Z d50ccbe PR opened
🔒 Security Review ✅ Completed 2026-11-25T08:24:30.312270Z d50ccbe PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
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