reachat 1.0.7 → 1.1.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/Chat.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { CSSProperties, FC, PropsWithChildren } from 'react';
2
2
  import { Session } from './types';
3
3
  import { ChatTheme } from './theme';
4
+ import { ChatViewType } from './ChatContext';
4
5
  import { PluggableList } from 'react-markdown/lib';
5
6
 
6
7
  export interface ChatProps extends PropsWithChildren {
@@ -13,11 +14,13 @@ export interface ChatProps extends PropsWithChildren {
13
14
  */
14
15
  className?: string;
15
16
  /**
16
- * The type of prompt to display. Companion prompts are smaller and are
17
- * meant to be displayed alongside other content. Full prompts are larger
18
- * and are meant to be displayed on their own.
17
+ * The type of prompt to display.
18
+ *
19
+ * - Companion: Smaller prompt screen with session lists.
20
+ * - Console: Full screen experience.
21
+ * - Chat: Only chat, no sessions.
19
22
  */
20
- viewType?: 'companion' | 'console';
23
+ viewType?: ChatViewType;
21
24
  /**
22
25
  * The list of sessions to display.
23
26
  */
@@ -2,6 +2,7 @@ import { Session } from './types';
2
2
  import { ChatTheme } from './theme';
3
3
  import { PluggableList } from 'react-markdown/lib';
4
4
 
5
+ export type ChatViewType = 'chat' | 'companion' | 'console';
5
6
  export interface ChatContextProps {
6
7
  sessions: Session[];
7
8
  disabled?: boolean;
@@ -9,6 +10,7 @@ export interface ChatContextProps {
9
10
  theme?: ChatTheme;
10
11
  isLoading?: boolean;
11
12
  isCompact?: boolean;
13
+ viewType?: ChatViewType;
12
14
  activeSession?: Session | null;
13
15
  remarkPlugins?: PluggableList[];
14
16
  selectSession?: (sessionId: string) => void;
package/dist/docs.json CHANGED
@@ -48,7 +48,7 @@
48
48
  "defaultValue": {
49
49
  "value": "console"
50
50
  },
51
- "description": "The type of prompt to display. Companion prompts are smaller and are\nmeant to be displayed alongside other content. Full prompts are larger\nand are meant to be displayed on their own.",
51
+ "description": "The type of prompt to display.\n\n- Companion: Smaller prompt screen with session lists.\n- Console: Full screen experience.\n- Chat: Only chat, no sessions.",
52
52
  "name": "viewType",
53
53
  "parent": {
54
54
  "fileName": "src/Chat.tsx",
@@ -62,7 +62,7 @@
62
62
  ],
63
63
  "required": false,
64
64
  "type": {
65
- "name": "\"companion\" | \"console\""
65
+ "name": "ChatViewType"
66
66
  }
67
67
  },
68
68
  "sessions": {
package/dist/index.js CHANGED
@@ -138,9 +138,9 @@ const SessionMessagesHeader = ({ children }) => {
138
138
  };
139
139
  const SvgBack = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1, strokeLinecap: "round", strokeLinejoin: "round", className: "lucide lucide-chevron-left", ...props }, /* @__PURE__ */ React.createElement("path", { d: "m15 18-6-6 6-6" }));
140
140
  const SessionMessagePanel = ({ children }) => {
141
- const { activeSessionId, theme, isCompact, selectSession } = useContext(ChatContext);
142
- const isVisible = isCompact && activeSessionId;
143
- return (!isCompact || isVisible) && /* @__PURE__ */ jsx(
141
+ const { activeSessionId, theme, isCompact, selectSession, viewType } = useContext(ChatContext);
142
+ const isVisible = isCompact && activeSessionId || viewType === "chat" || !isCompact;
143
+ return isVisible && /* @__PURE__ */ jsx(
144
144
  motion.div,
145
145
  {
146
146
  initial: { translateX: "200%" },
@@ -159,7 +159,7 @@ const SessionMessagePanel = ({ children }) => {
159
159
  [theme.messages.console]: !isCompact
160
160
  }),
161
161
  children: /* @__PURE__ */ jsxs("div", { className: cn(theme.messages.inner), children: [
162
- isCompact && /* @__PURE__ */ jsxs(
162
+ isCompact && viewType !== "chat" && /* @__PURE__ */ jsxs(
163
163
  Button,
164
164
  {
165
165
  variant: "text",
@@ -1517,7 +1517,7 @@ const SessionMessages = ({
1517
1517
  }
1518
1518
  }, [activeSession, isAnimating]);
1519
1519
  function handleShowMore() {
1520
- showNext(10);
1520
+ showNext(limit);
1521
1521
  requestAnimationFrame(() => contentRef.current.scrollTop = 0);
1522
1522
  }
1523
1523
  const reversedConvos = useMemo(
@@ -1526,7 +1526,7 @@ const SessionMessages = ({
1526
1526
  );
1527
1527
  const { data, hasMore, showNext } = useInfinityList({
1528
1528
  items: reversedConvos,
1529
- limit
1529
+ size: limit
1530
1530
  });
1531
1531
  const reReversedConvo = useMemo(() => [...data].reverse(), [data]);
1532
1532
  const convosToRender = limit ? reReversedConvo : activeSession == null ? void 0 : activeSession.conversations;
@@ -1551,7 +1551,7 @@ const SessionMessages = ({
1551
1551
  initial: "hidden",
1552
1552
  animate: "visible",
1553
1553
  onAnimationComplete: () => {
1554
- setIsAnimating(false);
1554
+ requestAnimationFrame(() => setIsAnimating(false));
1555
1555
  },
1556
1556
  children: children(convosToRender)
1557
1557
  },
@@ -1561,7 +1561,7 @@ const SessionMessages = ({
1561
1561
  };
1562
1562
  const chatTheme = {
1563
1563
  base: "dark:text-white text-gray-500",
1564
- console: "flex w-full gap-10 h-full",
1564
+ console: "flex w-full gap-4 h-full",
1565
1565
  companion: "w-full h-full overflow-hidden",
1566
1566
  empty: "text-center flex-1",
1567
1567
  sessions: {
@@ -1585,7 +1585,7 @@ const chatTheme = {
1585
1585
  },
1586
1586
  messages: {
1587
1587
  base: "",
1588
- console: "flex flex-col mr-5 flex-1 overflow-hidden",
1588
+ console: "flex flex-col mx-5 flex-1 overflow-hidden",
1589
1589
  companion: "flex w-full h-full",
1590
1590
  back: "self-start p-0 my-2",
1591
1591
  inner: "flex-1 h-full flex flex-col",
@@ -1759,6 +1759,7 @@ const Chat = ({
1759
1759
  disabled,
1760
1760
  isLoading,
1761
1761
  isCompact,
1762
+ viewType,
1762
1763
  activeSessionId: internalActiveSessionID,
1763
1764
  selectSession: handleSelectSession,
1764
1765
  deleteSession: handleDeleteSession,
@@ -1770,6 +1771,7 @@ const Chat = ({
1770
1771
  [
1771
1772
  isLoading,
1772
1773
  isCompact,
1774
+ viewType,
1773
1775
  disabled,
1774
1776
  theme,
1775
1777
  remarkPlugins,