@xinghunm/ai-chat 1.3.1 → 1.3.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 +18 -0
- package/dist/index.mjs +64 -46
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -852,6 +852,21 @@ var AiChatProvider = (props) => {
|
|
|
852
852
|
defaultAuthToken,
|
|
853
853
|
defaultTransformStreamPacket
|
|
854
854
|
]);
|
|
855
|
+
const latestTransportRef = (0, import_react2.useRef)(transport);
|
|
856
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
857
|
+
latestTransportRef.current = transport;
|
|
858
|
+
}, [transport]);
|
|
859
|
+
(0, import_react2.useEffect)(() => {
|
|
860
|
+
return () => {
|
|
861
|
+
const { isStreamingBySession } = store.getState();
|
|
862
|
+
const streamingIds = Object.entries(isStreamingBySession).filter(([, streaming]) => streaming).map(([id]) => id);
|
|
863
|
+
for (const sessionId of streamingIds) {
|
|
864
|
+
const terminateId = isDraftChatSessionId(sessionId) ? void 0 : sessionId;
|
|
865
|
+
void latestTransportRef.current.terminateStream(terminateId).catch(() => {
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
}, [store]);
|
|
855
870
|
const contextValue = (0, import_react2.useMemo)(
|
|
856
871
|
() => ({
|
|
857
872
|
store,
|
|
@@ -7224,6 +7239,9 @@ var useChatComposer = () => {
|
|
|
7224
7239
|
}
|
|
7225
7240
|
if (isDraftChatSessionId(sessionId)) {
|
|
7226
7241
|
finalizeStop(sessionId);
|
|
7242
|
+
void transport.terminateStream(void 0).catch((err) => {
|
|
7243
|
+
console.error("Failed to terminate draft chat session", err);
|
|
7244
|
+
});
|
|
7227
7245
|
return;
|
|
7228
7246
|
}
|
|
7229
7247
|
requestStopStreaming(sessionId);
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// src/components/ai-chat/index.tsx
|
|
2
|
-
import { useEffect as
|
|
2
|
+
import { useEffect as useEffect10 } from "react";
|
|
3
3
|
import styled17 from "@emotion/styled";
|
|
4
4
|
import { ConfigProvider } from "@xinghunm/compass-ui";
|
|
5
5
|
|
|
6
6
|
// src/components/ai-chat-provider/index.tsx
|
|
7
|
-
import { useRef, useMemo, useState } from "react";
|
|
7
|
+
import { useRef, useMemo, useState, useEffect, useLayoutEffect } from "react";
|
|
8
8
|
import axios2 from "axios";
|
|
9
9
|
|
|
10
10
|
// src/context/chat-context.ts
|
|
@@ -805,6 +805,21 @@ var AiChatProvider = (props) => {
|
|
|
805
805
|
defaultAuthToken,
|
|
806
806
|
defaultTransformStreamPacket
|
|
807
807
|
]);
|
|
808
|
+
const latestTransportRef = useRef(transport);
|
|
809
|
+
useLayoutEffect(() => {
|
|
810
|
+
latestTransportRef.current = transport;
|
|
811
|
+
}, [transport]);
|
|
812
|
+
useEffect(() => {
|
|
813
|
+
return () => {
|
|
814
|
+
const { isStreamingBySession } = store.getState();
|
|
815
|
+
const streamingIds = Object.entries(isStreamingBySession).filter(([, streaming]) => streaming).map(([id]) => id);
|
|
816
|
+
for (const sessionId of streamingIds) {
|
|
817
|
+
const terminateId = isDraftChatSessionId(sessionId) ? void 0 : sessionId;
|
|
818
|
+
void latestTransportRef.current.terminateStream(terminateId).catch(() => {
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
}, [store]);
|
|
808
823
|
const contextValue = useMemo(
|
|
809
824
|
() => ({
|
|
810
825
|
store,
|
|
@@ -845,7 +860,7 @@ var AiChatProvider = (props) => {
|
|
|
845
860
|
};
|
|
846
861
|
|
|
847
862
|
// src/components/chat-thread/index.tsx
|
|
848
|
-
import { useCallback as useCallback3, useLayoutEffect as
|
|
863
|
+
import { useCallback as useCallback3, useLayoutEffect as useLayoutEffect3, useMemo as useMemo4, useRef as useRef5, useState as useState4 } from "react";
|
|
849
864
|
import styled9 from "@emotion/styled";
|
|
850
865
|
|
|
851
866
|
// src/context/use-chat-context.ts
|
|
@@ -866,7 +881,7 @@ var useChatStore = (selector) => {
|
|
|
866
881
|
var CHAT_THREAD_SCROLL_TOP_GAP = 16;
|
|
867
882
|
|
|
868
883
|
// src/components/chat-thread/components/chat-message-item.tsx
|
|
869
|
-
import { Fragment, memo, useCallback as useCallback2, useLayoutEffect, useState as useState3 } from "react";
|
|
884
|
+
import { Fragment, memo, useCallback as useCallback2, useLayoutEffect as useLayoutEffect2, useState as useState3 } from "react";
|
|
870
885
|
import styled7 from "@emotion/styled";
|
|
871
886
|
import { keyframes } from "@emotion/react";
|
|
872
887
|
import ReactMarkdown from "react-markdown";
|
|
@@ -875,7 +890,7 @@ import remarkMath from "remark-math";
|
|
|
875
890
|
import rehypeKatex from "rehype-katex";
|
|
876
891
|
|
|
877
892
|
// src/components/chat-thread/hooks/use-chat-message-reveal.ts
|
|
878
|
-
import { useCallback, useEffect, useMemo as useMemo2, useReducer, useRef as useRef2 } from "react";
|
|
893
|
+
import { useCallback, useEffect as useEffect2, useMemo as useMemo2, useReducer, useRef as useRef2 } from "react";
|
|
879
894
|
|
|
880
895
|
// src/components/chat-thread/lib/message-reveal.ts
|
|
881
896
|
var STREAM_REVEAL_TICK_MS = 36;
|
|
@@ -1010,7 +1025,7 @@ var useChatMessageReveal = (message) => {
|
|
|
1010
1025
|
},
|
|
1011
1026
|
[isAssistantStreaming, message.role]
|
|
1012
1027
|
);
|
|
1013
|
-
|
|
1028
|
+
useEffect2(() => {
|
|
1014
1029
|
if (previousMessageIdRef.current === message.id) {
|
|
1015
1030
|
return;
|
|
1016
1031
|
}
|
|
@@ -1028,7 +1043,7 @@ var useChatMessageReveal = (message) => {
|
|
|
1028
1043
|
targetUnitCount: targetUnits.length
|
|
1029
1044
|
});
|
|
1030
1045
|
}, [isAssistantStreaming, message.id, targetUnits.length]);
|
|
1031
|
-
|
|
1046
|
+
useEffect2(() => {
|
|
1032
1047
|
pendingTargetUnitCountRef.current = targetUnits.length;
|
|
1033
1048
|
if (message.role !== "assistant" || !isAssistantStreaming) {
|
|
1034
1049
|
if (inputBatchTimeoutRef.current !== null) {
|
|
@@ -1064,7 +1079,7 @@ var useChatMessageReveal = (message) => {
|
|
|
1064
1079
|
[displayedUnitCount, targetUnits]
|
|
1065
1080
|
);
|
|
1066
1081
|
const contentBlocks = useMemo2(() => splitMarkdownBlocks(displayedContent), [displayedContent]);
|
|
1067
|
-
|
|
1082
|
+
useEffect2(() => {
|
|
1068
1083
|
const hasNewDisplayedBlock = message.role === "assistant" && contentBlocks.length > 1 && contentBlocks.length > lastDisplayedBlockCountRef.current;
|
|
1069
1084
|
lastDisplayedBlockCountRef.current = contentBlocks.length;
|
|
1070
1085
|
if (!hasNewDisplayedBlock) {
|
|
@@ -1078,7 +1093,7 @@ var useChatMessageReveal = (message) => {
|
|
|
1078
1093
|
window.clearTimeout(timer);
|
|
1079
1094
|
};
|
|
1080
1095
|
}, [contentBlocks.length, message.role]);
|
|
1081
|
-
|
|
1096
|
+
useEffect2(() => {
|
|
1082
1097
|
const shouldAnimateReveal = message.role === "assistant" && displayedUnitCount < batchedTargetUnitCount && (isAssistantStreaming || displayedUnitCount > 0);
|
|
1083
1098
|
if (!shouldAnimateReveal) {
|
|
1084
1099
|
if (displayedUnitCount !== batchedTargetUnitCount) {
|
|
@@ -1115,7 +1130,7 @@ var useChatMessageReveal = (message) => {
|
|
|
1115
1130
|
};
|
|
1116
1131
|
|
|
1117
1132
|
// src/components/chat-thread/hooks/use-timeline-block-anchors.ts
|
|
1118
|
-
import { useEffect as
|
|
1133
|
+
import { useEffect as useEffect3, useMemo as useMemo3, useReducer as useReducer2 } from "react";
|
|
1119
1134
|
|
|
1120
1135
|
// src/components/chat-thread/lib/chat-message-timeline.ts
|
|
1121
1136
|
var stringifyTimelineKeyPart = (value) => {
|
|
@@ -1394,14 +1409,14 @@ var useTimelineBlockAnchors = ({
|
|
|
1394
1409
|
state.timelineBlockAnchors,
|
|
1395
1410
|
timelineTextStreamLength
|
|
1396
1411
|
]);
|
|
1397
|
-
|
|
1412
|
+
useEffect3(() => {
|
|
1398
1413
|
dispatch({
|
|
1399
1414
|
type: "reset-message",
|
|
1400
1415
|
messageId: message.id,
|
|
1401
1416
|
currentBlockKeys: currentTimelineBlockKeys
|
|
1402
1417
|
});
|
|
1403
1418
|
}, [currentTimelineBlockKeys, message.id]);
|
|
1404
|
-
|
|
1419
|
+
useEffect3(() => {
|
|
1405
1420
|
if (messageRenderOrder !== "timeline" || !isAssistantStreaming) {
|
|
1406
1421
|
return;
|
|
1407
1422
|
}
|
|
@@ -1411,7 +1426,7 @@ var useTimelineBlockAnchors = ({
|
|
|
1411
1426
|
timelineTextStreamLength
|
|
1412
1427
|
});
|
|
1413
1428
|
}, [currentTimelineBlockKeys, isAssistantStreaming, messageRenderOrder, timelineTextStreamLength]);
|
|
1414
|
-
|
|
1429
|
+
useEffect3(() => {
|
|
1415
1430
|
if (messageRenderOrder !== "timeline") {
|
|
1416
1431
|
return;
|
|
1417
1432
|
}
|
|
@@ -1636,7 +1651,7 @@ var Value = styled3.span`
|
|
|
1636
1651
|
|
|
1637
1652
|
// src/components/chat-thread/components/questionnaire-card.tsx
|
|
1638
1653
|
import {
|
|
1639
|
-
useEffect as
|
|
1654
|
+
useEffect as useEffect4,
|
|
1640
1655
|
useRef as useRef3,
|
|
1641
1656
|
useState as useState2
|
|
1642
1657
|
} from "react";
|
|
@@ -2029,11 +2044,11 @@ var QuestionnaireCardInner = ({
|
|
|
2029
2044
|
const visibleErrorMessage = questionnaire.statusMessage ?? errorMessage;
|
|
2030
2045
|
const isInteractionLocked = !interactive || isSubmitting || isSubmitted || hasExternalFailureStatus;
|
|
2031
2046
|
questionnaireRef.current = questionnaire;
|
|
2032
|
-
|
|
2047
|
+
useEffect4(() => {
|
|
2033
2048
|
setAnswers(createInitialAnswers(questionnaireRef.current));
|
|
2034
2049
|
setOtherDrafts(createInitialOtherDrafts(questionnaireRef.current));
|
|
2035
2050
|
}, [questionnaire.answers]);
|
|
2036
|
-
|
|
2051
|
+
useEffect4(() => {
|
|
2037
2052
|
if (!pendingFocusQuestionId || isInteractionLocked) {
|
|
2038
2053
|
return;
|
|
2039
2054
|
}
|
|
@@ -2557,7 +2572,7 @@ var Detail = styled5.li`
|
|
|
2557
2572
|
|
|
2558
2573
|
// src/components/chat-thread/components/image-viewer.tsx
|
|
2559
2574
|
import styled6 from "@emotion/styled";
|
|
2560
|
-
import { useEffect as
|
|
2575
|
+
import { useEffect as useEffect5, useRef as useRef4 } from "react";
|
|
2561
2576
|
import { jsx as jsx7 } from "@emotion/react/jsx-runtime";
|
|
2562
2577
|
var Overlay = styled6.div`
|
|
2563
2578
|
position: fixed;
|
|
@@ -2577,7 +2592,7 @@ var Img = styled6.img`
|
|
|
2577
2592
|
`;
|
|
2578
2593
|
var ImageViewer = ({ src, alt, onClose }) => {
|
|
2579
2594
|
const overlayRef = useRef4(null);
|
|
2580
|
-
|
|
2595
|
+
useEffect5(() => {
|
|
2581
2596
|
const handleKey = (e) => {
|
|
2582
2597
|
if (e.key === "Escape")
|
|
2583
2598
|
onClose();
|
|
@@ -2585,7 +2600,7 @@ var ImageViewer = ({ src, alt, onClose }) => {
|
|
|
2585
2600
|
document.addEventListener("keydown", handleKey);
|
|
2586
2601
|
return () => document.removeEventListener("keydown", handleKey);
|
|
2587
2602
|
}, [onClose]);
|
|
2588
|
-
|
|
2603
|
+
useEffect5(() => {
|
|
2589
2604
|
overlayRef.current?.focus();
|
|
2590
2605
|
}, []);
|
|
2591
2606
|
const stopPropagation = (e) => e.stopPropagation();
|
|
@@ -2671,7 +2686,7 @@ var useUserMessageCollapse = ({
|
|
|
2671
2686
|
},
|
|
2672
2687
|
[syncCollapseState]
|
|
2673
2688
|
);
|
|
2674
|
-
|
|
2689
|
+
useLayoutEffect2(() => {
|
|
2675
2690
|
if (!bodyStackElement) {
|
|
2676
2691
|
return;
|
|
2677
2692
|
}
|
|
@@ -2691,7 +2706,7 @@ var useUserMessageCollapse = ({
|
|
|
2691
2706
|
settledContent,
|
|
2692
2707
|
syncCollapseState
|
|
2693
2708
|
]);
|
|
2694
|
-
|
|
2709
|
+
useLayoutEffect2(() => {
|
|
2695
2710
|
if (!bodyStackElement || !enabled || typeof ResizeObserver === "undefined") {
|
|
2696
2711
|
return;
|
|
2697
2712
|
}
|
|
@@ -3628,7 +3643,7 @@ var ChatThreadView = ({
|
|
|
3628
3643
|
setPendingNewMessageCount(0);
|
|
3629
3644
|
}
|
|
3630
3645
|
}, []);
|
|
3631
|
-
|
|
3646
|
+
useLayoutEffect3(() => {
|
|
3632
3647
|
const nextHistoryMessageId = latestHistoryMessage?.id;
|
|
3633
3648
|
if (lastHistoryMessageIdRef.current === nextHistoryMessageId) {
|
|
3634
3649
|
return;
|
|
@@ -3652,7 +3667,7 @@ var ChatThreadView = ({
|
|
|
3652
3667
|
});
|
|
3653
3668
|
}
|
|
3654
3669
|
}, [latestHistoryMessage, markThreadPinned, scrollToBottom]);
|
|
3655
|
-
|
|
3670
|
+
useLayoutEffect3(() => {
|
|
3656
3671
|
const nextStreamingMessageId = streamingMessage?.id;
|
|
3657
3672
|
if (lastStreamingMessageIdRef.current === nextStreamingMessageId) {
|
|
3658
3673
|
return;
|
|
@@ -3667,7 +3682,7 @@ var ChatThreadView = ({
|
|
|
3667
3682
|
});
|
|
3668
3683
|
}
|
|
3669
3684
|
}, [streamingMessage]);
|
|
3670
|
-
|
|
3685
|
+
useLayoutEffect3(() => {
|
|
3671
3686
|
if (reservedSpaceFrameRef.current !== null) {
|
|
3672
3687
|
window.cancelAnimationFrame(reservedSpaceFrameRef.current);
|
|
3673
3688
|
reservedSpaceFrameRef.current = null;
|
|
@@ -3697,7 +3712,7 @@ var ChatThreadView = ({
|
|
|
3697
3712
|
}
|
|
3698
3713
|
};
|
|
3699
3714
|
}, [latestTurn, latestUserMessageId, error2, measureLatestTurnMinHeight, scrollToBottom]);
|
|
3700
|
-
|
|
3715
|
+
useLayoutEffect3(() => {
|
|
3701
3716
|
if (!latestTurn)
|
|
3702
3717
|
return;
|
|
3703
3718
|
const handleResize = () => {
|
|
@@ -3723,7 +3738,7 @@ var ChatThreadView = ({
|
|
|
3723
3738
|
window.removeEventListener("resize", handleResize);
|
|
3724
3739
|
};
|
|
3725
3740
|
}, [latestTurn, latestUserMessageId, measureLatestTurnMinHeight, scrollToBottom]);
|
|
3726
|
-
|
|
3741
|
+
useLayoutEffect3(() => {
|
|
3727
3742
|
const latestTurnElement = latestTurnRef.current;
|
|
3728
3743
|
if (!latestTurnElement || typeof ResizeObserver === "undefined") {
|
|
3729
3744
|
return;
|
|
@@ -3736,7 +3751,7 @@ var ChatThreadView = ({
|
|
|
3736
3751
|
observer.disconnect();
|
|
3737
3752
|
};
|
|
3738
3753
|
}, [latestTurn, scrollToBottom]);
|
|
3739
|
-
|
|
3754
|
+
useLayoutEffect3(() => {
|
|
3740
3755
|
const latestTurnElement = latestTurnRef.current;
|
|
3741
3756
|
if (!latestTurnElement || typeof MutationObserver === "undefined") {
|
|
3742
3757
|
return;
|
|
@@ -4030,7 +4045,7 @@ var ScrollToLatestBadge = styled9.span`
|
|
|
4030
4045
|
`;
|
|
4031
4046
|
|
|
4032
4047
|
// src/components/chat-composer/index.tsx
|
|
4033
|
-
import { useCallback as useCallback8, useEffect as
|
|
4048
|
+
import { useCallback as useCallback8, useEffect as useEffect9, useLayoutEffect as useLayoutEffect6, useRef as useRef11, useState as useState10 } from "react";
|
|
4034
4049
|
import styled14 from "@emotion/styled";
|
|
4035
4050
|
|
|
4036
4051
|
// ../../node_modules/.pnpm/@floating-ui+react@0.27.16_react-dom@18.3.1_react@18.3.1/node_modules/@floating-ui/react/dist/floating-ui.react.mjs
|
|
@@ -4192,7 +4207,7 @@ function getFrameElement(win) {
|
|
|
4192
4207
|
|
|
4193
4208
|
// ../../node_modules/.pnpm/@floating-ui+react@0.27.16_react-dom@18.3.1_react@18.3.1/node_modules/@floating-ui/react/dist/floating-ui.react.utils.mjs
|
|
4194
4209
|
import * as React from "react";
|
|
4195
|
-
import { useLayoutEffect as
|
|
4210
|
+
import { useLayoutEffect as useLayoutEffect4 } from "react";
|
|
4196
4211
|
|
|
4197
4212
|
// ../../node_modules/.pnpm/@floating-ui+utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
4198
4213
|
var min = Math.min;
|
|
@@ -4679,7 +4694,7 @@ function getDocument(node) {
|
|
|
4679
4694
|
var isClient = typeof document !== "undefined";
|
|
4680
4695
|
var noop = function noop2() {
|
|
4681
4696
|
};
|
|
4682
|
-
var index = isClient ?
|
|
4697
|
+
var index = isClient ? useLayoutEffect4 : noop;
|
|
4683
4698
|
var SafeReact = {
|
|
4684
4699
|
...React
|
|
4685
4700
|
};
|
|
@@ -5888,12 +5903,12 @@ var computePosition2 = (reference, floating, options) => {
|
|
|
5888
5903
|
|
|
5889
5904
|
// ../../node_modules/.pnpm/@floating-ui+react-dom@2.1.6_react-dom@18.3.1_react@18.3.1/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
|
|
5890
5905
|
import * as React2 from "react";
|
|
5891
|
-
import { useLayoutEffect as
|
|
5906
|
+
import { useLayoutEffect as useLayoutEffect5 } from "react";
|
|
5892
5907
|
import * as ReactDOM from "react-dom";
|
|
5893
5908
|
var isClient2 = typeof document !== "undefined";
|
|
5894
5909
|
var noop3 = function noop4() {
|
|
5895
5910
|
};
|
|
5896
|
-
var index2 = isClient2 ?
|
|
5911
|
+
var index2 = isClient2 ? useLayoutEffect5 : noop3;
|
|
5897
5912
|
function deepEqual(a, b) {
|
|
5898
5913
|
if (a === b) {
|
|
5899
5914
|
return true;
|
|
@@ -6630,10 +6645,10 @@ var resolveSendSession = ({
|
|
|
6630
6645
|
};
|
|
6631
6646
|
|
|
6632
6647
|
// src/components/chat-composer/hooks/use-chat-composer.ts
|
|
6633
|
-
import { useCallback as useCallback7, useEffect as
|
|
6648
|
+
import { useCallback as useCallback7, useEffect as useEffect8, useRef as useRef10, useState as useState8 } from "react";
|
|
6634
6649
|
|
|
6635
6650
|
// src/components/chat-composer/hooks/use-composer-attachments.ts
|
|
6636
|
-
import { useEffect as
|
|
6651
|
+
import { useEffect as useEffect7, useRef as useRef9, useState as useState7 } from "react";
|
|
6637
6652
|
var SUPPORTED_IMAGE_MIME_TYPES = /* @__PURE__ */ new Set(["image/png", "image/jpeg", "image/webp"]);
|
|
6638
6653
|
var MAX_COMPOSER_ATTACHMENTS = 10;
|
|
6639
6654
|
var createObjectUrl = (file) => typeof URL !== "undefined" && typeof URL.createObjectURL === "function" ? URL.createObjectURL(file) : "";
|
|
@@ -6649,10 +6664,10 @@ var releaseComposerAttachments = (attachments) => {
|
|
|
6649
6664
|
var useComposerAttachments = () => {
|
|
6650
6665
|
const [attachments, setAttachments] = useState7([]);
|
|
6651
6666
|
const attachmentsRef = useRef9([]);
|
|
6652
|
-
|
|
6667
|
+
useEffect7(() => {
|
|
6653
6668
|
attachmentsRef.current = attachments;
|
|
6654
6669
|
}, [attachments]);
|
|
6655
|
-
|
|
6670
|
+
useEffect7(
|
|
6656
6671
|
() => () => {
|
|
6657
6672
|
releaseComposerAttachments(attachmentsRef.current);
|
|
6658
6673
|
},
|
|
@@ -6825,10 +6840,10 @@ var useChatComposer = () => {
|
|
|
6825
6840
|
setIsModelsLoading(false);
|
|
6826
6841
|
}
|
|
6827
6842
|
}, [modelsLoader]);
|
|
6828
|
-
|
|
6843
|
+
useEffect8(() => {
|
|
6829
6844
|
void fetchModels();
|
|
6830
6845
|
}, [fetchModels]);
|
|
6831
|
-
|
|
6846
|
+
useEffect8(() => {
|
|
6832
6847
|
activeSkillsLoaderRef.current = skillsLoader;
|
|
6833
6848
|
const cachedSkills = getCachedSkills(skillsLoader);
|
|
6834
6849
|
setAvailableSkills(cachedSkills.skills);
|
|
@@ -6864,7 +6879,7 @@ var useChatComposer = () => {
|
|
|
6864
6879
|
}
|
|
6865
6880
|
}
|
|
6866
6881
|
}, [skillsLoader]);
|
|
6867
|
-
|
|
6882
|
+
useEffect8(() => {
|
|
6868
6883
|
void fetchSkills();
|
|
6869
6884
|
}, [fetchSkills]);
|
|
6870
6885
|
const hasModels = availableModels.length > 0;
|
|
@@ -6878,25 +6893,25 @@ var useChatComposer = () => {
|
|
|
6878
6893
|
const stopRequestBySessionRef = useRef10(/* @__PURE__ */ new Map());
|
|
6879
6894
|
const lastRequestBySessionRef = useRef10(/* @__PURE__ */ new Map());
|
|
6880
6895
|
const previousActiveSessionIdRef = useRef10(activeSessionId);
|
|
6881
|
-
|
|
6896
|
+
useEffect8(() => {
|
|
6882
6897
|
setSelectedModel(
|
|
6883
6898
|
(current) => resolveSelectedChatModel({ currentModel: current, availableModels, isModelsLoading })
|
|
6884
6899
|
);
|
|
6885
6900
|
}, [availableModels, isModelsLoading]);
|
|
6886
|
-
|
|
6901
|
+
useEffect8(() => {
|
|
6887
6902
|
if (activeSession) {
|
|
6888
6903
|
setSelectedModeLocal(activeSession.mode ?? DEFAULT_CHAT_AGENT_MODE);
|
|
6889
6904
|
return;
|
|
6890
6905
|
}
|
|
6891
6906
|
setSelectedModeLocal(preferredMode ?? DEFAULT_CHAT_AGENT_MODE);
|
|
6892
6907
|
}, [activeSession, preferredMode]);
|
|
6893
|
-
|
|
6908
|
+
useEffect8(() => {
|
|
6894
6909
|
if (previousActiveSessionIdRef.current !== activeSessionId) {
|
|
6895
6910
|
setSelectedSkills([]);
|
|
6896
6911
|
previousActiveSessionIdRef.current = activeSessionId;
|
|
6897
6912
|
}
|
|
6898
6913
|
}, [activeSessionId]);
|
|
6899
|
-
|
|
6914
|
+
useEffect8(() => {
|
|
6900
6915
|
if (!attachmentNotice)
|
|
6901
6916
|
return;
|
|
6902
6917
|
const timeoutId = window.setTimeout(
|
|
@@ -7181,6 +7196,9 @@ var useChatComposer = () => {
|
|
|
7181
7196
|
}
|
|
7182
7197
|
if (isDraftChatSessionId(sessionId)) {
|
|
7183
7198
|
finalizeStop(sessionId);
|
|
7199
|
+
void transport.terminateStream(void 0).catch((err) => {
|
|
7200
|
+
console.error("Failed to terminate draft chat session", err);
|
|
7201
|
+
});
|
|
7184
7202
|
return;
|
|
7185
7203
|
}
|
|
7186
7204
|
requestStopStreaming(sessionId);
|
|
@@ -8026,7 +8044,7 @@ var ChatComposerView = ({
|
|
|
8026
8044
|
[refs]
|
|
8027
8045
|
);
|
|
8028
8046
|
const activeSkillIndex = activeSkillNavigation.queryKey === activeSkillQueryKey ? activeSkillNavigation.index : 0;
|
|
8029
|
-
|
|
8047
|
+
useLayoutEffect6(() => {
|
|
8030
8048
|
const element = inputRef.current;
|
|
8031
8049
|
if (!element) {
|
|
8032
8050
|
return;
|
|
@@ -8264,7 +8282,7 @@ var ChatComposer = () => {
|
|
|
8264
8282
|
const { labels, sendRef, retryRef, stopRef, enableImageAttachments } = useChatContext();
|
|
8265
8283
|
const { state, actions } = useChatComposer();
|
|
8266
8284
|
const { send, retry } = actions;
|
|
8267
|
-
|
|
8285
|
+
useEffect9(() => {
|
|
8268
8286
|
sendRef.current = send;
|
|
8269
8287
|
retryRef.current = async (sessionId) => {
|
|
8270
8288
|
retry(sessionId);
|
|
@@ -8779,7 +8797,7 @@ var AiChatWorkspaceContent = ({
|
|
|
8779
8797
|
})
|
|
8780
8798
|
);
|
|
8781
8799
|
const shouldShowComposerOnly = showComposerOnlyBeforeFirstMessage && !showConversationList && !isConversationStarted;
|
|
8782
|
-
|
|
8800
|
+
useEffect10(() => {
|
|
8783
8801
|
onConversationStartedChange?.(isConversationStarted);
|
|
8784
8802
|
}, [isConversationStarted, onConversationStartedChange]);
|
|
8785
8803
|
return /* @__PURE__ */ jsxs14(Root, { "data-testid": "ai-chat", children: [
|