mindcache 3.8.0 → 3.8.1

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/dist/index.js CHANGED
@@ -3656,6 +3656,7 @@ function useClientChat(options = {}) {
3656
3656
  setStatus("loading");
3657
3657
  setError(null);
3658
3658
  setStreamingContent("");
3659
+ let accumulatedText = "";
3659
3660
  try {
3660
3661
  const model = context.getModel();
3661
3662
  const finalSystemPrompt = systemPrompt || mc.get_system_prompt();
@@ -3666,7 +3667,6 @@ function useClientChat(options = {}) {
3666
3667
  }));
3667
3668
  setStatus("streaming");
3668
3669
  const parts = [];
3669
- let accumulatedText = "";
3670
3670
  const result = await ai.streamText({
3671
3671
  model,
3672
3672
  system: finalSystemPrompt,
@@ -3699,22 +3699,20 @@ function useClientChat(options = {}) {
3699
3699
  }
3700
3700
  }
3701
3701
  }
3702
- if (step.text) {
3703
- accumulatedText += step.text;
3704
- }
3705
3702
  }
3706
3703
  });
3707
3704
  for await (const chunk of result.textStream) {
3708
3705
  accumulatedText += chunk;
3709
3706
  setStreamingContent(accumulatedText);
3710
3707
  }
3711
- if (accumulatedText) {
3712
- parts.unshift({ type: "text", text: accumulatedText });
3708
+ const finalText = await result.text;
3709
+ if (finalText) {
3710
+ parts.unshift({ type: "text", text: finalText });
3713
3711
  }
3714
3712
  const assistantMessage = {
3715
3713
  id: generateId(),
3716
3714
  role: "assistant",
3717
- content: accumulatedText,
3715
+ content: finalText,
3718
3716
  parts: parts.length > 0 ? parts : void 0,
3719
3717
  createdAt: /* @__PURE__ */ new Date()
3720
3718
  };
@@ -3723,12 +3721,14 @@ function useClientChat(options = {}) {
3723
3721
  setStatus("idle");
3724
3722
  onFinish?.(assistantMessage);
3725
3723
  } catch (err) {
3726
- if (err.name === "AbortError") {
3727
- if (streamingContent) {
3724
+ const errorMessage = err instanceof Error ? err.message : String(err);
3725
+ const isAborted = err.name === "AbortError" || errorMessage.includes("aborted") || errorMessage.includes("No output generated");
3726
+ if (isAborted) {
3727
+ if (accumulatedText) {
3728
3728
  const partialMessage = {
3729
3729
  id: generateId(),
3730
3730
  role: "assistant",
3731
- content: streamingContent + " [stopped]",
3731
+ content: accumulatedText + " [stopped]",
3732
3732
  createdAt: /* @__PURE__ */ new Date()
3733
3733
  };
3734
3734
  setMessages((prev) => [...prev, partialMessage]);