@smartspace/chat-ui 1.14.4-dev.7281901 → 1.14.4-dev.7569a58
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 +77 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4290,6 +4290,8 @@ function useMessageComposerVm(props = {}) {
|
|
|
4290
4290
|
const isRunning = useThreadIsRunning(workspaceId, threadId);
|
|
4291
4291
|
const isUploadingFiles = props.isUploadingFiles ?? false;
|
|
4292
4292
|
const sendMessage = useSendMessage();
|
|
4293
|
+
const currentThreadId = useRef(threadId);
|
|
4294
|
+
currentThreadId.current = threadId;
|
|
4293
4295
|
const sendDisabled = useMemo(() => {
|
|
4294
4296
|
const nothingToSend = !newMessage.trim() && !props.hasAttachments;
|
|
4295
4297
|
const flowBlocked = isRunning || sendMessage.isPending;
|
|
@@ -4301,18 +4303,27 @@ function useMessageComposerVm(props = {}) {
|
|
|
4301
4303
|
newMessage,
|
|
4302
4304
|
props.hasAttachments
|
|
4303
4305
|
]);
|
|
4304
|
-
const internalSend = (text6, files) => {
|
|
4306
|
+
const internalSend = (text6, files, onFailed) => {
|
|
4305
4307
|
if (!workspaceId || !threadId) return;
|
|
4306
4308
|
const trimmed = text6.trim();
|
|
4307
4309
|
const contentList = trimmed ? [{ text: trimmed, image: void 0 }] : void 0;
|
|
4308
4310
|
const vars = variables && Object.keys(variables).length > 0 ? variables : void 0;
|
|
4309
|
-
sendMessage.mutate(
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4311
|
+
sendMessage.mutate(
|
|
4312
|
+
{
|
|
4313
|
+
workspaceId,
|
|
4314
|
+
threadId,
|
|
4315
|
+
contentList,
|
|
4316
|
+
files,
|
|
4317
|
+
variables: vars
|
|
4318
|
+
},
|
|
4319
|
+
// The composer stays mounted across threads: a send that fails after
|
|
4320
|
+
// the user moved to another thread must not put its text in that one.
|
|
4321
|
+
{
|
|
4322
|
+
onError: () => {
|
|
4323
|
+
if (currentThreadId.current === threadId) onFailed?.();
|
|
4324
|
+
}
|
|
4325
|
+
}
|
|
4326
|
+
);
|
|
4316
4327
|
setNewMessage("");
|
|
4317
4328
|
};
|
|
4318
4329
|
const canSend = (text6, files) => {
|
|
@@ -4321,9 +4332,9 @@ function useMessageComposerVm(props = {}) {
|
|
|
4321
4332
|
const flowBlocked = isRunning || sendMessage.isPending;
|
|
4322
4333
|
return !(isUploadingFiles || flowBlocked || nothingToSend);
|
|
4323
4334
|
};
|
|
4324
|
-
const handleSendMessage = (text6, files) => {
|
|
4335
|
+
const handleSendMessage = (text6, files, onFailed) => {
|
|
4325
4336
|
if (!canSend(text6, files)) return false;
|
|
4326
|
-
internalSend(text6, files);
|
|
4337
|
+
internalSend(text6, files, onFailed);
|
|
4327
4338
|
return true;
|
|
4328
4339
|
};
|
|
4329
4340
|
return {
|
|
@@ -4607,7 +4618,16 @@ function MessageComposer(_props = {}) {
|
|
|
4607
4618
|
}, [editorKey]);
|
|
4608
4619
|
const handleSendMessageAndClear = () => {
|
|
4609
4620
|
const latestText = editorRef.current?.getMarkdown() ?? newMessage;
|
|
4610
|
-
const
|
|
4621
|
+
const restoreText = () => {
|
|
4622
|
+
if ((editorRef.current?.getMarkdown() ?? "").trim()) return;
|
|
4623
|
+
setNewMessage(latestText);
|
|
4624
|
+
setEditorKey((k) => k + 1);
|
|
4625
|
+
};
|
|
4626
|
+
const sent = handleSendMessage(
|
|
4627
|
+
latestText,
|
|
4628
|
+
uploadedAttachments,
|
|
4629
|
+
restoreText
|
|
4630
|
+
);
|
|
4611
4631
|
if (!sent) return;
|
|
4612
4632
|
stopDictation();
|
|
4613
4633
|
handleClearAttachments();
|
|
@@ -20606,6 +20626,25 @@ function MessageErrorDetails({
|
|
|
20606
20626
|
] })
|
|
20607
20627
|
] });
|
|
20608
20628
|
}
|
|
20629
|
+
function MessageReasoning({ text: text6 }) {
|
|
20630
|
+
const [expanded, setExpanded] = useState(false);
|
|
20631
|
+
return /* @__PURE__ */ jsxs("div", { className: "mb-1", children: [
|
|
20632
|
+
/* @__PURE__ */ jsxs(
|
|
20633
|
+
"button",
|
|
20634
|
+
{
|
|
20635
|
+
type: "button",
|
|
20636
|
+
onClick: () => setExpanded((prev) => !prev),
|
|
20637
|
+
"aria-expanded": expanded,
|
|
20638
|
+
className: "m-0 inline-flex w-auto cursor-pointer appearance-none items-center gap-1 border-0 bg-transparent p-0 text-[11px] font-medium leading-none text-muted-foreground hover:text-foreground",
|
|
20639
|
+
children: [
|
|
20640
|
+
expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3 shrink-0" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 shrink-0" }),
|
|
20641
|
+
expanded ? "Hide reasoning" : "Show reasoning"
|
|
20642
|
+
]
|
|
20643
|
+
}
|
|
20644
|
+
),
|
|
20645
|
+
expanded && /* @__PURE__ */ jsx("div", { className: "mt-1.5 rounded-md bg-secondary/60 p-2 text-[13px] text-muted-foreground", children: /* @__PURE__ */ jsx(MessageMarkdown, { value: text6 }) })
|
|
20646
|
+
] });
|
|
20647
|
+
}
|
|
20609
20648
|
var ThinkingSection = ({ status }) => /* @__PURE__ */ jsxs(
|
|
20610
20649
|
"div",
|
|
20611
20650
|
{
|
|
@@ -20729,10 +20768,16 @@ var MessageItem = ({
|
|
|
20729
20768
|
let keyCounter = 0;
|
|
20730
20769
|
let lastStatusText = null;
|
|
20731
20770
|
let hasOutputContent = false;
|
|
20771
|
+
let firstOutputIndex = null;
|
|
20772
|
+
const markOutput = () => {
|
|
20773
|
+
if (firstOutputIndex === null) firstOutputIndex = bubbles.length;
|
|
20774
|
+
hasOutputContent = true;
|
|
20775
|
+
};
|
|
20776
|
+
const reasoningTexts = [];
|
|
20732
20777
|
const groupHasAnything = () => groupContent.length > 0 || groupFiles.length > 0 || groupSources.length > 0;
|
|
20733
20778
|
const flush = (nextType) => {
|
|
20734
20779
|
if (groupHasAnything()) {
|
|
20735
|
-
if (groupType === "Output" /* OUTPUT */)
|
|
20780
|
+
if (groupType === "Output" /* OUTPUT */) markOutput();
|
|
20736
20781
|
bubbles.push(
|
|
20737
20782
|
/* @__PURE__ */ jsx(
|
|
20738
20783
|
MessageBubble,
|
|
@@ -20842,6 +20887,12 @@ var MessageItem = ({
|
|
|
20842
20887
|
groupOpen = true;
|
|
20843
20888
|
break;
|
|
20844
20889
|
}
|
|
20890
|
+
case "reasoning": {
|
|
20891
|
+
if (typeof v.value === "string" && v.value.trim() !== "") {
|
|
20892
|
+
reasoningTexts.push(v.value);
|
|
20893
|
+
}
|
|
20894
|
+
continue;
|
|
20895
|
+
}
|
|
20845
20896
|
case "sources": {
|
|
20846
20897
|
groupSources = coerceSources(v.value);
|
|
20847
20898
|
if (groupSources.length > 0) groupOpen = true;
|
|
@@ -20859,7 +20910,7 @@ var MessageItem = ({
|
|
|
20859
20910
|
lastCreatedByUserId = v.createdByUserId;
|
|
20860
20911
|
}
|
|
20861
20912
|
if (groupOpen && groupHasAnything()) {
|
|
20862
|
-
if (groupType === "Output" /* OUTPUT */)
|
|
20913
|
+
if (groupType === "Output" /* OUTPUT */) markOutput();
|
|
20863
20914
|
bubbles.push(
|
|
20864
20915
|
/* @__PURE__ */ jsx(
|
|
20865
20916
|
MessageBubble,
|
|
@@ -20880,6 +20931,19 @@ var MessageItem = ({
|
|
|
20880
20931
|
)
|
|
20881
20932
|
);
|
|
20882
20933
|
}
|
|
20934
|
+
if (reasoningTexts.length > 0) {
|
|
20935
|
+
bubbles.splice(
|
|
20936
|
+
firstOutputIndex ?? bubbles.length,
|
|
20937
|
+
0,
|
|
20938
|
+
/* @__PURE__ */ jsx(
|
|
20939
|
+
MessageReasoning,
|
|
20940
|
+
{
|
|
20941
|
+
text: reasoningTexts.join("\n\n")
|
|
20942
|
+
},
|
|
20943
|
+
`reasoning-${message.id ?? "msg"}`
|
|
20944
|
+
)
|
|
20945
|
+
);
|
|
20946
|
+
}
|
|
20883
20947
|
const showThinking = isLive && (lastStatusText !== null || !hasOutputContent);
|
|
20884
20948
|
if (showThinking) {
|
|
20885
20949
|
bubbles.push(
|