@xinghunm/ai-chat 1.4.1 → 1.4.2
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/index.js +16 -17
- package/dist/index.mjs +17 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -387,13 +387,24 @@ var createChatStore = (initialState) => (0, import_vanilla.createStore)((set, ge
|
|
|
387
387
|
},
|
|
388
388
|
hydrateHistorySessions: (sessions) => {
|
|
389
389
|
const state = get();
|
|
390
|
-
const
|
|
390
|
+
const draftSessions = state.sessions.filter(
|
|
391
391
|
(session) => isDraftChatSessionId(session.sessionId)
|
|
392
392
|
);
|
|
393
|
-
const
|
|
393
|
+
const activePersistedSession = state.sessions.find(
|
|
394
|
+
(session) => session.sessionId === state.activeSessionId && !isDraftChatSessionId(session.sessionId)
|
|
395
|
+
);
|
|
396
|
+
const hasActiveInIncoming = sessions.some(
|
|
397
|
+
(session) => session.sessionId === state.activeSessionId
|
|
398
|
+
);
|
|
399
|
+
const keepActiveSession = activePersistedSession && !hasActiveInIncoming ? [activePersistedSession] : [];
|
|
400
|
+
const excludeIds = /* @__PURE__ */ new Set([
|
|
401
|
+
...draftSessions.map((s) => s.sessionId),
|
|
402
|
+
...keepActiveSession.map((s) => s.sessionId)
|
|
403
|
+
]);
|
|
394
404
|
const nextSessions = [
|
|
395
|
-
...
|
|
396
|
-
...sessions.filter((session) => !
|
|
405
|
+
...draftSessions,
|
|
406
|
+
...sessions.filter((session) => !excludeIds.has(session.sessionId)),
|
|
407
|
+
...keepActiveSession
|
|
397
408
|
];
|
|
398
409
|
const nextMessagesBySession = { ...state.messagesBySession };
|
|
399
410
|
const nextErrorBySession = { ...state.errorBySession };
|
|
@@ -9071,19 +9082,7 @@ var ChatConversationList = () => {
|
|
|
9071
9082
|
isLoadingMoreRef.current = false;
|
|
9072
9083
|
hasSeenLoadingMoreRef.current = false;
|
|
9073
9084
|
}, [historySessionList?.sessions.length, historySessionList?.hasMore]);
|
|
9074
|
-
const sessions =
|
|
9075
|
-
if (!historySessionList) {
|
|
9076
|
-
return localSessions;
|
|
9077
|
-
}
|
|
9078
|
-
const persistedLocalSessions = localSessions.filter(
|
|
9079
|
-
(session) => !isDraftChatSessionId(session.sessionId)
|
|
9080
|
-
);
|
|
9081
|
-
const localSessionIds = new Set(persistedLocalSessions.map((session) => session.sessionId));
|
|
9082
|
-
return [
|
|
9083
|
-
...persistedLocalSessions,
|
|
9084
|
-
...historySessionList.sessions.filter((session) => !localSessionIds.has(session.sessionId))
|
|
9085
|
-
];
|
|
9086
|
-
}, [historySessionList, localSessions]);
|
|
9085
|
+
const sessions = localSessions;
|
|
9087
9086
|
const handleSessionListScroll = (event) => {
|
|
9088
9087
|
if (!historySessionList?.hasMore || historySessionList.isLoading || !onLoadMoreSessions || isLoadingMoreRef.current) {
|
|
9089
9088
|
return;
|
package/dist/index.mjs
CHANGED
|
@@ -340,13 +340,24 @@ var createChatStore = (initialState) => createStore((set, get) => ({
|
|
|
340
340
|
},
|
|
341
341
|
hydrateHistorySessions: (sessions) => {
|
|
342
342
|
const state = get();
|
|
343
|
-
const
|
|
343
|
+
const draftSessions = state.sessions.filter(
|
|
344
344
|
(session) => isDraftChatSessionId(session.sessionId)
|
|
345
345
|
);
|
|
346
|
-
const
|
|
346
|
+
const activePersistedSession = state.sessions.find(
|
|
347
|
+
(session) => session.sessionId === state.activeSessionId && !isDraftChatSessionId(session.sessionId)
|
|
348
|
+
);
|
|
349
|
+
const hasActiveInIncoming = sessions.some(
|
|
350
|
+
(session) => session.sessionId === state.activeSessionId
|
|
351
|
+
);
|
|
352
|
+
const keepActiveSession = activePersistedSession && !hasActiveInIncoming ? [activePersistedSession] : [];
|
|
353
|
+
const excludeIds = /* @__PURE__ */ new Set([
|
|
354
|
+
...draftSessions.map((s) => s.sessionId),
|
|
355
|
+
...keepActiveSession.map((s) => s.sessionId)
|
|
356
|
+
]);
|
|
347
357
|
const nextSessions = [
|
|
348
|
-
...
|
|
349
|
-
...sessions.filter((session) => !
|
|
358
|
+
...draftSessions,
|
|
359
|
+
...sessions.filter((session) => !excludeIds.has(session.sessionId)),
|
|
360
|
+
...keepActiveSession
|
|
350
361
|
];
|
|
351
362
|
const nextMessagesBySession = { ...state.messagesBySession };
|
|
352
363
|
const nextErrorBySession = { ...state.errorBySession };
|
|
@@ -8906,7 +8917,7 @@ var SkillButton = styled14.button`
|
|
|
8906
8917
|
`;
|
|
8907
8918
|
|
|
8908
8919
|
// src/components/chat-conversation-list/index.tsx
|
|
8909
|
-
import { useEffect as useEffect10,
|
|
8920
|
+
import { useEffect as useEffect10, useRef as useRef12 } from "react";
|
|
8910
8921
|
import styled16 from "@emotion/styled";
|
|
8911
8922
|
|
|
8912
8923
|
// src/components/chat-conversation-list/components/chat-session-item.tsx
|
|
@@ -9028,19 +9039,7 @@ var ChatConversationList = () => {
|
|
|
9028
9039
|
isLoadingMoreRef.current = false;
|
|
9029
9040
|
hasSeenLoadingMoreRef.current = false;
|
|
9030
9041
|
}, [historySessionList?.sessions.length, historySessionList?.hasMore]);
|
|
9031
|
-
const sessions =
|
|
9032
|
-
if (!historySessionList) {
|
|
9033
|
-
return localSessions;
|
|
9034
|
-
}
|
|
9035
|
-
const persistedLocalSessions = localSessions.filter(
|
|
9036
|
-
(session) => !isDraftChatSessionId(session.sessionId)
|
|
9037
|
-
);
|
|
9038
|
-
const localSessionIds = new Set(persistedLocalSessions.map((session) => session.sessionId));
|
|
9039
|
-
return [
|
|
9040
|
-
...persistedLocalSessions,
|
|
9041
|
-
...historySessionList.sessions.filter((session) => !localSessionIds.has(session.sessionId))
|
|
9042
|
-
];
|
|
9043
|
-
}, [historySessionList, localSessions]);
|
|
9042
|
+
const sessions = localSessions;
|
|
9044
9043
|
const handleSessionListScroll = (event) => {
|
|
9045
9044
|
if (!historySessionList?.hasMore || historySessionList.isLoading || !onLoadMoreSessions || isLoadingMoreRef.current) {
|
|
9046
9045
|
return;
|