@sybilion/uilib 1.3.89 → 1.3.90
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/esm/components/ui/Chat/ChatMessage/ChatMessage.js +3 -1
- package/dist/esm/components/ui/Chat/ChatSheet/useChatPanelChromeModel.js +8 -3
- package/package.json +1 -1
- package/src/components/ui/Chat/ChatMessage/ChatMessage.tsx +6 -1
- package/src/components/ui/Chat/ChatSheet/useChatPanelChromeModel.tsx +7 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import cn from 'classnames';
|
|
3
|
+
import { useMemo } from 'react';
|
|
3
4
|
import { InteractiveContent } from '../../InteractiveContent/InteractiveContent.js';
|
|
4
5
|
import 'lucide-react';
|
|
5
6
|
import '../../InteractiveContent/InteractiveContent.styl.js';
|
|
@@ -17,7 +18,8 @@ function ChatMessage({ role, text, inProgress, userTextFileAttachments, onQuickR
|
|
|
17
18
|
});
|
|
18
19
|
const isAssistant = role === MessageRole.ASSISTANT;
|
|
19
20
|
const isSystem = role === MessageRole.SYSTEM;
|
|
20
|
-
|
|
21
|
+
const assistantDisplayText = useMemo(() => (isAssistant ? stripJsonDashboardFences(text) : text), [isAssistant, text]);
|
|
22
|
+
return (jsx("div", { className: cn(S.root, S[`role-${role}`], className), children: isSystem ? (jsx("div", { className: cn(S.text, textClassName), children: inProgress ? (jsx(TextShimmer, { as: "span", children: text })) : renderSystemMessage && message ? (renderSystemMessage(message)) : (text) })) : isAssistant ? (jsx(AgentMessageContent, { text: assistantDisplayText, textClassName: textClassName, onQuickReply: onQuickReply, suppressedQuickReplyKeys: suppressedQuickReplyKeys, quickReplyDisabled: quickReplyDisabled, quickReplyHidden: quickReplyHidden, isLastMessage: isLastMessage, scriptContinue: scriptContinue, onScriptContinue: onScriptContinue, renderMessageChart: renderMessageChart })) : (jsxs("div", { className: S.userColumn, children: [jsx("div", { className: cn(S.text, textClassName && S.textCustom, textClassName), children: jsx(InteractiveContent, { text: text }) }), fileAttachments.map(attachment => (jsx(UserTextFileAttachmentBubble, { attachment: attachment }, `${attachment.displayName}:${attachment.filename}`)))] })) }));
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export { ChatMessage };
|
|
@@ -529,9 +529,13 @@ function useChatPanelChromeModel({ embedAsPage, presets, scopeId, onMessage, onS
|
|
|
529
529
|
Boolean(preset.answer?.trim()) ||
|
|
530
530
|
Boolean(hasReplies));
|
|
531
531
|
if (!isLocalDemo) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
532
|
+
let chatId = currentChatId;
|
|
533
|
+
if (!chatId) {
|
|
534
|
+
chatId = startEmptyNewChat() ?? undefined;
|
|
535
|
+
if (!chatId)
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
endLocalDemoFlow(chatId);
|
|
535
539
|
await handlePromptSubmit(options?.message ?? preset.text);
|
|
536
540
|
return;
|
|
537
541
|
}
|
|
@@ -614,6 +618,7 @@ function useChatPanelChromeModel({ embedAsPage, presets, scopeId, onMessage, onS
|
|
|
614
618
|
}
|
|
615
619
|
}, [
|
|
616
620
|
currentChatId,
|
|
621
|
+
startEmptyNewChat,
|
|
617
622
|
endLocalDemoFlow,
|
|
618
623
|
handlePromptSubmit,
|
|
619
624
|
addMessage,
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import cn from 'classnames';
|
|
2
|
+
import { useMemo } from 'react';
|
|
2
3
|
|
|
3
4
|
import { InteractiveContent } from '#uilib/components/ui/InteractiveContent';
|
|
4
5
|
import { TextShimmer } from '#uilib/components/ui/TextShimmer';
|
|
@@ -33,6 +34,10 @@ export function ChatMessage({
|
|
|
33
34
|
});
|
|
34
35
|
const isAssistant = role === MessageRole.ASSISTANT;
|
|
35
36
|
const isSystem = role === MessageRole.SYSTEM;
|
|
37
|
+
const assistantDisplayText = useMemo(
|
|
38
|
+
() => (isAssistant ? stripJsonDashboardFences(text) : text),
|
|
39
|
+
[isAssistant, text],
|
|
40
|
+
);
|
|
36
41
|
|
|
37
42
|
return (
|
|
38
43
|
<div className={cn(S.root, S[`role-${role}`], className)}>
|
|
@@ -48,7 +53,7 @@ export function ChatMessage({
|
|
|
48
53
|
</div>
|
|
49
54
|
) : isAssistant ? (
|
|
50
55
|
<AgentMessageContent
|
|
51
|
-
text={
|
|
56
|
+
text={assistantDisplayText}
|
|
52
57
|
textClassName={textClassName}
|
|
53
58
|
onQuickReply={onQuickReply}
|
|
54
59
|
suppressedQuickReplyKeys={suppressedQuickReplyKeys}
|
|
@@ -817,8 +817,12 @@ export function useChatPanelChromeModel({
|
|
|
817
817
|
Boolean(hasReplies));
|
|
818
818
|
|
|
819
819
|
if (!isLocalDemo) {
|
|
820
|
-
|
|
821
|
-
|
|
820
|
+
let chatId = currentChatId;
|
|
821
|
+
if (!chatId) {
|
|
822
|
+
chatId = startEmptyNewChat() ?? undefined;
|
|
823
|
+
if (!chatId) return;
|
|
824
|
+
}
|
|
825
|
+
endLocalDemoFlow(chatId);
|
|
822
826
|
await handlePromptSubmit(options?.message ?? preset.text);
|
|
823
827
|
return;
|
|
824
828
|
}
|
|
@@ -898,6 +902,7 @@ export function useChatPanelChromeModel({
|
|
|
898
902
|
},
|
|
899
903
|
[
|
|
900
904
|
currentChatId,
|
|
905
|
+
startEmptyNewChat,
|
|
901
906
|
endLocalDemoFlow,
|
|
902
907
|
handlePromptSubmit,
|
|
903
908
|
addMessage,
|