Add scoped NPC voice session lane#270
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 14f16c9c0d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
| var voiceTarget = resolveVoiceSessionTarget(ctx, nk, userId, request); | ||
| var ttlSeconds = voiceSessionTtlSeconds(ctx, request); | ||
| var expiresAtMs = new Date().getTime() + ttlSeconds * 1000; | ||
| var sessionDescriptor = buildVoiceSessionDescriptor(nk, voiceTarget, request, ttlSeconds, expiresAtMs); | ||
| var disabledResponse = voiceSessionDisabledResponse(ctx, voiceTarget, sessionDescriptor); |
There was a problem hiding this comment.
Gate voice-session RPC before any profile writes
rpcVoiceSessionRequest resolves the actor target before checking whether voice sessions are disabled, and resolveVoiceSessionTarget calls getOrCreateWorldNpcProfileState for NPC targets. That helper performs storage writes on first access, so even with DOS_AI_VOICE_SESSIONS_ENABLED=false this supposedly presentation-only RPC mutates persistent actor state and can create per-user NPC records unexpectedly. This is reproducible by calling secondspawn_voice_session_request for a permanent NPC on a fresh account.
Useful? React with 👍 / 👎.
| yield return _gateway.GetVoiceSession(response => | ||
| yield return _gateway.GetVoiceSession(new VoiceSessionRequestDto | ||
| { | ||
| actor_id = _npcId, |
There was a problem hiding this comment.
Fallback invalid NPC id before requesting voice session
The voice-session request now sends actor_id = _npcId directly, but existing serialized scene data still uses legacy values like prototype-guide (for example Unity/Assets/_SecondSpawn/Scenes/ZoneTest_Hub.unity). The new Nakama RPC rejects non-permanent NPC ids, so enabling prototype hotkeys in that scene and pressing the voice key now fails with an RPC error instead of returning the structured fallback response.
Useful? React with 👍 / 👎.
| userId; | ||
| return { | ||
| owner_id: userId, | ||
| actor_id: trimString(player.player_id) || userId, |
There was a problem hiding this comment.
Return reusable actor_id for current-body voice responses
When actor_id is omitted, the RPC returns actor_id as the player id, but later validates provided actor_id values as permanent NPC ids only. This makes the response self-inconsistent: if a client reuses the returned actor_id on the next secondspawn_voice_session_request, the call is rejected with voice session actor must be a permanent NPC or omitted for the current body. Returning the current body source actor id (or omitting actor_id) avoids this contract break.
Useful? React with 👍 / 👎.
Summary
secondspawn_voice_session_requestas the scoped Nakama boundary for future NPC voice playback material.Safety and Authority
Verification
npm.cmd run buildinbackend/nakama- passed.npm.cmd testinbackend/nakama- passed.git diff --check- passed.6000.5.0b9- blocked by existing Package Manager error:The "path" argument must be of type string. Received undefined. No packages loaded.Log:Unity/Logs/npc-voice-session-batchmode.log.Refs #262