@q9labsai/chalk-react 5.2.4 → 5.2.6

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.
@@ -36,7 +36,7 @@ import {
36
36
  useRecording,
37
37
  useSpaceClient,
38
38
  useWhiteboard
39
- } from "./chunk-34SIWIY5.js";
39
+ } from "./chunk-JK4JXOGC.js";
40
40
  import {
41
41
  WHITEBOARD_ITEM_ID,
42
42
  screenShareItemId
@@ -262,15 +262,21 @@ function SpaceExperience(props) {
262
262
  const previousStatus = useRef(connection.status);
263
263
  const hasObservedStatus = useRef(false);
264
264
  const autoJoinAttempted = useRef(false);
265
- const previousClient = useRef(client);
265
+ const [previousClient, setPreviousClient] = useState2(client);
266
266
  const [joinError, setJoinError] = useState2(null);
267
267
  const [retryPending, setRetryPending] = useState2(false);
268
- const [episodeEnded, setEpisodeEnded] = useState2(connection.episodeEnded);
268
+ const [episodeEnded, setEpisodeEnded] = useState2(false);
269
269
  const [handledTerminal, setHandledTerminal] = useState2(void 0);
270
- useEffect2(() => setHandledTerminal(void 0), [props.terminalState]);
270
+ const [previousTerminal, setPreviousTerminal] = useState2(props.terminalState);
271
+ if (previousTerminal !== props.terminalState) {
272
+ setPreviousTerminal(props.terminalState);
273
+ setHandledTerminal(void 0);
274
+ }
271
275
  const spaceName = props.spaceName ?? props.space ?? "Space";
272
- if (previousClient.current !== client) {
273
- previousClient.current = client;
276
+ if (previousClient !== client) {
277
+ setPreviousClient(client);
278
+ setJoinError(null);
279
+ setEpisodeEnded(false);
274
280
  previousStatus.current = connection.status;
275
281
  hasObservedStatus.current = false;
276
282
  autoJoinAttempted.current = false;
@@ -293,10 +299,6 @@ function SpaceExperience(props) {
293
299
  setRetryPending(true);
294
300
  void join(defaultJoinOptions(props)).finally(() => setRetryPending(false));
295
301
  }, [join, props]);
296
- useEffect2(() => setJoinError(null), [client]);
297
- useEffect2(() => {
298
- setEpisodeEnded(false);
299
- }, [client]);
300
302
  useEffect2(
301
303
  () => client.on("episodeEnded", () => {
302
304
  setEpisodeEnded(true);
@@ -326,7 +328,21 @@ function SpaceExperience(props) {
326
328
  if (connection.status === "failed" && connection.lastError?.code === "episode.ended")
327
329
  return /* @__PURE__ */ jsx(StatusSurface, { phase: "episode-ended", callName, episodeEndReason: connection.episodeEndReason, endAction: props.timeLimit?.endAction, theme: statusTheme, onHome: props.onHome, onReportProblem: props.onOpenReport });
328
330
  if (connection.status === "failed") {
329
- return /* @__PURE__ */ jsx(StatusSurface, { phase: "failed", callName, errorCode: connection.lastError?.code, sync: connection.lastError?.sync, theme: statusTheme, onHome: props.onHome, onReportProblem: props.onOpenReport, onRetry: retryAutomaticJoin, retryPending });
331
+ return /* @__PURE__ */ jsx(
332
+ StatusSurface,
333
+ {
334
+ phase: "failed",
335
+ callName,
336
+ errorCode: connection.lastError?.code,
337
+ reason: connection.lastError?.code === "access.invalid" ? connection.lastError.message : void 0,
338
+ sync: connection.lastError?.sync,
339
+ theme: statusTheme,
340
+ onHome: props.onHome,
341
+ onReportProblem: props.onOpenReport,
342
+ onRetry: retryAutomaticJoin,
343
+ retryPending
344
+ }
345
+ );
330
346
  }
331
347
  if (connection.status === "leaving" || connection.status === "left")
332
348
  return /* @__PURE__ */ jsx(