@docyrus/ui-pro-ai-assistant 0.7.9 → 0.8.0

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
@@ -19584,8 +19584,26 @@ function ChatPanel({
19584
19584
  onManageMemories,
19585
19585
  appContext,
19586
19586
  onClearAppContext,
19587
- onForwardToAgent
19587
+ onForwardToAgent,
19588
+ chatError,
19589
+ onDismissChatError
19588
19590
  }) {
19591
+ const renderChatError = () => {
19592
+ if (!chatError) return null;
19593
+ return /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-start gap-2 self-stretch rounded-2xl border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-300", children: [
19594
+ /* @__PURE__ */ jsx("span", { className: "flex-1 whitespace-pre-wrap break-words", children: chatError }),
19595
+ /* @__PURE__ */ jsx(
19596
+ "button",
19597
+ {
19598
+ type: "button",
19599
+ "aria-label": "Dismiss error",
19600
+ onClick: onDismissChatError,
19601
+ className: "-mr-1 -mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full text-red-700/70 hover:bg-red-100 hover:text-red-700 dark:text-red-300/70 dark:hover:bg-red-900/40 dark:hover:text-red-200",
19602
+ children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
19603
+ }
19604
+ )
19605
+ ] });
19606
+ };
19589
19607
  const renderAppContextChip = () => {
19590
19608
  if (!appContext) return null;
19591
19609
  return /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center gap-2 self-start rounded-full border bg-muted/50 px-2 py-1 text-xs text-foreground", children: [
@@ -19659,6 +19677,7 @@ function ChatPanel({
19659
19677
  /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground [&_h4]:text-foreground [&_*]:my-0 [&_*+*]:mt-2", children: welcomeMessage ? /* @__PURE__ */ jsx(MessageResponse, { children: welcomeMessage }) : /* @__PURE__ */ jsx("p", { children: description || "Your AI-powered assistant for all your document needs." }) }),
19660
19678
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex flex-col", children: [
19661
19679
  renderAppContextChip(),
19680
+ renderChatError(),
19662
19681
  renderInputArea(true)
19663
19682
  ] })
19664
19683
  ] }) }),
@@ -19709,6 +19728,7 @@ function ChatPanel({
19709
19728
  ),
19710
19729
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col px-3 pb-3 pt-2", children: [
19711
19730
  renderAppContextChip(),
19731
+ renderChatError(),
19712
19732
  renderInputArea()
19713
19733
  ] })
19714
19734
  ] });
@@ -34567,6 +34587,8 @@ var AssistantView = ({ ref, ...props }) => {
34567
34587
  agentTools: commonProps2.agentTools,
34568
34588
  appContext: commonProps2.appContext,
34569
34589
  onClearAppContext: commonProps2.onClearAppContext,
34590
+ chatError: commonProps2.chatError,
34591
+ onDismissChatError: commonProps2.onDismissChatError,
34570
34592
  messagesClassName: "p-4"
34571
34593
  }
34572
34594
  );
@@ -34827,6 +34849,8 @@ var AssistantView = ({ ref, ...props }) => {
34827
34849
  agentTools: commonProps.agentTools,
34828
34850
  appContext: commonProps.appContext,
34829
34851
  onClearAppContext: commonProps.onClearAppContext,
34852
+ chatError: commonProps.chatError,
34853
+ onDismissChatError: commonProps.onDismissChatError,
34830
34854
  onManageMemories: onTabChange ? () => onTabChange(4) : void 0,
34831
34855
  compactToolbar: !isFullscreen
34832
34856
  }
@@ -36234,6 +36258,7 @@ var DocyAssistant = ({
36234
36258
  const { state: projectState, actions: projectActions } = useProjectState();
36235
36259
  const { state: worksState, actions: worksActions } = useWorksState();
36236
36260
  const [input, setInput] = useState(initialPrompt || "");
36261
+ const [chatError, setChatError] = useState(null);
36237
36262
  const [showWelcome, setShowWelcome] = useState(() => enableWelcomePage && tabs.length <= 1);
36238
36263
  const currentUserId = configUser.id;
36239
36264
  const [projectSearchQuery, setProjectSearchQuery] = useState("");
@@ -36356,6 +36381,8 @@ var DocyAssistant = ({
36356
36381
  },
36357
36382
  onError: (error) => {
36358
36383
  console.error("[AI] Chat error:", error);
36384
+ const errorText = error?.message || String(error) || "An unknown error occurred.";
36385
+ setChatError(errorText);
36359
36386
  },
36360
36387
  onToolCall: async ({ toolCall }) => {
36361
36388
  const name = toolCall?.toolName;
@@ -36713,6 +36740,7 @@ var DocyAssistant = ({
36713
36740
  isSendingRef.current = true;
36714
36741
  setInput("");
36715
36742
  setShowWelcome(false);
36743
+ setChatError(null);
36716
36744
  try {
36717
36745
  messageOptionsRef.current = options3;
36718
36746
  let currentThreadId = selectedSessionIdRef.current;
@@ -37021,6 +37049,8 @@ var DocyAssistant = ({
37021
37049
  agentTools: activeAgentMatchesDetails ? agentTools : [],
37022
37050
  appContext,
37023
37051
  onClearAppContext: clearAppContext,
37052
+ chatError,
37053
+ onDismissChatError: () => setChatError(null),
37024
37054
  initialModelId,
37025
37055
  initialFeatures,
37026
37056
  enableMicrophone,