@docyrus/ui-pro-ai-assistant 0.7.8 → 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/README.md CHANGED
@@ -36,13 +36,54 @@ npm install @docyrus/api-client @docyrus/ui-pro-shared react react-dom
36
36
  | `@docyrus/ui-pro-shared` | `>= 0.0.1` |
37
37
  | `react` | `^19` |
38
38
  | `react-dom` | `^19` |
39
+ | `tailwindcss` | `^4.0.0` |
39
40
  | `vite` | `>= 5.0.0` *(optional)* |
40
41
 
42
+ ## Setup
43
+
44
+ This package ships React component sources that use Tailwind v4 utility classes —
45
+ **it does not bundle a CSS utilities file**. Your app's Tailwind build generates the
46
+ utilities, which keeps the consumer in full control of theme tokens and avoids
47
+ class-name collisions.
48
+
49
+ ### 1. Import the component CSS once at app root
50
+
51
+ ```css
52
+ /* your app's globals.css */
53
+ @import "tailwindcss";
54
+ @import "@docyrus/ui-pro-ai-assistant/styles.css";
55
+ ```
56
+
57
+ This brings in component-specific custom CSS (container queries, has-selectors,
58
+ markdown styling) — roughly 100 lines.
59
+
60
+ ### 2. Tell Tailwind to scan the package sources
61
+
62
+ Tailwind needs to see the class strings used inside the package's compiled JS
63
+ (and inside its `@docyrus/ui-pro-shared` peer) to generate the utilities they
64
+ reference. Add these `@source` directives next to your other source patterns:
65
+
66
+ ```css
67
+ /* your app's globals.css */
68
+ @source "../path/to/node_modules/@docyrus/ui-pro-ai-assistant/dist/**/*.js";
69
+ @source "../path/to/node_modules/@docyrus/ui-pro-shared/src/**/*.{ts,tsx}";
70
+ ```
71
+
72
+ > The relative path depends on where your `globals.css` lives. In a Vite app the
73
+ > CSS file is usually under `src/styles/`, so the `@source` paths point up to the
74
+ > nearest `node_modules`. Tailwind resolves the path relative to the CSS file.
75
+
76
+ ### 3. Provide shadcn-style theme tokens
77
+
78
+ The package's utilities resolve `--color-background`, `--color-foreground`,
79
+ `--color-primary`, etc. against your app's tokens. If you follow the standard
80
+ shadcn convention (`--background`, `--foreground` on `:root`) plus a `@theme inline`
81
+ mapping (`--color-background: var(--background)`), you're already set. See the
82
+ [shadcn theming docs](https://ui.shadcn.com/docs/theming) for the full block.
83
+
41
84
  ## Quick start
42
85
 
43
86
  ```tsx
44
- import "@docyrus/ui-pro-ai-assistant/styles.css";
45
-
46
87
  import { useCallback, useMemo } from "react";
47
88
  import { useDocyrusAuth } from "@docyrus/signin";
48
89
  import { AssistantProvider, DocyAssistant } from "@docyrus/ui-pro-ai-assistant";
@@ -114,7 +155,7 @@ function ModalExample() {
114
155
  | Main | `@docyrus/ui-pro-ai-assistant` | Components, provider, hooks, and types |
115
156
  | Vite plugin | `@docyrus/ui-pro-ai-assistant/vite` | Dev-server middleware for Plate AI |
116
157
  | Web worker | `@docyrus/ui-pro-ai-assistant/worker` | Worker entry for AI command handlers |
117
- | Stylesheet | `@docyrus/ui-pro-ai-assistant/styles.css` | Required CSS — import once at app root |
158
+ | Stylesheet | `@docyrus/ui-pro-ai-assistant/styles.css` | Component-specific custom CSS — import once at app root. Tailwind utilities are generated by your app's Tailwind build (see [Setup](#setup)) |
118
159
 
119
160
  ### Exported symbols
120
161
 
@@ -527,7 +568,7 @@ VITE_DOCYRUS_EDITOR_AGENT_ID=your-editor-agent-id
527
568
 
528
569
  - React 19+
529
570
  - ESM only (`"type": "module"`)
530
- - Tailwind CSS v4 (the stylesheet uses Tailwind utilities)
571
+ - **Tailwind CSS v4** the package's components use Tailwind utility classes; your app's Tailwind build generates them via the `@source` directives shown in [Setup](#setup). The package itself ships no compiled utilities.
531
572
 
532
573
  ## License
533
574
 
package/dist/index.js CHANGED
@@ -2722,9 +2722,9 @@ var AgentTabs = ({
2722
2722
  ),
2723
2723
  onClick: () => onTabSelect(tab.id),
2724
2724
  children: [
2725
- avatar ? /* @__PURE__ */ jsxs(Avatar, { className: "w-5 h-5 shrink-0 after:border-0", children: [
2726
- /* @__PURE__ */ jsx(AvatarImage, { src: avatar, alt: name ?? "" }),
2727
- /* @__PURE__ */ jsx(AvatarFallback, { className: "text-[10px] bg-transparent" })
2725
+ name ? /* @__PURE__ */ jsxs(Avatar, { className: "w-5 h-5 shrink-0 after:border-0", children: [
2726
+ avatar && /* @__PURE__ */ jsx(AvatarImage, { src: avatar, alt: name }),
2727
+ /* @__PURE__ */ jsx(AvatarFallback, { children: /* @__PURE__ */ jsx(Brain, { className: "w-3 h-3 text-muted-foreground" }) })
2728
2728
  ] }) : /* @__PURE__ */ jsx("span", { className: "w-5 h-5 shrink-0" }),
2729
2729
  /* @__PURE__ */ jsx("span", { className: "truncate min-w-0", children: name ?? "" }),
2730
2730
  !tab.pinned ? /* @__PURE__ */ jsx(
@@ -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,