@djangocfg/ui-tools 2.1.369 → 2.1.371
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/ChatRoot-DYMCNGOB.mjs +5 -0
- package/dist/{ChatRoot-DENECC2Q.mjs.map → ChatRoot-DYMCNGOB.mjs.map} +1 -1
- package/dist/ChatRoot-HOQ37WRE.cjs +14 -0
- package/dist/{ChatRoot-PW6U3QVF.cjs.map → ChatRoot-HOQ37WRE.cjs.map} +1 -1
- package/dist/{chunk-OD3P64QD.cjs → chunk-2SKR4U5S.cjs} +15 -16
- package/dist/chunk-2SKR4U5S.cjs.map +1 -0
- package/dist/{chunk-YLIYXSUO.mjs → chunk-MVAT6OPZ.mjs} +16 -17
- package/dist/chunk-MVAT6OPZ.mjs.map +1 -0
- package/dist/index.cjs +47 -47
- package/dist/index.mjs +3 -3
- package/package.json +6 -6
- package/src/tools/Chat/components/MessageList.tsx +24 -10
- package/dist/ChatRoot-DENECC2Q.mjs +0 -5
- package/dist/ChatRoot-PW6U3QVF.cjs +0 -14
- package/dist/chunk-OD3P64QD.cjs.map +0 -1
- package/dist/chunk-YLIYXSUO.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var chunkKNDLV4PI_cjs = require('./chunk-KNDLV4PI.cjs');
|
|
|
7
7
|
var chunk5I5QNGUG_cjs = require('./chunk-5I5QNGUG.cjs');
|
|
8
8
|
var chunkYW5IVWHQ_cjs = require('./chunk-YW5IVWHQ.cjs');
|
|
9
9
|
var chunk76NNDZH6_cjs = require('./chunk-76NNDZH6.cjs');
|
|
10
|
-
var
|
|
10
|
+
var chunk2SKR4U5S_cjs = require('./chunk-2SKR4U5S.cjs');
|
|
11
11
|
var chunkYXZ6GU7H_cjs = require('./chunk-YXZ6GU7H.cjs');
|
|
12
12
|
var chunkFVVF7VCD_cjs = require('./chunk-FVVF7VCD.cjs');
|
|
13
13
|
var chunk7EYHNP3E_cjs = require('./chunk-7EYHNP3E.cjs');
|
|
@@ -373,7 +373,7 @@ var LazyTree = createLazyComponent(
|
|
|
373
373
|
}
|
|
374
374
|
);
|
|
375
375
|
var LazyChat = createLazyComponent(
|
|
376
|
-
() => import('./ChatRoot-
|
|
376
|
+
() => import('./ChatRoot-HOQ37WRE.cjs').then((m) => ({ default: m.ChatRoot })),
|
|
377
377
|
{
|
|
378
378
|
displayName: "LazyChat",
|
|
379
379
|
fallback: /* @__PURE__ */ jsxRuntime.jsx(LoadingFallback, { minHeight: 320, text: "Loading chat\u2026" })
|
|
@@ -410,7 +410,7 @@ async function* parseSSE(response, options = {}) {
|
|
|
410
410
|
throw new Error("SSE response has no body");
|
|
411
411
|
}
|
|
412
412
|
const map = options.map ?? DEFAULT_MAP;
|
|
413
|
-
const idleMs = options.idleTimeoutMs ??
|
|
413
|
+
const idleMs = options.idleTimeoutMs ?? chunk2SKR4U5S_cjs.LIMITS.sseIdleMs;
|
|
414
414
|
const reader = response.body.getReader();
|
|
415
415
|
const decoder = new TextDecoder();
|
|
416
416
|
let buffer = "";
|
|
@@ -613,7 +613,7 @@ function createMockTransport(opts = {}) {
|
|
|
613
613
|
async createSession(_opts) {
|
|
614
614
|
await sleep(latency);
|
|
615
615
|
return {
|
|
616
|
-
sessionId:
|
|
616
|
+
sessionId: chunk2SKR4U5S_cjs.createId("s"),
|
|
617
617
|
messages: history.length ? [...history] : void 0,
|
|
618
618
|
hasMore: false,
|
|
619
619
|
cursor: null,
|
|
@@ -630,12 +630,12 @@ function createMockTransport(opts = {}) {
|
|
|
630
630
|
throw new Error("mock transport scripted failure");
|
|
631
631
|
}
|
|
632
632
|
history.push({
|
|
633
|
-
id:
|
|
633
|
+
id: chunk2SKR4U5S_cjs.createId("u"),
|
|
634
634
|
role: "user",
|
|
635
635
|
content,
|
|
636
636
|
createdAt: Date.now()
|
|
637
637
|
});
|
|
638
|
-
const messageId =
|
|
638
|
+
const messageId = chunk2SKR4U5S_cjs.createId("a");
|
|
639
639
|
yield { type: "message_start", messageId, sessionId: _sid };
|
|
640
640
|
const reply = replies[turn % replies.length];
|
|
641
641
|
turn += 1;
|
|
@@ -664,7 +664,7 @@ function createMockTransport(opts = {}) {
|
|
|
664
664
|
turn += 1;
|
|
665
665
|
const text = typeof reply === "string" ? reply : reply.filter((e) => e.type === "chunk").map((e) => e.delta).join("");
|
|
666
666
|
return {
|
|
667
|
-
id:
|
|
667
|
+
id: chunk2SKR4U5S_cjs.createId("a"),
|
|
668
668
|
role: "assistant",
|
|
669
669
|
content: text || DEFAULT_REPLY,
|
|
670
670
|
createdAt: Date.now()
|
|
@@ -864,9 +864,9 @@ function AudioToggle({
|
|
|
864
864
|
alwaysShow = false,
|
|
865
865
|
className
|
|
866
866
|
}) {
|
|
867
|
-
const muted =
|
|
868
|
-
const setMuted =
|
|
869
|
-
const ctx =
|
|
867
|
+
const muted = chunk2SKR4U5S_cjs.useChatAudioPrefs((s) => s.muted);
|
|
868
|
+
const setMuted = chunk2SKR4U5S_cjs.useChatAudioPrefs((s) => s.setMuted);
|
|
869
|
+
const ctx = chunk2SKR4U5S_cjs.useChatContextOptional();
|
|
870
870
|
if (ctx && !ctx.hasAudio && !alwaysShow) return null;
|
|
871
871
|
const Icon = muted ? lucideReact.VolumeX : lucideReact.Volume2;
|
|
872
872
|
const label = muted ? "Unmute chat sounds" : "Mute chat sounds";
|
|
@@ -2180,151 +2180,151 @@ Object.defineProperty(exports, "useCronWeekDays", {
|
|
|
2180
2180
|
});
|
|
2181
2181
|
Object.defineProperty(exports, "Attachments", {
|
|
2182
2182
|
enumerable: true,
|
|
2183
|
-
get: function () { return
|
|
2183
|
+
get: function () { return chunk2SKR4U5S_cjs.Attachments; }
|
|
2184
2184
|
});
|
|
2185
2185
|
Object.defineProperty(exports, "AttachmentsGrid", {
|
|
2186
2186
|
enumerable: true,
|
|
2187
|
-
get: function () { return
|
|
2187
|
+
get: function () { return chunk2SKR4U5S_cjs.AttachmentsGrid; }
|
|
2188
2188
|
});
|
|
2189
2189
|
Object.defineProperty(exports, "AttachmentsList", {
|
|
2190
2190
|
enumerable: true,
|
|
2191
|
-
get: function () { return
|
|
2191
|
+
get: function () { return chunk2SKR4U5S_cjs.AttachmentsList; }
|
|
2192
2192
|
});
|
|
2193
2193
|
Object.defineProperty(exports, "CHAT_EVENT_NAME", {
|
|
2194
2194
|
enumerable: true,
|
|
2195
|
-
get: function () { return
|
|
2195
|
+
get: function () { return chunk2SKR4U5S_cjs.CHAT_EVENT_NAME; }
|
|
2196
2196
|
});
|
|
2197
2197
|
Object.defineProperty(exports, "CSS_VARS", {
|
|
2198
2198
|
enumerable: true,
|
|
2199
|
-
get: function () { return
|
|
2199
|
+
get: function () { return chunk2SKR4U5S_cjs.CSS_VARS; }
|
|
2200
2200
|
});
|
|
2201
2201
|
Object.defineProperty(exports, "ChatProvider", {
|
|
2202
2202
|
enumerable: true,
|
|
2203
|
-
get: function () { return
|
|
2203
|
+
get: function () { return chunk2SKR4U5S_cjs.ChatProvider; }
|
|
2204
2204
|
});
|
|
2205
2205
|
Object.defineProperty(exports, "ChatRoot", {
|
|
2206
2206
|
enumerable: true,
|
|
2207
|
-
get: function () { return
|
|
2207
|
+
get: function () { return chunk2SKR4U5S_cjs.ChatRoot; }
|
|
2208
2208
|
});
|
|
2209
2209
|
Object.defineProperty(exports, "Composer", {
|
|
2210
2210
|
enumerable: true,
|
|
2211
|
-
get: function () { return
|
|
2211
|
+
get: function () { return chunk2SKR4U5S_cjs.Composer; }
|
|
2212
2212
|
});
|
|
2213
2213
|
Object.defineProperty(exports, "DEFAULT_LABELS", {
|
|
2214
2214
|
enumerable: true,
|
|
2215
|
-
get: function () { return
|
|
2215
|
+
get: function () { return chunk2SKR4U5S_cjs.DEFAULT_LABELS; }
|
|
2216
2216
|
});
|
|
2217
2217
|
Object.defineProperty(exports, "DEFAULT_SIDEBAR", {
|
|
2218
2218
|
enumerable: true,
|
|
2219
|
-
get: function () { return
|
|
2219
|
+
get: function () { return chunk2SKR4U5S_cjs.DEFAULT_SIDEBAR; }
|
|
2220
2220
|
});
|
|
2221
2221
|
Object.defineProperty(exports, "DEFAULT_Z_INDEX", {
|
|
2222
2222
|
enumerable: true,
|
|
2223
|
-
get: function () { return
|
|
2223
|
+
get: function () { return chunk2SKR4U5S_cjs.DEFAULT_Z_INDEX; }
|
|
2224
2224
|
});
|
|
2225
2225
|
Object.defineProperty(exports, "EmptyState", {
|
|
2226
2226
|
enumerable: true,
|
|
2227
|
-
get: function () { return
|
|
2227
|
+
get: function () { return chunk2SKR4U5S_cjs.EmptyState; }
|
|
2228
2228
|
});
|
|
2229
2229
|
Object.defineProperty(exports, "ErrorBanner", {
|
|
2230
2230
|
enumerable: true,
|
|
2231
|
-
get: function () { return
|
|
2231
|
+
get: function () { return chunk2SKR4U5S_cjs.ErrorBanner; }
|
|
2232
2232
|
});
|
|
2233
2233
|
Object.defineProperty(exports, "HOTKEYS", {
|
|
2234
2234
|
enumerable: true,
|
|
2235
|
-
get: function () { return
|
|
2235
|
+
get: function () { return chunk2SKR4U5S_cjs.HOTKEYS; }
|
|
2236
2236
|
});
|
|
2237
2237
|
Object.defineProperty(exports, "JumpToLatest", {
|
|
2238
2238
|
enumerable: true,
|
|
2239
|
-
get: function () { return
|
|
2239
|
+
get: function () { return chunk2SKR4U5S_cjs.JumpToLatest; }
|
|
2240
2240
|
});
|
|
2241
2241
|
Object.defineProperty(exports, "LIMITS", {
|
|
2242
2242
|
enumerable: true,
|
|
2243
|
-
get: function () { return
|
|
2243
|
+
get: function () { return chunk2SKR4U5S_cjs.LIMITS; }
|
|
2244
2244
|
});
|
|
2245
2245
|
Object.defineProperty(exports, "MessageActions", {
|
|
2246
2246
|
enumerable: true,
|
|
2247
|
-
get: function () { return
|
|
2247
|
+
get: function () { return chunk2SKR4U5S_cjs.MessageActions; }
|
|
2248
2248
|
});
|
|
2249
2249
|
Object.defineProperty(exports, "MessageBubble", {
|
|
2250
2250
|
enumerable: true,
|
|
2251
|
-
get: function () { return
|
|
2251
|
+
get: function () { return chunk2SKR4U5S_cjs.MessageBubble; }
|
|
2252
2252
|
});
|
|
2253
2253
|
Object.defineProperty(exports, "MessageList", {
|
|
2254
2254
|
enumerable: true,
|
|
2255
|
-
get: function () { return
|
|
2255
|
+
get: function () { return chunk2SKR4U5S_cjs.MessageList; }
|
|
2256
2256
|
});
|
|
2257
2257
|
Object.defineProperty(exports, "STORAGE_KEYS", {
|
|
2258
2258
|
enumerable: true,
|
|
2259
|
-
get: function () { return
|
|
2259
|
+
get: function () { return chunk2SKR4U5S_cjs.STORAGE_KEYS; }
|
|
2260
2260
|
});
|
|
2261
2261
|
Object.defineProperty(exports, "Sources", {
|
|
2262
2262
|
enumerable: true,
|
|
2263
|
-
get: function () { return
|
|
2263
|
+
get: function () { return chunk2SKR4U5S_cjs.Sources; }
|
|
2264
2264
|
});
|
|
2265
2265
|
Object.defineProperty(exports, "StreamingIndicator", {
|
|
2266
2266
|
enumerable: true,
|
|
2267
|
-
get: function () { return
|
|
2267
|
+
get: function () { return chunk2SKR4U5S_cjs.StreamingIndicator; }
|
|
2268
2268
|
});
|
|
2269
2269
|
Object.defineProperty(exports, "ToolCalls", {
|
|
2270
2270
|
enumerable: true,
|
|
2271
|
-
get: function () { return
|
|
2271
|
+
get: function () { return chunk2SKR4U5S_cjs.ToolCalls; }
|
|
2272
2272
|
});
|
|
2273
2273
|
Object.defineProperty(exports, "createId", {
|
|
2274
2274
|
enumerable: true,
|
|
2275
|
-
get: function () { return
|
|
2275
|
+
get: function () { return chunk2SKR4U5S_cjs.createId; }
|
|
2276
2276
|
});
|
|
2277
2277
|
Object.defineProperty(exports, "createTokenBuffer", {
|
|
2278
2278
|
enumerable: true,
|
|
2279
|
-
get: function () { return
|
|
2279
|
+
get: function () { return chunk2SKR4U5S_cjs.createTokenBuffer; }
|
|
2280
2280
|
});
|
|
2281
2281
|
Object.defineProperty(exports, "deriveInitials", {
|
|
2282
2282
|
enumerable: true,
|
|
2283
|
-
get: function () { return
|
|
2283
|
+
get: function () { return chunk2SKR4U5S_cjs.deriveInitials; }
|
|
2284
2284
|
});
|
|
2285
2285
|
Object.defineProperty(exports, "getChatLogger", {
|
|
2286
2286
|
enumerable: true,
|
|
2287
|
-
get: function () { return
|
|
2287
|
+
get: function () { return chunk2SKR4U5S_cjs.getChatLogger; }
|
|
2288
2288
|
});
|
|
2289
2289
|
Object.defineProperty(exports, "initialState", {
|
|
2290
2290
|
enumerable: true,
|
|
2291
|
-
get: function () { return
|
|
2291
|
+
get: function () { return chunk2SKR4U5S_cjs.initialState; }
|
|
2292
2292
|
});
|
|
2293
2293
|
Object.defineProperty(exports, "reducer", {
|
|
2294
2294
|
enumerable: true,
|
|
2295
|
-
get: function () { return
|
|
2295
|
+
get: function () { return chunk2SKR4U5S_cjs.reducer; }
|
|
2296
2296
|
});
|
|
2297
2297
|
Object.defineProperty(exports, "resolvePersona", {
|
|
2298
2298
|
enumerable: true,
|
|
2299
|
-
get: function () { return
|
|
2299
|
+
get: function () { return chunk2SKR4U5S_cjs.resolvePersona; }
|
|
2300
2300
|
});
|
|
2301
2301
|
Object.defineProperty(exports, "useChat", {
|
|
2302
2302
|
enumerable: true,
|
|
2303
|
-
get: function () { return
|
|
2303
|
+
get: function () { return chunk2SKR4U5S_cjs.useChat; }
|
|
2304
2304
|
});
|
|
2305
2305
|
Object.defineProperty(exports, "useChatAudio", {
|
|
2306
2306
|
enumerable: true,
|
|
2307
|
-
get: function () { return
|
|
2307
|
+
get: function () { return chunk2SKR4U5S_cjs.useChatAudio; }
|
|
2308
2308
|
});
|
|
2309
2309
|
Object.defineProperty(exports, "useChatAudioPrefs", {
|
|
2310
2310
|
enumerable: true,
|
|
2311
|
-
get: function () { return
|
|
2311
|
+
get: function () { return chunk2SKR4U5S_cjs.useChatAudioPrefs; }
|
|
2312
2312
|
});
|
|
2313
2313
|
Object.defineProperty(exports, "useChatComposer", {
|
|
2314
2314
|
enumerable: true,
|
|
2315
|
-
get: function () { return
|
|
2315
|
+
get: function () { return chunk2SKR4U5S_cjs.useChatComposer; }
|
|
2316
2316
|
});
|
|
2317
2317
|
Object.defineProperty(exports, "useChatContext", {
|
|
2318
2318
|
enumerable: true,
|
|
2319
|
-
get: function () { return
|
|
2319
|
+
get: function () { return chunk2SKR4U5S_cjs.useChatContext; }
|
|
2320
2320
|
});
|
|
2321
2321
|
Object.defineProperty(exports, "useChatContextOptional", {
|
|
2322
2322
|
enumerable: true,
|
|
2323
|
-
get: function () { return
|
|
2323
|
+
get: function () { return chunk2SKR4U5S_cjs.useChatContextOptional; }
|
|
2324
2324
|
});
|
|
2325
2325
|
Object.defineProperty(exports, "useChatLayout", {
|
|
2326
2326
|
enumerable: true,
|
|
2327
|
-
get: function () { return
|
|
2327
|
+
get: function () { return chunk2SKR4U5S_cjs.useChatLayout; }
|
|
2328
2328
|
});
|
|
2329
2329
|
Object.defineProperty(exports, "TreeError", {
|
|
2330
2330
|
enumerable: true,
|
package/dist/index.mjs
CHANGED
|
@@ -5,8 +5,8 @@ export { NativeProvider, StreamProvider, VideoControls, VideoErrorFallback, Vide
|
|
|
5
5
|
export { ImageViewer } from './chunk-OBRSGM64.mjs';
|
|
6
6
|
export { generateContentKey, useAudioCache, useBlobUrlCleanup, useImageCache, useMediaCacheStore, useVideoCache, useVideoPlayerSettings } from './chunk-C6GXVH5J.mjs';
|
|
7
7
|
export { CronSchedulerProvider, CustomInput, DayChips, MonthDayGrid, SchedulePreview, ScheduleTypeSelector, TimeSelector, buildCron, humanizeCron, isValidCron, parseCron, useCronCustom, useCronMonthDays, useCronPreview, useCronScheduler, useCronSchedulerContext, useCronTime, useCronType, useCronWeekDays } from './chunk-PVAX67JG.mjs';
|
|
8
|
-
import { LIMITS, createId, useChatAudioPrefs, useChatContextOptional } from './chunk-
|
|
9
|
-
export { Attachments, AttachmentsGrid, AttachmentsList, CHAT_EVENT_NAME, CSS_VARS, ChatProvider, ChatRoot, Composer, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, EmptyState, ErrorBanner, HOTKEYS, JumpToLatest, LIMITS, MessageActions, MessageBubble, MessageList, STORAGE_KEYS, Sources, StreamingIndicator, ToolCalls, createId, createTokenBuffer, deriveInitials, getChatLogger, initialState, reducer, resolvePersona, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatLayout } from './chunk-
|
|
8
|
+
import { LIMITS, createId, useChatAudioPrefs, useChatContextOptional } from './chunk-MVAT6OPZ.mjs';
|
|
9
|
+
export { Attachments, AttachmentsGrid, AttachmentsList, CHAT_EVENT_NAME, CSS_VARS, ChatProvider, ChatRoot, Composer, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, EmptyState, ErrorBanner, HOTKEYS, JumpToLatest, LIMITS, MessageActions, MessageBubble, MessageList, STORAGE_KEYS, Sources, StreamingIndicator, ToolCalls, createId, createTokenBuffer, deriveInitials, getChatLogger, initialState, reducer, resolvePersona, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatLayout } from './chunk-MVAT6OPZ.mjs';
|
|
10
10
|
export { TreeError, TreeSkeleton, createDemoTree } from './chunk-B6IR5KSC.mjs';
|
|
11
11
|
export { DEFAULT_TREE_APPEARANCE, DEFAULT_TREE_LABELS, TreeRoot as Tree, TreeChevron, TreeContent, TreeEmpty, TreeIcon, TreeIndentGuides, TreeLabel, TreeProvider, TreeRoot, TreeRow, TreeSearchInput, appearanceToStyle, clearTreeState, createChildCache, flattenTree, loadTreeState, resolveAppearance, resolveChildren, saveTreeState, useTreeActions, useTreeContext, useTreeExpansion, useTreeFocus, useTreeKeyboard, useTreeLabels, useTreeRows, useTreeSearch, useTreeSelection, useTreeTypeAhead } from './chunk-ZL7FH4NW.mjs';
|
|
12
12
|
import { PlaygroundProvider } from './chunk-Y6UTOBF6.mjs';
|
|
@@ -348,7 +348,7 @@ var LazyTree = createLazyComponent(
|
|
|
348
348
|
}
|
|
349
349
|
);
|
|
350
350
|
var LazyChat = createLazyComponent(
|
|
351
|
-
() => import('./ChatRoot-
|
|
351
|
+
() => import('./ChatRoot-DYMCNGOB.mjs').then((m) => ({ default: m.ChatRoot })),
|
|
352
352
|
{
|
|
353
353
|
displayName: "LazyChat",
|
|
354
354
|
fallback: /* @__PURE__ */ jsx(LoadingFallback, { minHeight: 320, text: "Loading chat\u2026" })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/ui-tools",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.371",
|
|
4
4
|
"description": "Heavy React tools with lazy loading - for Electron, Vite, CRA, Next.js apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui-tools",
|
|
@@ -156,8 +156,8 @@
|
|
|
156
156
|
"check": "tsc --noEmit"
|
|
157
157
|
},
|
|
158
158
|
"peerDependencies": {
|
|
159
|
-
"@djangocfg/i18n": "^2.1.
|
|
160
|
-
"@djangocfg/ui-core": "^2.1.
|
|
159
|
+
"@djangocfg/i18n": "^2.1.371",
|
|
160
|
+
"@djangocfg/ui-core": "^2.1.371",
|
|
161
161
|
"consola": "^3.4.2",
|
|
162
162
|
"lodash-es": "^4.18.1",
|
|
163
163
|
"lucide-react": "^0.545.0",
|
|
@@ -211,10 +211,10 @@
|
|
|
211
211
|
"material-file-icons": "^2.4.0"
|
|
212
212
|
},
|
|
213
213
|
"devDependencies": {
|
|
214
|
-
"@djangocfg/i18n": "^2.1.
|
|
214
|
+
"@djangocfg/i18n": "^2.1.371",
|
|
215
215
|
"@djangocfg/playground": "workspace:*",
|
|
216
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
217
|
-
"@djangocfg/ui-core": "^2.1.
|
|
216
|
+
"@djangocfg/typescript-config": "^2.1.371",
|
|
217
|
+
"@djangocfg/ui-core": "^2.1.371",
|
|
218
218
|
"@types/lodash-es": "^4.17.12",
|
|
219
219
|
"@types/mapbox__mapbox-gl-draw": "^1.4.8",
|
|
220
220
|
"@types/node": "^24.7.2",
|
|
@@ -14,6 +14,7 @@ import { Virtuoso, type VirtuosoHandle } from 'react-virtuoso';
|
|
|
14
14
|
|
|
15
15
|
import { cn } from '@djangocfg/ui-core/lib';
|
|
16
16
|
import { Spinner } from '@djangocfg/ui-core/components';
|
|
17
|
+
import { useCopy } from '@djangocfg/ui-core/hooks';
|
|
17
18
|
|
|
18
19
|
import type { ChatMessage } from '../types';
|
|
19
20
|
import { useChatContextOptional } from '../context';
|
|
@@ -92,6 +93,7 @@ export const MessageList = forwardRef<MessageListHandle, MessageListProps>(funct
|
|
|
92
93
|
const ctx = useChatContextOptional();
|
|
93
94
|
const messages = messagesProp ?? ctx?.messages ?? [];
|
|
94
95
|
const isLoadingMore = isLoadingMoreProp ?? ctx?.isLoadingMore ?? false;
|
|
96
|
+
const { copyToClipboard } = useCopy();
|
|
95
97
|
|
|
96
98
|
const virtuosoRef = useRef<VirtuosoHandle | null>(null);
|
|
97
99
|
|
|
@@ -120,17 +122,26 @@ export const MessageList = forwardRef<MessageListHandle, MessageListProps>(funct
|
|
|
120
122
|
<div className={itemClassName}>
|
|
121
123
|
<MessageBubble
|
|
122
124
|
message={m}
|
|
123
|
-
onCopy={() =>
|
|
125
|
+
onCopy={() => void copyToClipboard(m.content)}
|
|
124
126
|
onRegenerate={ctx ? () => void ctx.regenerate(m.id) : undefined}
|
|
125
127
|
onDelete={ctx ? () => ctx.deleteMessage(m.id) : undefined}
|
|
126
128
|
/>
|
|
127
129
|
</div>
|
|
128
130
|
),
|
|
129
|
-
[itemClassName, ctx],
|
|
131
|
+
[itemClassName, ctx, copyToClipboard],
|
|
130
132
|
);
|
|
131
133
|
|
|
132
134
|
const itemRenderer = renderItem ?? defaultRenderItem;
|
|
133
|
-
|
|
135
|
+
// Virtuoso may invoke `computeItemKey` for an index briefly out of
|
|
136
|
+
// sync with `data` during fast state churn (streaming chunks +
|
|
137
|
+
// Strict Mode double-mount). `m` arrives undefined in that window.
|
|
138
|
+
// Falling back to the index keeps the lookup stable instead of
|
|
139
|
+
// crashing with `undefined.id` — the next pass with the real item
|
|
140
|
+
// re-keys it correctly. See react-virtuoso issue #532 / #1045.
|
|
141
|
+
const computeItemKey = useCallback(
|
|
142
|
+
(index: number, m: ChatMessage | undefined) => m?.id ?? index,
|
|
143
|
+
[],
|
|
144
|
+
);
|
|
134
145
|
|
|
135
146
|
// Wrap user-supplied onStartReached so we don't double-fire while a
|
|
136
147
|
// load is already in flight. Virtuoso pauses startReached until
|
|
@@ -200,7 +211,7 @@ export const MessageList = forwardRef<MessageListHandle, MessageListProps>(funct
|
|
|
200
211
|
className={cn('flex-1', className)}
|
|
201
212
|
data={messages}
|
|
202
213
|
computeItemKey={computeItemKey}
|
|
203
|
-
itemContent={(index, m) => itemRenderer(m, index)}
|
|
214
|
+
itemContent={(index, m) => (m ? itemRenderer(m, index) : null)}
|
|
204
215
|
defaultItemHeight={defaultItemHeight}
|
|
205
216
|
// Sticky-bottom: keep the viewport anchored to the latest message
|
|
206
217
|
// unless the user scrolled up. `'smooth'` while streaming would
|
|
@@ -218,6 +229,11 @@ export const MessageList = forwardRef<MessageListHandle, MessageListProps>(funct
|
|
|
218
229
|
// Spinner while older history is loading. Rendering it as the
|
|
219
230
|
// Header keeps it inside the virtualized scroll, so it doesn't
|
|
220
231
|
// shift the viewport when it appears/disappears.
|
|
232
|
+
//
|
|
233
|
+
// Always pass an object — virtuoso indexes `components[name]`
|
|
234
|
+
// internally without a null-guard, so passing `undefined` here
|
|
235
|
+
// crashes with `d[l]` on any render where the empty-defaults
|
|
236
|
+
// path runs (regression: ui-tools 2.1.369 first ship).
|
|
221
237
|
components={
|
|
222
238
|
isLoadingMore
|
|
223
239
|
? {
|
|
@@ -227,7 +243,7 @@ export const MessageList = forwardRef<MessageListHandle, MessageListProps>(funct
|
|
|
227
243
|
</div>
|
|
228
244
|
),
|
|
229
245
|
}
|
|
230
|
-
:
|
|
246
|
+
: EMPTY_COMPONENTS
|
|
231
247
|
}
|
|
232
248
|
// Item height is dynamic; Virtuoso re-measures on resize. We
|
|
233
249
|
// bias the initial overscan a bit so streaming-token re-layout
|
|
@@ -237,8 +253,6 @@ export const MessageList = forwardRef<MessageListHandle, MessageListProps>(funct
|
|
|
237
253
|
);
|
|
238
254
|
});
|
|
239
255
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
}
|
|
256
|
+
// Stable empty-components reference — passed when `isLoadingMore` is
|
|
257
|
+
// false so virtuoso's `components[name]` lookups never see undefined.
|
|
258
|
+
const EMPTY_COMPONENTS = {} as const;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkOD3P64QD_cjs = require('./chunk-OD3P64QD.cjs');
|
|
4
|
-
require('./chunk-XACCHZH2.cjs');
|
|
5
|
-
require('./chunk-OLISEQHS.cjs');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "ChatRoot", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () { return chunkOD3P64QD_cjs.ChatRoot; }
|
|
12
|
-
});
|
|
13
|
-
//# sourceMappingURL=ChatRoot-PW6U3QVF.cjs.map
|
|
14
|
-
//# sourceMappingURL=ChatRoot-PW6U3QVF.cjs.map
|