ai 6.0.89 → 6.0.90

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,11 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.90
4
+
5
+ ### Patch Changes
6
+
7
+ - 98e83ab: Fix `useChat` status briefly flashing to `submitted` on page load when `resume: true` is set and there is no active stream to resume. The `reconnectToStream` check is now performed before setting status to `submitted`, so status stays `ready` when the server responds with 204 (no active stream).
8
+
3
9
  ## 6.0.89
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1211,7 +1211,7 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
1211
1211
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
1212
1212
 
1213
1213
  // src/version.ts
1214
- var VERSION = true ? "6.0.89" : "0.0.0-test";
1214
+ var VERSION = true ? "6.0.90" : "0.0.0-test";
1215
1215
 
1216
1216
  // src/util/download/download.ts
1217
1217
  var download = async ({
@@ -12719,6 +12719,27 @@ var AbstractChat = class {
12719
12719
  messageId
12720
12720
  }) {
12721
12721
  var _a21, _b, _c;
12722
+ let resumeStream;
12723
+ if (trigger === "resume-stream") {
12724
+ try {
12725
+ const reconnect = await this.transport.reconnectToStream({
12726
+ chatId: this.id,
12727
+ metadata,
12728
+ headers,
12729
+ body
12730
+ });
12731
+ if (reconnect == null) {
12732
+ return;
12733
+ }
12734
+ resumeStream = reconnect;
12735
+ } catch (err) {
12736
+ if (this.onError && err instanceof Error) {
12737
+ this.onError(err);
12738
+ }
12739
+ this.setStatus({ status: "error", error: err });
12740
+ return;
12741
+ }
12742
+ }
12722
12743
  this.setStatus({ status: "submitted", error: void 0 });
12723
12744
  const lastMessage = this.lastMessage;
12724
12745
  let isAbort = false;
@@ -12738,17 +12759,7 @@ var AbstractChat = class {
12738
12759
  this.activeResponse = activeResponse;
12739
12760
  let stream;
12740
12761
  if (trigger === "resume-stream") {
12741
- const reconnect = await this.transport.reconnectToStream({
12742
- chatId: this.id,
12743
- metadata,
12744
- headers,
12745
- body
12746
- });
12747
- if (reconnect == null) {
12748
- this.setStatus({ status: "ready" });
12749
- return;
12750
- }
12751
- stream = reconnect;
12762
+ stream = resumeStream;
12752
12763
  } else {
12753
12764
  stream = await this.transport.sendMessages({
12754
12765
  chatId: this.id,