teodor-new-chat-ui 4.1.48 → 4.1.49

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.
@@ -1,7 +1,9 @@
1
+ import React from 'react';
1
2
  interface MarkdownContentProps {
2
3
  content: string;
3
4
  className?: string;
4
5
  allowHtml?: boolean;
6
+ style?: React.CSSProperties;
5
7
  }
6
- export declare function MarkdownContent({ content, className, allowHtml, }: MarkdownContentProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function MarkdownContent({ content, className, allowHtml, style, }: MarkdownContentProps): import("react/jsx-runtime").JSX.Element;
7
9
  export default MarkdownContent;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * ChatPageExample.tsx
3
+ *
4
+ * Example showing how to use TestChatApp with LangGraphThreadManager sidebar
5
+ */
6
+ export declare function ChatPageExample(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ export interface LangChainComponentProps {
2
+ threadId?: string | null;
3
+ onThreadIdChange?: (threadId: string | null) => void;
4
+ apiUrl?: string;
5
+ assistantId?: string;
6
+ }
7
+ export default function LangChainComponent({ threadId: controlledThreadId, onThreadIdChange, apiUrl, assistantId, }: LangChainComponentProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ export interface LangChainComponentProps {
2
+ threadId?: string | null;
3
+ onThreadIdChange?: (threadId: string | null) => void;
4
+ apiUrl?: string;
5
+ assistantId?: string;
6
+ }
7
+ export default function LangChainComponent({ threadId: controlledThreadId, onThreadIdChange, apiUrl, assistantId, }: LangChainComponentProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import type { ChatMessage } from '@/types/api';
3
+ export interface LangChainMessageComponentProps {
4
+ message: ChatMessage;
5
+ metadata?: Record<string, unknown>;
6
+ isStreaming?: boolean;
7
+ streamingText?: string;
8
+ className?: string;
9
+ onRequestEdit?: (args: {
10
+ message: ChatMessage;
11
+ metadata?: Record<string, unknown> | undefined;
12
+ draft: string;
13
+ }) => void;
14
+ onRequestRegenerate?: (args: {
15
+ message: ChatMessage;
16
+ metadata?: Record<string, unknown> | undefined;
17
+ }) => void;
18
+ onSelectBranchOption?: (args: {
19
+ message: ChatMessage;
20
+ metadata?: Record<string, unknown> | undefined;
21
+ option: string;
22
+ }) => void;
23
+ footerContent?: React.ReactNode;
24
+ }
25
+ export declare function LangChainMessageComponent({ message, metadata, isStreaming, streamingText, className, onRequestEdit, onRequestRegenerate, onSelectBranchOption, footerContent, }: LangChainMessageComponentProps): import("react/jsx-runtime").JSX.Element;
26
+ export default LangChainMessageComponent;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * LangChainMessageList - Simplified message list for useStream hook
3
+ *
4
+ * Designed specifically for LangChain SDK's useStream hook.
5
+ * Renders messages with streaming support and minimal dependencies.
6
+ */
7
+ import React from 'react';
8
+ import type { ChatMessage } from '@/types/api';
9
+ export interface LangChainMessageListProps {
10
+ messages: ChatMessage[];
11
+ isStreaming?: boolean;
12
+ streamingText?: string;
13
+ className?: string;
14
+ style?: React.CSSProperties;
15
+ emptyMessage?: React.ReactNode;
16
+ messageMetadata?: Array<any | undefined>;
17
+ renderMessageFooter?: (message: ChatMessage, info: {
18
+ index: number;
19
+ metadata?: any;
20
+ isStreaming: boolean;
21
+ }) => React.ReactNode;
22
+ onRequestEditMessage?: (args: {
23
+ message: ChatMessage;
24
+ metadata?: any;
25
+ draft: string;
26
+ }) => void;
27
+ onRequestRegenerateMessage?: (args: {
28
+ message: ChatMessage;
29
+ metadata?: any;
30
+ }) => void;
31
+ onBranchSelect?: (args: {
32
+ message: ChatMessage;
33
+ metadata?: any;
34
+ option: string;
35
+ }) => void;
36
+ }
37
+ export declare const LangChainMessageList: React.ForwardRefExoticComponent<LangChainMessageListProps & React.RefAttributes<HTMLDivElement>>;
38
+ export default LangChainMessageList;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * ThreadManager.tsx (LangGraph-focused variant)
3
+ *
4
+ * A thread sidebar component built specifically for LangGraph + useStream
5
+ * No external dependencies on the old ChatSessionProvider
6
+ */
7
+ import type { ThreadInfo } from '@/hooks/useLangGraphThreadManager';
8
+ export interface LangGraphThreadManagerProps {
9
+ className?: string;
10
+ showCreateButton?: boolean;
11
+ showDeleteButton?: boolean;
12
+ showEditTitle?: boolean;
13
+ maxHeight?: string;
14
+ customStyles?: {
15
+ container?: string;
16
+ threadList?: string;
17
+ threadItem?: string;
18
+ activeThread?: string;
19
+ createButton?: string;
20
+ header?: string;
21
+ };
22
+ threads: ThreadInfo[];
23
+ currentThreadId: string | null;
24
+ isLoading: boolean;
25
+ onThreadSelect: (threadId: string) => void;
26
+ onThreadCreate?: (threadId: string | null) => void;
27
+ onThreadDelete: (threadId: string) => void;
28
+ onThreadRename: (threadId: string, title: string) => Promise<void>;
29
+ onCreateNew?: () => Promise<string | null | void>;
30
+ }
31
+ export declare function LangGraphThreadManager({ className, showCreateButton, showDeleteButton, showEditTitle, maxHeight, customStyles, threads, currentThreadId, isLoading, onThreadSelect, onThreadCreate, onThreadDelete, onThreadRename, onCreateNew, }: LangGraphThreadManagerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * useLangGraphThreadManager.ts
3
+ *
4
+ * A lightweight thread manager hook for LangGraph-based applications.
5
+ * Works directly with the useStream hook from @langchain/langgraph-sdk/react
6
+ *
7
+ * Key features:
8
+ * - Manage thread lifecycle (create, list, switch, delete)
9
+ * - Fetch initial thread state from /threads/{id}
10
+ * - Cache threads locally to avoid flashing
11
+ * - Optimistic updates for better UX
12
+ */
13
+ export interface ThreadInfo {
14
+ threadId: string;
15
+ title: string;
16
+ createdAt?: string;
17
+ updatedAt?: string;
18
+ messageCount?: number;
19
+ }
20
+ export interface UseLangGraphThreadManagerOptions {
21
+ apiUrl: string;
22
+ assistantId: string;
23
+ }
24
+ export interface UseLangGraphThreadManagerReturn {
25
+ threads: ThreadInfo[];
26
+ currentThreadId: string | null;
27
+ isLoading: boolean;
28
+ error: Error | null;
29
+ setCurrentThreadId: (id: string | null) => void;
30
+ createThread: (title?: string) => Promise<string>;
31
+ deleteThread: (threadId: string) => Promise<void>;
32
+ updateThreadTitle: (threadId: string, title: string) => Promise<void>;
33
+ refreshThreads: (options?: {
34
+ suppressLoading?: boolean;
35
+ }) => Promise<void>;
36
+ loadThreadState: (threadId: string) => Promise<any>;
37
+ persistThreadsCache: (threads?: ThreadInfo[], currentThreadId?: string | null) => void;
38
+ }
39
+ /**
40
+ * LangGraph-focused thread manager
41
+ *
42
+ * Usage:
43
+ * ```tsx
44
+ * const threadManager = useLangGraphThreadManager({
45
+ * apiUrl: 'http://localhost:8001',
46
+ * assistantId: 'my-langgraph-agent',
47
+ * });
48
+ *
49
+ * // Use with useStream
50
+ * const stream = useStream({
51
+ * apiUrl: threadManager.apiUrl,
52
+ * assistantId: threadManager.assistantId,
53
+ * threadId: threadManager.currentThreadId,
54
+ * });
55
+ * ```
56
+ */
57
+ export declare function useLangGraphThreadManager({ apiUrl, assistantId, }: UseLangGraphThreadManagerOptions): UseLangGraphThreadManagerReturn;
@@ -7,7 +7,7 @@ declare const SheetClose: React.ForwardRefExoticComponent<SheetPrimitive.DialogC
7
7
  declare const SheetPortal: React.FC<SheetPrimitive.DialogPortalProps>;
8
8
  declare const SheetOverlay: React.ForwardRefExoticComponent<Omit<SheetPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
9
9
  declare const sheetVariants: (props?: {
10
- side?: "top" | "bottom" | "right" | "left";
10
+ side?: "left" | "right" | "bottom" | "top";
11
11
  } & import("class-variance-authority/dist/types").ClassProp) => string;
12
12
  interface SheetContentProps extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>, VariantProps<typeof sheetVariants> {
13
13
  }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * useLangGraphThreadManager.ts
3
+ *
4
+ * A lightweight thread manager hook for LangGraph-based applications.
5
+ * Works directly with the useStream hook from @langchain/langgraph-sdk/react
6
+ *
7
+ * Key features:
8
+ * - Manage thread lifecycle (create, list, switch, delete)
9
+ * - Fetch initial thread state from /threads/{id}
10
+ * - Cache threads locally to avoid flashing
11
+ * - Optimistic updates for better UX
12
+ */
13
+ export interface ThreadInfo {
14
+ threadId: string;
15
+ title: string;
16
+ createdAt?: string;
17
+ updatedAt?: string;
18
+ messageCount?: number;
19
+ }
20
+ export interface UseLangGraphThreadManagerOptions {
21
+ apiUrl: string;
22
+ assistantId: string;
23
+ }
24
+ export interface UseLangGraphThreadManagerReturn {
25
+ threads: ThreadInfo[];
26
+ currentThreadId: string | null;
27
+ isLoading: boolean;
28
+ error: Error | null;
29
+ setCurrentThreadId: (id: string | null) => void;
30
+ createThread: (title?: string) => Promise<string>;
31
+ deleteThread: (threadId: string) => Promise<void>;
32
+ updateThreadTitle: (threadId: string, title: string) => Promise<void>;
33
+ refreshThreads: (options?: {
34
+ suppressLoading?: boolean;
35
+ }) => Promise<void>;
36
+ loadThreadState: (threadId: string) => Promise<any>;
37
+ persistThreadsCache: (threads?: ThreadInfo[], currentThreadId?: string | null) => void;
38
+ }
39
+ /**
40
+ * LangGraph-focused thread manager
41
+ *
42
+ * Usage:
43
+ * ```tsx
44
+ * const threadManager = useLangGraphThreadManager({
45
+ * apiUrl: 'http://localhost:8001',
46
+ * assistantId: 'my-langgraph-agent',
47
+ * });
48
+ *
49
+ * // Use with useStream
50
+ * const stream = useStream({
51
+ * apiUrl: threadManager.apiUrl,
52
+ * assistantId: threadManager.assistantId,
53
+ * threadId: threadManager.currentThreadId,
54
+ * });
55
+ * ```
56
+ */
57
+ export declare function useLangGraphThreadManager({ apiUrl, assistantId, }: UseLangGraphThreadManagerOptions): UseLangGraphThreadManagerReturn;
package/dist/index.esm.js CHANGED
@@ -9306,24 +9306,49 @@ In.lex;
9306
9306
  function oc({
9307
9307
  content: e,
9308
9308
  className: t = "",
9309
- allowHtml: n = !1
9309
+ allowHtml: n = !1,
9310
+ style: r
9310
9311
  }) {
9311
- const r = at(() => {
9312
+ const o = at(() => {
9312
9313
  try {
9313
9314
  if (!n) {
9314
- const o = e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi, "").replace(/javascript:/gi, "").replace(/on\w+\s*=/gi, "");
9315
- return ye.parse(o);
9315
+ const i = e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi, "").replace(/javascript:/gi, "").replace(/on\w+\s*=/gi, "");
9316
+ return ye.parse(i);
9316
9317
  }
9317
9318
  return ye.parse(e);
9318
- } catch (o) {
9319
- return console.error("[MarkdownContent] parse error", o), `<pre>Error rendering markdown: ${String(o)}</pre>`;
9319
+ } catch (i) {
9320
+ return console.error("[MarkdownContent] parse error", i), `<pre>Error rendering markdown: ${String(i)}</pre>`;
9320
9321
  }
9321
- }, [e, n]);
9322
+ }, [e, n]), s = at(() => {
9323
+ if (r && r.color) {
9324
+ const i = r.color;
9325
+ return {
9326
+ ...r,
9327
+ "--tw-prose-body": i,
9328
+ "--tw-prose-headings": i,
9329
+ "--tw-prose-links": i,
9330
+ "--tw-prose-bold": i,
9331
+ "--tw-prose-counters": i,
9332
+ "--tw-prose-bullets": i,
9333
+ "--tw-prose-hr": i,
9334
+ "--tw-prose-quotes": i,
9335
+ "--tw-prose-quote-borders": i,
9336
+ "--tw-prose-captions": i,
9337
+ "--tw-prose-code": i,
9338
+ "--tw-prose-pre-code": i,
9339
+ "--tw-prose-pre-bg": "inherit",
9340
+ "--tw-prose-th-borders": i,
9341
+ "--tw-prose-td-borders": i
9342
+ };
9343
+ }
9344
+ return r;
9345
+ }, [r]);
9322
9346
  return /* @__PURE__ */ c.jsx(
9323
9347
  "div",
9324
9348
  {
9325
9349
  className: te("markdown prose max-w-none break-words dark:prose-invert", t),
9326
- dangerouslySetInnerHTML: { __html: r }
9350
+ style: s,
9351
+ dangerouslySetInnerHTML: { __html: o }
9327
9352
  }
9328
9353
  );
9329
9354
  }