@smartspace/chat-ui 1.14.4-dev.65f646d → 1.14.4-dev.7281901
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.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +224 -142
- package/dist/index.js +1361 -569
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import MuiButton from '@mui/material/Button';
|
|
2
|
-
import
|
|
3
|
-
import { Loader2,
|
|
4
|
-
import * as
|
|
5
|
-
import { createContext, forwardRef, useImperativeHandle, useRef, useState, useEffect, useMemo, useCallback, useContext, useSyncExternalStore } from 'react';
|
|
2
|
+
import IconButton2 from '@mui/material/IconButton';
|
|
3
|
+
import { Loader2, ChevronDown, Check, Cpu, SlidersHorizontal, X, Globe, Zap, Square, Mic, Paperclip, Send, Minimize2, AlertTriangle, FileImage, FileVideo, FileAudio, FileArchive, FileCode, FileSpreadsheet, Presentation, FileText, ChevronRight, ChevronUp, ExternalLink, Download, ShieldAlert, Copy } from 'lucide-react';
|
|
4
|
+
import * as React9 from 'react';
|
|
5
|
+
import React9__default, { createContext, forwardRef, useImperativeHandle, useRef, useState, useEffect, useMemo, useCallback, useContext, useSyncExternalStore, Fragment as Fragment$1 } from 'react';
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
|
-
import { useQuery, queryOptions, useQueryClient, useMutation
|
|
8
|
+
import { useQuery, queryOptions, useQueryClient, useMutation } from '@tanstack/react-query';
|
|
9
9
|
import { toast } from 'sonner';
|
|
10
10
|
import { ChatZod } from '@smartspace/api-client';
|
|
11
11
|
import { z } from 'zod';
|
|
@@ -17,14 +17,13 @@ import { codeBlockSchema, commonmark } from '@milkdown/preset-commonmark';
|
|
|
17
17
|
import { Slice, NodeType } from '@milkdown/prose/model';
|
|
18
18
|
import { MilkdownProvider, useEditor, Milkdown } from '@milkdown/react';
|
|
19
19
|
import { PluginKey, Plugin } from '@milkdown/prose/state';
|
|
20
|
-
import {
|
|
20
|
+
import { DecorationSet, Decoration } from '@milkdown/prose/view';
|
|
21
21
|
import 'crypto';
|
|
22
22
|
import '@milkdown/prose';
|
|
23
23
|
import '@milkdown/prose/inputrules';
|
|
24
24
|
import { withJsonFormsControlProps, withJsonFormsLayoutProps, JsonForms, ResolvedJsonFormsDispatch } from '@jsonforms/react';
|
|
25
25
|
import { rankWith, uiTypeIs, createAjv } from '@jsonforms/core';
|
|
26
26
|
import { vanillaRenderers, vanillaCells } from '@jsonforms/vanilla-renderers';
|
|
27
|
-
import { FormControl, InputLabel, Select, MenuItem, useTheme, Box, Skeleton as Skeleton$1 } from '@mui/material';
|
|
28
27
|
import 'ace-builds/src-noconflict/ace';
|
|
29
28
|
import 'ace-builds/src-noconflict/ext-language_tools';
|
|
30
29
|
import 'ace-builds/src-noconflict/mode-json';
|
|
@@ -48,15 +47,16 @@ import vertexaiIcon from '@lobehub/icons-static-svg/icons/vertexai-color.svg';
|
|
|
48
47
|
import xaiIcon from '@lobehub/icons-static-svg/icons/xai.svg';
|
|
49
48
|
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
50
49
|
import ReactMarkdown, { defaultUrlTransform } from 'react-markdown';
|
|
51
|
-
import
|
|
50
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
51
|
+
import { cva } from 'class-variance-authority';
|
|
52
52
|
import { clsx } from 'clsx';
|
|
53
53
|
import { twMerge } from 'tailwind-merge';
|
|
54
|
+
import MuiSkeleton from '@mui/material/Skeleton';
|
|
54
55
|
import dayjs from 'dayjs';
|
|
55
56
|
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
|
56
57
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
57
58
|
import utc from 'dayjs/plugin/utc';
|
|
58
|
-
import {
|
|
59
|
-
import { cva } from 'class-variance-authority';
|
|
59
|
+
import { useTheme, Box, Skeleton as Skeleton$1 } from '@mui/material';
|
|
60
60
|
|
|
61
61
|
var __defProp = Object.defineProperty;
|
|
62
62
|
var __export = (target, all5) => {
|
|
@@ -115,8 +115,7 @@ var filesKeys = {
|
|
|
115
115
|
mutation: {
|
|
116
116
|
upload: (scope) => [...filesKeys.mutations(), "upload", { scope }],
|
|
117
117
|
download: (fileId) => [...filesKeys.mutations(), "download", { fileId }],
|
|
118
|
-
downloadBlob: (fileId) => [...filesKeys.mutations(), "downloadBlob", { fileId }]
|
|
119
|
-
downloadByUri: (uri) => [...filesKeys.mutations(), "downloadByUri", { uri }]
|
|
118
|
+
downloadBlob: (fileId) => [...filesKeys.mutations(), "downloadBlob", { fileId }]
|
|
120
119
|
}
|
|
121
120
|
};
|
|
122
121
|
|
|
@@ -163,20 +162,6 @@ var useFileMutations = (scope) => {
|
|
|
163
162
|
},
|
|
164
163
|
onError: () => toast.error("Failed to download file")
|
|
165
164
|
});
|
|
166
|
-
const downloadFileByUriMutation = useMutation({
|
|
167
|
-
mutationFn: async ({
|
|
168
|
-
name,
|
|
169
|
-
sourceUri
|
|
170
|
-
}) => {
|
|
171
|
-
const uri = await service.getFileDownloadUrl(sourceUri);
|
|
172
|
-
if (!uri) throw new Error("No download URL");
|
|
173
|
-
const response = await fetch(uri);
|
|
174
|
-
const blob = await response.blob();
|
|
175
|
-
saveFile(blob, name);
|
|
176
|
-
return blob;
|
|
177
|
-
},
|
|
178
|
-
onError: () => toast.error("Failed to download file")
|
|
179
|
-
});
|
|
180
165
|
const fileStates = (files) => files.map((file) => ({
|
|
181
166
|
name: file.name,
|
|
182
167
|
progress: fileProgress[file.name] ?? 0,
|
|
@@ -200,7 +185,6 @@ var useFileMutations = (scope) => {
|
|
|
200
185
|
return {
|
|
201
186
|
uploadFilesMutation,
|
|
202
187
|
downloadFileMutation,
|
|
203
|
-
downloadFileByUriMutation,
|
|
204
188
|
getFileBlobUrl,
|
|
205
189
|
fileProgress,
|
|
206
190
|
uploadedFiles,
|
|
@@ -556,7 +540,10 @@ var threadDetailOptions = ({
|
|
|
556
540
|
queryKey: threadsKeys.detail(workspaceId, threadId),
|
|
557
541
|
queryFn: () => service.fetchThread(workspaceId, threadId),
|
|
558
542
|
refetchOnWindowFocus: false,
|
|
559
|
-
staleTime: 6e4
|
|
543
|
+
staleTime: 6e4,
|
|
544
|
+
// The route loader has just tried and failed. Retrying on mount delays
|
|
545
|
+
// the inline error by several seconds; the user has Try again.
|
|
546
|
+
retryOnMount: false
|
|
560
547
|
});
|
|
561
548
|
function getThreadPlaceholderFromListCache(queryClient, workspaceId, threadId) {
|
|
562
549
|
const entries = queryClient.getQueriesData({
|
|
@@ -600,9 +587,14 @@ var useThread = ({
|
|
|
600
587
|
};
|
|
601
588
|
var useThreadIsRunning = (workspaceId, threadId) => {
|
|
602
589
|
const queryClient = useQueryClient();
|
|
590
|
+
const service = useChatService();
|
|
603
591
|
const { data: detailThread } = useQuery({
|
|
604
|
-
|
|
605
|
-
|
|
592
|
+
...threadDetailOptions({
|
|
593
|
+
service,
|
|
594
|
+
workspaceId: workspaceId ?? "",
|
|
595
|
+
threadId: threadId ?? ""
|
|
596
|
+
}),
|
|
597
|
+
enabled: false
|
|
606
598
|
});
|
|
607
599
|
const listThread = workspaceId && threadId ? getThreadPlaceholderFromListCache(queryClient, workspaceId, threadId) : void 0;
|
|
608
600
|
const { data: optimistic } = useQuery({
|
|
@@ -837,6 +829,37 @@ function useMessages(threadId) {
|
|
|
837
829
|
});
|
|
838
830
|
}
|
|
839
831
|
|
|
832
|
+
// src/domains/speech/queryKeys.ts
|
|
833
|
+
var speechKeys = {
|
|
834
|
+
all: ["speech"],
|
|
835
|
+
config: () => [...speechKeys.all, "config"]
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
// src/domains/speech/queries.ts
|
|
839
|
+
var unavailable = { enabled: false, defaultLocale: "en-US" };
|
|
840
|
+
var isNotFound = (error) => error?.type === "NotFound" || error?.response?.status === 404;
|
|
841
|
+
function useSpeechConfig() {
|
|
842
|
+
const service = useChatService();
|
|
843
|
+
const supported = !!service.getSpeechConfig && !!service.getSpeechToken;
|
|
844
|
+
return useQuery({
|
|
845
|
+
...queryOptions({
|
|
846
|
+
queryKey: speechKeys.config(),
|
|
847
|
+
queryFn: async () => {
|
|
848
|
+
try {
|
|
849
|
+
return await service.getSpeechConfig?.() ?? unavailable;
|
|
850
|
+
} catch (error) {
|
|
851
|
+
if (isNotFound(error)) return unavailable;
|
|
852
|
+
throw error;
|
|
853
|
+
}
|
|
854
|
+
},
|
|
855
|
+
staleTime: Infinity,
|
|
856
|
+
retry: (failureCount) => failureCount < 2,
|
|
857
|
+
retryDelay: 1e3
|
|
858
|
+
}),
|
|
859
|
+
enabled: supported
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
|
|
840
863
|
// ../../node_modules/.pnpm/@milkdown+exception@7.20.0/node_modules/@milkdown/exception/lib/index.js
|
|
841
864
|
var ErrorCode = /* @__PURE__ */ (function(ErrorCode2) {
|
|
842
865
|
ErrorCode2["docTypeError"] = "docTypeError";
|
|
@@ -970,6 +993,75 @@ var autolink = $prose(() => {
|
|
|
970
993
|
}
|
|
971
994
|
});
|
|
972
995
|
});
|
|
996
|
+
var dictationGhostKey = new PluginKey("dictationGhost");
|
|
997
|
+
function buildDecorations2(state, text6) {
|
|
998
|
+
const doc = state.doc;
|
|
999
|
+
const from = state.selection.head;
|
|
1000
|
+
const before = from > 0 ? doc.textBetween(from - 1, from, " ") : "";
|
|
1001
|
+
const display = before !== "" && !/\s/.test(before) ? ` ${text6}` : text6;
|
|
1002
|
+
const widget = Decoration.widget(
|
|
1003
|
+
from,
|
|
1004
|
+
() => {
|
|
1005
|
+
const span = document.createElement("span");
|
|
1006
|
+
span.className = "md-editor__dictation-ghost";
|
|
1007
|
+
span.setAttribute("aria-hidden", "true");
|
|
1008
|
+
span.appendChild(document.createTextNode(display));
|
|
1009
|
+
const dots = document.createElement("span");
|
|
1010
|
+
dots.className = "md-editor__dictation-dots";
|
|
1011
|
+
for (let i = 0; i < 3; i += 1)
|
|
1012
|
+
dots.appendChild(document.createElement("span"));
|
|
1013
|
+
span.appendChild(dots);
|
|
1014
|
+
return span;
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
// Render after the caret so typing still lands where the user expects.
|
|
1018
|
+
side: 1,
|
|
1019
|
+
// Keyed by content so ProseMirror reuses the node between renders instead
|
|
1020
|
+
// of tearing it down on every interim result.
|
|
1021
|
+
key: `dictation-ghost:${display}`
|
|
1022
|
+
}
|
|
1023
|
+
);
|
|
1024
|
+
const decorations = [widget];
|
|
1025
|
+
const $head = state.selection.$head;
|
|
1026
|
+
if ($head.depth > 0) {
|
|
1027
|
+
decorations.push(
|
|
1028
|
+
Decoration.node($head.before(), $head.after(), {
|
|
1029
|
+
class: "md-editor__has-dictation-ghost"
|
|
1030
|
+
})
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
1033
|
+
return DecorationSet.create(doc, decorations);
|
|
1034
|
+
}
|
|
1035
|
+
var dictationGhost = $prose(() => {
|
|
1036
|
+
return new Plugin({
|
|
1037
|
+
key: dictationGhostKey,
|
|
1038
|
+
state: {
|
|
1039
|
+
init: () => "",
|
|
1040
|
+
apply(tr, previous2) {
|
|
1041
|
+
const meta = tr.getMeta(dictationGhostKey);
|
|
1042
|
+
if (meta) return meta.text;
|
|
1043
|
+
if (tr.docChanged || tr.selectionSet) return "";
|
|
1044
|
+
return previous2;
|
|
1045
|
+
}
|
|
1046
|
+
},
|
|
1047
|
+
props: {
|
|
1048
|
+
decorations(state) {
|
|
1049
|
+
const text6 = dictationGhostKey.getState(state) ?? "";
|
|
1050
|
+
if (!text6) return DecorationSet.empty;
|
|
1051
|
+
return buildDecorations2(state, text6);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
});
|
|
1056
|
+
function setDictationGhost(view, text6) {
|
|
1057
|
+
const current = dictationGhostKey.getState(view.state) ?? "";
|
|
1058
|
+
if (current === text6) return;
|
|
1059
|
+
const tr = view.state.tr.setMeta(dictationGhostKey, {
|
|
1060
|
+
text: text6
|
|
1061
|
+
});
|
|
1062
|
+
tr.setMeta("addToHistory", false);
|
|
1063
|
+
view.dispatch(tr);
|
|
1064
|
+
}
|
|
973
1065
|
|
|
974
1066
|
// src/shared/markdown/extensions/fileTag.ts
|
|
975
1067
|
var fileTag = $node("fileTag", () => ({
|
|
@@ -1879,7 +1971,7 @@ function EditorInner({
|
|
|
1879
1971
|
} catch {
|
|
1880
1972
|
}
|
|
1881
1973
|
});
|
|
1882
|
-
}).use(commonmark).use(history).use(clipboard).use(listener).use(autolink).use(fileTag).use(ssImageNode).use(ssImageView).use(htmlPreviewView).use(enableMentions ? mention : fileTag);
|
|
1974
|
+
}).use(commonmark).use(history).use(clipboard).use(listener).use(autolink).use(dictationGhost).use(fileTag).use(ssImageNode).use(ssImageView).use(htmlPreviewView).use(enableMentions ? mention : fileTag);
|
|
1883
1975
|
},
|
|
1884
1976
|
[isEditable]
|
|
1885
1977
|
);
|
|
@@ -2089,6 +2181,25 @@ function EditorInner({
|
|
|
2089
2181
|
return value ?? "";
|
|
2090
2182
|
}
|
|
2091
2183
|
},
|
|
2184
|
+
insertText: (text6) => {
|
|
2185
|
+
const view = viewRef.current;
|
|
2186
|
+
if (!view || !isEditable || !text6) return;
|
|
2187
|
+
try {
|
|
2188
|
+
const { from } = view.state.selection;
|
|
2189
|
+
const before = from > 0 ? view.state.doc.textBetween(from - 1, from, " ") : "";
|
|
2190
|
+
const needsSpace = before !== "" && !/\s/.test(before);
|
|
2191
|
+
insertTextAtSelection(view, (needsSpace ? " " : "") + text6);
|
|
2192
|
+
} catch {
|
|
2193
|
+
}
|
|
2194
|
+
},
|
|
2195
|
+
setDictationGhost: (text6) => {
|
|
2196
|
+
const view = viewRef.current;
|
|
2197
|
+
if (!view || !isEditable) return;
|
|
2198
|
+
try {
|
|
2199
|
+
setDictationGhost(view, text6);
|
|
2200
|
+
} catch {
|
|
2201
|
+
}
|
|
2202
|
+
},
|
|
2092
2203
|
clear: () => {
|
|
2093
2204
|
const view = viewRef.current;
|
|
2094
2205
|
if (!view) return;
|
|
@@ -2432,6 +2543,327 @@ var MarkdownEditor = forwardRef((props, ref) => {
|
|
|
2432
2543
|
return /* @__PURE__ */ jsx(MilkdownProvider, { children: /* @__PURE__ */ jsx(EditorInner, { ...props, editorHandleRef: ref }) });
|
|
2433
2544
|
});
|
|
2434
2545
|
MarkdownEditor.displayName = "MarkdownEditor";
|
|
2546
|
+
var TOKEN_EXPIRY_MARGIN_MS = 15e3;
|
|
2547
|
+
var noLevelMonitor = () => void 0;
|
|
2548
|
+
var SILENCE_HINT_MS = 6e3;
|
|
2549
|
+
var SILENCE_LEVEL = 3;
|
|
2550
|
+
function monitorInputLevel(stream, onSilent, onSound) {
|
|
2551
|
+
let context;
|
|
2552
|
+
let source;
|
|
2553
|
+
let analyser;
|
|
2554
|
+
try {
|
|
2555
|
+
context = new AudioContext();
|
|
2556
|
+
source = context.createMediaStreamSource(stream);
|
|
2557
|
+
analyser = context.createAnalyser();
|
|
2558
|
+
analyser.fftSize = 512;
|
|
2559
|
+
source.connect(analyser);
|
|
2560
|
+
} catch {
|
|
2561
|
+
return () => void 0;
|
|
2562
|
+
}
|
|
2563
|
+
if (context.state === "suspended")
|
|
2564
|
+
void context.resume().catch(() => void 0);
|
|
2565
|
+
const samples = new Uint8Array(analyser.fftSize);
|
|
2566
|
+
let lastSound = Date.now();
|
|
2567
|
+
let silent = false;
|
|
2568
|
+
let stopped = false;
|
|
2569
|
+
const poll = window.setInterval(() => {
|
|
2570
|
+
if (context.state !== "running") return;
|
|
2571
|
+
analyser.getByteTimeDomainData(samples);
|
|
2572
|
+
let peak = 0;
|
|
2573
|
+
for (const sample of samples) peak = Math.max(peak, Math.abs(sample - 128));
|
|
2574
|
+
if (peak > SILENCE_LEVEL) {
|
|
2575
|
+
lastSound = Date.now();
|
|
2576
|
+
if (silent) {
|
|
2577
|
+
silent = false;
|
|
2578
|
+
onSound();
|
|
2579
|
+
}
|
|
2580
|
+
} else if (!silent && Date.now() - lastSound > SILENCE_HINT_MS) {
|
|
2581
|
+
silent = true;
|
|
2582
|
+
onSilent();
|
|
2583
|
+
}
|
|
2584
|
+
}, 250);
|
|
2585
|
+
return () => {
|
|
2586
|
+
if (stopped) return;
|
|
2587
|
+
stopped = true;
|
|
2588
|
+
window.clearInterval(poll);
|
|
2589
|
+
try {
|
|
2590
|
+
source.disconnect();
|
|
2591
|
+
void context.close().catch(() => void 0);
|
|
2592
|
+
} catch {
|
|
2593
|
+
}
|
|
2594
|
+
};
|
|
2595
|
+
}
|
|
2596
|
+
var STALE_TOKEN_FLOOR_MS = 6e4;
|
|
2597
|
+
function kickOff(fn) {
|
|
2598
|
+
let promise;
|
|
2599
|
+
try {
|
|
2600
|
+
promise = Promise.resolve(fn());
|
|
2601
|
+
} catch (e) {
|
|
2602
|
+
promise = Promise.reject(e);
|
|
2603
|
+
}
|
|
2604
|
+
promise.catch(() => void 0);
|
|
2605
|
+
return promise;
|
|
2606
|
+
}
|
|
2607
|
+
var isSupported = () => typeof window !== "undefined" && window.isSecureContext && !!navigator.mediaDevices?.getUserMedia;
|
|
2608
|
+
function classifyTokenFailure(error) {
|
|
2609
|
+
const code3 = error?.code;
|
|
2610
|
+
if (code3 === "speech.identity_misconfigured" || code3 === "SP500")
|
|
2611
|
+
return "unavailable";
|
|
2612
|
+
if (error?.type === "NotFound") {
|
|
2613
|
+
return "unavailable";
|
|
2614
|
+
}
|
|
2615
|
+
return "unavailable-temporarily";
|
|
2616
|
+
}
|
|
2617
|
+
function useDictation({
|
|
2618
|
+
region,
|
|
2619
|
+
locale,
|
|
2620
|
+
getToken,
|
|
2621
|
+
onPhrase,
|
|
2622
|
+
onInterim,
|
|
2623
|
+
maxDurationMs = 18e4,
|
|
2624
|
+
idleTimeoutMs = 2e4
|
|
2625
|
+
}) {
|
|
2626
|
+
const [state, setState] = useState("idle");
|
|
2627
|
+
const [error, setError] = useState(null);
|
|
2628
|
+
const [deviceLabel, setDeviceLabel] = useState("");
|
|
2629
|
+
const [silent, setSilent] = useState(false);
|
|
2630
|
+
const sessionRef = useRef(null);
|
|
2631
|
+
const generationRef = useRef(0);
|
|
2632
|
+
const onPhraseRef = useRef(onPhrase);
|
|
2633
|
+
const onInterimRef = useRef(onInterim);
|
|
2634
|
+
useEffect(() => {
|
|
2635
|
+
onPhraseRef.current = onPhrase;
|
|
2636
|
+
onInterimRef.current = onInterim;
|
|
2637
|
+
});
|
|
2638
|
+
const clearInterim = useCallback(() => onInterimRef.current?.(""), []);
|
|
2639
|
+
const supported = isSupported();
|
|
2640
|
+
const available = supported && !!region && !!getToken;
|
|
2641
|
+
useEffect(() => {
|
|
2642
|
+
if (!available) return;
|
|
2643
|
+
const nav = navigator;
|
|
2644
|
+
if (nav.connection?.saveData) return;
|
|
2645
|
+
const warm = () => void kickOff(() => import('microsoft-cognitiveservices-speech-sdk'));
|
|
2646
|
+
if (typeof window.requestIdleCallback === "function") {
|
|
2647
|
+
const id2 = window.requestIdleCallback(warm, { timeout: 2e3 });
|
|
2648
|
+
return () => window.cancelIdleCallback(id2);
|
|
2649
|
+
}
|
|
2650
|
+
const id = window.setTimeout(warm, 1500);
|
|
2651
|
+
return () => window.clearTimeout(id);
|
|
2652
|
+
}, [available]);
|
|
2653
|
+
const stop = useCallback(() => {
|
|
2654
|
+
generationRef.current += 1;
|
|
2655
|
+
const session = sessionRef.current;
|
|
2656
|
+
sessionRef.current = null;
|
|
2657
|
+
clearInterim();
|
|
2658
|
+
setState("idle");
|
|
2659
|
+
setSilent(false);
|
|
2660
|
+
setDeviceLabel("");
|
|
2661
|
+
if (!session) return;
|
|
2662
|
+
window.clearTimeout(session.timers.idle);
|
|
2663
|
+
window.clearTimeout(session.timers.max);
|
|
2664
|
+
session.stopLevelMonitor();
|
|
2665
|
+
session.stream.getTracks().forEach((t) => t.stop());
|
|
2666
|
+
session.recognizer.stopContinuousRecognitionAsync(
|
|
2667
|
+
() => session.recognizer.close(),
|
|
2668
|
+
() => session.recognizer.close()
|
|
2669
|
+
);
|
|
2670
|
+
}, [clearInterim]);
|
|
2671
|
+
const start = useCallback(async () => {
|
|
2672
|
+
if (!available || sessionRef.current) return;
|
|
2673
|
+
const generation = ++generationRef.current;
|
|
2674
|
+
const superseded = () => generationRef.current !== generation;
|
|
2675
|
+
setError(null);
|
|
2676
|
+
setSilent(false);
|
|
2677
|
+
setState("starting");
|
|
2678
|
+
const streamPromise = kickOff(
|
|
2679
|
+
() => navigator.mediaDevices.getUserMedia({
|
|
2680
|
+
audio: {
|
|
2681
|
+
echoCancellation: true,
|
|
2682
|
+
noiseSuppression: true,
|
|
2683
|
+
autoGainControl: true
|
|
2684
|
+
}
|
|
2685
|
+
})
|
|
2686
|
+
);
|
|
2687
|
+
const tokenPromise = kickOff(getToken);
|
|
2688
|
+
const sdkPromise = kickOff(
|
|
2689
|
+
() => import('microsoft-cognitiveservices-speech-sdk')
|
|
2690
|
+
);
|
|
2691
|
+
let stream;
|
|
2692
|
+
try {
|
|
2693
|
+
stream = await streamPromise;
|
|
2694
|
+
} catch (e) {
|
|
2695
|
+
if (superseded()) return;
|
|
2696
|
+
const name = e?.name;
|
|
2697
|
+
setError(
|
|
2698
|
+
name === "NotAllowedError" || name === "SecurityError" ? "permission-denied" : name === "NotFoundError" || name === "OverconstrainedError" ? "no-microphone" : "unknown"
|
|
2699
|
+
);
|
|
2700
|
+
setState("idle");
|
|
2701
|
+
return;
|
|
2702
|
+
}
|
|
2703
|
+
if (superseded()) {
|
|
2704
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
2705
|
+
return;
|
|
2706
|
+
}
|
|
2707
|
+
let token;
|
|
2708
|
+
try {
|
|
2709
|
+
token = await tokenPromise;
|
|
2710
|
+
if (Date.parse(token.expiresOn) - Date.now() < STALE_TOKEN_FLOOR_MS) {
|
|
2711
|
+
token = await getToken();
|
|
2712
|
+
}
|
|
2713
|
+
} catch (e) {
|
|
2714
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
2715
|
+
if (superseded()) return;
|
|
2716
|
+
setError(classifyTokenFailure(e));
|
|
2717
|
+
setState("idle");
|
|
2718
|
+
return;
|
|
2719
|
+
}
|
|
2720
|
+
if (superseded()) {
|
|
2721
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
2722
|
+
return;
|
|
2723
|
+
}
|
|
2724
|
+
let recognizer = null;
|
|
2725
|
+
let published = null;
|
|
2726
|
+
try {
|
|
2727
|
+
const sdk = await sdkPromise;
|
|
2728
|
+
if (superseded()) {
|
|
2729
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
2730
|
+
return;
|
|
2731
|
+
}
|
|
2732
|
+
const speechConfig = sdk.SpeechConfig.fromAuthorizationToken(
|
|
2733
|
+
token.token,
|
|
2734
|
+
region
|
|
2735
|
+
);
|
|
2736
|
+
speechConfig.speechRecognitionLanguage = locale;
|
|
2737
|
+
speechConfig.setProfanity(sdk.ProfanityOption.Raw);
|
|
2738
|
+
speechConfig.setProperty(
|
|
2739
|
+
sdk.PropertyId.Speech_SegmentationSilenceTimeoutMs,
|
|
2740
|
+
"700"
|
|
2741
|
+
);
|
|
2742
|
+
recognizer = new sdk.SpeechRecognizer(
|
|
2743
|
+
speechConfig,
|
|
2744
|
+
sdk.AudioConfig.fromStreamInput(stream)
|
|
2745
|
+
);
|
|
2746
|
+
const untilExpiry = Date.parse(token.expiresOn) - Date.now() - TOKEN_EXPIRY_MARGIN_MS;
|
|
2747
|
+
const sessionCapMs = Number.isFinite(untilExpiry) && untilExpiry > 0 ? Math.min(maxDurationMs, untilExpiry) : maxDurationMs;
|
|
2748
|
+
const session = {
|
|
2749
|
+
recognizer,
|
|
2750
|
+
stream,
|
|
2751
|
+
timers: {},
|
|
2752
|
+
stopLevelMonitor: noLevelMonitor
|
|
2753
|
+
};
|
|
2754
|
+
const armIdle = () => {
|
|
2755
|
+
window.clearTimeout(session.timers.idle);
|
|
2756
|
+
session.timers.idle = window.setTimeout(stop, idleTimeoutMs);
|
|
2757
|
+
};
|
|
2758
|
+
const isLive = () => sessionRef.current === session;
|
|
2759
|
+
sessionRef.current = session;
|
|
2760
|
+
published = session;
|
|
2761
|
+
const goLive = () => {
|
|
2762
|
+
if (!isLive()) return;
|
|
2763
|
+
session.timers.max ??= window.setTimeout(stop, sessionCapMs);
|
|
2764
|
+
if (session.stopLevelMonitor === noLevelMonitor) {
|
|
2765
|
+
try {
|
|
2766
|
+
setDeviceLabel(stream.getAudioTracks()[0]?.label ?? "");
|
|
2767
|
+
session.stopLevelMonitor = monitorInputLevel(
|
|
2768
|
+
stream,
|
|
2769
|
+
() => {
|
|
2770
|
+
if (isLive()) setSilent(true);
|
|
2771
|
+
},
|
|
2772
|
+
() => {
|
|
2773
|
+
if (isLive()) setSilent(false);
|
|
2774
|
+
}
|
|
2775
|
+
);
|
|
2776
|
+
} catch {
|
|
2777
|
+
session.stopLevelMonitor = noLevelMonitor;
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
armIdle();
|
|
2781
|
+
setState("listening");
|
|
2782
|
+
};
|
|
2783
|
+
recognizer.sessionStarted = () => goLive();
|
|
2784
|
+
recognizer.recognizing = (_sender, event) => {
|
|
2785
|
+
if (!isLive()) return;
|
|
2786
|
+
onInterimRef.current?.(event.result.text ?? "");
|
|
2787
|
+
armIdle();
|
|
2788
|
+
};
|
|
2789
|
+
recognizer.recognized = (_sender, event) => {
|
|
2790
|
+
if (!isLive()) return;
|
|
2791
|
+
const text6 = event.result.text?.trim();
|
|
2792
|
+
clearInterim();
|
|
2793
|
+
if (event.result.reason === sdk.ResultReason.RecognizedSpeech && text6) {
|
|
2794
|
+
onPhraseRef.current(text6);
|
|
2795
|
+
}
|
|
2796
|
+
armIdle();
|
|
2797
|
+
};
|
|
2798
|
+
recognizer.canceled = (_sender, event) => {
|
|
2799
|
+
if (!isLive()) return;
|
|
2800
|
+
if (event.reason === sdk.CancellationReason.Error) {
|
|
2801
|
+
console.warn("[dictation] cancelled, errorCode:", event.errorCode);
|
|
2802
|
+
setError(
|
|
2803
|
+
event.errorCode === sdk.CancellationErrorCode.ConnectionFailure ? "network" : event.errorCode === sdk.CancellationErrorCode.AuthenticationFailure ? "unavailable-temporarily" : "unknown"
|
|
2804
|
+
);
|
|
2805
|
+
}
|
|
2806
|
+
stop();
|
|
2807
|
+
};
|
|
2808
|
+
recognizer.sessionStopped = () => {
|
|
2809
|
+
if (isLive()) stop();
|
|
2810
|
+
};
|
|
2811
|
+
try {
|
|
2812
|
+
const connection = sdk.Connection.fromRecognizer(recognizer);
|
|
2813
|
+
connection.connected = () => goLive();
|
|
2814
|
+
connection.openConnection();
|
|
2815
|
+
} catch {
|
|
2816
|
+
}
|
|
2817
|
+
await new Promise(
|
|
2818
|
+
(resolve, reject) => session.recognizer.startContinuousRecognitionAsync(resolve, reject)
|
|
2819
|
+
);
|
|
2820
|
+
goLive();
|
|
2821
|
+
} catch (e) {
|
|
2822
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
2823
|
+
try {
|
|
2824
|
+
recognizer?.close();
|
|
2825
|
+
} catch {
|
|
2826
|
+
}
|
|
2827
|
+
if (published) {
|
|
2828
|
+
window.clearTimeout(published.timers.idle);
|
|
2829
|
+
window.clearTimeout(published.timers.max);
|
|
2830
|
+
published.stopLevelMonitor();
|
|
2831
|
+
if (sessionRef.current === published) sessionRef.current = null;
|
|
2832
|
+
}
|
|
2833
|
+
if (superseded()) return;
|
|
2834
|
+
console.warn("[dictation] failed to start:", e);
|
|
2835
|
+
setError((prev) => prev ?? "unavailable-temporarily");
|
|
2836
|
+
setState("idle");
|
|
2837
|
+
}
|
|
2838
|
+
}, [
|
|
2839
|
+
available,
|
|
2840
|
+
clearInterim,
|
|
2841
|
+
getToken,
|
|
2842
|
+
idleTimeoutMs,
|
|
2843
|
+
locale,
|
|
2844
|
+
maxDurationMs,
|
|
2845
|
+
region,
|
|
2846
|
+
stop
|
|
2847
|
+
]);
|
|
2848
|
+
useEffect(() => stop, [stop]);
|
|
2849
|
+
const toggle = useCallback(() => {
|
|
2850
|
+
if (state === "idle") void start();
|
|
2851
|
+
else stop();
|
|
2852
|
+
}, [start, state, stop]);
|
|
2853
|
+
return {
|
|
2854
|
+
supported,
|
|
2855
|
+
available,
|
|
2856
|
+
state,
|
|
2857
|
+
error,
|
|
2858
|
+
/** Name of the microphone in use, once a session is live. May be ''. */
|
|
2859
|
+
deviceLabel,
|
|
2860
|
+
/** Listening, but the microphone has produced no sound for a while. */
|
|
2861
|
+
silent,
|
|
2862
|
+
start,
|
|
2863
|
+
stop,
|
|
2864
|
+
toggle
|
|
2865
|
+
};
|
|
2866
|
+
}
|
|
2435
2867
|
function useFlowRunVariables(flowRunId) {
|
|
2436
2868
|
const service = useChatService();
|
|
2437
2869
|
return useQuery({
|
|
@@ -2443,6 +2875,31 @@ function useFlowRunVariables(flowRunId) {
|
|
|
2443
2875
|
enabled: !!flowRunId
|
|
2444
2876
|
});
|
|
2445
2877
|
}
|
|
2878
|
+
|
|
2879
|
+
// src/chat-variables/renders/fieldStyles.ts
|
|
2880
|
+
var scaleFor = (surface) => surface === "form" ? "comfortable" : "dense";
|
|
2881
|
+
var fieldLabelClass = (scale) => `block truncate font-medium text-muted-foreground ${scale === "dense" ? "mb-1 text-xs" : "mb-1.5 text-sm"}`;
|
|
2882
|
+
var CONTROL_BASE = "rounded-md border bg-background text-foreground transition-colors placeholder:text-muted-foreground ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60";
|
|
2883
|
+
var borderClass = (hasError) => hasError ? "border-destructive" : "border-input";
|
|
2884
|
+
var fieldControlClass = (scale, hasError) => `w-full ${CONTROL_BASE} ${borderClass(hasError)} ${scale === "dense" ? "px-2.5 py-1.5 text-xs" : "px-3 py-2 text-sm"}`;
|
|
2885
|
+
var fieldTriggerClass = (scale, hasError) => `w-full ${CONTROL_BASE} ${borderClass(
|
|
2886
|
+
hasError
|
|
2887
|
+
)} flex items-center justify-between gap-2 text-left ${scale === "dense" ? "h-8 px-2.5 text-xs" : "h-10 px-3 text-sm"}`;
|
|
2888
|
+
var fieldNumberClass = (scale, hasError) => `${CONTROL_BASE} ${borderClass(hasError)} tabular-nums ${scale === "dense" ? "h-8 w-20 px-2 text-xs" : "h-10 w-24 px-2.5 text-sm"}`;
|
|
2889
|
+
var fieldHintClass = "mt-1 text-xs text-muted-foreground";
|
|
2890
|
+
var fieldErrorClass = "mt-1 text-xs text-destructive";
|
|
2891
|
+
var fieldRowClass = "flex items-center justify-between gap-3";
|
|
2892
|
+
var fieldRowLabelClass = (scale) => `min-w-0 flex-1 truncate font-medium text-muted-foreground ${scale === "dense" ? "text-xs" : "text-sm"}`;
|
|
2893
|
+
var pillClass = (opts) => `flex h-8 shrink-0 items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${opts.active ? "border-primary/30 bg-primary/10 text-primary" : "border-border/70 bg-transparent text-muted-foreground hover:bg-secondary"} ${opts.hasError ? "border-destructive text-destructive" : ""} ${opts.disabled ? "cursor-not-allowed opacity-60" : ""}`;
|
|
2894
|
+
var pillLabelClass = "max-w-[9rem] truncate";
|
|
2895
|
+
var pillValueClass = "max-w-[9rem] truncate text-foreground";
|
|
2896
|
+
var switchTrackClass = (on, disabled) => `peer inline-flex h-6 w-11 shrink-0 items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background ${on ? "bg-primary" : "bg-input"} ${disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"}`;
|
|
2897
|
+
var switchThumbClass = (on) => `pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform ${on ? "translate-x-5" : "translate-x-0"}`;
|
|
2898
|
+
var POPOVER_WIDTH_PX = 288;
|
|
2899
|
+
var POPOVER_MAX_HEIGHT_PX = 288;
|
|
2900
|
+
var popoverClass = "flex flex-col overflow-hidden rounded-xl border border-border bg-popover shadow-lg";
|
|
2901
|
+
var popoverRowClass = "flex w-full items-center gap-2.5 px-3 py-2 text-left transition-colors hover:bg-secondary/60";
|
|
2902
|
+
var popoverHeadingClass = "text-[10px] font-semibold uppercase tracking-wide text-muted-foreground";
|
|
2446
2903
|
function iconFor(label) {
|
|
2447
2904
|
const name = (label ?? "").toLowerCase();
|
|
2448
2905
|
if (/search|web|browse|internet/.test(name)) return Globe;
|
|
@@ -2458,7 +2915,8 @@ var BooleanRenderer = ({
|
|
|
2458
2915
|
errors,
|
|
2459
2916
|
uischema,
|
|
2460
2917
|
visible,
|
|
2461
|
-
enabled
|
|
2918
|
+
enabled,
|
|
2919
|
+
config
|
|
2462
2920
|
}) => {
|
|
2463
2921
|
const onToggle = useCallback(() => {
|
|
2464
2922
|
handleChange(path2, !data);
|
|
@@ -2469,13 +2927,17 @@ var BooleanRenderer = ({
|
|
|
2469
2927
|
const hasError = !!errors && errors.length > 0;
|
|
2470
2928
|
const isChecked = Boolean(data);
|
|
2471
2929
|
const Icon = iconFor(label);
|
|
2930
|
+
const surface = (config ?? {}).surface ?? "form";
|
|
2931
|
+
const scale = scaleFor(surface);
|
|
2472
2932
|
const tooltip = [label, description, hasError ? errors : null].filter(Boolean).join(" \u2014 ");
|
|
2473
|
-
|
|
2933
|
+
const toggle = /* @__PURE__ */ jsx(
|
|
2474
2934
|
"button",
|
|
2475
2935
|
{
|
|
2476
2936
|
id: `toggle-${path2}`,
|
|
2477
2937
|
type: "button",
|
|
2478
|
-
"
|
|
2938
|
+
role: surface === "bar" ? void 0 : "switch",
|
|
2939
|
+
"aria-pressed": surface === "bar" ? isChecked : void 0,
|
|
2940
|
+
"aria-checked": surface === "bar" ? void 0 : isChecked,
|
|
2479
2941
|
"aria-label": label,
|
|
2480
2942
|
title: tooltip || void 0,
|
|
2481
2943
|
onClick: onToggle,
|
|
@@ -2485,16 +2947,28 @@ var BooleanRenderer = ({
|
|
|
2485
2947
|
e.currentTarget.blur();
|
|
2486
2948
|
}
|
|
2487
2949
|
},
|
|
2488
|
-
className:
|
|
2489
|
-
|
|
2950
|
+
className: surface === "bar" ? `boolean-switch ${pillClass({
|
|
2951
|
+
active: isChecked,
|
|
2952
|
+
hasError,
|
|
2953
|
+
disabled: isDisabled
|
|
2954
|
+
})}` : switchTrackClass(isChecked, isDisabled),
|
|
2955
|
+
children: surface === "bar" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2490
2956
|
/* @__PURE__ */ jsx(Icon, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
2491
2957
|
label && // Desktop-first: the app and the package each ship a full Tailwind
|
|
2492
|
-
// build, so a base `hidden` can out-order `sm:inline`.
|
|
2493
|
-
// is the form that survives both cascades.
|
|
2494
|
-
/* @__PURE__ */ jsx("span", { className:
|
|
2495
|
-
]
|
|
2958
|
+
// build, so a base `hidden` can out-order `sm:inline`.
|
|
2959
|
+
// `max-sm:hidden` is the form that survives both cascades.
|
|
2960
|
+
/* @__PURE__ */ jsx("span", { className: `inline ${pillLabelClass} max-sm:hidden`, children: label })
|
|
2961
|
+
] }) : /* @__PURE__ */ jsx("span", { className: switchThumbClass(isChecked) })
|
|
2496
2962
|
}
|
|
2497
2963
|
);
|
|
2964
|
+
if (surface === "bar") return toggle;
|
|
2965
|
+
return /* @__PURE__ */ jsxs("div", { className: "ss-jsonforms-field ss-jsonforms-boolean", children: [
|
|
2966
|
+
/* @__PURE__ */ jsxs("div", { className: fieldRowClass, children: [
|
|
2967
|
+
/* @__PURE__ */ jsx("label", { htmlFor: `toggle-${path2}`, className: fieldRowLabelClass(scale), children: label }),
|
|
2968
|
+
toggle
|
|
2969
|
+
] }),
|
|
2970
|
+
hasError && /* @__PURE__ */ jsx("div", { className: fieldErrorClass, children: errors })
|
|
2971
|
+
] });
|
|
2498
2972
|
};
|
|
2499
2973
|
var booleanRendererTester = rankWith(40, (uischema, schema) => {
|
|
2500
2974
|
if (uischema.type !== "Control") return false;
|
|
@@ -2504,6 +2978,104 @@ var booleanRendererTester = rankWith(40, (uischema, schema) => {
|
|
|
2504
2978
|
return fieldSchema?.type === "boolean";
|
|
2505
2979
|
});
|
|
2506
2980
|
var BooleanRendererControl = withJsonFormsControlProps(BooleanRenderer);
|
|
2981
|
+
var GAP_PX = 8;
|
|
2982
|
+
var MIN_TRIGGER_WIDTH_PX = 224;
|
|
2983
|
+
var MIN_PANEL_HEIGHT_PX = 180;
|
|
2984
|
+
var NestedPopoverContext = React9__default.createContext(null);
|
|
2985
|
+
function useAnchoredPopover({
|
|
2986
|
+
trigger,
|
|
2987
|
+
popover,
|
|
2988
|
+
width,
|
|
2989
|
+
maxHeight,
|
|
2990
|
+
role,
|
|
2991
|
+
label
|
|
2992
|
+
}) {
|
|
2993
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
2994
|
+
const parentRegistry = useContext(NestedPopoverContext);
|
|
2995
|
+
const descendants = useRef(/* @__PURE__ */ new Set());
|
|
2996
|
+
const close = useCallback(() => setIsOpen(false), []);
|
|
2997
|
+
const toggle = useCallback(() => setIsOpen((open) => !open), []);
|
|
2998
|
+
const registry = useMemo(
|
|
2999
|
+
() => ({
|
|
3000
|
+
register: (el) => {
|
|
3001
|
+
descendants.current.add(el);
|
|
3002
|
+
parentRegistry?.register(el);
|
|
3003
|
+
},
|
|
3004
|
+
unregister: (el) => {
|
|
3005
|
+
descendants.current.delete(el);
|
|
3006
|
+
parentRegistry?.unregister(el);
|
|
3007
|
+
}
|
|
3008
|
+
}),
|
|
3009
|
+
[parentRegistry]
|
|
3010
|
+
);
|
|
3011
|
+
useEffect(() => {
|
|
3012
|
+
if (!isOpen || !parentRegistry) return;
|
|
3013
|
+
const el = popover.current;
|
|
3014
|
+
if (!el) return;
|
|
3015
|
+
parentRegistry.register(el);
|
|
3016
|
+
return () => parentRegistry.unregister(el);
|
|
3017
|
+
}, [isOpen, parentRegistry, popover]);
|
|
3018
|
+
useEffect(() => {
|
|
3019
|
+
if (!isOpen) return;
|
|
3020
|
+
const onPointerDown = (event) => {
|
|
3021
|
+
const target = event.target;
|
|
3022
|
+
if (trigger.current?.contains(target)) return;
|
|
3023
|
+
if (popover.current?.contains(target)) return;
|
|
3024
|
+
for (const el of descendants.current) {
|
|
3025
|
+
if (el.contains(target)) return;
|
|
3026
|
+
}
|
|
3027
|
+
close();
|
|
3028
|
+
};
|
|
3029
|
+
const onKeyDown = (event) => {
|
|
3030
|
+
if (event.key === "Escape") close();
|
|
3031
|
+
};
|
|
3032
|
+
document.addEventListener("mousedown", onPointerDown);
|
|
3033
|
+
document.addEventListener("keydown", onKeyDown);
|
|
3034
|
+
window.addEventListener("resize", close);
|
|
3035
|
+
return () => {
|
|
3036
|
+
document.removeEventListener("mousedown", onPointerDown);
|
|
3037
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
3038
|
+
window.removeEventListener("resize", close);
|
|
3039
|
+
};
|
|
3040
|
+
}, [isOpen, close, trigger, popover]);
|
|
3041
|
+
const renderPopover = (children2) => {
|
|
3042
|
+
if (!isOpen) return null;
|
|
3043
|
+
const anchor = trigger.current?.getBoundingClientRect();
|
|
3044
|
+
if (!anchor) return null;
|
|
3045
|
+
const panelWidth = width === "trigger" ? Math.max(anchor.width, MIN_TRIGGER_WIDTH_PX) : width;
|
|
3046
|
+
const spaceAbove = anchor.top - GAP_PX * 2;
|
|
3047
|
+
const spaceBelow = window.innerHeight - anchor.bottom - GAP_PX * 2;
|
|
3048
|
+
const openAbove = spaceAbove >= MIN_PANEL_HEIGHT_PX || spaceAbove >= spaceBelow;
|
|
3049
|
+
const panelMaxHeight = Math.max(
|
|
3050
|
+
0,
|
|
3051
|
+
Math.min(maxHeight, openAbove ? spaceAbove : spaceBelow)
|
|
3052
|
+
);
|
|
3053
|
+
return createPortal(
|
|
3054
|
+
/* @__PURE__ */ jsx(
|
|
3055
|
+
"div",
|
|
3056
|
+
{
|
|
3057
|
+
ref: popover,
|
|
3058
|
+
role,
|
|
3059
|
+
"aria-label": label,
|
|
3060
|
+
className: `fixed z-50 ${popoverClass}`,
|
|
3061
|
+
style: {
|
|
3062
|
+
width: panelWidth,
|
|
3063
|
+
maxWidth: `calc(100vw - ${GAP_PX * 4}px)`,
|
|
3064
|
+
left: Math.max(
|
|
3065
|
+
GAP_PX,
|
|
3066
|
+
Math.min(anchor.left, window.innerWidth - panelWidth - GAP_PX)
|
|
3067
|
+
),
|
|
3068
|
+
...openAbove ? { bottom: window.innerHeight - anchor.top + GAP_PX } : { top: anchor.bottom + GAP_PX },
|
|
3069
|
+
maxHeight: panelMaxHeight
|
|
3070
|
+
},
|
|
3071
|
+
children: /* @__PURE__ */ jsx(NestedPopoverContext.Provider, { value: registry, children: children2 })
|
|
3072
|
+
}
|
|
3073
|
+
),
|
|
3074
|
+
document.body
|
|
3075
|
+
);
|
|
3076
|
+
};
|
|
3077
|
+
return { isOpen, close, toggle, renderPopover };
|
|
3078
|
+
}
|
|
2507
3079
|
function hasConst(x) {
|
|
2508
3080
|
return !!x && typeof x === "object" && "const" in x;
|
|
2509
3081
|
}
|
|
@@ -2542,185 +3114,109 @@ var DropdownRenderer = ({
|
|
|
2542
3114
|
label,
|
|
2543
3115
|
description,
|
|
2544
3116
|
errors,
|
|
2545
|
-
|
|
3117
|
+
config,
|
|
3118
|
+
uischema,
|
|
3119
|
+
visible
|
|
2546
3120
|
}) => {
|
|
3121
|
+
const triggerRef = useRef(null);
|
|
3122
|
+
const listRef = useRef(null);
|
|
3123
|
+
const surface = (config ?? {}).surface ?? "form";
|
|
3124
|
+
const scale = scaleFor(surface);
|
|
3125
|
+
const { isOpen, close, toggle, renderPopover } = useAnchoredPopover({
|
|
3126
|
+
trigger: triggerRef,
|
|
3127
|
+
popover: listRef,
|
|
3128
|
+
// A select's list lines up with its own control.
|
|
3129
|
+
width: "trigger",
|
|
3130
|
+
maxHeight: POPOVER_MAX_HEIGHT_PX,
|
|
3131
|
+
role: "listbox",
|
|
3132
|
+
label: label || "Options"
|
|
3133
|
+
});
|
|
2547
3134
|
const options = toOptions(schema);
|
|
2548
|
-
const
|
|
2549
|
-
(
|
|
2550
|
-
handleChange(path2,
|
|
3135
|
+
const select = useCallback(
|
|
3136
|
+
(value) => {
|
|
3137
|
+
handleChange(path2, value);
|
|
3138
|
+
close();
|
|
2551
3139
|
},
|
|
2552
|
-
[handleChange, path2]
|
|
3140
|
+
[handleChange, path2, close]
|
|
2553
3141
|
);
|
|
2554
|
-
|
|
3142
|
+
if (!visible) return null;
|
|
2555
3143
|
const readOnly = uischema?.access === "Read";
|
|
2556
3144
|
const isDisabled = !enabled || readOnly;
|
|
2557
|
-
|
|
2558
|
-
|
|
3145
|
+
const hasError = !!errors;
|
|
3146
|
+
const selected = options.find((option) => option.const === data);
|
|
3147
|
+
const valueText = selected ? selected.title ?? String(selected.const) : data != null && data !== "" ? String(data) : "";
|
|
3148
|
+
const triggerId = `${path2}-trigger`;
|
|
3149
|
+
const isBar = surface === "bar";
|
|
3150
|
+
const placeholder = `Select ${(label || "value").toLowerCase()}\u2026`;
|
|
3151
|
+
const trigger = /* @__PURE__ */ jsxs(
|
|
3152
|
+
"button",
|
|
2559
3153
|
{
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
error: !!errors,
|
|
3154
|
+
id: triggerId,
|
|
3155
|
+
ref: triggerRef,
|
|
3156
|
+
type: "button",
|
|
2564
3157
|
disabled: isDisabled,
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
3158
|
+
onClick: toggle,
|
|
3159
|
+
"aria-haspopup": "listbox",
|
|
3160
|
+
"aria-expanded": isOpen,
|
|
3161
|
+
"aria-label": label,
|
|
3162
|
+
title: [label, valueText, hasError ? errors : null].filter(Boolean).join(" \u2014 ") || void 0,
|
|
3163
|
+
className: isBar ? `ss-jsonforms-select-trigger ${pillClass({
|
|
3164
|
+
active: isOpen,
|
|
3165
|
+
hasError,
|
|
3166
|
+
disabled: isDisabled
|
|
3167
|
+
})}` : `ss-jsonforms-select-trigger ${fieldTriggerClass(scale, hasError)}`,
|
|
2569
3168
|
children: [
|
|
3169
|
+
isBar && label && /* @__PURE__ */ jsx("span", { className: `inline ${pillLabelClass} max-sm:hidden`, children: label }),
|
|
2570
3170
|
/* @__PURE__ */ jsx(
|
|
2571
|
-
|
|
3171
|
+
"span",
|
|
2572
3172
|
{
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
color: "#6b7280",
|
|
2576
|
-
fontSize: "0.875rem",
|
|
2577
|
-
fontWeight: 500,
|
|
2578
|
-
"&.Mui-focused": {
|
|
2579
|
-
color: "#6366f1"
|
|
2580
|
-
},
|
|
2581
|
-
"&.Mui-error": {
|
|
2582
|
-
color: "#ef4444"
|
|
2583
|
-
}
|
|
2584
|
-
},
|
|
2585
|
-
children: label
|
|
3173
|
+
className: isBar ? pillValueClass : `min-w-0 flex-1 truncate ${valueText ? "" : "text-muted-foreground"}`,
|
|
3174
|
+
children: valueText || (isBar ? "\u2014" : placeholder)
|
|
2586
3175
|
}
|
|
2587
3176
|
),
|
|
2588
3177
|
/* @__PURE__ */ jsx(
|
|
2589
|
-
|
|
3178
|
+
ChevronDown,
|
|
2590
3179
|
{
|
|
2591
|
-
|
|
2592
|
-
value: displayValue,
|
|
2593
|
-
onChange: handleSelectionChange,
|
|
2594
|
-
label,
|
|
2595
|
-
sx: {
|
|
2596
|
-
"& .MuiOutlinedInput-root": {
|
|
2597
|
-
backgroundColor: "#fafafa",
|
|
2598
|
-
borderRadius: "8px",
|
|
2599
|
-
transition: "all 0.2s ease-in-out",
|
|
2600
|
-
height: "40px",
|
|
2601
|
-
// Same height as model dropdown
|
|
2602
|
-
"& fieldset": {
|
|
2603
|
-
borderColor: "#e5e7eb",
|
|
2604
|
-
borderWidth: "1px"
|
|
2605
|
-
},
|
|
2606
|
-
"&:hover": {
|
|
2607
|
-
backgroundColor: "#ffffff",
|
|
2608
|
-
"& fieldset": {
|
|
2609
|
-
borderColor: "#9ca3af"
|
|
2610
|
-
}
|
|
2611
|
-
},
|
|
2612
|
-
"&.Mui-focused": {
|
|
2613
|
-
backgroundColor: "#ffffff",
|
|
2614
|
-
"& fieldset": {
|
|
2615
|
-
borderColor: "#6366f1",
|
|
2616
|
-
borderWidth: "2px"
|
|
2617
|
-
}
|
|
2618
|
-
},
|
|
2619
|
-
"&.Mui-error": {
|
|
2620
|
-
"& fieldset": {
|
|
2621
|
-
borderColor: "#ef4444"
|
|
2622
|
-
}
|
|
2623
|
-
}
|
|
2624
|
-
},
|
|
2625
|
-
"& .MuiSelect-select": {
|
|
2626
|
-
backgroundColor: "#fafafa",
|
|
2627
|
-
borderRadius: "8px",
|
|
2628
|
-
transition: "all 0.2s ease-in-out",
|
|
2629
|
-
height: "40px",
|
|
2630
|
-
display: "flex",
|
|
2631
|
-
alignItems: "center",
|
|
2632
|
-
paddingRight: "32px !important",
|
|
2633
|
-
"&:hover": {
|
|
2634
|
-
backgroundColor: "#ffffff"
|
|
2635
|
-
},
|
|
2636
|
-
"&.Mui-focused": {
|
|
2637
|
-
backgroundColor: "#ffffff"
|
|
2638
|
-
}
|
|
2639
|
-
},
|
|
2640
|
-
"& .MuiOutlinedInput-notchedOutline": {
|
|
2641
|
-
borderColor: "#e5e7eb",
|
|
2642
|
-
borderWidth: "1px",
|
|
2643
|
-
borderRadius: "8px"
|
|
2644
|
-
},
|
|
2645
|
-
"&:hover .MuiOutlinedInput-notchedOutline": {
|
|
2646
|
-
borderColor: "#9ca3af"
|
|
2647
|
-
},
|
|
2648
|
-
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
|
2649
|
-
borderColor: "#6366f1",
|
|
2650
|
-
borderWidth: "2px"
|
|
2651
|
-
},
|
|
2652
|
-
"&.Mui-error .MuiOutlinedInput-notchedOutline": {
|
|
2653
|
-
borderColor: "#ef4444"
|
|
2654
|
-
},
|
|
2655
|
-
"& .MuiSelect-icon": {
|
|
2656
|
-
color: "#9ca3af",
|
|
2657
|
-
"&:hover": {
|
|
2658
|
-
color: "#6b7280"
|
|
2659
|
-
}
|
|
2660
|
-
}
|
|
2661
|
-
},
|
|
2662
|
-
MenuProps: {
|
|
2663
|
-
PaperProps: {
|
|
2664
|
-
sx: {
|
|
2665
|
-
borderRadius: "8px",
|
|
2666
|
-
boxShadow: "0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
|
|
2667
|
-
border: "1px solid #e5e7eb",
|
|
2668
|
-
marginTop: "4px",
|
|
2669
|
-
maxHeight: "280px"
|
|
2670
|
-
}
|
|
2671
|
-
},
|
|
2672
|
-
MenuListProps: {
|
|
2673
|
-
sx: {
|
|
2674
|
-
padding: 0
|
|
2675
|
-
}
|
|
2676
|
-
}
|
|
2677
|
-
},
|
|
2678
|
-
children: options.map((option, index) => {
|
|
2679
|
-
const raw2 = option.const;
|
|
2680
|
-
const key = typeof raw2 === "string" || typeof raw2 === "number" ? String(raw2) : String(index);
|
|
2681
|
-
const value = typeof raw2 === "string" || typeof raw2 === "number" ? raw2 : String(raw2 ?? index);
|
|
2682
|
-
return /* @__PURE__ */ jsx(
|
|
2683
|
-
MenuItem,
|
|
2684
|
-
{
|
|
2685
|
-
value,
|
|
2686
|
-
sx: {
|
|
2687
|
-
padding: "12px 16px",
|
|
2688
|
-
fontSize: "0.875rem",
|
|
2689
|
-
borderBottom: "1px solid #f3f4f6",
|
|
2690
|
-
"&:last-child": {
|
|
2691
|
-
borderBottom: "none"
|
|
2692
|
-
},
|
|
2693
|
-
"&:hover": {
|
|
2694
|
-
backgroundColor: "#f8fafc"
|
|
2695
|
-
},
|
|
2696
|
-
"&.Mui-selected": {
|
|
2697
|
-
backgroundColor: "#eff6ff",
|
|
2698
|
-
"&:hover": {
|
|
2699
|
-
backgroundColor: "#dbeafe"
|
|
2700
|
-
}
|
|
2701
|
-
}
|
|
2702
|
-
},
|
|
2703
|
-
children: option.title ?? String(raw2)
|
|
2704
|
-
},
|
|
2705
|
-
key
|
|
2706
|
-
);
|
|
2707
|
-
})
|
|
2708
|
-
}
|
|
2709
|
-
),
|
|
2710
|
-
(description || errors) && /* @__PURE__ */ jsx(
|
|
2711
|
-
"div",
|
|
2712
|
-
{
|
|
2713
|
-
style: {
|
|
2714
|
-
fontSize: "0.75rem",
|
|
2715
|
-
marginTop: "4px",
|
|
2716
|
-
color: errors ? "#ef4444" : "#6b7280"
|
|
2717
|
-
},
|
|
2718
|
-
children: errors || description
|
|
3180
|
+
className: `shrink-0 opacity-50 ${isBar ? "h-3 w-3" : "h-4 w-4"}`
|
|
2719
3181
|
}
|
|
2720
3182
|
)
|
|
2721
3183
|
]
|
|
2722
3184
|
}
|
|
2723
3185
|
);
|
|
3186
|
+
return /* @__PURE__ */ jsxs("div", { className: "ss-jsonforms-field ss-jsonforms-select compact-field", children: [
|
|
3187
|
+
!isBar && label && /* @__PURE__ */ jsx("label", { htmlFor: triggerId, className: fieldLabelClass(scale), children: label }),
|
|
3188
|
+
trigger,
|
|
3189
|
+
!isBar && (errors || description) && /* @__PURE__ */ jsx("div", { className: errors ? fieldErrorClass : fieldHintClass, children: errors || description }),
|
|
3190
|
+
renderPopover(
|
|
3191
|
+
/* @__PURE__ */ jsxs("div", { className: "min-h-0 overflow-y-auto py-1", children: [
|
|
3192
|
+
options.length === 0 && /* @__PURE__ */ jsx("p", { className: "px-3 py-6 text-center text-xs text-muted-foreground", children: "No options available" }),
|
|
3193
|
+
options.map((option, index) => {
|
|
3194
|
+
const active = option.const === data;
|
|
3195
|
+
const text6 = option.title ?? String(option.const);
|
|
3196
|
+
return /* @__PURE__ */ jsxs(
|
|
3197
|
+
"button",
|
|
3198
|
+
{
|
|
3199
|
+
type: "button",
|
|
3200
|
+
role: "option",
|
|
3201
|
+
"aria-selected": active,
|
|
3202
|
+
onClick: () => select(option.const),
|
|
3203
|
+
className: popoverRowClass,
|
|
3204
|
+
children: [
|
|
3205
|
+
/* @__PURE__ */ jsx(
|
|
3206
|
+
Check,
|
|
3207
|
+
{
|
|
3208
|
+
className: `h-3.5 w-3.5 shrink-0 ${active ? "text-primary" : "opacity-0"}`
|
|
3209
|
+
}
|
|
3210
|
+
),
|
|
3211
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-sm text-foreground", children: text6 })
|
|
3212
|
+
]
|
|
3213
|
+
},
|
|
3214
|
+
typeof option.const === "string" || typeof option.const === "number" ? String(option.const) : `option-${index}`
|
|
3215
|
+
);
|
|
3216
|
+
})
|
|
3217
|
+
] })
|
|
3218
|
+
)
|
|
3219
|
+
] });
|
|
2724
3220
|
};
|
|
2725
3221
|
var dropdownRendererTester = rankWith(
|
|
2726
3222
|
90,
|
|
@@ -2738,8 +3234,8 @@ var dropdownRendererTester = rankWith(
|
|
|
2738
3234
|
return false;
|
|
2739
3235
|
}
|
|
2740
3236
|
const hasDropdownOptions = !!(fieldSchema.oneOf || fieldSchema.anyOf || fieldSchema.enum && Array.isArray(fieldSchema.enum));
|
|
2741
|
-
const
|
|
2742
|
-
return hasDropdownOptions && !
|
|
3237
|
+
const isModelSelector2 = typeof fieldSchema === "object" && fieldSchema && fieldSchema["x-model-selector"] === true || fieldSchema.title === "ModelId" || fieldSchema.format === "uuid";
|
|
3238
|
+
return hasDropdownOptions && !isModelSelector2;
|
|
2743
3239
|
}
|
|
2744
3240
|
);
|
|
2745
3241
|
var DropdownRendererControl = withJsonFormsControlProps(DropdownRenderer);
|
|
@@ -2774,7 +3270,8 @@ var JsonEditorRenderer = ({
|
|
|
2774
3270
|
uischema,
|
|
2775
3271
|
visible,
|
|
2776
3272
|
enabled,
|
|
2777
|
-
required
|
|
3273
|
+
required,
|
|
3274
|
+
config
|
|
2778
3275
|
}) => {
|
|
2779
3276
|
const [jsonValue, setJsonValue] = useState("");
|
|
2780
3277
|
const [displayedParseError, setDisplayedParseError] = useState(
|
|
@@ -2828,43 +3325,19 @@ var JsonEditorRenderer = ({
|
|
|
2828
3325
|
}
|
|
2829
3326
|
const readOnly = uischema?.access === "Read";
|
|
2830
3327
|
const isDisabled = !enabled || readOnly;
|
|
3328
|
+
const scale = scaleFor(
|
|
3329
|
+
(config ?? {}).surface ?? "form"
|
|
3330
|
+
);
|
|
2831
3331
|
return /* @__PURE__ */ jsxs("div", { style: { marginBottom: "1rem" }, children: [
|
|
2832
|
-
label && /* @__PURE__ */ jsxs(
|
|
2833
|
-
|
|
2834
|
-
{
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
color: "#475569",
|
|
2838
|
-
fontSize: "0.875rem",
|
|
2839
|
-
fontWeight: 500,
|
|
2840
|
-
marginBottom: "0.375rem"
|
|
2841
|
-
},
|
|
2842
|
-
children: [
|
|
2843
|
-
label,
|
|
2844
|
-
required && /* @__PURE__ */ jsx("span", { style: { color: "#ef4444", marginLeft: "0.25rem" }, children: "*" })
|
|
2845
|
-
]
|
|
2846
|
-
}
|
|
2847
|
-
),
|
|
2848
|
-
description && /* @__PURE__ */ jsx(
|
|
2849
|
-
"div",
|
|
2850
|
-
{
|
|
2851
|
-
style: {
|
|
2852
|
-
color: "#6b7280",
|
|
2853
|
-
fontSize: "0.75rem",
|
|
2854
|
-
marginBottom: "0.5rem"
|
|
2855
|
-
},
|
|
2856
|
-
children: description
|
|
2857
|
-
}
|
|
2858
|
-
),
|
|
3332
|
+
label && /* @__PURE__ */ jsxs("label", { className: fieldLabelClass(scale), children: [
|
|
3333
|
+
label,
|
|
3334
|
+
required && /* @__PURE__ */ jsx("span", { className: "ml-1 text-destructive", children: "*" })
|
|
3335
|
+
] }),
|
|
3336
|
+
description && /* @__PURE__ */ jsx("div", { className: fieldHintClass, children: description }),
|
|
2859
3337
|
/* @__PURE__ */ jsx(
|
|
2860
3338
|
"div",
|
|
2861
3339
|
{
|
|
2862
|
-
|
|
2863
|
-
border: errors || displayedParseError ? "1px solid #ef4444" : "1px solid #d1d5db",
|
|
2864
|
-
borderRadius: "6px",
|
|
2865
|
-
overflow: "hidden",
|
|
2866
|
-
opacity: isDisabled ? 0.6 : 1
|
|
2867
|
-
},
|
|
3340
|
+
className: `overflow-hidden rounded-md border ${errors || displayedParseError ? "border-destructive" : "border-input"} ${isDisabled ? "opacity-60" : ""}`,
|
|
2868
3341
|
children: /* @__PURE__ */ jsx(
|
|
2869
3342
|
AceEditor,
|
|
2870
3343
|
{
|
|
@@ -2897,28 +3370,8 @@ var JsonEditorRenderer = ({
|
|
|
2897
3370
|
)
|
|
2898
3371
|
}
|
|
2899
3372
|
),
|
|
2900
|
-
displayedParseError && /* @__PURE__ */ jsx(
|
|
2901
|
-
|
|
2902
|
-
{
|
|
2903
|
-
style: {
|
|
2904
|
-
color: "#ef4444",
|
|
2905
|
-
fontSize: "0.75rem",
|
|
2906
|
-
marginTop: "0.25rem"
|
|
2907
|
-
},
|
|
2908
|
-
children: displayedParseError
|
|
2909
|
-
}
|
|
2910
|
-
),
|
|
2911
|
-
errors && /* @__PURE__ */ jsx(
|
|
2912
|
-
"div",
|
|
2913
|
-
{
|
|
2914
|
-
style: {
|
|
2915
|
-
color: "#ef4444",
|
|
2916
|
-
fontSize: "0.75rem",
|
|
2917
|
-
marginTop: "0.25rem"
|
|
2918
|
-
},
|
|
2919
|
-
children: errors
|
|
2920
|
-
}
|
|
2921
|
-
)
|
|
3373
|
+
displayedParseError && /* @__PURE__ */ jsx("div", { className: fieldErrorClass, children: displayedParseError }),
|
|
3374
|
+
errors && /* @__PURE__ */ jsx("div", { className: fieldErrorClass, children: errors })
|
|
2922
3375
|
] });
|
|
2923
3376
|
};
|
|
2924
3377
|
var jsonEditorTester = rankWith(
|
|
@@ -3009,14 +3462,31 @@ var ModelIdRenderer = ({
|
|
|
3009
3462
|
description,
|
|
3010
3463
|
errors,
|
|
3011
3464
|
uischema,
|
|
3012
|
-
visible
|
|
3465
|
+
visible,
|
|
3466
|
+
config
|
|
3013
3467
|
}) => {
|
|
3014
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
3015
3468
|
const [searchValue, setSearchValue] = useState("");
|
|
3016
3469
|
const [debouncedSearchValue, setDebouncedSearchValue] = useState("");
|
|
3017
|
-
const
|
|
3470
|
+
const triggerRef = useRef(null);
|
|
3018
3471
|
const menuRef = useRef(null);
|
|
3019
3472
|
const searchRef = useRef(null);
|
|
3473
|
+
const surface = (config ?? {}).surface ?? "bar";
|
|
3474
|
+
const scale = scaleFor(surface);
|
|
3475
|
+
const isBar = surface === "bar";
|
|
3476
|
+
const {
|
|
3477
|
+
isOpen,
|
|
3478
|
+
close: closeMenu,
|
|
3479
|
+
toggle,
|
|
3480
|
+
renderPopover
|
|
3481
|
+
} = useAnchoredPopover({
|
|
3482
|
+
trigger: triggerRef,
|
|
3483
|
+
popover: menuRef,
|
|
3484
|
+
// Wide enough for a provider glyph, a model name and its id underneath.
|
|
3485
|
+
width: POPOVER_WIDTH_PX,
|
|
3486
|
+
maxHeight: POPOVER_MAX_HEIGHT_PX,
|
|
3487
|
+
role: "listbox",
|
|
3488
|
+
label: "Models"
|
|
3489
|
+
});
|
|
3020
3490
|
const debounceTimerRef = useRef(
|
|
3021
3491
|
void 0
|
|
3022
3492
|
);
|
|
@@ -3055,35 +3525,13 @@ var ModelIdRenderer = ({
|
|
|
3055
3525
|
handleChange(path2, model.id);
|
|
3056
3526
|
setSearchValue("");
|
|
3057
3527
|
setDebouncedSearchValue("");
|
|
3058
|
-
|
|
3528
|
+
closeMenu();
|
|
3059
3529
|
},
|
|
3060
|
-
[handleChange, path2]
|
|
3530
|
+
[handleChange, path2, closeMenu]
|
|
3061
3531
|
);
|
|
3062
|
-
const close = useCallback(() => {
|
|
3063
|
-
setIsOpen(false);
|
|
3064
|
-
setSearchValue("");
|
|
3065
|
-
}, []);
|
|
3066
3532
|
useEffect(() => {
|
|
3067
|
-
if (!isOpen)
|
|
3068
|
-
|
|
3069
|
-
const target = event.target;
|
|
3070
|
-
if (containerRef.current && !containerRef.current.contains(target) && !(menuRef.current && menuRef.current.contains(target))) {
|
|
3071
|
-
close();
|
|
3072
|
-
}
|
|
3073
|
-
};
|
|
3074
|
-
const onKeyDown = (event) => {
|
|
3075
|
-
if (event.key === "Escape") close();
|
|
3076
|
-
};
|
|
3077
|
-
const onResize = () => close();
|
|
3078
|
-
document.addEventListener("mousedown", onPointerDown);
|
|
3079
|
-
document.addEventListener("keydown", onKeyDown);
|
|
3080
|
-
window.addEventListener("resize", onResize);
|
|
3081
|
-
return () => {
|
|
3082
|
-
document.removeEventListener("mousedown", onPointerDown);
|
|
3083
|
-
document.removeEventListener("keydown", onKeyDown);
|
|
3084
|
-
window.removeEventListener("resize", onResize);
|
|
3085
|
-
};
|
|
3086
|
-
}, [isOpen, close]);
|
|
3533
|
+
if (!isOpen) setSearchValue("");
|
|
3534
|
+
}, [isOpen]);
|
|
3087
3535
|
useEffect(() => {
|
|
3088
3536
|
if (isOpen) searchRef.current?.focus();
|
|
3089
3537
|
}, [isOpen]);
|
|
@@ -3092,53 +3540,58 @@ var ModelIdRenderer = ({
|
|
|
3092
3540
|
const isDisabled = !enabled || readOnly;
|
|
3093
3541
|
const hasError = !!errors && errors.length > 0;
|
|
3094
3542
|
const selectedName = selectedModel ? selectedModel.displayName || selectedModel.name || "" : "";
|
|
3095
|
-
const triggerText = selectedName ||
|
|
3543
|
+
const triggerText = selectedName || "Select model";
|
|
3096
3544
|
const iconSrc = getModelIcon(selectedModel);
|
|
3097
3545
|
const tooltip = [selectedName || label, description, hasError ? errors : null].filter(Boolean).join(" \u2014 ");
|
|
3098
|
-
const
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3546
|
+
const triggerLabel = !label || label === "ModelId" ? "Model" : label;
|
|
3547
|
+
const trigger = /* @__PURE__ */ jsxs(
|
|
3548
|
+
"button",
|
|
3549
|
+
{
|
|
3550
|
+
ref: triggerRef,
|
|
3551
|
+
id: `${path2}-trigger`,
|
|
3552
|
+
type: "button",
|
|
3553
|
+
onClick: toggle,
|
|
3554
|
+
disabled: isDisabled,
|
|
3555
|
+
"aria-expanded": isOpen,
|
|
3556
|
+
"aria-haspopup": "listbox",
|
|
3557
|
+
"aria-label": triggerLabel,
|
|
3558
|
+
title: tooltip || void 0,
|
|
3559
|
+
className: isBar ? pillClass({ active: isOpen, hasError, disabled: isDisabled }) : fieldTriggerClass(scale, hasError),
|
|
3560
|
+
children: [
|
|
3561
|
+
iconSrc ? /* @__PURE__ */ jsx(
|
|
3562
|
+
"img",
|
|
3563
|
+
{
|
|
3564
|
+
src: iconSrc,
|
|
3565
|
+
alt: "",
|
|
3566
|
+
className: "h-3.5 w-3.5 shrink-0 object-contain"
|
|
3567
|
+
}
|
|
3568
|
+
) : /* @__PURE__ */ jsx(Cpu, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
3569
|
+
/* @__PURE__ */ jsx(
|
|
3570
|
+
"span",
|
|
3571
|
+
{
|
|
3572
|
+
className: isBar ? `inline ${pillValueClass} max-sm:hidden` : "min-w-0 flex-1 truncate",
|
|
3573
|
+
children: triggerText
|
|
3574
|
+
}
|
|
3575
|
+
),
|
|
3576
|
+
/* @__PURE__ */ jsx(
|
|
3577
|
+
ChevronDown,
|
|
3578
|
+
{
|
|
3579
|
+
className: `shrink-0 opacity-60 ${isBar ? "h-3 w-3" : "h-4 w-4"}`
|
|
3580
|
+
}
|
|
3581
|
+
)
|
|
3582
|
+
]
|
|
3583
|
+
}
|
|
3584
|
+
);
|
|
3585
|
+
return /* @__PURE__ */ jsxs(
|
|
3586
|
+
"div",
|
|
3587
|
+
{
|
|
3588
|
+
className: isBar ? "ss-jsonforms-field ss-jsonforms-model relative shrink-0" : "ss-jsonforms-field ss-jsonforms-model compact-field",
|
|
3589
|
+
children: [
|
|
3590
|
+
!isBar && /* @__PURE__ */ jsx("label", { htmlFor: `${path2}-trigger`, className: fieldLabelClass(scale), children: triggerLabel }),
|
|
3591
|
+
trigger,
|
|
3592
|
+
renderPopover(
|
|
3593
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3594
|
+
/* @__PURE__ */ jsx("div", { className: "shrink-0 border-b border-border p-2", children: /* @__PURE__ */ jsx(
|
|
3142
3595
|
"input",
|
|
3143
3596
|
{
|
|
3144
3597
|
ref: searchRef,
|
|
@@ -3150,7 +3603,7 @@ var ModelIdRenderer = ({
|
|
|
3150
3603
|
className: "h-8 w-full rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none placeholder:text-muted-foreground focus:border-primary/40"
|
|
3151
3604
|
}
|
|
3152
3605
|
) }),
|
|
3153
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
3606
|
+
/* @__PURE__ */ jsxs("div", { className: "min-h-0 overflow-y-auto", children: [
|
|
3154
3607
|
isLoading && listModels.length === 0 && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-primary" }) }),
|
|
3155
3608
|
!isLoading && listModels.length === 0 && /* @__PURE__ */ jsx("p", { className: "px-3 py-6 text-center text-xs text-muted-foreground", children: searchValue ? "No models found" : "No models available" }),
|
|
3156
3609
|
listModels.map((model) => {
|
|
@@ -3163,7 +3616,7 @@ var ModelIdRenderer = ({
|
|
|
3163
3616
|
role: "option",
|
|
3164
3617
|
"aria-selected": active,
|
|
3165
3618
|
onClick: () => handleSelect(model),
|
|
3166
|
-
className:
|
|
3619
|
+
className: popoverRowClass,
|
|
3167
3620
|
children: [
|
|
3168
3621
|
/* @__PURE__ */ jsx(
|
|
3169
3622
|
Check,
|
|
@@ -3189,12 +3642,11 @@ var ModelIdRenderer = ({
|
|
|
3189
3642
|
);
|
|
3190
3643
|
})
|
|
3191
3644
|
] })
|
|
3192
|
-
]
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
] });
|
|
3645
|
+
] })
|
|
3646
|
+
)
|
|
3647
|
+
]
|
|
3648
|
+
}
|
|
3649
|
+
);
|
|
3198
3650
|
};
|
|
3199
3651
|
var modelIdRendererTester = rankWith(
|
|
3200
3652
|
100,
|
|
@@ -3229,6 +3681,7 @@ var NumberRenderer = ({
|
|
|
3229
3681
|
uischema,
|
|
3230
3682
|
visible,
|
|
3231
3683
|
enabled,
|
|
3684
|
+
config,
|
|
3232
3685
|
required
|
|
3233
3686
|
}) => {
|
|
3234
3687
|
const isInteger = schema?.type === "integer";
|
|
@@ -3257,40 +3710,58 @@ var NumberRenderer = ({
|
|
|
3257
3710
|
const max = fieldSchema?.maximum;
|
|
3258
3711
|
const step = isInteger ? 1 : fieldSchema?.multipleOf ?? "any";
|
|
3259
3712
|
const tooltip = [label, description, hasError ? errors : null].filter(Boolean).join(" \u2014 ");
|
|
3260
|
-
|
|
3261
|
-
|
|
3713
|
+
const surface = (config ?? {}).surface ?? "form";
|
|
3714
|
+
const scale = scaleFor(surface);
|
|
3715
|
+
const input = /* @__PURE__ */ jsx(
|
|
3716
|
+
"input",
|
|
3262
3717
|
{
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
label,
|
|
3273
|
-
required && /* @__PURE__ */ jsx("span", { className: "ml-1 text-destructive", children: "*" })
|
|
3274
|
-
]
|
|
3275
|
-
}
|
|
3276
|
-
),
|
|
3277
|
-
/* @__PURE__ */ jsx(
|
|
3278
|
-
"input",
|
|
3279
|
-
{
|
|
3280
|
-
id: `number-${path2}`,
|
|
3281
|
-
type: "number",
|
|
3282
|
-
value: data ?? "",
|
|
3283
|
-
onChange: handleInputChange,
|
|
3284
|
-
disabled: isDisabled,
|
|
3285
|
-
min,
|
|
3286
|
-
max,
|
|
3287
|
-
step,
|
|
3288
|
-
className: "w-14 border-0 bg-transparent p-0 text-xs font-medium tabular-nums text-foreground outline-none disabled:cursor-not-allowed"
|
|
3289
|
-
}
|
|
3290
|
-
)
|
|
3291
|
-
]
|
|
3718
|
+
id: `number-${path2}`,
|
|
3719
|
+
type: "number",
|
|
3720
|
+
value: data ?? "",
|
|
3721
|
+
onChange: handleInputChange,
|
|
3722
|
+
disabled: isDisabled,
|
|
3723
|
+
min,
|
|
3724
|
+
max,
|
|
3725
|
+
step,
|
|
3726
|
+
className: surface === "bar" ? "w-14 border-0 bg-transparent p-0 text-xs font-medium tabular-nums text-foreground outline-none disabled:cursor-not-allowed" : fieldNumberClass(scale, hasError)
|
|
3292
3727
|
}
|
|
3293
3728
|
);
|
|
3729
|
+
if (surface === "bar") {
|
|
3730
|
+
return /* @__PURE__ */ jsxs(
|
|
3731
|
+
"div",
|
|
3732
|
+
{
|
|
3733
|
+
className: `ss-jsonforms-field ss-jsonforms-number ${pillClass({
|
|
3734
|
+
hasError,
|
|
3735
|
+
disabled: isDisabled
|
|
3736
|
+
})}`,
|
|
3737
|
+
title: tooltip || void 0,
|
|
3738
|
+
children: [
|
|
3739
|
+
label && /* @__PURE__ */ jsxs(
|
|
3740
|
+
"label",
|
|
3741
|
+
{
|
|
3742
|
+
htmlFor: `number-${path2}`,
|
|
3743
|
+
className: `${pillLabelClass} whitespace-nowrap ${hasError ? "text-destructive" : "text-muted-foreground"}`,
|
|
3744
|
+
children: [
|
|
3745
|
+
label,
|
|
3746
|
+
required && /* @__PURE__ */ jsx("span", { className: "ml-1 text-destructive", children: "*" })
|
|
3747
|
+
]
|
|
3748
|
+
}
|
|
3749
|
+
),
|
|
3750
|
+
input
|
|
3751
|
+
]
|
|
3752
|
+
}
|
|
3753
|
+
);
|
|
3754
|
+
}
|
|
3755
|
+
return /* @__PURE__ */ jsxs("div", { className: "ss-jsonforms-field ss-jsonforms-number", children: [
|
|
3756
|
+
/* @__PURE__ */ jsxs("div", { className: fieldRowClass, children: [
|
|
3757
|
+
/* @__PURE__ */ jsxs("label", { htmlFor: `number-${path2}`, className: fieldRowLabelClass(scale), children: [
|
|
3758
|
+
label,
|
|
3759
|
+
required && /* @__PURE__ */ jsx("span", { className: "ml-1 text-destructive", children: "*" })
|
|
3760
|
+
] }),
|
|
3761
|
+
input
|
|
3762
|
+
] }),
|
|
3763
|
+
hasError && /* @__PURE__ */ jsx("div", { className: fieldErrorClass, children: errors })
|
|
3764
|
+
] });
|
|
3294
3765
|
};
|
|
3295
3766
|
var numberRendererTester = rankWith(
|
|
3296
3767
|
40,
|
|
@@ -3306,6 +3777,14 @@ var numberRendererTester = rankWith(
|
|
|
3306
3777
|
}
|
|
3307
3778
|
);
|
|
3308
3779
|
var NumberRendererControl = withJsonFormsControlProps(NumberRenderer);
|
|
3780
|
+
var SCALE = {
|
|
3781
|
+
comfortable: { lineHeight: 20, padding: 8 },
|
|
3782
|
+
dense: { lineHeight: 16, padding: 6 }
|
|
3783
|
+
};
|
|
3784
|
+
var rowsToPx = (rows, scale) => rows * scale.lineHeight + scale.padding * 2 + 2;
|
|
3785
|
+
var MAX_VIEWPORT_SHARE = 0.5;
|
|
3786
|
+
var DEFAULT_MIN_ROWS = 3;
|
|
3787
|
+
var DEFAULT_MAX_ROWS = 9;
|
|
3309
3788
|
var TextareaRenderer = ({
|
|
3310
3789
|
data,
|
|
3311
3790
|
handleChange,
|
|
@@ -3317,28 +3796,49 @@ var TextareaRenderer = ({
|
|
|
3317
3796
|
uischema,
|
|
3318
3797
|
visible,
|
|
3319
3798
|
enabled,
|
|
3320
|
-
required
|
|
3799
|
+
required,
|
|
3800
|
+
config
|
|
3321
3801
|
}) => {
|
|
3322
3802
|
const textareaRef = useRef(null);
|
|
3803
|
+
const textareaOptions = schema["ui:textarea"] ?? {};
|
|
3804
|
+
const formConfig = config ?? {};
|
|
3805
|
+
const scaleName = scaleFor(formConfig.surface ?? "form");
|
|
3806
|
+
const scale = SCALE[scaleName];
|
|
3807
|
+
const minRows = textareaOptions.minRows ?? formConfig.minRows ?? DEFAULT_MIN_ROWS;
|
|
3808
|
+
const maxRows = Math.max(
|
|
3809
|
+
minRows,
|
|
3810
|
+
textareaOptions.maxRows ?? formConfig.maxRows ?? DEFAULT_MAX_ROWS
|
|
3811
|
+
);
|
|
3812
|
+
const minHeight = rowsToPx(minRows, scale);
|
|
3813
|
+
const maxHeight = rowsToPx(maxRows, scale);
|
|
3814
|
+
const [viewportCap, setViewportCap] = useState(
|
|
3815
|
+
() => typeof window === "undefined" ? Number.POSITIVE_INFINITY : Math.round(window.innerHeight * MAX_VIEWPORT_SHARE)
|
|
3816
|
+
);
|
|
3817
|
+
const ceiling = Math.max(minHeight, Math.min(maxHeight, viewportCap));
|
|
3323
3818
|
const autoResize = useCallback(() => {
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
}
|
|
3333
|
-
}, []);
|
|
3819
|
+
const el = textareaRef.current;
|
|
3820
|
+
if (!el) return;
|
|
3821
|
+
el.style.height = "auto";
|
|
3822
|
+
el.style.height = `${Math.min(
|
|
3823
|
+
Math.max(el.scrollHeight, minHeight),
|
|
3824
|
+
ceiling
|
|
3825
|
+
)}px`;
|
|
3826
|
+
}, [minHeight, ceiling]);
|
|
3334
3827
|
useEffect(() => {
|
|
3335
3828
|
autoResize();
|
|
3336
3829
|
}, [data, autoResize]);
|
|
3830
|
+
useEffect(() => {
|
|
3831
|
+
const onResize = () => {
|
|
3832
|
+
setViewportCap(Math.round(window.innerHeight * MAX_VIEWPORT_SHARE));
|
|
3833
|
+
autoResize();
|
|
3834
|
+
};
|
|
3835
|
+
window.addEventListener("resize", onResize);
|
|
3836
|
+
return () => window.removeEventListener("resize", onResize);
|
|
3837
|
+
}, [autoResize]);
|
|
3337
3838
|
const handleInputChange = useCallback(
|
|
3338
3839
|
(event) => {
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
setTimeout(autoResize, 0);
|
|
3840
|
+
handleChange(path2, event.target.value);
|
|
3841
|
+
autoResize();
|
|
3342
3842
|
},
|
|
3343
3843
|
[handleChange, path2, autoResize]
|
|
3344
3844
|
);
|
|
@@ -3348,89 +3848,34 @@ var TextareaRenderer = ({
|
|
|
3348
3848
|
const readOnly = uischema?.access === "Read";
|
|
3349
3849
|
const isDisabled = !enabled || readOnly;
|
|
3350
3850
|
const hasError = errors && errors.length > 0;
|
|
3351
|
-
const textareaOptions = schema["ui:textarea"] ?? {};
|
|
3352
3851
|
const placeholder = textareaOptions.placeholder || schema?.description || `Enter ${label?.toLowerCase() || "text"}...`;
|
|
3353
|
-
const minRows = textareaOptions.minRows || 3;
|
|
3354
3852
|
return /* @__PURE__ */ jsxs("div", { className: "ss-jsonforms-field ss-jsonforms-textarea", children: [
|
|
3355
|
-
label && /* @__PURE__ */ jsxs(
|
|
3356
|
-
|
|
3357
|
-
{
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
color: hasError ? "#ef4444" : "#475569",
|
|
3361
|
-
fontSize: "0.875rem",
|
|
3362
|
-
fontWeight: 500,
|
|
3363
|
-
marginBottom: "0.375rem"
|
|
3364
|
-
},
|
|
3365
|
-
children: [
|
|
3366
|
-
label,
|
|
3367
|
-
required && /* @__PURE__ */ jsx("span", { style: { color: "#ef4444", marginLeft: "0.25rem" }, children: "*" })
|
|
3368
|
-
]
|
|
3369
|
-
}
|
|
3370
|
-
),
|
|
3371
|
-
description && /* @__PURE__ */ jsx(
|
|
3372
|
-
"div",
|
|
3373
|
-
{
|
|
3374
|
-
style: {
|
|
3375
|
-
color: "#6b7280",
|
|
3376
|
-
fontSize: "0.75rem",
|
|
3377
|
-
marginBottom: "0.5rem"
|
|
3378
|
-
},
|
|
3379
|
-
children: description
|
|
3380
|
-
}
|
|
3381
|
-
),
|
|
3853
|
+
label && /* @__PURE__ */ jsxs("label", { htmlFor: path2, className: fieldLabelClass(scaleName), children: [
|
|
3854
|
+
label,
|
|
3855
|
+
required && /* @__PURE__ */ jsx("span", { className: "ml-1 text-destructive", children: "*" })
|
|
3856
|
+
] }),
|
|
3857
|
+
description && /* @__PURE__ */ jsx("div", { className: fieldHintClass, children: description }),
|
|
3382
3858
|
/* @__PURE__ */ jsx(
|
|
3383
3859
|
"textarea",
|
|
3384
3860
|
{
|
|
3861
|
+
id: path2,
|
|
3385
3862
|
ref: textareaRef,
|
|
3386
3863
|
value: data || "",
|
|
3387
3864
|
onChange: handleInputChange,
|
|
3388
3865
|
placeholder,
|
|
3389
3866
|
disabled: isDisabled,
|
|
3390
3867
|
rows: minRows,
|
|
3868
|
+
className: `resize-y ${fieldControlClass(scaleName, !!hasError)}`,
|
|
3391
3869
|
style: {
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
padding: "0.75rem",
|
|
3397
|
-
border: hasError ? "2px solid #ef4444" : "1px solid #d1d5db",
|
|
3398
|
-
borderRadius: "6px",
|
|
3399
|
-
fontSize: "16px",
|
|
3400
|
-
lineHeight: "1.5",
|
|
3401
|
-
fontFamily: "inherit",
|
|
3402
|
-
backgroundColor: isDisabled ? "#f9fafb" : "#ffffff",
|
|
3403
|
-
color: isDisabled ? "#9ca3af" : "#111827",
|
|
3404
|
-
outline: "none",
|
|
3405
|
-
transition: "border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out",
|
|
3406
|
-
boxShadow: hasError ? "0 0 0 1px #ef4444" : "none",
|
|
3870
|
+
minHeight: `${minHeight}px`,
|
|
3871
|
+
maxHeight: `${ceiling}px`,
|
|
3872
|
+
// iOS zooms a focused control under 16px; the design's fields are
|
|
3873
|
+
// 14px, so opt out of the adjustment rather than the design.
|
|
3407
3874
|
WebkitTextSizeAdjust: "100%"
|
|
3408
|
-
},
|
|
3409
|
-
onFocus: (e) => {
|
|
3410
|
-
if (!hasError) {
|
|
3411
|
-
e.target.style.borderColor = "#6366f1";
|
|
3412
|
-
e.target.style.boxShadow = "0 0 0 1px #6366f1";
|
|
3413
|
-
}
|
|
3414
|
-
},
|
|
3415
|
-
onBlur: (e) => {
|
|
3416
|
-
if (!hasError) {
|
|
3417
|
-
e.target.style.borderColor = "#d1d5db";
|
|
3418
|
-
e.target.style.boxShadow = "none";
|
|
3419
|
-
}
|
|
3420
3875
|
}
|
|
3421
3876
|
}
|
|
3422
3877
|
),
|
|
3423
|
-
hasError && /* @__PURE__ */ jsx(
|
|
3424
|
-
"div",
|
|
3425
|
-
{
|
|
3426
|
-
style: {
|
|
3427
|
-
color: "#ef4444",
|
|
3428
|
-
fontSize: "0.75rem",
|
|
3429
|
-
marginTop: "0.25rem"
|
|
3430
|
-
},
|
|
3431
|
-
children: errors
|
|
3432
|
-
}
|
|
3433
|
-
)
|
|
3878
|
+
hasError && /* @__PURE__ */ jsx("div", { className: fieldErrorClass, children: errors })
|
|
3434
3879
|
] });
|
|
3435
3880
|
};
|
|
3436
3881
|
var textareaRendererTester = rankWith(
|
|
@@ -3482,10 +3927,25 @@ var renderers = [
|
|
|
3482
3927
|
];
|
|
3483
3928
|
|
|
3484
3929
|
// src/chat-variables/VariablesForm.vm.ts
|
|
3930
|
+
var MAX_INLINE_VARIABLES = 3;
|
|
3931
|
+
var isModelSelector = (schema) => schema.title === "ModelId" || schema["x-model-selector"] === true;
|
|
3932
|
+
function rowLayout(controls) {
|
|
3933
|
+
const innerRow = {
|
|
3934
|
+
type: "HorizontalLayout",
|
|
3935
|
+
elements: controls,
|
|
3936
|
+
options: { gap: "12px", alignItems: "flex-start" }
|
|
3937
|
+
};
|
|
3938
|
+
const ui = {
|
|
3939
|
+
type: "VerticalLayout",
|
|
3940
|
+
elements: [innerRow]
|
|
3941
|
+
};
|
|
3942
|
+
return ui;
|
|
3943
|
+
}
|
|
3485
3944
|
function buildSimpleSchemaAndUi(vars, threadVars, useDefaults) {
|
|
3486
3945
|
const names = Object.keys(vars || {});
|
|
3487
3946
|
const properties2 = {};
|
|
3488
3947
|
const controls = [];
|
|
3948
|
+
const inlineOnly = [];
|
|
3489
3949
|
const initialData = {};
|
|
3490
3950
|
const $defs = {};
|
|
3491
3951
|
for (const name of names) {
|
|
@@ -3505,19 +3965,24 @@ function buildSimpleSchemaAndUi(vars, threadVars, useDefaults) {
|
|
|
3505
3965
|
control.enabled = false;
|
|
3506
3966
|
}
|
|
3507
3967
|
controls.push(control);
|
|
3968
|
+
if (isModelSelector(properties2[name])) inlineOnly.push(control);
|
|
3508
3969
|
}
|
|
3509
3970
|
const schema = { type: "object", properties: properties2 };
|
|
3510
3971
|
if (Object.keys($defs).length > 0) schema.$defs = $defs;
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3972
|
+
if (controls.length <= MAX_INLINE_VARIABLES) {
|
|
3973
|
+
return {
|
|
3974
|
+
schema,
|
|
3975
|
+
inlineControls: controls,
|
|
3976
|
+
overflowControls: [],
|
|
3977
|
+
initialData
|
|
3978
|
+
};
|
|
3979
|
+
}
|
|
3980
|
+
return {
|
|
3981
|
+
schema,
|
|
3982
|
+
inlineControls: inlineOnly,
|
|
3983
|
+
overflowControls: controls.filter((c) => !inlineOnly.includes(c)),
|
|
3984
|
+
initialData
|
|
3519
3985
|
};
|
|
3520
|
-
return { schema, uiSchema: ui, initialData };
|
|
3521
3986
|
}
|
|
3522
3987
|
function useChatVariablesFormVm({
|
|
3523
3988
|
workspace,
|
|
@@ -3532,26 +3997,26 @@ function useChatVariablesFormVm({
|
|
|
3532
3997
|
const { mutate: updateVariableMutation } = useUpdateFlowRunVariable();
|
|
3533
3998
|
const querySettled = !isLoading && (threadVars !== void 0 || isError);
|
|
3534
3999
|
const shouldUseDefaults = isError || threadVars && Object.keys(threadVars).length === 0;
|
|
3535
|
-
const built =
|
|
4000
|
+
const built = React9.useMemo(() => {
|
|
3536
4001
|
return buildSimpleSchemaAndUi(
|
|
3537
4002
|
workspace.variables,
|
|
3538
4003
|
threadVars,
|
|
3539
4004
|
shouldUseDefaults ?? false
|
|
3540
4005
|
);
|
|
3541
4006
|
}, [workspace.variables, threadVars, shouldUseDefaults]);
|
|
3542
|
-
const [data, setData] =
|
|
3543
|
-
|
|
4007
|
+
const [data, setData] = React9.useState(null);
|
|
4008
|
+
React9.useEffect(() => {
|
|
3544
4009
|
if (querySettled) {
|
|
3545
4010
|
setData(built.initialData);
|
|
3546
4011
|
setVariables(built.initialData);
|
|
3547
4012
|
}
|
|
3548
4013
|
}, [querySettled, built.initialData, setVariables]);
|
|
3549
|
-
const ajv =
|
|
3550
|
-
const prevRef =
|
|
3551
|
-
|
|
4014
|
+
const ajv = React9.useMemo(() => createAjv({ useDefaults: false }), []);
|
|
4015
|
+
const prevRef = React9.useRef(null);
|
|
4016
|
+
React9.useEffect(() => {
|
|
3552
4017
|
prevRef.current = data;
|
|
3553
4018
|
}, [data]);
|
|
3554
|
-
const onChange =
|
|
4019
|
+
const onChange = React9.useCallback(
|
|
3555
4020
|
({ data: next2 }) => {
|
|
3556
4021
|
if (prevRef.current && !isDraftThreadId(threadId)) {
|
|
3557
4022
|
const keys2 = Object.keys(workspace.variables || {});
|
|
@@ -3572,29 +4037,96 @@ function useChatVariablesFormVm({
|
|
|
3572
4037
|
},
|
|
3573
4038
|
[workspace.variables, setVariables, updateVariableMutation, threadId]
|
|
3574
4039
|
);
|
|
3575
|
-
const
|
|
4040
|
+
const barConfig = React9.useMemo(
|
|
3576
4041
|
() => ({
|
|
3577
4042
|
restrict: true,
|
|
3578
4043
|
trim: false,
|
|
3579
4044
|
showUnfocusedDescription: true,
|
|
3580
|
-
hideRequiredAsterisk: true
|
|
4045
|
+
hideRequiredAsterisk: true,
|
|
4046
|
+
surface: "bar",
|
|
4047
|
+
minRows: 1,
|
|
4048
|
+
maxRows: 6
|
|
3581
4049
|
}),
|
|
3582
4050
|
[]
|
|
3583
4051
|
);
|
|
4052
|
+
const panelConfig = React9.useMemo(
|
|
4053
|
+
() => ({ ...barConfig, surface: "panel" }),
|
|
4054
|
+
[barConfig]
|
|
4055
|
+
);
|
|
4056
|
+
const inlineUiSchema = React9.useMemo(
|
|
4057
|
+
() => built.inlineControls.length ? rowLayout(built.inlineControls) : null,
|
|
4058
|
+
[built.inlineControls]
|
|
4059
|
+
);
|
|
4060
|
+
const overflowUiSchema = React9.useMemo(
|
|
4061
|
+
() => built.overflowControls.length ? rowLayout(built.overflowControls) : null,
|
|
4062
|
+
[built.overflowControls]
|
|
4063
|
+
);
|
|
3584
4064
|
return {
|
|
3585
4065
|
schema: built.schema,
|
|
3586
|
-
|
|
4066
|
+
inlineUiSchema,
|
|
4067
|
+
overflowUiSchema,
|
|
4068
|
+
overflowCount: built.overflowControls.length,
|
|
3587
4069
|
data,
|
|
3588
4070
|
renderers,
|
|
3589
4071
|
cells,
|
|
3590
4072
|
ajv,
|
|
3591
4073
|
onChange,
|
|
3592
|
-
|
|
4074
|
+
barConfig,
|
|
4075
|
+
panelConfig,
|
|
3593
4076
|
isLoading,
|
|
3594
4077
|
isReady: querySettled,
|
|
3595
4078
|
isHydrated: data !== null
|
|
3596
4079
|
};
|
|
3597
4080
|
}
|
|
4081
|
+
function VariablesOverflowPanel({ count, children: children2 }) {
|
|
4082
|
+
const triggerRef = useRef(null);
|
|
4083
|
+
const panelRef = useRef(null);
|
|
4084
|
+
const { isOpen, close, toggle, renderPopover } = useAnchoredPopover({
|
|
4085
|
+
trigger: triggerRef,
|
|
4086
|
+
popover: panelRef,
|
|
4087
|
+
width: POPOVER_WIDTH_PX,
|
|
4088
|
+
maxHeight: POPOVER_MAX_HEIGHT_PX,
|
|
4089
|
+
role: "dialog",
|
|
4090
|
+
label: "Workspace variables"
|
|
4091
|
+
});
|
|
4092
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4093
|
+
/* @__PURE__ */ jsxs(
|
|
4094
|
+
"button",
|
|
4095
|
+
{
|
|
4096
|
+
ref: triggerRef,
|
|
4097
|
+
type: "button",
|
|
4098
|
+
onClick: toggle,
|
|
4099
|
+
"aria-expanded": isOpen,
|
|
4100
|
+
"aria-haspopup": "dialog",
|
|
4101
|
+
"aria-label": `Variables (${count})`,
|
|
4102
|
+
className: `flex h-8 shrink-0 items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${isOpen ? "border-primary/30 bg-primary/10 text-primary" : "border-border/70 bg-transparent text-muted-foreground hover:bg-secondary"}`,
|
|
4103
|
+
children: [
|
|
4104
|
+
/* @__PURE__ */ jsx(SlidersHorizontal, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
4105
|
+
/* @__PURE__ */ jsx("span", { className: "inline max-sm:hidden", children: "Variables" }),
|
|
4106
|
+
/* @__PURE__ */ jsx("span", { className: "rounded-full bg-secondary px-1.5 text-[10px] leading-4 tabular-nums", children: count })
|
|
4107
|
+
]
|
|
4108
|
+
}
|
|
4109
|
+
),
|
|
4110
|
+
renderPopover(
|
|
4111
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4112
|
+
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center justify-between border-b border-border px-3 py-2", children: [
|
|
4113
|
+
/* @__PURE__ */ jsx("span", { className: popoverHeadingClass, children: "Variables" }),
|
|
4114
|
+
/* @__PURE__ */ jsx(
|
|
4115
|
+
"button",
|
|
4116
|
+
{
|
|
4117
|
+
type: "button",
|
|
4118
|
+
onClick: close,
|
|
4119
|
+
"aria-label": "Close variables",
|
|
4120
|
+
className: "inline-flex h-5 w-5 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground",
|
|
4121
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-3.5 w-3.5" })
|
|
4122
|
+
}
|
|
4123
|
+
)
|
|
4124
|
+
] }),
|
|
4125
|
+
/* @__PURE__ */ jsx("div", { className: "ss-variables-panel min-h-0 overflow-y-auto p-3", children: children2 })
|
|
4126
|
+
] })
|
|
4127
|
+
)
|
|
4128
|
+
] });
|
|
4129
|
+
}
|
|
3598
4130
|
var ChatVariablesForm = forwardRef(({ workspace, threadId, setVariables }, ref) => {
|
|
3599
4131
|
const vm = useChatVariablesFormVm({ workspace, threadId, setVariables });
|
|
3600
4132
|
useImperativeHandle(ref, () => ({
|
|
@@ -3610,20 +4142,85 @@ var ChatVariablesForm = forwardRef(({ workspace, threadId, setVariables }, ref)
|
|
|
3610
4142
|
if (!vm.isHydrated) {
|
|
3611
4143
|
return /* @__PURE__ */ jsx("div", { className: "flex justify-center items-center w-full h-8", children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-primary" }) });
|
|
3612
4144
|
}
|
|
3613
|
-
|
|
3614
|
-
|
|
4145
|
+
const formProps = {
|
|
4146
|
+
schema: vm.schema,
|
|
4147
|
+
data: vm.data,
|
|
4148
|
+
renderers: vm.renderers,
|
|
4149
|
+
cells: vm.cells,
|
|
4150
|
+
ajv: vm.ajv,
|
|
4151
|
+
onChange: vm.onChange
|
|
4152
|
+
};
|
|
4153
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full min-w-0 items-center gap-1", children: [
|
|
4154
|
+
vm.inlineUiSchema && /* @__PURE__ */ jsx("div", { className: "min-w-0 jsonforms-compact", children: /* @__PURE__ */ jsx(
|
|
4155
|
+
JsonForms,
|
|
4156
|
+
{
|
|
4157
|
+
...formProps,
|
|
4158
|
+
uischema: vm.inlineUiSchema,
|
|
4159
|
+
config: vm.barConfig
|
|
4160
|
+
}
|
|
4161
|
+
) }),
|
|
4162
|
+
vm.overflowUiSchema && /* @__PURE__ */ jsx(VariablesOverflowPanel, { count: vm.overflowCount, children: /* @__PURE__ */ jsx("div", { className: "jsonforms-compact", children: /* @__PURE__ */ jsx(
|
|
4163
|
+
JsonForms,
|
|
4164
|
+
{
|
|
4165
|
+
...formProps,
|
|
4166
|
+
uischema: vm.overflowUiSchema,
|
|
4167
|
+
config: vm.panelConfig
|
|
4168
|
+
}
|
|
4169
|
+
) }) })
|
|
4170
|
+
] });
|
|
4171
|
+
});
|
|
4172
|
+
var dictationErrorMessages = {
|
|
4173
|
+
"permission-denied": "Microphone access is blocked \u2014 allow it in your browser settings and try again",
|
|
4174
|
+
"no-microphone": "No microphone was found",
|
|
4175
|
+
network: "Could not reach the speech service \u2014 try again",
|
|
4176
|
+
"unavailable-temporarily": "Dictation is starting up \u2014 try again in a moment",
|
|
4177
|
+
unavailable: "Dictation is not available on this workspace",
|
|
4178
|
+
unknown: "Dictation stopped unexpectedly \u2014 try again"
|
|
4179
|
+
};
|
|
4180
|
+
function DictationButton({
|
|
4181
|
+
state,
|
|
4182
|
+
error,
|
|
4183
|
+
disabled,
|
|
4184
|
+
onToggle,
|
|
4185
|
+
deviceLabel,
|
|
4186
|
+
size = "sm"
|
|
4187
|
+
}) {
|
|
4188
|
+
const listening = state === "listening";
|
|
4189
|
+
const starting = state === "starting";
|
|
4190
|
+
const label = listening ? "Stop dictation" : "Dictate a message";
|
|
4191
|
+
const hint = listening && deviceLabel ? `${label} \u2014 ${deviceLabel}` : label;
|
|
4192
|
+
const dims = size === "sm" ? "h-8 w-8" : "h-9 w-9";
|
|
4193
|
+
const icon = size === "sm" ? "h-4 w-4" : "h-5 w-5";
|
|
4194
|
+
return /* @__PURE__ */ jsxs(
|
|
4195
|
+
IconButton2,
|
|
3615
4196
|
{
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
4197
|
+
type: "button",
|
|
4198
|
+
onClick: onToggle,
|
|
4199
|
+
disabled,
|
|
4200
|
+
"aria-pressed": listening,
|
|
4201
|
+
"aria-label": label,
|
|
4202
|
+
title: error ? dictationErrorMessages[error] : hint,
|
|
4203
|
+
className: `relative ${dims} rounded-full transition-colors ${listening ? "bg-destructive text-destructive-foreground hover:bg-destructive/90" : "text-muted-foreground hover:bg-secondary"}`,
|
|
4204
|
+
children: [
|
|
4205
|
+
starting && /* @__PURE__ */ jsx(
|
|
4206
|
+
"span",
|
|
4207
|
+
{
|
|
4208
|
+
"aria-hidden": "true",
|
|
4209
|
+
className: "absolute inset-0 animate-spin rounded-full border-2 border-transparent border-t-current opacity-70"
|
|
4210
|
+
}
|
|
4211
|
+
),
|
|
4212
|
+
listening && /* @__PURE__ */ jsx(
|
|
4213
|
+
"span",
|
|
4214
|
+
{
|
|
4215
|
+
"aria-hidden": "true",
|
|
4216
|
+
className: "absolute inset-0 animate-ping rounded-full bg-destructive/30"
|
|
4217
|
+
}
|
|
4218
|
+
),
|
|
4219
|
+
listening ? /* @__PURE__ */ jsx(Square, { className: `relative ${icon} fill-current` }) : /* @__PURE__ */ jsx(Mic, { className: `relative ${icon}` })
|
|
4220
|
+
]
|
|
3624
4221
|
}
|
|
3625
|
-
)
|
|
3626
|
-
}
|
|
4222
|
+
);
|
|
4223
|
+
}
|
|
3627
4224
|
|
|
3628
4225
|
// src/domains/workspaces/queryKeys.ts
|
|
3629
4226
|
var workspaceKeys = {
|
|
@@ -3642,7 +4239,10 @@ var workspaceDetailOptions = ({
|
|
|
3642
4239
|
}) => queryOptions({
|
|
3643
4240
|
queryKey: workspaceKeys.byId(workspaceId),
|
|
3644
4241
|
queryFn: () => service.fetchWorkspace(workspaceId),
|
|
3645
|
-
staleTime: 3e4
|
|
4242
|
+
staleTime: 3e4,
|
|
4243
|
+
// The route loader has just tried and failed. Retrying on mount delays
|
|
4244
|
+
// the header's error by several seconds.
|
|
4245
|
+
retryOnMount: false
|
|
3646
4246
|
});
|
|
3647
4247
|
function useWorkspace(workspaceId) {
|
|
3648
4248
|
const service = useChatService();
|
|
@@ -3856,6 +4456,40 @@ function MessageComposer(_props = {}) {
|
|
|
3856
4456
|
cancelReset();
|
|
3857
4457
|
}
|
|
3858
4458
|
}, [isSending, cancelAccepted, cancelErrored, cancelReset]);
|
|
4459
|
+
const attachEditor = useCallback(
|
|
4460
|
+
(handle2) => {
|
|
4461
|
+
if (handle2) editorRef.current = handle2;
|
|
4462
|
+
},
|
|
4463
|
+
// Both flags matter: the portal mounts on `isMobile && isFullscreen`, and
|
|
4464
|
+
// nothing resets isFullscreen when the breakpoint flips, so crossing it
|
|
4465
|
+
// while fullscreen would unmount the portal editor without re-attaching the
|
|
4466
|
+
// inline one — leaving a destroyed handle and silently swallowing phrases.
|
|
4467
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4468
|
+
[isFullscreen, isMobile]
|
|
4469
|
+
);
|
|
4470
|
+
const { data: speechConfig, isFetching: speechConfigLoading } = useSpeechConfig();
|
|
4471
|
+
const getSpeechToken = useMemo(
|
|
4472
|
+
() => chatService.getSpeechToken?.bind(chatService),
|
|
4473
|
+
[chatService]
|
|
4474
|
+
);
|
|
4475
|
+
const dictation = useDictation({
|
|
4476
|
+
region: speechConfig?.enabled ? speechConfig.region : null,
|
|
4477
|
+
locale: speechConfig?.defaultLocale ?? "en-US",
|
|
4478
|
+
getToken: getSpeechToken,
|
|
4479
|
+
// Final phrases become real text; provisional ones render as greyed ghost
|
|
4480
|
+
// text at the caret and never enter the document.
|
|
4481
|
+
onPhrase: (text6) => editorRef.current?.insertText(`${text6} `),
|
|
4482
|
+
onInterim: (text6) => editorRef.current?.setDictationGhost(text6)
|
|
4483
|
+
});
|
|
4484
|
+
const { stop: stopDictation } = dictation;
|
|
4485
|
+
const dictationUnavailableReason = speechConfigLoading ? "Checking whether dictation is available" : dictation.supported ? "Dictation is not enabled for this workspace" : "Dictation is not available in this browser";
|
|
4486
|
+
const handleDictationToggle = () => {
|
|
4487
|
+
if (dictation.state === "idle") editorRef.current?.focus();
|
|
4488
|
+
dictation.toggle();
|
|
4489
|
+
};
|
|
4490
|
+
useEffect(() => {
|
|
4491
|
+
if (disabled) stopDictation();
|
|
4492
|
+
}, [disabled, stopDictation]);
|
|
3859
4493
|
useEffect(() => {
|
|
3860
4494
|
if (typeof window === "undefined") return;
|
|
3861
4495
|
window.__ssDownloadFile = (id) => getFileBlobUrl(id);
|
|
@@ -3975,6 +4609,7 @@ function MessageComposer(_props = {}) {
|
|
|
3975
4609
|
const latestText = editorRef.current?.getMarkdown() ?? newMessage;
|
|
3976
4610
|
const sent = handleSendMessage(latestText, uploadedAttachments);
|
|
3977
4611
|
if (!sent) return;
|
|
4612
|
+
stopDictation();
|
|
3978
4613
|
handleClearAttachments();
|
|
3979
4614
|
setEditorKey((k) => k + 1);
|
|
3980
4615
|
};
|
|
@@ -4081,7 +4716,7 @@ function MessageComposer(_props = {}) {
|
|
|
4081
4716
|
/* @__PURE__ */ jsx("div", { className: "max-h-[400px] w-full overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
4082
4717
|
MarkdownEditor,
|
|
4083
4718
|
{
|
|
4084
|
-
ref:
|
|
4719
|
+
ref: attachEditor,
|
|
4085
4720
|
value: newMessage,
|
|
4086
4721
|
onChange: (md) => setNewMessage(md),
|
|
4087
4722
|
onKeyDown: handleComposerKeyDown,
|
|
@@ -4094,14 +4729,22 @@ function MessageComposer(_props = {}) {
|
|
|
4094
4729
|
disabled,
|
|
4095
4730
|
placeholder: "What would you like to do?",
|
|
4096
4731
|
className: "md-editor--bare px-5 pb-3 pt-4 text-sm",
|
|
4097
|
-
minHeight:
|
|
4732
|
+
minHeight: 24
|
|
4098
4733
|
},
|
|
4099
4734
|
`composer-md-${editorKey}`
|
|
4100
4735
|
) }),
|
|
4736
|
+
/* @__PURE__ */ jsx("div", { role: "status", className: "sr-only", children: dictation.state === "listening" ? dictation.silent ? `Listening, but not hearing anything from ${dictation.deviceLabel || "your microphone"}` : "Listening" : dictation.state === "starting" ? "Starting dictation" : "" }),
|
|
4737
|
+
dictation.state === "listening" && dictation.silent && /* @__PURE__ */ jsxs("div", { className: "px-5 pb-1 text-xs text-muted-foreground", children: [
|
|
4738
|
+
"Not hearing anything from",
|
|
4739
|
+
" ",
|
|
4740
|
+
dictation.deviceLabel || "your microphone",
|
|
4741
|
+
"."
|
|
4742
|
+
] }),
|
|
4743
|
+
dictation.error && /* @__PURE__ */ jsx("div", { role: "alert", className: "px-5 pb-1 text-xs text-destructive", children: dictationErrorMessages[dictation.error] }),
|
|
4101
4744
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 px-3 pb-3", children: [
|
|
4102
4745
|
/* @__PURE__ */ jsxs("div", { className: "ss-composer__actions flex min-w-0 flex-1 items-center gap-1", children: [
|
|
4103
4746
|
supportsFiles && /* @__PURE__ */ jsx(
|
|
4104
|
-
|
|
4747
|
+
IconButton2,
|
|
4105
4748
|
{
|
|
4106
4749
|
type: "button",
|
|
4107
4750
|
onClick: handlePickFilesClick,
|
|
@@ -4122,19 +4765,39 @@ function MessageComposer(_props = {}) {
|
|
|
4122
4765
|
)
|
|
4123
4766
|
] }),
|
|
4124
4767
|
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [
|
|
4125
|
-
/* @__PURE__ */ jsx(
|
|
4126
|
-
|
|
4768
|
+
dictation.available ? /* @__PURE__ */ jsx(
|
|
4769
|
+
DictationButton,
|
|
4127
4770
|
{
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
children: /* @__PURE__ */ jsx(Mic, { className: "h-4 w-4" })
|
|
4771
|
+
state: dictation.state,
|
|
4772
|
+
error: dictation.error,
|
|
4773
|
+
disabled,
|
|
4774
|
+
onToggle: handleDictationToggle,
|
|
4775
|
+
deviceLabel: dictation.deviceLabel
|
|
4134
4776
|
}
|
|
4777
|
+
) : (
|
|
4778
|
+
// A disabled button receives no pointer events, so its own
|
|
4779
|
+
// `title` never renders a tooltip. The wrapper is what the user
|
|
4780
|
+
// actually hovers.
|
|
4781
|
+
/* @__PURE__ */ jsx(
|
|
4782
|
+
"span",
|
|
4783
|
+
{
|
|
4784
|
+
title: dictationUnavailableReason,
|
|
4785
|
+
className: "inline-flex cursor-not-allowed",
|
|
4786
|
+
children: /* @__PURE__ */ jsx(
|
|
4787
|
+
IconButton2,
|
|
4788
|
+
{
|
|
4789
|
+
type: "button",
|
|
4790
|
+
disabled: true,
|
|
4791
|
+
"aria-label": `Dictate a message. ${dictationUnavailableReason}`,
|
|
4792
|
+
className: "h-8 w-8 rounded-full text-muted-foreground",
|
|
4793
|
+
children: /* @__PURE__ */ jsx(Mic, { className: "h-4 w-4" })
|
|
4794
|
+
}
|
|
4795
|
+
)
|
|
4796
|
+
}
|
|
4797
|
+
)
|
|
4135
4798
|
),
|
|
4136
4799
|
canStop ? /* @__PURE__ */ jsx(
|
|
4137
|
-
|
|
4800
|
+
IconButton2,
|
|
4138
4801
|
{
|
|
4139
4802
|
onClick: handleStopRun,
|
|
4140
4803
|
className: "chat-send h-8 w-8 rounded-full",
|
|
@@ -4148,7 +4811,7 @@ function MessageComposer(_props = {}) {
|
|
|
4148
4811
|
)
|
|
4149
4812
|
}
|
|
4150
4813
|
) : /* @__PURE__ */ jsx(
|
|
4151
|
-
|
|
4814
|
+
IconButton2,
|
|
4152
4815
|
{
|
|
4153
4816
|
onClick: handleSendMessageAndClear,
|
|
4154
4817
|
className: `chat-send h-8 w-8 rounded-full ${sendDisabled ? "cursor-not-allowed" : ""}`,
|
|
@@ -4177,7 +4840,7 @@ function MessageComposer(_props = {}) {
|
|
|
4177
4840
|
},
|
|
4178
4841
|
children: /* @__PURE__ */ jsxs("div", { className: "relative h-full w-full bg-background border shadow-lg", children: [
|
|
4179
4842
|
/* @__PURE__ */ jsx(
|
|
4180
|
-
|
|
4843
|
+
IconButton2,
|
|
4181
4844
|
{
|
|
4182
4845
|
type: "button",
|
|
4183
4846
|
size: "small",
|
|
@@ -4195,7 +4858,7 @@ function MessageComposer(_props = {}) {
|
|
|
4195
4858
|
/* @__PURE__ */ jsx("div", { className: "flex-1 p-4", children: /* @__PURE__ */ jsx(
|
|
4196
4859
|
MarkdownEditor,
|
|
4197
4860
|
{
|
|
4198
|
-
ref:
|
|
4861
|
+
ref: attachEditor,
|
|
4199
4862
|
value: newMessage,
|
|
4200
4863
|
onChange: (md) => setNewMessage(md),
|
|
4201
4864
|
onKeyDown: handleComposerKeyDown,
|
|
@@ -4210,10 +4873,18 @@ function MessageComposer(_props = {}) {
|
|
|
4210
4873
|
},
|
|
4211
4874
|
`composer-md-${editorKey}`
|
|
4212
4875
|
) }),
|
|
4876
|
+
dictation.error && /* @__PURE__ */ jsx(
|
|
4877
|
+
"div",
|
|
4878
|
+
{
|
|
4879
|
+
"aria-hidden": "true",
|
|
4880
|
+
className: "px-4 pb-1 text-xs text-destructive",
|
|
4881
|
+
children: dictationErrorMessages[dictation.error]
|
|
4882
|
+
}
|
|
4883
|
+
),
|
|
4213
4884
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-3 py-2 border-t bg-background", children: [
|
|
4214
4885
|
/* @__PURE__ */ jsx("div", { className: "flex-1" }),
|
|
4215
4886
|
supportsFiles && /* @__PURE__ */ jsx(
|
|
4216
|
-
|
|
4887
|
+
IconButton2,
|
|
4217
4888
|
{
|
|
4218
4889
|
type: "button",
|
|
4219
4890
|
onClick: handlePickFilesClick,
|
|
@@ -4228,8 +4899,19 @@ function MessageComposer(_props = {}) {
|
|
|
4228
4899
|
)
|
|
4229
4900
|
}
|
|
4230
4901
|
),
|
|
4902
|
+
dictation.available && /* @__PURE__ */ jsx(
|
|
4903
|
+
DictationButton,
|
|
4904
|
+
{
|
|
4905
|
+
size: "md",
|
|
4906
|
+
state: dictation.state,
|
|
4907
|
+
error: dictation.error,
|
|
4908
|
+
disabled,
|
|
4909
|
+
onToggle: handleDictationToggle,
|
|
4910
|
+
deviceLabel: dictation.deviceLabel
|
|
4911
|
+
}
|
|
4912
|
+
),
|
|
4231
4913
|
canStop ? /* @__PURE__ */ jsx(
|
|
4232
|
-
|
|
4914
|
+
IconButton2,
|
|
4233
4915
|
{
|
|
4234
4916
|
onClick: handleStopRun,
|
|
4235
4917
|
className: "chat-send h-9 w-9 rounded-full",
|
|
@@ -4243,7 +4925,7 @@ function MessageComposer(_props = {}) {
|
|
|
4243
4925
|
)
|
|
4244
4926
|
}
|
|
4245
4927
|
) : /* @__PURE__ */ jsx(
|
|
4246
|
-
|
|
4928
|
+
IconButton2,
|
|
4247
4929
|
{
|
|
4248
4930
|
onClick: handleSendMessageAndClear,
|
|
4249
4931
|
className: `chat-send h-9 w-9 rounded-full ${sendDisabled ? "cursor-not-allowed" : ""}`,
|
|
@@ -18907,6 +19589,45 @@ function MessageMarkdown({ value, className }) {
|
|
|
18907
19589
|
function cn(...inputs) {
|
|
18908
19590
|
return twMerge(clsx(inputs));
|
|
18909
19591
|
}
|
|
19592
|
+
var buttonVariants = cva(
|
|
19593
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
19594
|
+
{
|
|
19595
|
+
variants: {
|
|
19596
|
+
variant: {
|
|
19597
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
19598
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
19599
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
19600
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
19601
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
19602
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
19603
|
+
},
|
|
19604
|
+
size: {
|
|
19605
|
+
default: "h-10 px-4 py-2",
|
|
19606
|
+
sm: "h-9 rounded-md px-3",
|
|
19607
|
+
lg: "h-11 rounded-md px-8",
|
|
19608
|
+
icon: "h-10 w-10"
|
|
19609
|
+
}
|
|
19610
|
+
},
|
|
19611
|
+
defaultVariants: {
|
|
19612
|
+
variant: "default",
|
|
19613
|
+
size: "default"
|
|
19614
|
+
}
|
|
19615
|
+
}
|
|
19616
|
+
);
|
|
19617
|
+
var Button = React9.forwardRef(
|
|
19618
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
19619
|
+
const Comp = asChild ? Slot : "button";
|
|
19620
|
+
return /* @__PURE__ */ jsx(
|
|
19621
|
+
Comp,
|
|
19622
|
+
{
|
|
19623
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
19624
|
+
ref,
|
|
19625
|
+
...props
|
|
19626
|
+
}
|
|
19627
|
+
);
|
|
19628
|
+
}
|
|
19629
|
+
);
|
|
19630
|
+
Button.displayName = "Button";
|
|
18910
19631
|
function Skeleton({ className, ...props }) {
|
|
18911
19632
|
return /* @__PURE__ */ jsx(
|
|
18912
19633
|
MuiSkeleton,
|
|
@@ -18935,7 +19656,23 @@ var ERROR_CODE_TEXT = {
|
|
|
18935
19656
|
"llm.content_policy": "\u26A0\uFE0F **The response was blocked by a content filter**\n\nPlease rephrase your request.",
|
|
18936
19657
|
"llm.schema_validation": "\u26A0\uFE0F **The model returned an invalid response**\n\nPlease try again.",
|
|
18937
19658
|
"llm.unsupported_modality": "\u26A0\uFE0F **This model can't read images**\n\nSwitch to a vision-capable model, or remove the attachment and describe it instead.",
|
|
18938
|
-
"llm.unknown": GENERIC_ERROR_TEXT
|
|
19659
|
+
"llm.unknown": GENERIC_ERROR_TEXT,
|
|
19660
|
+
// The AI API's current name for llm.auth; older messages stored that one.
|
|
19661
|
+
"llm.auth_failed": "\u26A0\uFE0F **The model connection isn't authorised**\n\nAn administrator needs to check the model configuration.",
|
|
19662
|
+
"llm.unsupported_tools": "\u26A0\uFE0F **This model can't use tools**\n\nAn administrator needs to choose a model that supports tools for this step.",
|
|
19663
|
+
"embeddings.model_not_found": "\u26A0\uFE0F **The model or deployment could not be found**\n\nAn administrator needs to check the model configuration.",
|
|
19664
|
+
// The app API's names for losing the AI API before or part-way through a reply.
|
|
19665
|
+
"ai_api.unavailable": "\u26A0\uFE0F **The connection to the model was interrupted**\n\nThis is usually temporary. Please try again.",
|
|
19666
|
+
"ai_api.stream_broken": "\u26A0\uFE0F **The connection to the model was interrupted**\n\nThis is usually temporary. Please try again.",
|
|
19667
|
+
// Managed secrets. A secret's failure arrives as a 404 or 400, which the
|
|
19668
|
+
// status table below would read as a missing model or a generic error.
|
|
19669
|
+
"secret.user_value_not_set": "\u26A0\uFE0F **Your own key for this isn't set**\n\nThis step uses a credential each person sets for themselves, and none is set for you yet. Ask an administrator to add it.",
|
|
19670
|
+
"secret.run_has_no_user": "\u26A0\uFE0F **This step needs a signed-in user**\n\nIt uses a person's own credential, so it can't run when no one started the run.",
|
|
19671
|
+
"secret.user_mismatch": "\u26A0\uFE0F **A credential couldn't be loaded**\n\nAn administrator needs to check this flow's secrets.",
|
|
19672
|
+
"secret.run_required": "\u26A0\uFE0F **A credential couldn't be loaded**\n\nAn administrator needs to check this flow's secrets.",
|
|
19673
|
+
"secret.not_found": "\u26A0\uFE0F **A secret this flow uses doesn't exist**\n\nAn administrator needs to add it, or point the flow at another one.",
|
|
19674
|
+
// The API's name for secret.not_found before it was renamed; older messages stored it.
|
|
19675
|
+
MS404: "\u26A0\uFE0F **A secret this flow uses doesn't exist**\n\nAn administrator needs to add it, or point the flow at another one."
|
|
18939
19676
|
};
|
|
18940
19677
|
var STATUS_CODE_TEXT = {
|
|
18941
19678
|
408: ERROR_CODE_TEXT["llm.timeout"],
|
|
@@ -18955,8 +19692,39 @@ var getMessageErrorText = (error) => {
|
|
|
18955
19692
|
if (error.errorCode && ERROR_CODE_TEXT[error.errorCode]) {
|
|
18956
19693
|
return ERROR_CODE_TEXT[error.errorCode];
|
|
18957
19694
|
}
|
|
19695
|
+
if (error.errorCode && !error.errorCode.startsWith("llm.")) {
|
|
19696
|
+
return GENERIC_ERROR_TEXT;
|
|
19697
|
+
}
|
|
18958
19698
|
return STATUS_CODE_TEXT[error.code] ?? GENERIC_ERROR_TEXT;
|
|
18959
19699
|
};
|
|
19700
|
+
function extractProviderErrorDetail(raw2) {
|
|
19701
|
+
const start = raw2.indexOf("{");
|
|
19702
|
+
if (start === -1) return null;
|
|
19703
|
+
let parsed;
|
|
19704
|
+
try {
|
|
19705
|
+
parsed = JSON.parse(raw2.slice(start));
|
|
19706
|
+
} catch {
|
|
19707
|
+
return null;
|
|
19708
|
+
}
|
|
19709
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
19710
|
+
const record = parsed;
|
|
19711
|
+
const inner = typeof record.error === "object" && record.error !== null ? record.error : record;
|
|
19712
|
+
if (typeof inner.message !== "string") return null;
|
|
19713
|
+
return {
|
|
19714
|
+
message: inner.message,
|
|
19715
|
+
param: typeof inner.param === "string" ? inner.param : void 0
|
|
19716
|
+
};
|
|
19717
|
+
}
|
|
19718
|
+
var getMessageErrorDetail = (error) => {
|
|
19719
|
+
if (typeof error === "number" || !error.message) {
|
|
19720
|
+
return null;
|
|
19721
|
+
}
|
|
19722
|
+
const detail = extractProviderErrorDetail(error.message);
|
|
19723
|
+
if (!detail) {
|
|
19724
|
+
return error.message;
|
|
19725
|
+
}
|
|
19726
|
+
return detail.param ? `${detail.message} (param: ${detail.param})` : detail.message;
|
|
19727
|
+
};
|
|
18960
19728
|
var FileInfoSchema = z.object({
|
|
18961
19729
|
id: z.string(),
|
|
18962
19730
|
name: z.string()
|
|
@@ -19000,7 +19768,8 @@ var MessageErrorMessageSchema = z.object({
|
|
|
19000
19768
|
error_code: z.string().nullish(),
|
|
19001
19769
|
message: z.string().nullish(),
|
|
19002
19770
|
data: z.string().nullish(),
|
|
19003
|
-
blockId: z.string().nullish()
|
|
19771
|
+
blockId: z.string().nullish(),
|
|
19772
|
+
traceId: z.string().nullish()
|
|
19004
19773
|
});
|
|
19005
19774
|
var MessageSchema = z.object({
|
|
19006
19775
|
id: z.string().nullish(),
|
|
@@ -19148,45 +19917,6 @@ function parseDateTime(date, customFormat) {
|
|
|
19148
19917
|
function parseDateTimeHuman(date) {
|
|
19149
19918
|
return dayjs.utc(date).local().fromNow();
|
|
19150
19919
|
}
|
|
19151
|
-
var buttonVariants = cva(
|
|
19152
|
-
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
19153
|
-
{
|
|
19154
|
-
variants: {
|
|
19155
|
-
variant: {
|
|
19156
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
19157
|
-
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
19158
|
-
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
19159
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
19160
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
19161
|
-
link: "text-primary underline-offset-4 hover:underline"
|
|
19162
|
-
},
|
|
19163
|
-
size: {
|
|
19164
|
-
default: "h-10 px-4 py-2",
|
|
19165
|
-
sm: "h-9 rounded-md px-3",
|
|
19166
|
-
lg: "h-11 rounded-md px-8",
|
|
19167
|
-
icon: "h-10 w-10"
|
|
19168
|
-
}
|
|
19169
|
-
},
|
|
19170
|
-
defaultVariants: {
|
|
19171
|
-
variant: "default",
|
|
19172
|
-
size: "default"
|
|
19173
|
-
}
|
|
19174
|
-
}
|
|
19175
|
-
);
|
|
19176
|
-
var Button = React8.forwardRef(
|
|
19177
|
-
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
19178
|
-
const Comp = asChild ? Slot : "button";
|
|
19179
|
-
return /* @__PURE__ */ jsx(
|
|
19180
|
-
Comp,
|
|
19181
|
-
{
|
|
19182
|
-
className: cn(buttonVariants({ variant, size, className })),
|
|
19183
|
-
ref,
|
|
19184
|
-
...props
|
|
19185
|
-
}
|
|
19186
|
-
);
|
|
19187
|
-
}
|
|
19188
|
-
);
|
|
19189
|
-
Button.displayName = "Button";
|
|
19190
19920
|
|
|
19191
19921
|
// src/messages/smartCopy.ts
|
|
19192
19922
|
async function copyMessageRich(container, markdown) {
|
|
@@ -19724,6 +20454,7 @@ function ChatMessageSources({
|
|
|
19724
20454
|
] })
|
|
19725
20455
|
] });
|
|
19726
20456
|
}
|
|
20457
|
+
var USER_FORM_CONFIG = { surface: "form", minRows: 6, maxRows: 20 };
|
|
19727
20458
|
var REVEAL_ON_HOVER = "opacity-100 focus-visible:opacity-100 [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover:opacity-100";
|
|
19728
20459
|
var MessageBubble = (props) => {
|
|
19729
20460
|
const {
|
|
@@ -19777,7 +20508,7 @@ var MessageBubble = (props) => {
|
|
|
19777
20508
|
);
|
|
19778
20509
|
})
|
|
19779
20510
|
] }),
|
|
19780
|
-
showForm && /* @__PURE__ */ jsxs("div", { className: "mt-4 border-t border-border pt-4", children: [
|
|
20511
|
+
showForm && /* @__PURE__ */ jsxs("div", { className: "ss-chat-message__user-form mt-4 border-t border-border pt-4", children: [
|
|
19781
20512
|
/* @__PURE__ */ jsx(
|
|
19782
20513
|
JsonForms,
|
|
19783
20514
|
{
|
|
@@ -19786,6 +20517,7 @@ var MessageBubble = (props) => {
|
|
|
19786
20517
|
renderers,
|
|
19787
20518
|
cells,
|
|
19788
20519
|
readonly: userInput !== void 0,
|
|
20520
|
+
config: USER_FORM_CONFIG,
|
|
19789
20521
|
onChange: ({ data, errors }) => {
|
|
19790
20522
|
setResponseFormData(data);
|
|
19791
20523
|
setResponseFormValid(!errors?.length);
|
|
@@ -19846,6 +20578,34 @@ var MessageBubble = (props) => {
|
|
|
19846
20578
|
/* @__PURE__ */ jsx("div", { className: "mt-1.5", children: metaRow })
|
|
19847
20579
|
] });
|
|
19848
20580
|
};
|
|
20581
|
+
function MessageErrorDetails({
|
|
20582
|
+
detail,
|
|
20583
|
+
traceId
|
|
20584
|
+
}) {
|
|
20585
|
+
const [expanded, setExpanded] = useState(false);
|
|
20586
|
+
return /* @__PURE__ */ jsxs("div", { className: "mt-1", children: [
|
|
20587
|
+
/* @__PURE__ */ jsxs(
|
|
20588
|
+
"button",
|
|
20589
|
+
{
|
|
20590
|
+
type: "button",
|
|
20591
|
+
onClick: () => setExpanded((prev) => !prev),
|
|
20592
|
+
"aria-expanded": expanded,
|
|
20593
|
+
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",
|
|
20594
|
+
children: [
|
|
20595
|
+
expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3 shrink-0" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 shrink-0" }),
|
|
20596
|
+
expanded ? "Hide details" : "Show details"
|
|
20597
|
+
]
|
|
20598
|
+
}
|
|
20599
|
+
),
|
|
20600
|
+
expanded && /* @__PURE__ */ jsxs("div", { className: "mt-1.5 whitespace-pre-wrap break-words rounded-md bg-secondary/60 p-2 font-mono text-[11px] leading-relaxed text-muted-foreground", children: [
|
|
20601
|
+
detail,
|
|
20602
|
+
traceId && /* @__PURE__ */ jsxs("div", { className: detail ? "mt-1.5" : void 0, children: [
|
|
20603
|
+
"Reference: ",
|
|
20604
|
+
traceId
|
|
20605
|
+
] })
|
|
20606
|
+
] })
|
|
20607
|
+
] });
|
|
20608
|
+
}
|
|
19849
20609
|
var ThinkingSection = ({ status }) => /* @__PURE__ */ jsxs(
|
|
19850
20610
|
"div",
|
|
19851
20611
|
{
|
|
@@ -19930,14 +20690,14 @@ var MessageItem = ({
|
|
|
19930
20690
|
const { data: workspace } = useWorkspace(workspaceId);
|
|
19931
20691
|
const chatbotName = getChatbotName(workspace?.name);
|
|
19932
20692
|
const { addInputToMessageMutation } = useAddInputToMessage();
|
|
19933
|
-
const onSubmitUserForm = (messageId) => (name, value) => {
|
|
20693
|
+
const onSubmitUserForm = (messageId, channels = {}) => (name, value) => {
|
|
19934
20694
|
if (!threadId || !messageId) return;
|
|
19935
20695
|
addInputToMessageMutation.mutate({
|
|
19936
20696
|
threadId,
|
|
19937
20697
|
messageId,
|
|
19938
20698
|
name,
|
|
19939
20699
|
value,
|
|
19940
|
-
channels
|
|
20700
|
+
channels
|
|
19941
20701
|
});
|
|
19942
20702
|
};
|
|
19943
20703
|
const safeTime = (d) => {
|
|
@@ -20068,7 +20828,7 @@ var MessageItem = ({
|
|
|
20068
20828
|
userOutput: v.value && typeof v.value === "object" ? v.value : null,
|
|
20069
20829
|
chatbotName,
|
|
20070
20830
|
userInput: userInput?.value,
|
|
20071
|
-
onSubmitUserForm: onSubmitUserForm(message.id ?? "")
|
|
20831
|
+
onSubmitUserForm: onSubmitUserForm(message.id ?? "", v.channels)
|
|
20072
20832
|
},
|
|
20073
20833
|
`user-${message.id ?? "msg"}-${keyCounter++}`
|
|
20074
20834
|
)
|
|
@@ -20133,22 +20893,26 @@ var MessageItem = ({
|
|
|
20133
20893
|
);
|
|
20134
20894
|
}
|
|
20135
20895
|
(message.errors ?? []).forEach((error, errorIndex) => {
|
|
20896
|
+
const key = `error-${message.id ?? "msg"}-${errorIndex}-${error.errorCode ?? error.code}`;
|
|
20897
|
+
const detail = getMessageErrorDetail(error);
|
|
20136
20898
|
bubbles.push(
|
|
20137
|
-
/* @__PURE__ */
|
|
20138
|
-
|
|
20139
|
-
|
|
20140
|
-
|
|
20141
|
-
|
|
20142
|
-
|
|
20143
|
-
|
|
20144
|
-
|
|
20145
|
-
|
|
20146
|
-
|
|
20147
|
-
|
|
20148
|
-
|
|
20149
|
-
|
|
20150
|
-
|
|
20151
|
-
|
|
20899
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
20900
|
+
/* @__PURE__ */ jsx(
|
|
20901
|
+
MessageBubble,
|
|
20902
|
+
{
|
|
20903
|
+
createdBy: chatbotName,
|
|
20904
|
+
createdAt: message.createdAt,
|
|
20905
|
+
type: "Output" /* OUTPUT */,
|
|
20906
|
+
content: [{ text: getMessageErrorText(error) }],
|
|
20907
|
+
files: [],
|
|
20908
|
+
sources: [],
|
|
20909
|
+
chatbotName,
|
|
20910
|
+
userOutput: null,
|
|
20911
|
+
userInput: null
|
|
20912
|
+
}
|
|
20913
|
+
),
|
|
20914
|
+
(detail || error.traceId) && /* @__PURE__ */ jsx(MessageErrorDetails, { detail, traceId: error.traceId })
|
|
20915
|
+
] }, key)
|
|
20152
20916
|
);
|
|
20153
20917
|
});
|
|
20154
20918
|
return bubbles;
|
|
@@ -20174,14 +20938,16 @@ function MessageList({
|
|
|
20174
20938
|
data: thread,
|
|
20175
20939
|
isPending: threadPending,
|
|
20176
20940
|
isFetching: threadFetching,
|
|
20177
|
-
error: threadError
|
|
20941
|
+
error: threadError,
|
|
20942
|
+
refetch: refetchThread
|
|
20178
20943
|
} = useThread({ workspaceId, threadId });
|
|
20179
20944
|
const isRunning = useThreadIsRunning(workspaceId, threadId);
|
|
20180
20945
|
const {
|
|
20181
20946
|
data: messages,
|
|
20182
20947
|
isPending: messagesPending,
|
|
20183
20948
|
isFetching: messagesFetching,
|
|
20184
|
-
error: messagesError
|
|
20949
|
+
error: messagesError,
|
|
20950
|
+
refetch: refetchMessages
|
|
20185
20951
|
} = useMessages(threadId);
|
|
20186
20952
|
const hostBg = applyHostBackgroundOverride ? "chat-main" : "";
|
|
20187
20953
|
const scrollToBottom = useCallback((behavior = "auto") => {
|
|
@@ -20260,10 +21026,23 @@ function MessageList({
|
|
|
20260
21026
|
messagesError && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-destructive", children: [
|
|
20261
21027
|
/* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4" }),
|
|
20262
21028
|
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Failed to load messages" })
|
|
20263
|
-
] })
|
|
21029
|
+
] }),
|
|
21030
|
+
/* @__PURE__ */ jsx(
|
|
21031
|
+
Button,
|
|
21032
|
+
{
|
|
21033
|
+
size: "sm",
|
|
21034
|
+
variant: "outline",
|
|
21035
|
+
onClick: () => {
|
|
21036
|
+
if (threadError) void refetchThread();
|
|
21037
|
+
if (messagesError) void refetchMessages();
|
|
21038
|
+
},
|
|
21039
|
+
children: "Try again"
|
|
21040
|
+
}
|
|
21041
|
+
)
|
|
20264
21042
|
] }) });
|
|
20265
21043
|
}
|
|
20266
21044
|
if (safeMessages.length === 0 && !hadMessagesBefore) {
|
|
21045
|
+
const descriptionParagraphs = (activeWorkspace?.summary ?? "").split(/\n+/).map((paragraph2) => paragraph2.trim()).filter(Boolean);
|
|
20267
21046
|
return (
|
|
20268
21047
|
// A new thread opens the way the design does: the greeting and the
|
|
20269
21048
|
// composer travel together as one narrower block centred in the canvas.
|
|
@@ -20276,6 +21055,14 @@ function MessageList({
|
|
|
20276
21055
|
"data-ss-layer": "message-list",
|
|
20277
21056
|
children: /* @__PURE__ */ jsxs("div", { className: "mx-auto mb-6 w-full max-w-2xl px-4 text-center", children: [
|
|
20278
21057
|
/* @__PURE__ */ jsx("h2", { className: "text-2xl font-semibold text-foreground", children: "What\u2019s on the agenda today?" }),
|
|
21058
|
+
descriptionParagraphs.length > 0 && /* @__PURE__ */ jsx(
|
|
21059
|
+
"div",
|
|
21060
|
+
{
|
|
21061
|
+
className: "mx-auto mt-2 max-w-lg space-y-1.5 text-sm text-muted-foreground",
|
|
21062
|
+
"data-ss-layer": "workspace-description",
|
|
21063
|
+
children: descriptionParagraphs.map((paragraph2, index) => /* @__PURE__ */ jsx("p", { children: paragraph2 }, index))
|
|
21064
|
+
}
|
|
21065
|
+
),
|
|
20279
21066
|
activeWorkspace?.firstPrompt && /* @__PURE__ */ jsx("div", { className: "chat-prose mt-3 text-center", children: /* @__PURE__ */ jsx(MessageMarkdown, { value: activeWorkspace.firstPrompt }) })
|
|
20280
21067
|
] })
|
|
20281
21068
|
}
|
|
@@ -20394,6 +21181,11 @@ function MessageListSkeleton() {
|
|
|
20394
21181
|
i
|
|
20395
21182
|
)) });
|
|
20396
21183
|
}
|
|
21184
|
+
|
|
21185
|
+
// src/shared/utils/enums.ts
|
|
21186
|
+
var isMember = (e, value) => Object.values(e).includes(value);
|
|
21187
|
+
|
|
21188
|
+
// src/domains/messages/mapper.ts
|
|
20397
21189
|
var {
|
|
20398
21190
|
messageThreadsThreadMessagesIdMessagesResponse: messagesResponseSchema
|
|
20399
21191
|
} = ChatZod;
|
|
@@ -20420,6 +21212,7 @@ function mapMessageValueDtoToModel(dto) {
|
|
|
20420
21212
|
createdByUserId: dto.createdByUserId ?? void 0
|
|
20421
21213
|
};
|
|
20422
21214
|
}
|
|
21215
|
+
var mapMessageValuesDtoToModels = (dtos) => dtos.filter((dto) => isMember(MessageValueType, dto.type)).map(mapMessageValueDtoToModel);
|
|
20423
21216
|
function mapMessageErrorDtoToModel(dto) {
|
|
20424
21217
|
const { error_code, ...rest } = dto;
|
|
20425
21218
|
return {
|
|
@@ -20437,7 +21230,7 @@ function mapMessageDtoToModel(dto) {
|
|
|
20437
21230
|
createdByUserId: dto.createdByUserId ?? void 0,
|
|
20438
21231
|
messageThreadId: dto.messageThreadId ?? void 0,
|
|
20439
21232
|
errors: dto.errors?.map(mapMessageErrorDtoToModel) ?? void 0,
|
|
20440
|
-
values: dto.values
|
|
21233
|
+
values: dto.values && mapMessageValuesDtoToModels(dto.values)
|
|
20441
21234
|
};
|
|
20442
21235
|
}
|
|
20443
21236
|
function mapMessagesDtoToModels(dto) {
|
|
@@ -20553,8 +21346,7 @@ var mapWorkspacesDtoToModels = (arr) => arr.map(mapWorkspaceDtoToModel);
|
|
|
20553
21346
|
function getChatApiBaseUrl() {
|
|
20554
21347
|
try {
|
|
20555
21348
|
const w = window;
|
|
20556
|
-
const
|
|
20557
|
-
const cfg = w?.ssconfig?.Chat_Api_Uri ?? env2?.VITE_CHAT_API_URI;
|
|
21349
|
+
const cfg = w?.ssconfig?.Chat_Api_Uri;
|
|
20558
21350
|
return typeof cfg === "string" && cfg.trim() ? cfg.trim() : "";
|
|
20559
21351
|
} catch {
|
|
20560
21352
|
return "";
|
|
@@ -20567,6 +21359,6 @@ function getUserPhotoUrl(userId) {
|
|
|
20567
21359
|
return `${base2}/users/${userId}/photo`;
|
|
20568
21360
|
}
|
|
20569
21361
|
|
|
20570
|
-
export { ChatProvider, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, MarkdownEditor, MessageComposer, MessageList, MessageListSkeleton, MessageMarkdown, MessageValueType, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getMessageErrorText, getModelIcon, getRetryStatusText, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, parseRetryStatus, randomUUID, setThreadOptimisticRunning, setThreadRunningInLists, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useIsDraftThreadId, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
|
|
21362
|
+
export { ChatProvider, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, DictationButton, MarkdownEditor, MessageComposer, MessageList, MessageListSkeleton, MessageMarkdown, MessageValueType, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getMessageErrorDetail, getMessageErrorText, getModelIcon, getRetryStatusText, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessageValuesDtoToModels, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, parseRetryStatus, randomUUID, setThreadOptimisticRunning, setThreadRunningInLists, speechKeys, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDictation, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useIsDraftThreadId, useMessages, useModels, useSendMessage, useSpeechConfig, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
|
|
20571
21363
|
//# sourceMappingURL=index.js.map
|
|
20572
21364
|
//# sourceMappingURL=index.js.map
|