@gendive/chatllm 0.12.2 → 0.13.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.
@@ -462,6 +462,8 @@ interface ChatUIProps {
462
462
  theme?: ThemeConfig;
463
463
  /** 사이드바 표시 여부 */
464
464
  showSidebar?: boolean;
465
+ /** @Todo vibecode - 사이드바 너비 (기본: 288px) */
466
+ sidebarWidth?: number | string;
465
467
  /** 설정 버튼 표시 여부 */
466
468
  showSettings?: boolean;
467
469
  /** 모델 선택기 표시 여부 */
@@ -554,7 +556,7 @@ interface ChatUIProps {
554
556
  * @Todo vibecode - 메시지 전송 완료 후 호출
555
557
  */
556
558
  onSaveMessages?: (sessionId: string, messages: {
557
- role: 'USER' | 'ASSISTANT';
559
+ role: 'user' | 'assistant';
558
560
  message: string;
559
561
  }[]) => Promise<void>;
560
562
  /**
@@ -624,6 +626,10 @@ interface SidebarProps {
624
626
  onRenameSession?: (id: string, newTitle: string) => void;
625
627
  isOpen: boolean;
626
628
  onToggle: () => void;
629
+ /** @Todo vibecode - 사이드바 너비 (기본: 288px) */
630
+ width?: number | string;
631
+ /** @Todo vibecode - 테마 모드 (chatllm-root 밖에서 사용 시 CSS 변수 직접 적용) */
632
+ theme?: ThemeMode;
627
633
  }
628
634
  interface MessageListProps {
629
635
  messages: ChatMessage[];
@@ -977,7 +983,7 @@ interface UseChatUIOptions {
977
983
  * @Todo vibecode - 메시지 전송 완료 후 호출
978
984
  */
979
985
  onSaveMessages?: (sessionId: string, messages: {
980
- role: 'USER' | 'ASSISTANT';
986
+ role: 'user' | 'assistant';
981
987
  message: string;
982
988
  }[]) => Promise<void>;
983
989
  /**
@@ -462,6 +462,8 @@ interface ChatUIProps {
462
462
  theme?: ThemeConfig;
463
463
  /** 사이드바 표시 여부 */
464
464
  showSidebar?: boolean;
465
+ /** @Todo vibecode - 사이드바 너비 (기본: 288px) */
466
+ sidebarWidth?: number | string;
465
467
  /** 설정 버튼 표시 여부 */
466
468
  showSettings?: boolean;
467
469
  /** 모델 선택기 표시 여부 */
@@ -554,7 +556,7 @@ interface ChatUIProps {
554
556
  * @Todo vibecode - 메시지 전송 완료 후 호출
555
557
  */
556
558
  onSaveMessages?: (sessionId: string, messages: {
557
- role: 'USER' | 'ASSISTANT';
559
+ role: 'user' | 'assistant';
558
560
  message: string;
559
561
  }[]) => Promise<void>;
560
562
  /**
@@ -624,6 +626,10 @@ interface SidebarProps {
624
626
  onRenameSession?: (id: string, newTitle: string) => void;
625
627
  isOpen: boolean;
626
628
  onToggle: () => void;
629
+ /** @Todo vibecode - 사이드바 너비 (기본: 288px) */
630
+ width?: number | string;
631
+ /** @Todo vibecode - 테마 모드 (chatllm-root 밖에서 사용 시 CSS 변수 직접 적용) */
632
+ theme?: ThemeMode;
627
633
  }
628
634
  interface MessageListProps {
629
635
  messages: ChatMessage[];
@@ -977,7 +983,7 @@ interface UseChatUIOptions {
977
983
  * @Todo vibecode - 메시지 전송 완료 후 호출
978
984
  */
979
985
  onSaveMessages?: (sessionId: string, messages: {
980
- role: 'USER' | 'ASSISTANT';
986
+ role: 'user' | 'assistant';
981
987
  message: string;
982
988
  }[]) => Promise<void>;
983
989
  /**
@@ -1273,7 +1273,7 @@ var useChatUI = (options) => {
1273
1273
  // Memory options
1274
1274
  useGlobalMemoryEnabled = true,
1275
1275
  globalMemoryConfig,
1276
- enableAutoExtraction = true,
1276
+ enableAutoExtraction: enableAutoExtractionProp,
1277
1277
  // External storage options
1278
1278
  useExternalStorage = false,
1279
1279
  onLoadSessions,
@@ -1289,6 +1289,7 @@ var useChatUI = (options) => {
1289
1289
  // Skills options
1290
1290
  skills
1291
1291
  } = options;
1292
+ const enableAutoExtraction = enableAutoExtractionProp ?? !useExternalStorage;
1292
1293
  const [sessions, setSessions] = (0, import_react4.useState)([]);
1293
1294
  const [currentSessionId, setCurrentSessionId] = (0, import_react4.useState)(null);
1294
1295
  const [input, setInput] = (0, import_react4.useState)("");
@@ -1806,18 +1807,40 @@ ${newConversation}
1806
1807
  if (!messageContent.trim() || isLoading) return;
1807
1808
  let sessionId = currentSessionId;
1808
1809
  if (!sessionId) {
1809
- const now = Date.now();
1810
- const newSess = {
1811
- id: generateId2("session"),
1812
- title: "\uC0C8 \uB300\uD654",
1813
- messages: [],
1814
- model: selectedModel,
1815
- createdAt: now,
1816
- updatedAt: now
1817
- };
1818
- setSessions((prev) => [newSess, ...prev]);
1819
- sessionId = newSess.id;
1820
- setCurrentSessionId(sessionId);
1810
+ if (useExternalStorage && onCreateSession) {
1811
+ try {
1812
+ const created = await onCreateSession();
1813
+ const now = Date.now();
1814
+ const newSess = {
1815
+ id: created.id,
1816
+ title: created.title,
1817
+ messages: [],
1818
+ model: selectedModel,
1819
+ createdAt: now,
1820
+ updatedAt: now
1821
+ };
1822
+ setSessions((prev) => [newSess, ...prev]);
1823
+ sessionId = newSess.id;
1824
+ setCurrentSessionId(sessionId);
1825
+ } catch (error) {
1826
+ onError?.(error instanceof Error ? error : new Error("Failed to create session"));
1827
+ setIsLoading(false);
1828
+ return;
1829
+ }
1830
+ } else {
1831
+ const now = Date.now();
1832
+ const newSess = {
1833
+ id: generateId2("session"),
1834
+ title: "\uC0C8 \uB300\uD654",
1835
+ messages: [],
1836
+ model: selectedModel,
1837
+ createdAt: now,
1838
+ updatedAt: now
1839
+ };
1840
+ setSessions((prev) => [newSess, ...prev]);
1841
+ sessionId = newSess.id;
1842
+ setCurrentSessionId(sessionId);
1843
+ }
1821
1844
  }
1822
1845
  let finalContent = messageContent.trim();
1823
1846
  if (quotedText) {
@@ -2213,8 +2236,8 @@ ${result.content}
2213
2236
  const assistantContentForSave = accumulatedContent;
2214
2237
  if (assistantContentForSave && onSaveMessages) {
2215
2238
  const messagesToSave = [
2216
- { role: "USER", message: finalContent },
2217
- { role: "ASSISTANT", message: assistantContentForSave }
2239
+ { role: "user", message: finalContent },
2240
+ { role: "assistant", message: assistantContentForSave }
2218
2241
  ];
2219
2242
  onSaveMessages(capturedSessionId, messagesToSave).catch((saveError) => {
2220
2243
  console.error("[useChatUI] Failed to save messages:", saveError);
@@ -2917,8 +2940,11 @@ var ChatSidebar = ({
2917
2940
  onDeleteSession,
2918
2941
  onRenameSession,
2919
2942
  isOpen,
2920
- onToggle
2943
+ onToggle,
2944
+ width: widthProp,
2945
+ theme
2921
2946
  }) => {
2947
+ const sidebarWidth = typeof widthProp === "number" ? `${widthProp}px` : widthProp || "288px";
2922
2948
  const [editingId, setEditingId] = (0, import_react5.useState)(null);
2923
2949
  const [editingTitle, setEditingTitle] = (0, import_react5.useState)("");
2924
2950
  const inputRef = (0, import_react5.useRef)(null);
@@ -2953,12 +2979,13 @@ var ChatSidebar = ({
2953
2979
  handleCancelEdit();
2954
2980
  }
2955
2981
  };
2982
+ const themeClass = theme === "dark" ? "chatllm-dark" : "";
2956
2983
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2957
2984
  "aside",
2958
2985
  {
2959
- className: "chatllm-sidebar chatllm-sidebar-transition",
2986
+ className: `chatllm-sidebar chatllm-sidebar-transition ${theme ? `chatllm-root ${themeClass}` : ""}`,
2960
2987
  style: {
2961
- width: isOpen ? "288px" : "0",
2988
+ width: isOpen ? sidebarWidth : "0",
2962
2989
  flexShrink: 0,
2963
2990
  backgroundColor: "var(--chatllm-sidebar-bg)",
2964
2991
  borderRight: isOpen ? "1px solid var(--chatllm-border)" : "none",
@@ -2971,7 +2998,7 @@ var ChatSidebar = ({
2971
2998
  "div",
2972
2999
  {
2973
3000
  style: {
2974
- width: "288px",
3001
+ width: sidebarWidth,
2975
3002
  height: "100%",
2976
3003
  display: "flex",
2977
3004
  flexDirection: "column",
@@ -6161,7 +6188,7 @@ var MessageBubble = ({
6161
6188
  display: "flex",
6162
6189
  flexDirection: "column",
6163
6190
  alignItems: "flex-end",
6164
- padding: "8px 24px"
6191
+ padding: "4px 24px"
6165
6192
  },
6166
6193
  onMouseEnter: () => setShowActions(true),
6167
6194
  onMouseLeave: () => setShowActions(false),
@@ -6227,7 +6254,7 @@ var MessageBubble = ({
6227
6254
  display: "flex",
6228
6255
  flexDirection: "column",
6229
6256
  alignItems: "flex-start",
6230
- padding: "8px 24px"
6257
+ padding: "4px 24px"
6231
6258
  },
6232
6259
  onMouseEnter: () => setShowActions(true),
6233
6260
  onMouseLeave: () => setShowActions(false),
@@ -6239,25 +6266,25 @@ var MessageBubble = ({
6239
6266
  className: "chatllm-sheet",
6240
6267
  style: {
6241
6268
  width: "100%",
6242
- padding: "24px",
6269
+ padding: "16px",
6243
6270
  display: "flex",
6244
- gap: "16px"
6271
+ gap: "12px"
6245
6272
  },
6246
6273
  children: [
6247
6274
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
6248
6275
  "div",
6249
6276
  {
6250
6277
  style: {
6251
- width: "40px",
6252
- height: "40px",
6253
- borderRadius: "12px",
6278
+ width: "32px",
6279
+ height: "32px",
6280
+ borderRadius: "10px",
6254
6281
  backgroundColor: "var(--chatllm-primary-light)",
6255
6282
  display: "flex",
6256
6283
  alignItems: "center",
6257
6284
  justifyContent: "center",
6258
6285
  color: "var(--chatllm-primary)"
6259
6286
  },
6260
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(IconSvg, { name: "magic-line", size: 24 })
6287
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(IconSvg, { name: "magic-line", size: 20 })
6261
6288
  }
6262
6289
  ) }),
6263
6290
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: { flex: 1, minWidth: 0 }, children: [
@@ -6268,7 +6295,7 @@ var MessageBubble = ({
6268
6295
  display: "flex",
6269
6296
  alignItems: "center",
6270
6297
  gap: "8px",
6271
- marginBottom: "16px"
6298
+ marginBottom: "8px"
6272
6299
  },
6273
6300
  children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
6274
6301
  "span",
@@ -6518,7 +6545,7 @@ var MessageBubble = ({
6518
6545
  display: "flex",
6519
6546
  gap: "2px",
6520
6547
  marginTop: "4px",
6521
- marginLeft: "56px",
6548
+ marginLeft: "44px",
6522
6549
  height: "24px",
6523
6550
  opacity: showActions ? 1 : 0,
6524
6551
  transition: "opacity 0.15s ease"
@@ -7862,6 +7889,7 @@ var ChatUI = ({
7862
7889
  apiEndpoint = "/api/chat",
7863
7890
  theme,
7864
7891
  showSidebar = true,
7892
+ sidebarWidth,
7865
7893
  showSettings = true,
7866
7894
  showModelSelector = true,
7867
7895
  systemPrompt,
@@ -8022,7 +8050,9 @@ var ChatUI = ({
8022
8050
  onDeleteSession: deleteSession,
8023
8051
  onRenameSession: renameSession,
8024
8052
  isOpen: sidebarOpen,
8025
- onToggle: toggleSidebar
8053
+ onToggle: toggleSidebar,
8054
+ width: sidebarWidth,
8055
+ theme: theme?.mode
8026
8056
  }
8027
8057
  ),
8028
8058
  /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(