Keep shared membership per client session and add helpers.ensureJoined - #1856
Merged
Merged
Conversation
joinServer/leaveServer take an optional sessionId; a member leaves only when its last live session does. ensureJoined lets host mutations join a trusted actor before helpers.runCommand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GvRbbu8yG1WYz7wQnZUpC8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An LLMville player reported "it says I can place, but it fails". Shared-world membership is stored per user, but clients join and leave per session. Closing a second tab, or a join that resolves after a remount (StrictMode, quick route changes), evicted the user while the open tab still showed "joined". Every host mutation then failed with "Not a member of this server".
joinServer/leaveServertake an optionalsessionId, andcreateTransportSessionId()generates one.sessionIds.helpers.ensureJoined(ctx, { gameId, userId, serverId? })runs the join path for an actor host code has already authorized. WithserverIdset and the user already a member, it returns without extra work.runCommanddocs now point to it.useServerSession, the Convex transport's pagehide leave, and the shell sync each pass one id per session.sessionId. A user is only removed when no other connection of theirs still holds the server.jgengine-multiplayerskill covers sessions andensureJoined.Bugfix notes
singleSession: false, can hit this.jgGameServers.Verification
bun test packages/convex packages/core/src/runtime packages/react packages/ws packages/shell: 1355 pass, 0 fail.ensureJoinedidempotence, the pagehide transport, and ws multi-connection.check-typesfor core, convex, react, ws and shell: pass.bun run gen: done;ship:preflight: ok.🤖 Generated with Claude Code
https://claude.ai/code/session_01GvRbbu8yG1WYz7wQnZUpC8
Generated by Claude Code