[PR #200] [MERGED] Play with friends (3/3): Join a friend with the code alone, in game and in the launcher; end-to-end harness #2400

Closed
opened 2026-11-02 15:55:42 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/200
Author: @ludovic111
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @ludovic111

Base: main ← Head: feat/friends-join


📝 Commits (10+)

  • 7784350 Play with friends: Invite friends in the pause menu
  • 21a70c8 LAN: a guest's entity id no longer takes the host's
  • 241dee2 Invite friends: count direct and relayed sessions in friends status
  • 872e77e Invite friends: who is here and notices read in the muted colour, the hint stays faint
  • 7a475a9 Invite friends works with no relay: the code, and what friends can expect
  • 5d29f31 Play with friends: Join a friend in game and in the launcher
  • c7f30d2 Relay: RELAY_BIND listens on one address (tailnet-only test relays)
  • 341aa98 test_friends: --hold for the guest role, report chunks once they arrive
  • a3913be Join a friend with the full code (no server) or a relay's short code
  • 9e6d248 test_friends: --xvfb and --offscreen for headless Linux machines

📊 Changes

23 files changed (+1369 additions, -44 deletions)

View changed files

📝 Cargo.lock (+1 -0)
📝 crates/horizon-client/Cargo.toml (+1 -0)
📝 crates/horizon-client/src/front.rs (+235 -3)
📝 crates/horizon-client/src/game.rs (+5 -0)
📝 crates/horizon-client/src/game/control.rs (+4 -0)
📝 crates/horizon-client/src/game/extras.rs (+1 -1)
➕ crates/horizon-client/src/game/friends.rs (+254 -0)
📝 crates/horizon-client/src/game/lan.rs (+1 -0)
📝 crates/horizon-client/src/game/remote.rs (+11 -6)
📝 crates/horizon-client/src/game/screens.rs (+11 -1)
📝 crates/horizon-client/src/lan/hub.rs (+3 -1)
📝 crates/horizon-client/src/multiplayer.rs (+79 -6)
📝 crates/horizon-client/src/net.rs (+71 -3)
📝 crates/horizon-client/src/ui_theme.rs (+24 -1)
📝 crates/horizon-friends/Cargo.toml (+2 -3)
📝 crates/horizon-friends/src/lib.rs (+5 -0)
📝 crates/horizon-relay/src/main.rs (+16 -10)
📝 launcher/Cargo.lock (+146 -5)
📝 launcher/Cargo.toml (+2 -0)
📝 launcher/src/backend.rs (+9 -0)

...and 3 more files

📄 Description

Stacked on #199 (on #192).

What

  • Game, guest side (net.rs): friend:CODE joins with either code: a full invite is dialled directly (every endpoint at once, no server), then through the relay it names if any; a short code goes through the relay the player set. Everything after is an ordinary offline-mode join (no protocol change). Errors in plain words on the Disconnected screen: typo, other Horizon version, short code without a relay, "Couldn't reach your friend's game. Ask them to read the note under their code: they may need UPnP on their router, a forwarded port, a relay or a VPN.", ended invite, wrong code, version mismatch, rate limits. Addresses shown/logged never include the code.
  • Join a friend (Horizon multiplayer page): Invite code (shows the end of long codes, says what is wrong with one) + Relay (optional) field, saved to horizon.txt (friendsRelay) and used for hosting too. Classic screens keep vanilla's buttons.
  • Launcher: "Join a friend" row on Play (client mode; field with typing and paste, Join) that starts the game straight into the join; horizon-launcher play --join CODE. Both code kinds validated. Uses the restyled launcher's index_row.
  • tools/test_friends.py (dev-only): --baseline (plain LAN), (a) the code alone, no relay process anywhere, (b) a relay run locally with the short code; --role host|guest for two machines; --xvfb --offscreen for headless Linux. Routers and STUN are never touched by tests (HORIZON_FRIENDS_UPNP=0, HORIZON_STUN_SERVERS=none).
  • Harness hooks: status.server.player_positions, Disconnected reason in the agent's screen.

How tested

Mac mini, after rebasing on main (#229):

host shares the world: a 76-symbol code, no relay; Friends on your network or VPN can join. For friends on the internet: turn on UPnP on your router, or forward TCP port 25580 to 192.168.1.133, …
plain LAN: chat, movement and blocks both ways
code alone: chat, movement and blocks both ways, no server involved
after stopping: "Couldn't reach your friend's game. …"
self-hosted relay, short code 2YSM-****: chat, movement and blocks both ways; relay carried 84622 bytes
after stopping: "This invite has ended: your friend stopped sharing or left the world."
Play with friends passed: the code alone and a self-hosted relay; chat, movement and blocks both ways

Two machines, code alone (no relay running anywhere): host = ThinkPad (headless: Xvfb + lavapipe, --offscreen), guest = Mac mini over the tailnet with only the 66-symbol code → joined, 10 chunks, chat/walk; host status direct: 1, verdict LocalOnly (no UPnP asked in tests) with the forward-port advice.

Workspace clippy -D warnings + launcher clippy (gpui/runtime_shaders), fmt, 522 client lib tests, 41 friends/relay tests (macOS + Linux).

Not tested: real routers (UPnP/NAT-PMP/PCP are covered by mock responders) and real internet NATs; the launcher row on screen (compiled, clippy-clean).

Needs Ludovic

Nothing: no hosted service, no cost. feature: friends can join from the code as soon as #192–#200 merge.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/200 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/friends-join` --- ### 📝 Commits (10+) - [`7784350`](https://github.com/horizon-rust/horizon/commit/7784350bad422fff2741959e5e1698255d3d8251) Play with friends: Invite friends in the pause menu - [`21a70c8`](https://github.com/horizon-rust/horizon/commit/21a70c8e97b606bf791a6e79b244b23e37d3883f) LAN: a guest's entity id no longer takes the host's - [`241dee2`](https://github.com/horizon-rust/horizon/commit/241dee2649b601ebb43326345cd0ea85b845f55a) Invite friends: count direct and relayed sessions in friends status - [`872e77e`](https://github.com/horizon-rust/horizon/commit/872e77e19bdf6af8c58a3b1c269ba0e8344fc206) Invite friends: who is here and notices read in the muted colour, the hint stays faint - [`7a475a9`](https://github.com/horizon-rust/horizon/commit/7a475a948cd934373cdfc4326155efac2b69dba8) Invite friends works with no relay: the code, and what friends can expect - [`5d29f31`](https://github.com/horizon-rust/horizon/commit/5d29f316638e66bb77b62ea82164611fe381e94d) Play with friends: Join a friend in game and in the launcher - [`c7f30d2`](https://github.com/horizon-rust/horizon/commit/c7f30d2105394215cfb9b12630e8a6580d863b5f) Relay: RELAY_BIND listens on one address (tailnet-only test relays) - [`341aa98`](https://github.com/horizon-rust/horizon/commit/341aa98a968c7067e6e778683b67f71e4be30b76) test_friends: --hold for the guest role, report chunks once they arrive - [`a3913be`](https://github.com/horizon-rust/horizon/commit/a3913be6410bff7fa71ca8012d35e4c3c6103e13) Join a friend with the full code (no server) or a relay's short code - [`9e6d248`](https://github.com/horizon-rust/horizon/commit/9e6d248fbea88d87cb5f1db9f06a7bbff02daaad) test_friends: --xvfb and --offscreen for headless Linux machines ### 📊 Changes **23 files changed** (+1369 additions, -44 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1 -0) 📝 `crates/horizon-client/Cargo.toml` (+1 -0) 📝 `crates/horizon-client/src/front.rs` (+235 -3) 📝 `crates/horizon-client/src/game.rs` (+5 -0) 📝 `crates/horizon-client/src/game/control.rs` (+4 -0) 📝 `crates/horizon-client/src/game/extras.rs` (+1 -1) ➕ `crates/horizon-client/src/game/friends.rs` (+254 -0) 📝 `crates/horizon-client/src/game/lan.rs` (+1 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+11 -6) 📝 `crates/horizon-client/src/game/screens.rs` (+11 -1) 📝 `crates/horizon-client/src/lan/hub.rs` (+3 -1) 📝 `crates/horizon-client/src/multiplayer.rs` (+79 -6) 📝 `crates/horizon-client/src/net.rs` (+71 -3) 📝 `crates/horizon-client/src/ui_theme.rs` (+24 -1) 📝 `crates/horizon-friends/Cargo.toml` (+2 -3) 📝 `crates/horizon-friends/src/lib.rs` (+5 -0) 📝 `crates/horizon-relay/src/main.rs` (+16 -10) 📝 `launcher/Cargo.lock` (+146 -5) 📝 `launcher/Cargo.toml` (+2 -0) 📝 `launcher/src/backend.rs` (+9 -0) _...and 3 more files_ </details> ### 📄 Description Stacked on #199 (on #192). ## What - **Game, guest side** (`net.rs`): `friend:CODE` joins with either code: a **full invite** is dialled directly (every endpoint at once, no server), then through the relay it names if any; a **short code** goes through the relay the player set. Everything after is an ordinary offline-mode join (no protocol change). Errors in plain words on the Disconnected screen: typo, other Horizon version, short code without a relay, "Couldn't reach your friend's game. Ask them to read the note under their code: they may need UPnP on their router, a forwarded port, a relay or a VPN.", ended invite, wrong code, version mismatch, rate limits. Addresses shown/logged never include the code. - **Join a friend** (Horizon multiplayer page): Invite code (shows the end of long codes, says what is wrong with one) + **Relay (optional)** field, saved to horizon.txt (`friendsRelay`) and used for hosting too. Classic screens keep vanilla's buttons. - **Launcher**: "Join a friend" row on Play (client mode; field with typing and paste, Join) that starts the game straight into the join; `horizon-launcher play --join CODE`. Both code kinds validated. Uses the restyled launcher's `index_row`. - `tools/test_friends.py` (dev-only): `--baseline` (plain LAN), **(a) the code alone, no relay process anywhere**, **(b) a relay run locally** with the short code; `--role host|guest` for two machines; `--xvfb --offscreen` for headless Linux. Routers and STUN are never touched by tests (`HORIZON_FRIENDS_UPNP=0`, `HORIZON_STUN_SERVERS=none`). - Harness hooks: `status.server.player_positions`, Disconnected reason in the agent's `screen`. ## How tested Mac mini, after rebasing on main (#229): ``` host shares the world: a 76-symbol code, no relay; Friends on your network or VPN can join. For friends on the internet: turn on UPnP on your router, or forward TCP port 25580 to 192.168.1.133, … plain LAN: chat, movement and blocks both ways code alone: chat, movement and blocks both ways, no server involved after stopping: "Couldn't reach your friend's game. …" self-hosted relay, short code 2YSM-****: chat, movement and blocks both ways; relay carried 84622 bytes after stopping: "This invite has ended: your friend stopped sharing or left the world." Play with friends passed: the code alone and a self-hosted relay; chat, movement and blocks both ways ``` **Two machines, code alone** (no relay running anywhere): host = ThinkPad (headless: Xvfb + lavapipe, `--offscreen`), guest = Mac mini over the tailnet with only the 66-symbol code → joined, 10 chunks, chat/walk; host status `direct: 1`, verdict `LocalOnly` (no UPnP asked in tests) with the forward-port advice. Workspace clippy `-D warnings` + launcher clippy (`gpui/runtime_shaders`), fmt, 522 client lib tests, 41 friends/relay tests (macOS + Linux). Not tested: real routers (UPnP/NAT-PMP/PCP are covered by mock responders) and real internet NATs; the launcher row on screen (compiled, clippy-clean). ## Needs Ludovic Nothing: no hosted service, no cost. `feature`: friends can join from the code as soon as #192–#200 merge. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:55:42 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2400
No description provided.