@springbrand/message-panel 0.1.3-alpha.21 → 0.1.3-alpha.23
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.
|
@@ -444,7 +444,11 @@ export function CloudOsChatMessages({
|
|
|
444
444
|
running={block.running}
|
|
445
445
|
/>
|
|
446
446
|
);
|
|
447
|
-
case "text":
|
|
447
|
+
case "text": {
|
|
448
|
+
const streaming =
|
|
449
|
+
isActive &&
|
|
450
|
+
entryIndex === entries.length - 1 &&
|
|
451
|
+
block === entry.blocks.at(-1);
|
|
448
452
|
return (
|
|
449
453
|
<div
|
|
450
454
|
key={block.key}
|
|
@@ -453,9 +457,11 @@ export function CloudOsChatMessages({
|
|
|
453
457
|
<MarkdownMessage
|
|
454
458
|
message={block.text}
|
|
455
459
|
resolveUrl={resolveUrl}
|
|
460
|
+
streaming={streaming}
|
|
456
461
|
/>
|
|
457
462
|
</div>
|
|
458
463
|
);
|
|
464
|
+
}
|
|
459
465
|
case "toolGroup":
|
|
460
466
|
return (
|
|
461
467
|
<ToolGroupRow
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
export type CloudOsUrlResolver = (url: string) => string | null | undefined;
|
|
15
15
|
|
|
16
16
|
const ALLOWED_PROTOCOLS = new Set(["http:", "https:", "mailto:"]);
|
|
17
|
+
const CJK_TEXT = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;
|
|
17
18
|
|
|
18
19
|
export function safeExternalUrl(href: string | undefined): string | undefined {
|
|
19
20
|
if (!href) return undefined;
|
|
@@ -94,9 +95,11 @@ const DEFAULT_COMPONENTS: Components = {
|
|
|
94
95
|
export const MarkdownMessage = memo(function MarkdownMessage({
|
|
95
96
|
message,
|
|
96
97
|
resolveUrl,
|
|
98
|
+
streaming = false,
|
|
97
99
|
}: {
|
|
98
100
|
message: string;
|
|
99
101
|
resolveUrl?: CloudOsUrlResolver;
|
|
102
|
+
streaming?: boolean;
|
|
100
103
|
}): ReactNode {
|
|
101
104
|
const rehypePlugins = useMemo(
|
|
102
105
|
() =>
|
|
@@ -107,9 +110,17 @@ export const MarkdownMessage = memo(function MarkdownMessage({
|
|
|
107
110
|
);
|
|
108
111
|
return (
|
|
109
112
|
<Streamdown
|
|
113
|
+
animated={
|
|
114
|
+
streaming
|
|
115
|
+
? CJK_TEXT.test(message)
|
|
116
|
+
? { sep: "char", duration: 100, stagger: 5 }
|
|
117
|
+
: true
|
|
118
|
+
: false
|
|
119
|
+
}
|
|
110
120
|
className="space-y-0"
|
|
111
121
|
controls={false}
|
|
112
|
-
mode="static"
|
|
122
|
+
mode={streaming ? "streaming" : "static"}
|
|
123
|
+
isAnimating={streaming}
|
|
113
124
|
rehypePlugins={rehypePlugins}
|
|
114
125
|
skipHtml
|
|
115
126
|
components={DEFAULT_COMPONENTS}
|