Skip to content

fix(remote-connect): keep mobile controllers subscribed across presence changes - #3856

Merged
bobleer merged 2 commits into
openBitFun:mainfrom
bobleer:bob/keep-browser-stream-subscriptions
Nov 10, 2026
Merged

bobleer merged 2 commits into
openBitFun:mainfrom
bobleer:bob/keep-browser-stream-subscriptions

Conversation

@bobleer

@bobleer bobleer commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Mobile clients did not show a session created on the desktop until they were reloaded. The host now keeps stream-hint subscriptions for controllers that never take part in relay presence, so catalog and session hints keep reaching them.

Type and Areas

Type: bug fix

Areas: Rust core (remote connect host streams), mobile web / KMP / HarmonyOS (remote control), docs

Motivation / Impact

On every relay device-presence update, Desktop and CLI call HostStreamHub::retain_online and drop every stream-hint subscriber missing from the list. The relay only puts machine-scoped sockets in presence. All three mobile controllers (mobile web AccountRealtime.ts, KMP AccountRealtime.kt, HarmonyOS AccountRealtime.ets) connect user-scoped ("hidden controllers"), so they never appear. Any unrelated presence change silently ended their @host/catalog and session subscriptions, for example another device connecting or the phone reconnecting after the screen locks. After that, a session created on the desktop sent no host-stream-changed hint. The list stayed stale until the 4-minute renewal, a return to the foreground, or a reload. Live chat updates were exposed to the same gap.

retain_online now decides only for devices that presence has reported at least once. A device that was online and is now absent is dropped as before. Other subscribers fall back to the existing 10-minute read lease, which every mobile client renews every 4 minutes. No relay or controller change is needed, so existing relays and deployed clients pick up the fix once the host updates. Hosts without this change keep the old behavior.

The Peer Device Mode doc now records the lease length, the renewal, and when presence may end a lease early.

Verification

  • cargo test --locked -p openbitfun-services-integrations --no-default-features --features remote-connect --lib remote_connect::host_stream:: passes (21 tests), including the new presence_drops_only_devices_that_take_part_in_it. The test checks that a hidden subscriber survives presence updates, including an empty one, and still gets the catalog hint, and that a peer that was reported online and then went absent is dropped.
  • rustfmt --check on the changed file and pnpm run check:repo-hygiene pass.
  • Remote scenario: remote control (mobile driving Desktop/CLI). Covered by unit tests only. Not yet run end to end with a live Desktop, Relay and phone.

Reviewer Notes

  • A closed mobile tab now keeps its subscription until its lease expires (at most 10 minutes) instead of until the next presence change. During that window the host may encrypt and send a few coalesced hints that the relay rejects. Desktop logs those failures at debug. Streams are still byte-bounded and released after the existing grace period.
  • The known-participant set lives for the hub's lifetime and is bounded by the account's devices.
  • Peer controller fanout (retain_online_controllers) is unchanged. Peer controllers are machine-scoped, and mobile web never calls peer_control_attach.
  • AI-assisted change; lightly tested (unit tests only).

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

…nce changes

Mobile web did not show a session created on the desktop until the page
was reloaded. The host drops every stream-hint subscriber that is absent
from each relay presence update, but the relay only reports
machine-scoped sockets. Browser controllers connect user-scoped and never
appear, so any unrelated presence change (another device connecting, the
phone reconnecting after the screen locks) ended their catalog and
session subscriptions. Later catalog changes sent them no hint until the
4-minute renewal, a return to the tab, or a reload.

Presence now decides only for devices it has reported at least once: a
device that was online and is now absent is dropped as before. Other
subscribers are governed by the existing 10-minute read lease, which mobile
web renews every 4 minutes. No relay or controller change is required.
…e rule

Name the affected clients as hidden controllers (mobile web, KMP,
HarmonyOS), which all connect user-scoped, and record in the Peer Device
Mode host stream section how long a hint lease lasts, how controllers
renew it, and when presence may end it early.
@bobleer bobleer changed the title fix(remote-connect): keep browser controllers subscribed across presence changes fix(remote-connect): keep mobile controllers subscribed across presence changes Nov 10, 2026
@bobleer
bobleer merged commit d394f99 into openBitFun:main Nov 10, 2026
13 checks 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