@smartspace/chat-ui 1.13.1-dev.aa44752 → 1.13.1-dev.b59850a
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/LICENSE +21 -0
- package/dist/index.d.ts +8 -15
- package/dist/index.js +192 -34
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Smartspace.ai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
CHANGED
|
@@ -238,6 +238,14 @@ type MessageThread = {
|
|
|
238
238
|
totalMessages: number;
|
|
239
239
|
pinned: boolean;
|
|
240
240
|
workSpaceId: string;
|
|
241
|
+
/**
|
|
242
|
+
* Monotonic version of when this summary was emitted (epoch ms). Used by
|
|
243
|
+
* `applyThreadToCache` to reject stale writes — e.g. a SignalR summary
|
|
244
|
+
* landing after a fresher SSE thread frame because the server's DB write
|
|
245
|
+
* lagged Redis. Mappers derive this from `lastUpdatedAt`; client-side
|
|
246
|
+
* writers like `ensureDraftThread` use `Date.now()`.
|
|
247
|
+
*/
|
|
248
|
+
summaryEmittedAt: number;
|
|
241
249
|
};
|
|
242
250
|
type ThreadsResponse = {
|
|
243
251
|
data: MessageThread[];
|
|
@@ -269,7 +277,6 @@ type Workspace = {
|
|
|
269
277
|
firstPrompt: string;
|
|
270
278
|
outputSchema?: unknown;
|
|
271
279
|
inputs?: unknown;
|
|
272
|
-
isPromptAndResponseLoggingEnabled: boolean;
|
|
273
280
|
variables: Variables;
|
|
274
281
|
sandBoxThreadId?: string;
|
|
275
282
|
supportsFiles: boolean;
|
|
@@ -969,20 +976,6 @@ declare function mapMentionUserDtoToModel(dto: MentionUserDto): MentionUser;
|
|
|
969
976
|
declare function mapWorkspaceDtoToModel(dto: WorkspaceDto): Workspace;
|
|
970
977
|
declare const mapWorkspacesDtoToModels: (arr: WorkspacesListItemDto[]) => Workspace[];
|
|
971
978
|
|
|
972
|
-
/**
|
|
973
|
-
* Write a freshly-observed thread (from SignalR or an SSE thread frame)
|
|
974
|
-
* directly into the relevant query caches so subscribers paint without a
|
|
975
|
-
* refetch roundtrip.
|
|
976
|
-
*
|
|
977
|
-
* - Merges into `threadsKeys.detail(workspaceId, thread.id)`.
|
|
978
|
-
* - Splices into every threads-list cache for the workspace, handling both
|
|
979
|
-
* finite `ThreadsResponse` and infinite `{ pages, pageParams }` shapes.
|
|
980
|
-
*
|
|
981
|
-
* Returns `true` when the thread was found in at least one list cache.
|
|
982
|
-
* Callers that need to surface brand-new threads (e.g. another user just
|
|
983
|
-
* created one) can fall back to invalidating the list queries when this
|
|
984
|
-
* returns `false`.
|
|
985
|
-
*/
|
|
986
979
|
declare function applyThreadToCache(qc: QueryClient, thread: MessageThread): boolean;
|
|
987
980
|
/**
|
|
988
981
|
* Invalidate every threads-list cache for a workspace. Use as a fallback when
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import MuiButton from '@mui/material/Button';
|
|
2
2
|
import IconButton from '@mui/material/IconButton';
|
|
3
3
|
import { Loader2, Check, X, Paperclip, ArrowBigUp, Minimize2, AlertTriangle, FileImage, FileVideo, FileAudio, FileArchive, FileCode, FileSpreadsheet, Presentation, FileText, ChevronUp, ExternalLink, Copy, Download } from 'lucide-react';
|
|
4
|
-
import * as
|
|
4
|
+
import * as React9 from 'react';
|
|
5
5
|
import { createContext, forwardRef, useImperativeHandle, useRef, useState, useEffect, useMemo, useCallback, createElement, useContext } from 'react';
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
7
|
import { useQuery, queryOptions, useQueryClient, useMutation, skipToken } from '@tanstack/react-query';
|
|
@@ -1687,7 +1687,7 @@ var buttonVariants = cva(
|
|
|
1687
1687
|
}
|
|
1688
1688
|
}
|
|
1689
1689
|
);
|
|
1690
|
-
var Button =
|
|
1690
|
+
var Button = React9.forwardRef(
|
|
1691
1691
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
1692
1692
|
const Comp = asChild ? Slot : "button";
|
|
1693
1693
|
return /* @__PURE__ */ jsx(
|
|
@@ -2902,6 +2902,128 @@ var modelIdRendererTester = rankWith(
|
|
|
2902
2902
|
}
|
|
2903
2903
|
);
|
|
2904
2904
|
var ModelIdRendererControl = withJsonFormsControlProps(ModelIdRenderer);
|
|
2905
|
+
var NumberRenderer = ({
|
|
2906
|
+
data,
|
|
2907
|
+
handleChange,
|
|
2908
|
+
path: path2,
|
|
2909
|
+
label,
|
|
2910
|
+
description,
|
|
2911
|
+
errors,
|
|
2912
|
+
schema,
|
|
2913
|
+
uischema,
|
|
2914
|
+
visible,
|
|
2915
|
+
enabled,
|
|
2916
|
+
required
|
|
2917
|
+
}) => {
|
|
2918
|
+
const isInteger = schema?.type === "integer";
|
|
2919
|
+
const handleInputChange = useCallback(
|
|
2920
|
+
(event) => {
|
|
2921
|
+
const raw2 = event.target.value;
|
|
2922
|
+
if (raw2 === "") {
|
|
2923
|
+
handleChange(path2, void 0);
|
|
2924
|
+
return;
|
|
2925
|
+
}
|
|
2926
|
+
const parsed = isInteger ? parseInt(raw2, 10) : parseFloat(raw2);
|
|
2927
|
+
if (Number.isNaN(parsed)) {
|
|
2928
|
+
handleChange(path2, void 0);
|
|
2929
|
+
return;
|
|
2930
|
+
}
|
|
2931
|
+
handleChange(path2, parsed);
|
|
2932
|
+
},
|
|
2933
|
+
[handleChange, path2, isInteger]
|
|
2934
|
+
);
|
|
2935
|
+
if (!visible) return null;
|
|
2936
|
+
const readOnly = uischema?.access === "Read";
|
|
2937
|
+
const isDisabled = !enabled || readOnly;
|
|
2938
|
+
const hasError = !!errors && errors.length > 0;
|
|
2939
|
+
const fieldSchema = schema;
|
|
2940
|
+
const min = fieldSchema?.minimum;
|
|
2941
|
+
const max = fieldSchema?.maximum;
|
|
2942
|
+
const step = isInteger ? 1 : fieldSchema?.multipleOf ?? "any";
|
|
2943
|
+
return /* @__PURE__ */ jsxs(
|
|
2944
|
+
"div",
|
|
2945
|
+
{
|
|
2946
|
+
className: "ss-jsonforms-field ss-jsonforms-number",
|
|
2947
|
+
style: {
|
|
2948
|
+
display: "inline-flex",
|
|
2949
|
+
flexDirection: "row",
|
|
2950
|
+
alignItems: "center",
|
|
2951
|
+
gap: 8,
|
|
2952
|
+
minHeight: "40px"
|
|
2953
|
+
},
|
|
2954
|
+
children: [
|
|
2955
|
+
label && /* @__PURE__ */ jsxs(
|
|
2956
|
+
"label",
|
|
2957
|
+
{
|
|
2958
|
+
htmlFor: `number-${path2}`,
|
|
2959
|
+
style: {
|
|
2960
|
+
color: hasError ? "#ef4444" : "#475569",
|
|
2961
|
+
fontSize: "0.875rem",
|
|
2962
|
+
fontWeight: 500,
|
|
2963
|
+
whiteSpace: "nowrap",
|
|
2964
|
+
lineHeight: "24px"
|
|
2965
|
+
},
|
|
2966
|
+
children: [
|
|
2967
|
+
label,
|
|
2968
|
+
required && /* @__PURE__ */ jsx("span", { style: { color: "#ef4444", marginLeft: "0.25rem" }, children: "*" })
|
|
2969
|
+
]
|
|
2970
|
+
}
|
|
2971
|
+
),
|
|
2972
|
+
/* @__PURE__ */ jsx(
|
|
2973
|
+
"input",
|
|
2974
|
+
{
|
|
2975
|
+
id: `number-${path2}`,
|
|
2976
|
+
type: "number",
|
|
2977
|
+
value: data ?? "",
|
|
2978
|
+
onChange: handleInputChange,
|
|
2979
|
+
disabled: isDisabled,
|
|
2980
|
+
min,
|
|
2981
|
+
max,
|
|
2982
|
+
step,
|
|
2983
|
+
style: {
|
|
2984
|
+
width: "80px",
|
|
2985
|
+
height: "24px",
|
|
2986
|
+
padding: "0 0.5rem",
|
|
2987
|
+
border: hasError ? "2px solid #ef4444" : "1px solid #d1d5db",
|
|
2988
|
+
borderRadius: "6px",
|
|
2989
|
+
fontSize: "0.875rem",
|
|
2990
|
+
lineHeight: "24px",
|
|
2991
|
+
fontFamily: "inherit",
|
|
2992
|
+
backgroundColor: isDisabled ? "#f9fafb" : "#ffffff",
|
|
2993
|
+
color: isDisabled ? "#9ca3af" : "#111827",
|
|
2994
|
+
outline: "none",
|
|
2995
|
+
boxSizing: "border-box"
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
),
|
|
2999
|
+
hasError && /* @__PURE__ */ jsx(
|
|
3000
|
+
"div",
|
|
3001
|
+
{
|
|
3002
|
+
style: {
|
|
3003
|
+
color: "#ef4444",
|
|
3004
|
+
fontSize: "0.75rem"
|
|
3005
|
+
},
|
|
3006
|
+
children: errors
|
|
3007
|
+
}
|
|
3008
|
+
)
|
|
3009
|
+
]
|
|
3010
|
+
}
|
|
3011
|
+
);
|
|
3012
|
+
};
|
|
3013
|
+
var numberRendererTester = rankWith(
|
|
3014
|
+
40,
|
|
3015
|
+
(uischema, schema) => {
|
|
3016
|
+
if (uischema.type !== "Control") return false;
|
|
3017
|
+
const propertyPath = uischema.scope.replace(
|
|
3018
|
+
"#/properties/",
|
|
3019
|
+
""
|
|
3020
|
+
);
|
|
3021
|
+
const fieldSchema = schema?.properties?.[propertyPath];
|
|
3022
|
+
if (!fieldSchema) return false;
|
|
3023
|
+
return fieldSchema.type === "integer" || fieldSchema.type === "number";
|
|
3024
|
+
}
|
|
3025
|
+
);
|
|
3026
|
+
var NumberRendererControl = withJsonFormsControlProps(NumberRenderer);
|
|
2905
3027
|
var TextareaRenderer = ({
|
|
2906
3028
|
data,
|
|
2907
3029
|
handleChange,
|
|
@@ -3071,6 +3193,7 @@ var renderers = [
|
|
|
3071
3193
|
{ tester: modelIdRendererTester, renderer: ModelIdRendererControl },
|
|
3072
3194
|
{ tester: booleanRendererTester, renderer: BooleanRendererControl },
|
|
3073
3195
|
{ tester: dropdownRendererTester, renderer: DropdownRendererControl },
|
|
3196
|
+
{ tester: numberRendererTester, renderer: NumberRendererControl },
|
|
3074
3197
|
{ tester: textareaRendererTester, renderer: TextareaRendererControl },
|
|
3075
3198
|
...vanillaRenderers,
|
|
3076
3199
|
{ tester: jsonEditorTester, renderer: JsonEditorRendererControl }
|
|
@@ -3124,26 +3247,26 @@ function useChatVariablesFormVm({
|
|
|
3124
3247
|
const { mutate: updateVariableMutation } = useUpdateFlowRunVariable();
|
|
3125
3248
|
const querySettled = !isLoading && (threadVars !== void 0 || isError);
|
|
3126
3249
|
const shouldUseDefaults = isError || threadVars && Object.keys(threadVars).length === 0;
|
|
3127
|
-
const built =
|
|
3250
|
+
const built = React9.useMemo(() => {
|
|
3128
3251
|
return buildSimpleSchemaAndUi(
|
|
3129
3252
|
workspace.variables,
|
|
3130
3253
|
threadVars,
|
|
3131
3254
|
shouldUseDefaults ?? false
|
|
3132
3255
|
);
|
|
3133
3256
|
}, [workspace.variables, threadVars, shouldUseDefaults]);
|
|
3134
|
-
const [data, setData] =
|
|
3135
|
-
|
|
3257
|
+
const [data, setData] = React9.useState(null);
|
|
3258
|
+
React9.useEffect(() => {
|
|
3136
3259
|
if (querySettled) {
|
|
3137
3260
|
setData(built.initialData);
|
|
3138
3261
|
setVariables(built.initialData);
|
|
3139
3262
|
}
|
|
3140
3263
|
}, [querySettled, built.initialData, setVariables]);
|
|
3141
|
-
const ajv =
|
|
3142
|
-
const prevRef =
|
|
3143
|
-
|
|
3264
|
+
const ajv = React9.useMemo(() => createAjv({ useDefaults: false }), []);
|
|
3265
|
+
const prevRef = React9.useRef(null);
|
|
3266
|
+
React9.useEffect(() => {
|
|
3144
3267
|
prevRef.current = data;
|
|
3145
3268
|
}, [data]);
|
|
3146
|
-
const onChange =
|
|
3269
|
+
const onChange = React9.useCallback(
|
|
3147
3270
|
({ data: next2 }) => {
|
|
3148
3271
|
if (prevRef.current && !isDraftThreadId(threadId)) {
|
|
3149
3272
|
const keys2 = Object.keys(workspace.variables || {});
|
|
@@ -3164,7 +3287,7 @@ function useChatVariablesFormVm({
|
|
|
3164
3287
|
},
|
|
3165
3288
|
[workspace.variables, setVariables, updateVariableMutation, threadId]
|
|
3166
3289
|
);
|
|
3167
|
-
const config =
|
|
3290
|
+
const config = React9.useMemo(
|
|
3168
3291
|
() => ({
|
|
3169
3292
|
restrict: true,
|
|
3170
3293
|
trim: false,
|
|
@@ -3233,7 +3356,20 @@ var threadsKeys = {
|
|
|
3233
3356
|
};
|
|
3234
3357
|
|
|
3235
3358
|
// src/domains/threads/cache.ts
|
|
3359
|
+
function isStaleSummary(incoming, existing) {
|
|
3360
|
+
if (!existing) return false;
|
|
3361
|
+
if (typeof existing.summaryEmittedAt !== "number") return false;
|
|
3362
|
+
if (typeof incoming.summaryEmittedAt !== "number") return false;
|
|
3363
|
+
if (incoming.summaryEmittedAt >= existing.summaryEmittedAt) return false;
|
|
3364
|
+
return existing.isFlowRunning === false && incoming.isFlowRunning === true;
|
|
3365
|
+
}
|
|
3236
3366
|
function applyThreadToCache(qc, thread) {
|
|
3367
|
+
const existingDetail = qc.getQueryData(
|
|
3368
|
+
threadsKeys.detail(thread.workSpaceId, thread.id)
|
|
3369
|
+
);
|
|
3370
|
+
if (isStaleSummary(thread, existingDetail)) {
|
|
3371
|
+
return false;
|
|
3372
|
+
}
|
|
3237
3373
|
qc.setQueryData(
|
|
3238
3374
|
threadsKeys.detail(thread.workSpaceId, thread.id),
|
|
3239
3375
|
(old) => ({ ...old ?? thread, ...thread })
|
|
@@ -3254,6 +3390,7 @@ function applyThreadToCache(qc, thread) {
|
|
|
3254
3390
|
if (!page?.data) return page;
|
|
3255
3391
|
const idx2 = page.data.findIndex((t) => t.id === thread.id);
|
|
3256
3392
|
if (idx2 === -1) return page;
|
|
3393
|
+
if (isStaleSummary(thread, page.data[idx2])) return page;
|
|
3257
3394
|
changed = true;
|
|
3258
3395
|
foundInList = true;
|
|
3259
3396
|
const nextData2 = page.data.slice();
|
|
@@ -3266,6 +3403,7 @@ function applyThreadToCache(qc, thread) {
|
|
|
3266
3403
|
if (!list2.data) return old;
|
|
3267
3404
|
const idx = list2.data.findIndex((t) => t.id === thread.id);
|
|
3268
3405
|
if (idx === -1) return old;
|
|
3406
|
+
if (isStaleSummary(thread, list2.data[idx])) return old;
|
|
3269
3407
|
foundInList = true;
|
|
3270
3408
|
const nextData = list2.data.slice();
|
|
3271
3409
|
nextData[idx] = { ...nextData[idx], ...thread };
|
|
@@ -3335,36 +3473,40 @@ var {
|
|
|
3335
3473
|
messageThreadsGetMessageThreadWorkspacesWorkspaceIdMessagethreadsIdResponse: threadResponseSchema
|
|
3336
3474
|
} = ChatZod;
|
|
3337
3475
|
function mapThreadDtoToModel(dto) {
|
|
3476
|
+
const lastUpdatedAt = utcDate(dto.lastUpdatedAt);
|
|
3338
3477
|
return {
|
|
3339
3478
|
id: dto.id,
|
|
3340
3479
|
createdAt: utcDate(dto.createdAt),
|
|
3341
3480
|
createdBy: dto.createdBy ?? "",
|
|
3342
3481
|
createdByUserId: dto.createdByUserId,
|
|
3343
3482
|
isFlowRunning: dto.isFlowRunning,
|
|
3344
|
-
lastUpdatedAt
|
|
3483
|
+
lastUpdatedAt,
|
|
3345
3484
|
lastUpdatedByUserId: dto.lastUpdatedByUserId,
|
|
3346
3485
|
name: dto.name ?? "",
|
|
3347
3486
|
totalMessages: dto.totalMessages,
|
|
3348
3487
|
pinned: dto.favorited,
|
|
3349
|
-
workSpaceId: dto.workSpaceId
|
|
3488
|
+
workSpaceId: dto.workSpaceId,
|
|
3489
|
+
summaryEmittedAt: lastUpdatedAt.getTime()
|
|
3350
3490
|
};
|
|
3351
3491
|
}
|
|
3352
3492
|
function mapThreadsResponseDtoToModel(dto) {
|
|
3353
3493
|
return { data: dto.data.map(mapThreadDtoToModel), total: dto.total };
|
|
3354
3494
|
}
|
|
3355
3495
|
function mapSignalRThreadSummaryToModel(summary) {
|
|
3496
|
+
const lastUpdatedAt = utcDate(summary.lastUpdatedAt);
|
|
3356
3497
|
return {
|
|
3357
3498
|
id: summary.id,
|
|
3358
3499
|
createdAt: utcDate(summary.createdAt),
|
|
3359
3500
|
createdBy: summary.createdBy ?? "",
|
|
3360
3501
|
createdByUserId: summary.createdByUserId,
|
|
3361
3502
|
isFlowRunning: summary.isFlowRunning,
|
|
3362
|
-
lastUpdatedAt
|
|
3503
|
+
lastUpdatedAt,
|
|
3363
3504
|
lastUpdatedByUserId: summary.lastUpdatedByUserId,
|
|
3364
3505
|
name: summary.name ?? "",
|
|
3365
3506
|
totalMessages: summary.totalMessages,
|
|
3366
3507
|
pinned: summary.favorited,
|
|
3367
|
-
workSpaceId: summary.workSpaceId
|
|
3508
|
+
workSpaceId: summary.workSpaceId,
|
|
3509
|
+
summaryEmittedAt: lastUpdatedAt.getTime()
|
|
3368
3510
|
};
|
|
3369
3511
|
}
|
|
3370
3512
|
var threadDetailOptions = ({
|
|
@@ -3457,6 +3599,15 @@ var messagesMutationsKeys = {
|
|
|
3457
3599
|
};
|
|
3458
3600
|
|
|
3459
3601
|
// src/domains/messages/mutations.ts
|
|
3602
|
+
function reconcileWithMessage(old, incoming, onDuplicate = "keep-existing") {
|
|
3603
|
+
const stable = old.filter((m) => !m.optimistic);
|
|
3604
|
+
const idx = stable.findIndex((m) => m.id === incoming.id);
|
|
3605
|
+
if (idx === -1) return [...stable, incoming];
|
|
3606
|
+
if (onDuplicate === "keep-existing") return stable;
|
|
3607
|
+
const copy = stable.slice();
|
|
3608
|
+
copy[idx] = incoming;
|
|
3609
|
+
return copy;
|
|
3610
|
+
}
|
|
3460
3611
|
function useSendMessage() {
|
|
3461
3612
|
const qc = useQueryClient();
|
|
3462
3613
|
const { userId, displayName: userName } = useChatIdentity();
|
|
@@ -3540,7 +3691,10 @@ function useSendMessage() {
|
|
|
3540
3691
|
toast.error("There was an error posting your message");
|
|
3541
3692
|
throw err;
|
|
3542
3693
|
}
|
|
3543
|
-
qc.setQueryData(
|
|
3694
|
+
qc.setQueryData(
|
|
3695
|
+
messagesKeys.list(threadId),
|
|
3696
|
+
(old = []) => reconcileWithMessage(old, realMessage)
|
|
3697
|
+
);
|
|
3544
3698
|
qc.setQueryData(
|
|
3545
3699
|
threadsKeys.detail(workspaceId, threadId),
|
|
3546
3700
|
(old) => old ? { ...old, isFlowRunning: true } : old
|
|
@@ -3596,14 +3750,10 @@ function useAddInputToMessage() {
|
|
|
3596
3750
|
});
|
|
3597
3751
|
},
|
|
3598
3752
|
onSuccess: (message, { threadId }) => {
|
|
3599
|
-
qc.setQueryData(
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
const copy = stable.slice();
|
|
3604
|
-
copy[idx] = message;
|
|
3605
|
-
return copy;
|
|
3606
|
-
});
|
|
3753
|
+
qc.setQueryData(
|
|
3754
|
+
messagesKeys.list(threadId),
|
|
3755
|
+
(old = []) => reconcileWithMessage(old, message, "replace")
|
|
3756
|
+
);
|
|
3607
3757
|
},
|
|
3608
3758
|
onError: (_e, { threadId }) => {
|
|
3609
3759
|
qc.setQueryData(
|
|
@@ -19050,7 +19200,7 @@ function getAvatarColour(name) {
|
|
|
19050
19200
|
const textColor = brightness > 128 ? "#000000" : "#FFFFFF";
|
|
19051
19201
|
return { backgroundColor, textColor };
|
|
19052
19202
|
}
|
|
19053
|
-
var Avatar =
|
|
19203
|
+
var Avatar = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
19054
19204
|
"div",
|
|
19055
19205
|
{
|
|
19056
19206
|
ref,
|
|
@@ -19062,7 +19212,7 @@ var Avatar = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
19062
19212
|
}
|
|
19063
19213
|
));
|
|
19064
19214
|
Avatar.displayName = "Avatar";
|
|
19065
|
-
var AvatarImage =
|
|
19215
|
+
var AvatarImage = React9.forwardRef(({ className, alt, src, children: children2, ...props }, _ref) => /* @__PURE__ */ jsx(
|
|
19066
19216
|
MuiAvatar,
|
|
19067
19217
|
{
|
|
19068
19218
|
className: cn("aspect-square h-full w-full", className),
|
|
@@ -19073,7 +19223,7 @@ var AvatarImage = React8.forwardRef(({ className, alt, src, children: children2,
|
|
|
19073
19223
|
}
|
|
19074
19224
|
));
|
|
19075
19225
|
AvatarImage.displayName = "AvatarImage";
|
|
19076
|
-
var AvatarFallback =
|
|
19226
|
+
var AvatarFallback = React9.forwardRef(
|
|
19077
19227
|
({ className, colored = true, ...props }, ref) => {
|
|
19078
19228
|
const childText = String(props.children ?? "");
|
|
19079
19229
|
const colours = colored ? getAvatarColour(childText) : void 0;
|
|
@@ -19663,7 +19813,8 @@ var MessageItem = ({
|
|
|
19663
19813
|
groupType = v.type;
|
|
19664
19814
|
const name = v.name.toLowerCase();
|
|
19665
19815
|
switch (name) {
|
|
19666
|
-
case "variables":
|
|
19816
|
+
case "variables":
|
|
19817
|
+
case "userinfo": {
|
|
19667
19818
|
continue;
|
|
19668
19819
|
}
|
|
19669
19820
|
case "status": {
|
|
@@ -19804,6 +19955,10 @@ function MessageList({
|
|
|
19804
19955
|
const messagesEndRef = useRef(null);
|
|
19805
19956
|
const prevMessageCountRef = useRef(0);
|
|
19806
19957
|
const hasInitialScrollRef = useRef(false);
|
|
19958
|
+
const everHadMessagesRef = useRef({
|
|
19959
|
+
threadId: "",
|
|
19960
|
+
had: false
|
|
19961
|
+
});
|
|
19807
19962
|
const isMobile = useIsMobile();
|
|
19808
19963
|
const { data: activeWorkspace } = useWorkspace(workspaceId);
|
|
19809
19964
|
const [isAtBottom, setIsAtBottom] = useState(true);
|
|
@@ -19875,8 +20030,15 @@ function MessageList({
|
|
|
19875
20030
|
ro.observe(content);
|
|
19876
20031
|
return () => ro.disconnect();
|
|
19877
20032
|
}, [isAtBottom, scrollToBottom]);
|
|
20033
|
+
const safeMessages = messages ?? [];
|
|
20034
|
+
if (everHadMessagesRef.current.threadId !== threadId) {
|
|
20035
|
+
everHadMessagesRef.current = { threadId, had: safeMessages.length > 0 };
|
|
20036
|
+
} else if (safeMessages.length > 0) {
|
|
20037
|
+
everHadMessagesRef.current.had = true;
|
|
20038
|
+
}
|
|
20039
|
+
const hadMessagesBefore = everHadMessagesRef.current.had;
|
|
19878
20040
|
const isLoading = isChoosingThread || (threadPending || threadFetching) && !thread || (messagesPending || messagesFetching) && messages === void 0;
|
|
19879
|
-
if (isLoading) {
|
|
20041
|
+
if (isLoading && !hadMessagesBefore) {
|
|
19880
20042
|
return /* @__PURE__ */ jsx(
|
|
19881
20043
|
"div",
|
|
19882
20044
|
{
|
|
@@ -19892,7 +20054,7 @@ function MessageList({
|
|
|
19892
20054
|
}
|
|
19893
20055
|
);
|
|
19894
20056
|
}
|
|
19895
|
-
if (threadError || messagesError) {
|
|
20057
|
+
if ((threadError || messagesError) && !hadMessagesBefore) {
|
|
19896
20058
|
return /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-center p-6", children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-md space-y-3", children: [
|
|
19897
20059
|
threadError && /* @__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: [
|
|
19898
20060
|
/* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4" }),
|
|
@@ -19904,8 +20066,7 @@ function MessageList({
|
|
|
19904
20066
|
] })
|
|
19905
20067
|
] }) });
|
|
19906
20068
|
}
|
|
19907
|
-
|
|
19908
|
-
if (safeMessages.length === 0) {
|
|
20069
|
+
if (safeMessages.length === 0 && !hadMessagesBefore) {
|
|
19909
20070
|
return /* @__PURE__ */ jsxs("div", { className: "flex overflow-auto flex-shrink-10 flex-col p-8 text-center", children: [
|
|
19910
20071
|
/* @__PURE__ */ jsx("h3", { className: "text-lg font-medium mb-2", children: activeWorkspace?.name ?? "No messages yet" }),
|
|
19911
20072
|
activeWorkspace?.firstPrompt && /* @__PURE__ */ jsx("div", { className: "max-w-3xl mx-auto p-4", children: /* @__PURE__ */ jsx(MessageMarkdown, { value: activeWorkspace.firstPrompt }) })
|
|
@@ -20157,9 +20318,6 @@ function mapWorkspaceDtoToModel(dto) {
|
|
|
20157
20318
|
firstPrompt: dto.firstPrompt ?? "",
|
|
20158
20319
|
outputSchema: dto.outputSchema ?? void 0,
|
|
20159
20320
|
inputs: dto.inputs ?? void 0,
|
|
20160
|
-
isPromptAndResponseLoggingEnabled: truthy(
|
|
20161
|
-
dto.isPromptAndResponseLoggingEnabled
|
|
20162
|
-
),
|
|
20163
20321
|
variables,
|
|
20164
20322
|
sandBoxThreadId: dto.sandBoxThreadId ?? void 0,
|
|
20165
20323
|
supportsFiles: truthy(dto.supportsFiles),
|