@mastra/react 1.2.3-alpha.2 → 1.2.3-alpha.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @mastra/react
2
2
 
3
+ ## 1.2.3-alpha.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`4039488`](https://github.com/mastra-ai/mastra/commit/403948898af7293198d9e8b3e7fb47f623c78b94), [`b2c9d70`](https://github.com/mastra-ai/mastra/commit/b2c9d70757207fb01a9069549e69b6f0d73a6636), [`252f63d`](https://github.com/mastra-ai/mastra/commit/252f63d8fec723955adb2202be2f01a75ad0e69c), [`c547a77`](https://github.com/mastra-ai/mastra/commit/c547a7729bdf64dfc2df29c965046c0712a18f10), [`81542c1`](https://github.com/mastra-ai/mastra/commit/81542c1835c35bc32f2ce4fa9136ee11993cd299), [`cb24ce7`](https://github.com/mastra-ai/mastra/commit/cb24ce76bd16ca88eb6a963f6277f8780e703029), [`5f9858f`](https://github.com/mastra-ai/mastra/commit/5f9858f791f1137ca7d52d23559fb4568f7a9026)]:
8
+ - @mastra/core@1.50.0-alpha.4
9
+ - @mastra/client-js@1.31.0-alpha.4
10
+
11
+ ## 1.2.3-alpha.3
12
+
13
+ ### Patch Changes
14
+
15
+ - Fixed Studio agent chat hanging on the first message when thread signals are enabled. When the thread subscription was aborted during mount, `useChat` cached the failed attempt and never retried it, so the assistant reply never arrived until a full page reload. The subscription is now retried on the next send. Also, when a send fails for any reason (subscription setup, request, or stream), `useChat` now resets its running state instead of leaving the chat spinner stuck until reload. ([#18903](https://github.com/mastra-ai/mastra/pull/18903))
16
+
17
+ - Updated dependencies [[`b291760`](https://github.com/mastra-ai/mastra/commit/b291760df9d6c7e4fc72606c8f0a4af2cf6e946c), [`29b7ea6`](https://github.com/mastra-ai/mastra/commit/29b7ea64e72b5523d5bdcbd34ee03d2b854d54e1), [`10959d5`](https://github.com/mastra-ai/mastra/commit/10959d509d824f682d40ff96e05ee044aec3b0e5), [`ffc3c17`](https://github.com/mastra-ai/mastra/commit/ffc3c17274ea17c11aa6f73d3140649cd7fc8abc), [`3908e53`](https://github.com/mastra-ai/mastra/commit/3908e53ce04bbea04f5e0c097d7aa298c35fabee), [`3908e53`](https://github.com/mastra-ai/mastra/commit/3908e53ce04bbea04f5e0c097d7aa298c35fabee)]:
18
+ - @mastra/core@1.50.0-alpha.3
19
+ - @mastra/client-js@1.31.0-alpha.3
20
+
3
21
  ## 1.2.3-alpha.2
4
22
 
5
23
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/agent/hooks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAY,eAAe,EAA4B,MAAM,iCAAiC,CAAC;AAE3G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,KAAK,EAAE,SAAS,EAAiB,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAkBtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAmI/D,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,eAAe,EAAE,CAAC;IACpC,6FAA6F;IAC7F,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;;;OAIG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,YAAY,CAAC,EAAE,CAAC,Q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,CAAC;IAC1D,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IACpC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IACrC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D,CAAC;AAoDF,eAAO,MAAM,OAAO,GAAI,qMAWrB,eAAe;;qCA60ByC,eAAe;;;;;;;;;;kCAtN7B,MAAM,eAAe,OAAO;kCAkD5B,MAAM;0CAgDE,MAAM;0CA0BN,MAAM;;;;oBA5tBvB,UAAU,GAAG,UAAU;;;uCAsvBT,MAAM,UAAU,MAAM;uCAgCtB,MAAM,UAAU,MAAM;;;oBAnxBtC,UAAU,GAAG,UAAU;;;CAu3BxD,CAAC"}
package/dist/index.cjs CHANGED
@@ -2069,6 +2069,13 @@ var useChat = ({
2069
2069
  const subscriptionAbort = new AbortController();
2070
2070
  _threadSubscriptionAbortRef.current = subscriptionAbort;
2071
2071
  _threadSubscriptionKeyRef.current = subscriptionKey;
2072
+ const releaseSubscriptionRefs = () => {
2073
+ if (_threadSubscriptionAbortRef.current !== subscriptionAbort) return;
2074
+ _threadSubscriptionRef.current = null;
2075
+ _threadSubscriptionAbortRef.current = null;
2076
+ _threadSubscriptionKeyRef.current = void 0;
2077
+ _threadSubscriptionPromiseRef.current = null;
2078
+ };
2072
2079
  const clientWithAbort = new clientJs.MastraClient({
2073
2080
  ...baseClient.options,
2074
2081
  abortSignal: subscriptionAbort.signal
@@ -2092,21 +2099,12 @@ var useChat = ({
2092
2099
  if (_threadSubscriptionRef.current === subscription) {
2093
2100
  _threadSubscriptionRef.current = null;
2094
2101
  }
2095
- if (_threadSubscriptionAbortRef.current === subscriptionAbort) {
2096
- _threadSubscriptionAbortRef.current = null;
2097
- _threadSubscriptionKeyRef.current = void 0;
2098
- _threadSubscriptionPromiseRef.current = null;
2099
- }
2102
+ releaseSubscriptionRefs();
2100
2103
  });
2101
2104
  }).catch((error) => {
2105
+ releaseSubscriptionRefs();
2102
2106
  if (isThreadSignalUnsupportedError(error)) {
2103
2107
  markThreadSignalsUnsupported();
2104
- if (_threadSubscriptionAbortRef.current === subscriptionAbort) {
2105
- _threadSubscriptionRef.current = null;
2106
- _threadSubscriptionAbortRef.current = null;
2107
- _threadSubscriptionKeyRef.current = void 0;
2108
- _threadSubscriptionPromiseRef.current = null;
2109
- }
2110
2108
  return;
2111
2109
  }
2112
2110
  if (!isAbortError(error)) {
@@ -2643,12 +2641,17 @@ var useChat = ({
2643
2641
  } else {
2644
2642
  setMessages((s) => [...s, dbUserMessage]);
2645
2643
  }
2646
- if (mode === "generate") {
2647
- await generate({ ...args, coreUserMessages });
2648
- } else if (mode === "stream") {
2649
- await stream({ ...args, coreUserMessages, signalId, clientMessageId });
2650
- } else if (mode === "network") {
2651
- await network({ ...args, coreUserMessages });
2644
+ try {
2645
+ if (mode === "generate") {
2646
+ await generate({ ...args, coreUserMessages });
2647
+ } else if (mode === "stream") {
2648
+ await stream({ ...args, coreUserMessages, signalId, clientMessageId });
2649
+ } else if (mode === "network") {
2650
+ await network({ ...args, coreUserMessages });
2651
+ }
2652
+ } catch (error) {
2653
+ setIsRunning(false);
2654
+ throw error;
2652
2655
  }
2653
2656
  };
2654
2657
  return {