Close private lobby when host leaves 🚪#3503
Conversation
WalkthroughThis pull request adds a new kick reason for when the lobby host disconnects before the game starts. It includes server-side detection of host disconnection, client-side error handling with user alerts, and localization support for the kick message. Changes
Sequence DiagramsequenceDiagram
participant Host as Host Client
participant Server as GameServer
participant OtherPlayers as Other Players
Host->>Server: Disconnects (close event)
activate Server
Server->>Server: Detect host disconnect<br/>(creatorPersistentID matches,<br/>!hasStarted, !isPublic)
Server->>Server: Set _hasEnded = true
Server->>OtherPlayers: kickClient(...,<br/>KICK_REASON_HOST_LEFT)
deactivate Server
OtherPlayers->>OtherPlayers: Receive error message<br/>kick_reason.host_left
OtherPlayers->>OtherPlayers: Show alert
OtherPlayers->>OtherPlayers: Dispatch<br/>leave-lobby event
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/server/GameServer.ts`:
- Around line 541-554: Host leaving before game start can set _hasEnded = true
while gameStartInfo is still unset, causing archive logic in end() to access
missing start data; update GameServer.end() to guard the archive/finish flow by
returning early (or skipping archive) if the game never actually started—e.g.,
check this._hasStarted and/or that this.gameStartInfo is defined before running
any code that uses start data, and ensure _hasEnded stays true but archive is
not invoked when those conditions fail.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cfbbae2a-ca58-471b-add5-74fe14fc6de7
📒 Files selected for processing (3)
resources/lang/en.jsonsrc/client/ClientGameRunner.tssrc/server/GameServer.ts
Description:
When the host of a private lobby disconnects before the game starts, the lobby is now closed:
creatorPersistentIDmatch, kicks all remaining clients with ahost_leftreason, and marks the game as ended so it's cleaned up by the game manager and can no longer be joined.alert()saying "The host has left the lobby." and their JoinLobbyModal is closed automatically via theleave-lobbyevent.phase()now returnsFinishedfor ended private lobbies that haven't started, preventing the game from lingering inLobbystate.Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
FloPinguin