@docyrus/ui-pro-ai-assistant 0.6.1 → 0.6.3

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.
@@ -4,5 +4,5 @@ interface MermaidDiagramProps {
4
4
  mermaidNotation: string;
5
5
  state?: string;
6
6
  }
7
- export declare function MermaidDiagram({ title, description, mermaidNotation, state }: MermaidDiagramProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function MermaidDiagram({ title, description, mermaidNotation }: MermaidDiagramProps): import("react/jsx-runtime").JSX.Element;
8
8
  export {};
package/dist/index.js CHANGED
@@ -12410,10 +12410,16 @@ function MermaidRender({ content, className }) {
12410
12410
  setZoom(1);
12411
12411
  setPan({ x: 0, y: 0 });
12412
12412
  };
12413
- const onWheel = useCallback((e) => {
12414
- e.preventDefault();
12415
- const delta = e.deltaY > 0 ? -0.1 : 0.1;
12416
- setZoom((z) => Math.min(Math.max(z + delta, 0.2), 4));
12413
+ useEffect(() => {
12414
+ const el = containerRef.current;
12415
+ if (!el) return;
12416
+ const handleWheel = (e) => {
12417
+ e.preventDefault();
12418
+ const delta = e.deltaY > 0 ? -0.1 : 0.1;
12419
+ setZoom((z) => Math.min(Math.max(z + delta, 0.2), 4));
12420
+ };
12421
+ el.addEventListener("wheel", handleWheel, { passive: false });
12422
+ return () => el.removeEventListener("wheel", handleWheel);
12417
12423
  }, []);
12418
12424
  const onMouseDown = useCallback((e) => {
12419
12425
  isDragging.current = true;
@@ -12438,7 +12444,6 @@ function MermaidRender({ content, className }) {
12438
12444
  "bg-[radial-gradient(circle,_#94a3b8_1px,_transparent_1px)] bg-[size:22px_22px] bg-slate-50",
12439
12445
  className
12440
12446
  ),
12441
- onWheel,
12442
12447
  onMouseDown,
12443
12448
  onMouseMove,
12444
12449
  onMouseUp,
@@ -12465,11 +12470,10 @@ function MermaidRender({ content, className }) {
12465
12470
  function MermaidDiagram({
12466
12471
  title,
12467
12472
  description,
12468
- mermaidNotation,
12469
- state
12473
+ mermaidNotation
12470
12474
  }) {
12471
12475
  const [modalOpen, setModalOpen] = useState(false);
12472
- if (state !== "output-available") {
12476
+ if (!mermaidNotation) {
12473
12477
  return /* @__PURE__ */ jsx("div", { className: "w-full h-[400px] rounded-lg border bg-muted/30 animate-pulse" });
12474
12478
  }
12475
12479
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -32006,6 +32010,7 @@ var DocyAssistant = ({
32006
32010
  const authTokenRef = useRef("");
32007
32011
  const messageOptionsRef = useRef(null);
32008
32012
  const initialPromptSentRef = useRef(false);
32013
+ const isSendingRef = useRef(false);
32009
32014
  const clientToolMap = useMemo(() => buildClientToolMap(clientTools), [clientTools]);
32010
32015
  const clientToolDefs = useMemo(() => serializeClientTools(clientTools), [clientTools]);
32011
32016
  const clientToolMapRef = useRef(clientToolMap);
@@ -32282,75 +32287,82 @@ var DocyAssistant = ({
32282
32287
  };
32283
32288
  const handleSendMessage = async (e, options3, overrideText) => {
32284
32289
  e?.preventDefault();
32290
+ if (isSendingRef.current) return;
32291
+ if (status === "submitted" || status === "streaming") return;
32285
32292
  const messageText = (overrideText ?? input).trim();
32286
32293
  if (!messageText) return;
32294
+ isSendingRef.current = true;
32295
+ setInput("");
32287
32296
  setShowWelcome(false);
32288
- messageOptionsRef.current = options3;
32289
- let currentThreadId = selectedSessionIdRef.current;
32290
- if (!currentThreadId) {
32291
- const subject = messageText.substring(0, 100);
32292
- const newThread = await createThread(apiClient, {
32293
- subject,
32294
- body_text: messageText,
32295
- sender_name: userDisplayName,
32296
- deploymentId,
32297
- tenantAiAgentId: activeAgentId,
32298
- projectId: projectState.projectContext?.id
32299
- });
32300
- if (newThread) {
32301
- currentThreadId = newThread.id;
32302
- sessionActions.selectSessionId(currentThreadId);
32303
- selectedSessionIdRef.current = currentThreadId;
32304
- const session = {
32305
- id: newThread.id,
32306
- title: newThread.subject || subject,
32307
- messages: [],
32308
- createdAt: new Date(newThread.created_on || /* @__PURE__ */ new Date()),
32309
- updatedAt: new Date(newThread.last_modified_on || /* @__PURE__ */ new Date())
32310
- };
32311
- sessionActions.addSession(session);
32312
- fetchThreads();
32313
- if (projectState.projectContext?.id) {
32314
- fetchProjectThreads2(projectState.projectContext.id);
32297
+ try {
32298
+ messageOptionsRef.current = options3;
32299
+ let currentThreadId = selectedSessionIdRef.current;
32300
+ if (!currentThreadId) {
32301
+ const subject = messageText.substring(0, 100);
32302
+ const newThread = await createThread(apiClient, {
32303
+ subject,
32304
+ body_text: messageText,
32305
+ sender_name: userDisplayName,
32306
+ deploymentId,
32307
+ tenantAiAgentId: activeAgentId,
32308
+ projectId: projectState.projectContext?.id
32309
+ });
32310
+ if (newThread) {
32311
+ currentThreadId = newThread.id;
32312
+ sessionActions.selectSessionId(currentThreadId);
32313
+ selectedSessionIdRef.current = currentThreadId;
32314
+ const session = {
32315
+ id: newThread.id,
32316
+ title: newThread.subject || subject,
32317
+ messages: [],
32318
+ createdAt: new Date(newThread.created_on || /* @__PURE__ */ new Date()),
32319
+ updatedAt: new Date(newThread.last_modified_on || /* @__PURE__ */ new Date())
32320
+ };
32321
+ sessionActions.addSession(session);
32322
+ fetchThreads();
32323
+ if (projectState.projectContext?.id) {
32324
+ fetchProjectThreads2(projectState.projectContext.id);
32325
+ }
32326
+ } else {
32327
+ return;
32315
32328
  }
32316
- } else {
32317
- return;
32318
32329
  }
32319
- }
32320
- onMessageSend?.(messageText);
32321
- setInput("");
32322
- const rawFiles = options3?.files || [];
32323
- const filePaths = [];
32324
- if (rawFiles.length > 0 && currentThreadId) {
32325
- for (const rawFile of rawFiles) {
32326
- try {
32327
- const file = dataUrlToFile(rawFile.url, rawFile.filename);
32328
- const path = await uploadThreadFile(apiClient, currentThreadId, file);
32329
- if (path) {
32330
- filePaths.push(path);
32330
+ onMessageSend?.(messageText);
32331
+ const rawFiles = options3?.files || [];
32332
+ const filePaths = [];
32333
+ if (rawFiles.length > 0 && currentThreadId) {
32334
+ for (const rawFile of rawFiles) {
32335
+ try {
32336
+ const file = dataUrlToFile(rawFile.url, rawFile.filename);
32337
+ const path = await uploadThreadFile(apiClient, currentThreadId, file);
32338
+ if (path) {
32339
+ filePaths.push(path);
32340
+ }
32341
+ } catch (error) {
32342
+ console.error("[FILE_UPLOAD] Error:", error);
32331
32343
  }
32332
- } catch (error) {
32333
- console.error("[FILE_UPLOAD] Error:", error);
32334
32344
  }
32335
32345
  }
32346
+ messageOptionsRef.current = {
32347
+ ...options3,
32348
+ filePaths: filePaths.length > 0 ? filePaths : void 0
32349
+ };
32350
+ await sendMessage({
32351
+ text: messageText,
32352
+ metadata: {
32353
+ modelId: options3?.modelId,
32354
+ supportMultipleModels: options3?.supportMultipleModels,
32355
+ supportFiles: options3?.supportFiles,
32356
+ supportWebSearch: options3?.supportWebSearch,
32357
+ supportDeepResearch: options3?.supportDeepResearch,
32358
+ supportDocumentSearch: options3?.supportDocumentSearch,
32359
+ supportThinking: options3?.supportThinking,
32360
+ supportWorkCanvas: options3?.supportWorkCanvas
32361
+ }
32362
+ });
32363
+ } finally {
32364
+ isSendingRef.current = false;
32336
32365
  }
32337
- messageOptionsRef.current = {
32338
- ...options3,
32339
- filePaths: filePaths.length > 0 ? filePaths : void 0
32340
- };
32341
- await sendMessage({
32342
- text: messageText,
32343
- metadata: {
32344
- modelId: options3?.modelId,
32345
- supportMultipleModels: options3?.supportMultipleModels,
32346
- supportFiles: options3?.supportFiles,
32347
- supportWebSearch: options3?.supportWebSearch,
32348
- supportDeepResearch: options3?.supportDeepResearch,
32349
- supportDocumentSearch: options3?.supportDocumentSearch,
32350
- supportThinking: options3?.supportThinking,
32351
- supportWorkCanvas: options3?.supportWorkCanvas
32352
- }
32353
- });
32354
32366
  };
32355
32367
  useEffect(() => {
32356
32368
  if (!initialPrompt || initialPromptSentRef.current) return;