Repository navigation
fix(livekit): stop a late ingress_ended restarting the wrong scene, and close the room when the last player leaves - #57
Merged
Conversation
…nd close the room when the last player leaves Soundtrack race: ensure() deleted the old scene's ingress and then spent a few hundred ms creating the new one, and only set the wanted scene at the end. The ingress_ended webhook for the deleted ingress could arrive in that window, see the old scene as still wanted, and restart it, which deleted the new scene's ingress seconds after it started. ensure(), stop() and onEnded() now run one at a time per room, so a late webhook is judged against the scene the story is in. Room never finished: the story agent stays in the room after a player leaves (closeOnDisconnect is false) and the app keeps the soundtrack playing, so the room was never empty and LiveKit never sent room_finished. When the last human leaves, and nobody comes back within 10 s, the agent marks the story ended, asks the app to delete the soundtrack ingress, and leaves 10 s later (so a bot player sees the ended state and leaves too). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Two bugs found while recording the voice-adventure demo on 24 Nov:
ensure()deleted the old scene's ingress and only recorded the new scene once the new ingress existed. Theingress_endedwebhook for the deleted ingress could arrive in between, see the old scene as still wanted, and restart it, which deleted the new scene's ingress 2 seconds after it started.ensure(),stop()andonEnded()now run one at a time per room.closeOnDisconnect: false) and the app keeps the soundtrack playing, so LiveKit never sentroom_finished. When the last human leaves and nobody rejoins within 10 seconds, the agent marks the story ended, asks the app to stop the soundtrack, and leaves 10 seconds later.Tests: app
npm test66 pass and agentnpm test60 pass, both typecheck clean, with new tests for both fixes. Live check:room_finishedarrived 51 seconds after the last player left, with no manual room close, and a tavern to forest scene change produced no wrong-scene restart.🤖 Generated with Claude Code