Skip to content

Keep a view-through-host guest in the room when it reconnects - #45

Merged
EgeSeker merged 1 commit into
mainfrom
fix/guest-reconnect-signin
Nov 24, 2026
Merged

EgeSeker merged 1 commit into
mainfrom
fix/guest-reconnect-signin

Conversation

@EgeSeker

Copy link
Copy Markdown
Collaborator

A view-through-host guest whose connection dropped could leave the room on reconnecting instead of coming back. It showed the start screen and "Can't reach the room server. Check your network and try again in a minute." This was seen once on main, in CI run 45433928289 (e2e/room.spec.ts:516, Web job). It is already in 0.1.3.

Cause

  • While offline, a guest asks the host what to show every 400 ms (guestEnter in src/session.ts).
  • RoomClient.open was true as soon as a new socket opened, before hello and the handshake. So that request could be the first message on the new connection.
  • The relay takes the first message after hello as the handshake. first_text gets a binary frame there, and the relay closes with 4400 bad handshake.
  • afterClose treats 4400 as final, and closeMessage falls back to the "Can't reach the room server" text.
  • Under Playwright's routeWebSocket, hello reaches the page through a Node round trip, which widens the window. That is why it failed only now and then.

Fix

  • RoomClient keeps a signedIn flag for the socket that is open now. It is set on welcome and cleared on connect, close, misfit and close(). open requires it, so send, request and sendFrame hold off until then. The handshake still goes out on hello.
  • A member already welcomed who is closed with 4400 handshake timed out now reconnects, because that is a slow network. Any other 4400, and every code that ends a membership, keeps its behaviour and its message.
  • The relay is unchanged.
  • Docs: ROOMS-PROTOCOL.md §3 (send nothing before welcome, on every reconnect) and the §11 row for 4400, a DECISIONS.md row, and a CHANGELOG entry under Unreleased.

Tests, written first and seen to fail

  • e2e/helpers.ts: cuttable(page).restore(ms) brings the network back slow. On new connections, what the room server says reaches the page ms late.
  • e2e/room.spec.ts: new test "a view-through-host guest comes back over a slow connection instead of leaving the room". On the old code it failed like CI: guest-banner not found, with the start screen and the same toast.
  • src/collab/client.test.ts: a fake socket drives RoomClient. After a reconnect, nothing is sent and sendFrame returns false until the next welcome, and request waits for it too. afterClose retries 4400 handshake timed out for a welcomed member only.

Checks (Windows 11, Edge, local)

  • pnpm lint and pnpm typecheck: clean.
  • pnpm test: 1126 passed, 2 failed. The 2 failures are the timing checks in src/collab/hardening.test.ts, which fail the same way on unchanged main on this PC and pass when that file runs alone. They are unrelated to this change.
  • e2e, the old blanked-view test and the new one: 3 of 3 passes each.
  • Full e2e with the relay: 263 passed, 2 failed. The failures are the known Windows clipboard tests (operations.spec.ts:147, report.spec.ts:100).
  • cargo test --workspace: all passed, none ignored. No Rust changed.
  • macOS and Linux: not verified locally; CI covers them.
  • The watchdog gate was not run. GOAL.md and LOOP.md were not updated: this is a bug fix outside a loop iteration.

No UI or copy changed.

🤖 Generated with Claude Code

The guest asks the host for pictures every 400 ms while offline, and
RoomClient.open was true as soon as a new socket opened. A request could
reach the relay before the handshake, the relay closed with 4400 "bad
handshake", and the guest left the room with "Can't reach the room
server". Nothing is sent now until welcome arrives on the socket that is
open. A member closed with 4400 "handshake timed out" reconnects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@EgeSeker
EgeSeker merged commit 3331f49 into main Nov 24, 2026
18 checks passed
@EgeSeker
EgeSeker deleted the fix/guest-reconnect-signin branch November 24, 2026 22:19
@EgeSeker EgeSeker mentioned this pull request Nov 24, 2026
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