Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

test(stage): wait for the caption to sync instead of racing the broadcast

nirholas7a053e6f3b36
diff --git a/tests/multiplayer-server-boot.test.js b/tests/multiplayer-server-boot.test.js
index e38e859cc..faa457a10 100644
--- a/tests/multiplayer-server-boot.test.js
+++ b/tests/multiplayer-server-boot.test.js
@@ -250,6 +250,16 @@ describe('multiplayer entry point', () => {
while (!utterances.length && Date.now() < deadline) await sleep(100);
expect(utterances.length, 'the opening beat reached a handler registered before state wiring').toBeGreaterThan(0);
expect(utterances[0].text).toBeTruthy();
+
+ // The line and the caption are two separate deliveries, and the room
+ // sends them in that order on purpose: the broadcast carries
+ // `afterNextPatch: false` so the audience hears the host without
+ // waiting on a patch tick. So the caption in synced state ALWAYS lands
+ // after the message, and asserting it the moment the message arrives is
+ // a race the test only ever won by scheduling luck. Wait for state to
+ // catch up. _performUtterance sets caption and phase together and never
+ // clears the caption, so this settles once and stays settled.
+ while (room.state.host.caption !== utterances[0].text && Date.now() < deadline) await sleep(50);
expect(room.state.host.caption).toBe(utterances[0].text);
expect(room.state.phase).toBe('live');
} finally {