@gendive/chatllm 0.13.2 → 0.14.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.
@@ -1313,7 +1313,8 @@ var useChatUI = (options) => {
1313
1313
  }));
1314
1314
  setSessions(sessionsWithoutMessages);
1315
1315
  if (sessionsWithoutMessages.length > 0) {
1316
- setCurrentSessionId(sessionsWithoutMessages[0].id);
1316
+ const targetId = options.initialSessionId && sessionsWithoutMessages.some((s) => s.id === options.initialSessionId) ? options.initialSessionId : sessionsWithoutMessages[0].id;
1317
+ setCurrentSessionId(targetId);
1317
1318
  }
1318
1319
  }).catch((error) => {
1319
1320
  onError?.(error instanceof Error ? error : new Error("Failed to load sessions"));
@@ -1335,8 +1336,10 @@ var useChatUI = (options) => {
1335
1336
  const parsed = JSON.parse(saved);
1336
1337
  setSessions(parsed);
1337
1338
  if (parsed.length > 0) {
1338
- setCurrentSessionId(parsed[0].id);
1339
- setSelectedModel(parsed[0].model);
1339
+ const targetSession = options.initialSessionId ? parsed.find((s) => s.id === options.initialSessionId) : null;
1340
+ const selected = targetSession || parsed[0];
1341
+ setCurrentSessionId(selected.id);
1342
+ setSelectedModel(selected.model);
1340
1343
  }
1341
1344
  } catch {
1342
1345
  }
@@ -7832,76 +7835,23 @@ var injectStyles = () => {
7832
7835
  `;
7833
7836
  document.head.appendChild(style);
7834
7837
  };
7835
- var ChatUI = ({
7836
- models = DEFAULT_MODELS,
7837
- actions = DEFAULT_ACTIONS,
7838
- templates = DEFAULT_TEMPLATES,
7839
- personalization,
7840
- onPersonalizationChange,
7838
+ var ChatUIView = ({
7839
+ state,
7840
+ models,
7841
+ actions,
7842
+ templates,
7843
+ showSidebar,
7844
+ sidebarWidth,
7845
+ showSettings,
7846
+ showModelSelector,
7847
+ showThinking,
7848
+ thinkingDefaultOpen,
7849
+ theme,
7850
+ className,
7841
7851
  apiKey,
7842
7852
  onApiKeyChange,
7843
- apiEndpoint = "/api/chat",
7844
- theme,
7845
- showSidebar = true,
7846
- sidebarWidth,
7847
- showSettings = true,
7848
- showModelSelector = true,
7849
- systemPrompt,
7850
- contextCompressionThreshold = 20,
7851
- keepRecentMessages = 6,
7852
- storageKey = "chatllm_sessions",
7853
- className = "",
7854
- onSendMessage,
7855
- onSessionChange,
7856
- onError,
7857
- onTitleChange,
7858
- generateTitle: generateTitle2,
7859
- // External Storage Props
7860
- useExternalStorage = false,
7861
- onLoadSessions,
7862
- onCreateSession,
7863
- onLoadSession,
7864
- onDeleteSession,
7865
- onUpdateSessionTitle,
7866
- onSaveMessages,
7867
- // Thinking Block Props
7868
- showThinking = true,
7869
- thinkingDefaultOpen = false,
7870
- // Deep Research Props
7871
- deepResearch,
7872
- // Skills Props
7873
- skills
7853
+ deepResearchEnabled
7874
7854
  }) => {
7875
- injectStyles();
7876
- const hookOptions = {
7877
- models,
7878
- actions,
7879
- initialPersonalization: personalization,
7880
- onPersonalizationChange,
7881
- apiKey,
7882
- apiEndpoint,
7883
- initialModel: models[0]?.id,
7884
- storageKey,
7885
- contextCompressionThreshold,
7886
- keepRecentMessages,
7887
- onSendMessage,
7888
- onSessionChange,
7889
- onError,
7890
- onTitleChange,
7891
- generateTitle: generateTitle2,
7892
- // External Storage Options
7893
- useExternalStorage,
7894
- onLoadSessions,
7895
- onCreateSession,
7896
- onLoadSession,
7897
- onDeleteSession,
7898
- onUpdateSessionTitle,
7899
- onSaveMessages,
7900
- // Deep Research Options
7901
- deepResearch,
7902
- // Skills Options
7903
- skills
7904
- };
7905
7855
  const {
7906
7856
  sessions,
7907
7857
  currentSession,
@@ -7932,8 +7882,6 @@ var ChatUI = ({
7932
7882
  setSelectedAction,
7933
7883
  copyMessage,
7934
7884
  startEdit,
7935
- cancelEdit,
7936
- saveEdit,
7937
7885
  regenerate,
7938
7886
  askOtherModel,
7939
7887
  setActiveAlternative,
@@ -7941,19 +7889,15 @@ var ChatUI = ({
7941
7889
  loadingAlternativeFor,
7942
7890
  updatePersonalization,
7943
7891
  models: hookModels,
7944
- // Deep Research
7945
7892
  isDeepResearchMode,
7946
7893
  toggleDeepResearchMode,
7947
- // Poll
7948
7894
  handlePollSubmit,
7949
- // Memory
7950
7895
  globalMemory,
7951
7896
  compressionState,
7952
- // Skills
7953
7897
  manualSkills,
7954
7898
  activeSkillExecution,
7955
7899
  executeManualSkill
7956
- } = useChatUI(hookOptions);
7900
+ } = state;
7957
7901
  const greeting = currentPersonalization.userProfile.nickname ? `\uC548\uB155\uD558\uC138\uC694, ${currentPersonalization.userProfile.nickname}\uB2D8` : "\uC548\uB155\uD558\uC138\uC694";
7958
7902
  const handleTemplateClick = (template) => {
7959
7903
  setInput(template.prompt);
@@ -8084,7 +8028,7 @@ var ChatUI = ({
8084
8028
  actions,
8085
8029
  onDeepResearch: toggleDeepResearchMode,
8086
8030
  isDeepResearchMode,
8087
- deepResearchEnabled: !!deepResearch?.onWebSearch,
8031
+ deepResearchEnabled,
8088
8032
  manualSkills,
8089
8033
  onSkillSelect: executeManualSkill,
8090
8034
  activeSkillExecution
@@ -8117,6 +8061,134 @@ var ChatUI = ({
8117
8061
  }
8118
8062
  );
8119
8063
  };
8064
+ var ChatUIWithHook = ({
8065
+ models = DEFAULT_MODELS,
8066
+ actions = DEFAULT_ACTIONS,
8067
+ templates = DEFAULT_TEMPLATES,
8068
+ personalization,
8069
+ onPersonalizationChange,
8070
+ apiKey,
8071
+ onApiKeyChange,
8072
+ apiEndpoint = "/api/chat",
8073
+ theme,
8074
+ showSidebar = true,
8075
+ sidebarWidth,
8076
+ showSettings = true,
8077
+ showModelSelector = true,
8078
+ systemPrompt,
8079
+ contextCompressionThreshold = 20,
8080
+ keepRecentMessages = 6,
8081
+ storageKey = "chatllm_sessions",
8082
+ initialSessionId,
8083
+ className = "",
8084
+ onSendMessage,
8085
+ onSessionChange,
8086
+ onError,
8087
+ onTitleChange,
8088
+ generateTitle: generateTitle2,
8089
+ useExternalStorage = false,
8090
+ onLoadSessions,
8091
+ onCreateSession,
8092
+ onLoadSession,
8093
+ onDeleteSession,
8094
+ onUpdateSessionTitle,
8095
+ onSaveMessages,
8096
+ showThinking = true,
8097
+ thinkingDefaultOpen = false,
8098
+ deepResearch,
8099
+ skills
8100
+ }) => {
8101
+ const hookOptions = {
8102
+ models,
8103
+ actions,
8104
+ initialPersonalization: personalization,
8105
+ onPersonalizationChange,
8106
+ initialSessionId,
8107
+ apiKey,
8108
+ apiEndpoint,
8109
+ initialModel: models[0]?.id,
8110
+ storageKey,
8111
+ contextCompressionThreshold,
8112
+ keepRecentMessages,
8113
+ onSendMessage,
8114
+ onSessionChange,
8115
+ onError,
8116
+ onTitleChange,
8117
+ generateTitle: generateTitle2,
8118
+ useExternalStorage,
8119
+ onLoadSessions,
8120
+ onCreateSession,
8121
+ onLoadSession,
8122
+ onDeleteSession,
8123
+ onUpdateSessionTitle,
8124
+ onSaveMessages,
8125
+ deepResearch,
8126
+ skills
8127
+ };
8128
+ const state = useChatUI(hookOptions);
8129
+ return /* @__PURE__ */ jsx14(
8130
+ ChatUIView,
8131
+ {
8132
+ state,
8133
+ models,
8134
+ actions,
8135
+ templates,
8136
+ showSidebar,
8137
+ sidebarWidth,
8138
+ showSettings,
8139
+ showModelSelector,
8140
+ showThinking,
8141
+ thinkingDefaultOpen,
8142
+ theme,
8143
+ className,
8144
+ apiKey,
8145
+ onApiKeyChange,
8146
+ deepResearchEnabled: !!deepResearch?.onWebSearch
8147
+ }
8148
+ );
8149
+ };
8150
+ var ChatUI = (props) => {
8151
+ injectStyles();
8152
+ if (props.chatState) {
8153
+ const {
8154
+ models = DEFAULT_MODELS,
8155
+ actions = DEFAULT_ACTIONS,
8156
+ templates = DEFAULT_TEMPLATES,
8157
+ showSidebar = true,
8158
+ sidebarWidth,
8159
+ showSettings = true,
8160
+ showModelSelector = true,
8161
+ showThinking = true,
8162
+ thinkingDefaultOpen = false,
8163
+ theme,
8164
+ className = "",
8165
+ apiKey,
8166
+ onApiKeyChange,
8167
+ deepResearch
8168
+ } = props;
8169
+ return /* @__PURE__ */ jsx14(
8170
+ ChatUIView,
8171
+ {
8172
+ state: props.chatState,
8173
+ models,
8174
+ actions,
8175
+ templates,
8176
+ showSidebar,
8177
+ sidebarWidth,
8178
+ showSettings,
8179
+ showModelSelector,
8180
+ showThinking,
8181
+ thinkingDefaultOpen,
8182
+ theme,
8183
+ className,
8184
+ apiKey,
8185
+ onApiKeyChange,
8186
+ deepResearchEnabled: !!deepResearch?.onWebSearch
8187
+ }
8188
+ );
8189
+ }
8190
+ return /* @__PURE__ */ jsx14(ChatUIWithHook, { ...props });
8191
+ };
8120
8192
 
8121
8193
  // src/react/hooks/useDeepResearch.ts
8122
8194
  import { useState as useState13, useCallback as useCallback8, useRef as useRef7 } from "react";