@unoverse-platform/studio 0.1.114 → 0.1.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unoverse-platform/studio",
3
- "version": "0.1.114",
3
+ "version": "0.1.115",
4
4
  "type": "module",
5
5
  "description": "Unoverse Studio: the local authoring app. Reads your own rx/ folder, no backend.",
6
6
  "scripts": {
@@ -12,6 +12,7 @@ import type { LaneSession } from "../manifests/runtime/duplex/audioLane.js";
12
12
 
13
13
  /** How long a call the workflow started waits for its page to join before nobody is there. */
14
14
  const JOIN_WAIT_MS = 15_000;
15
+ const ASK_EVERY_MS = 500;
15
16
 
16
17
  export interface AudioWebSocketManager {
17
18
  claim(conversationId: string, session: LaneSession): () => void;
@@ -77,6 +78,7 @@ class DistributedAudioManager implements AudioWebSocketManager {
77
78
  return new Promise<boolean>((resolve) => {
78
79
  const answer = (ok: boolean) => {
79
80
  clearTimeout(timer);
81
+ clearInterval(retry);
80
82
  const waiting = this.joining.get(conversationId);
81
83
  if (waiting?.answer !== answer) return;
82
84
  this.joining.delete(conversationId);
@@ -86,8 +88,19 @@ class DistributedAudioManager implements AudioWebSocketManager {
86
88
  };
87
89
  const timer = setTimeout(() => answer(false), JOIN_WAIT_MS);
88
90
  this.joining.set(conversationId, { held: [], answer });
89
- const asked = !!call?.userId && clientTransport().pushToClient(call.userId, conversationId, { type: "JOIN_CALL", workflowId: call.workflowId });
90
- console.log(`[DistributedAudioManager] ${conversationId}: ${asked ? "asked the page to join" : "no page stream to ask; waiting for its audio socket"}`);
91
+ // ASKED UNTIL THE PAGE CAN HEAR. The press that starts the workflow also opens the page's
92
+ // stream, and over a long way (a visitor far from the server) the voice node asks before
93
+ // that stream is registered. One ask would be lost, so it is repeated until one lands.
94
+ const ask = () => !!call?.userId && clientTransport().pushToClient(call.userId, conversationId, { type: "JOIN_CALL", workflowId: call.workflowId });
95
+ const asked = ask();
96
+ const retry = asked
97
+ ? undefined
98
+ : setInterval(() => {
99
+ if (!ask()) return;
100
+ clearInterval(retry);
101
+ console.log(`[DistributedAudioManager] ${conversationId}: the page's stream arrived; asked the page to join`);
102
+ }, ASK_EVERY_MS);
103
+ console.log(`[DistributedAudioManager] ${conversationId}: ${asked ? "asked the page to join" : "no page stream to ask yet; asking again until one arrives"}`);
91
104
  });
92
105
  }
93
106