@djangocfg/ui-tools 2.1.371 → 2.1.372
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-2WNYE2V5.mjs +5 -0
- package/dist/{ChatRoot-DYMCNGOB.mjs.map → ChatRoot-2WNYE2V5.mjs.map} +1 -1
- package/dist/ChatRoot-AD2JIUIU.cjs +14 -0
- package/dist/{ChatRoot-HOQ37WRE.cjs.map → ChatRoot-AD2JIUIU.cjs.map} +1 -1
- package/dist/{chunk-2SKR4U5S.cjs → chunk-A6DDYQQV.cjs} +17 -2
- package/dist/chunk-A6DDYQQV.cjs.map +1 -0
- package/dist/{chunk-MVAT6OPZ.mjs → chunk-KSBMKHYY.mjs} +18 -3
- package/dist/chunk-KSBMKHYY.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 +33 -0
- package/dist/ChatRoot-DYMCNGOB.mjs +0 -5
- package/dist/ChatRoot-HOQ37WRE.cjs +0 -14
- package/dist/chunk-2SKR4U5S.cjs.map +0 -1
- package/dist/chunk-MVAT6OPZ.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 chunkA6DDYQQV_cjs = require('./chunk-A6DDYQQV.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-AD2JIUIU.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 ?? chunkA6DDYQQV_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: chunkA6DDYQQV_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: chunkA6DDYQQV_cjs.createId("u"),
|
|
634
634
|
role: "user",
|
|
635
635
|
content,
|
|
636
636
|
createdAt: Date.now()
|
|
637
637
|
});
|
|
638
|
-
const messageId =
|
|
638
|
+
const messageId = chunkA6DDYQQV_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: chunkA6DDYQQV_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 = chunkA6DDYQQV_cjs.useChatAudioPrefs((s) => s.muted);
|
|
868
|
+
const setMuted = chunkA6DDYQQV_cjs.useChatAudioPrefs((s) => s.setMuted);
|
|
869
|
+
const ctx = chunkA6DDYQQV_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 chunkA6DDYQQV_cjs.Attachments; }
|
|
2184
2184
|
});
|
|
2185
2185
|
Object.defineProperty(exports, "AttachmentsGrid", {
|
|
2186
2186
|
enumerable: true,
|
|
2187
|
-
get: function () { return
|
|
2187
|
+
get: function () { return chunkA6DDYQQV_cjs.AttachmentsGrid; }
|
|
2188
2188
|
});
|
|
2189
2189
|
Object.defineProperty(exports, "AttachmentsList", {
|
|
2190
2190
|
enumerable: true,
|
|
2191
|
-
get: function () { return
|
|
2191
|
+
get: function () { return chunkA6DDYQQV_cjs.AttachmentsList; }
|
|
2192
2192
|
});
|
|
2193
2193
|
Object.defineProperty(exports, "CHAT_EVENT_NAME", {
|
|
2194
2194
|
enumerable: true,
|
|
2195
|
-
get: function () { return
|
|
2195
|
+
get: function () { return chunkA6DDYQQV_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 chunkA6DDYQQV_cjs.CSS_VARS; }
|
|
2200
2200
|
});
|
|
2201
2201
|
Object.defineProperty(exports, "ChatProvider", {
|
|
2202
2202
|
enumerable: true,
|
|
2203
|
-
get: function () { return
|
|
2203
|
+
get: function () { return chunkA6DDYQQV_cjs.ChatProvider; }
|
|
2204
2204
|
});
|
|
2205
2205
|
Object.defineProperty(exports, "ChatRoot", {
|
|
2206
2206
|
enumerable: true,
|
|
2207
|
-
get: function () { return
|
|
2207
|
+
get: function () { return chunkA6DDYQQV_cjs.ChatRoot; }
|
|
2208
2208
|
});
|
|
2209
2209
|
Object.defineProperty(exports, "Composer", {
|
|
2210
2210
|
enumerable: true,
|
|
2211
|
-
get: function () { return
|
|
2211
|
+
get: function () { return chunkA6DDYQQV_cjs.Composer; }
|
|
2212
2212
|
});
|
|
2213
2213
|
Object.defineProperty(exports, "DEFAULT_LABELS", {
|
|
2214
2214
|
enumerable: true,
|
|
2215
|
-
get: function () { return
|
|
2215
|
+
get: function () { return chunkA6DDYQQV_cjs.DEFAULT_LABELS; }
|
|
2216
2216
|
});
|
|
2217
2217
|
Object.defineProperty(exports, "DEFAULT_SIDEBAR", {
|
|
2218
2218
|
enumerable: true,
|
|
2219
|
-
get: function () { return
|
|
2219
|
+
get: function () { return chunkA6DDYQQV_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 chunkA6DDYQQV_cjs.DEFAULT_Z_INDEX; }
|
|
2224
2224
|
});
|
|
2225
2225
|
Object.defineProperty(exports, "EmptyState", {
|
|
2226
2226
|
enumerable: true,
|
|
2227
|
-
get: function () { return
|
|
2227
|
+
get: function () { return chunkA6DDYQQV_cjs.EmptyState; }
|
|
2228
2228
|
});
|
|
2229
2229
|
Object.defineProperty(exports, "ErrorBanner", {
|
|
2230
2230
|
enumerable: true,
|
|
2231
|
-
get: function () { return
|
|
2231
|
+
get: function () { return chunkA6DDYQQV_cjs.ErrorBanner; }
|
|
2232
2232
|
});
|
|
2233
2233
|
Object.defineProperty(exports, "HOTKEYS", {
|
|
2234
2234
|
enumerable: true,
|
|
2235
|
-
get: function () { return
|
|
2235
|
+
get: function () { return chunkA6DDYQQV_cjs.HOTKEYS; }
|
|
2236
2236
|
});
|
|
2237
2237
|
Object.defineProperty(exports, "JumpToLatest", {
|
|
2238
2238
|
enumerable: true,
|
|
2239
|
-
get: function () { return
|
|
2239
|
+
get: function () { return chunkA6DDYQQV_cjs.JumpToLatest; }
|
|
2240
2240
|
});
|
|
2241
2241
|
Object.defineProperty(exports, "LIMITS", {
|
|
2242
2242
|
enumerable: true,
|
|
2243
|
-
get: function () { return
|
|
2243
|
+
get: function () { return chunkA6DDYQQV_cjs.LIMITS; }
|
|
2244
2244
|
});
|
|
2245
2245
|
Object.defineProperty(exports, "MessageActions", {
|
|
2246
2246
|
enumerable: true,
|
|
2247
|
-
get: function () { return
|
|
2247
|
+
get: function () { return chunkA6DDYQQV_cjs.MessageActions; }
|
|
2248
2248
|
});
|
|
2249
2249
|
Object.defineProperty(exports, "MessageBubble", {
|
|
2250
2250
|
enumerable: true,
|
|
2251
|
-
get: function () { return
|
|
2251
|
+
get: function () { return chunkA6DDYQQV_cjs.MessageBubble; }
|
|
2252
2252
|
});
|
|
2253
2253
|
Object.defineProperty(exports, "MessageList", {
|
|
2254
2254
|
enumerable: true,
|
|
2255
|
-
get: function () { return
|
|
2255
|
+
get: function () { return chunkA6DDYQQV_cjs.MessageList; }
|
|
2256
2256
|
});
|
|
2257
2257
|
Object.defineProperty(exports, "STORAGE_KEYS", {
|
|
2258
2258
|
enumerable: true,
|
|
2259
|
-
get: function () { return
|
|
2259
|
+
get: function () { return chunkA6DDYQQV_cjs.STORAGE_KEYS; }
|
|
2260
2260
|
});
|
|
2261
2261
|
Object.defineProperty(exports, "Sources", {
|
|
2262
2262
|
enumerable: true,
|
|
2263
|
-
get: function () { return
|
|
2263
|
+
get: function () { return chunkA6DDYQQV_cjs.Sources; }
|
|
2264
2264
|
});
|
|
2265
2265
|
Object.defineProperty(exports, "StreamingIndicator", {
|
|
2266
2266
|
enumerable: true,
|
|
2267
|
-
get: function () { return
|
|
2267
|
+
get: function () { return chunkA6DDYQQV_cjs.StreamingIndicator; }
|
|
2268
2268
|
});
|
|
2269
2269
|
Object.defineProperty(exports, "ToolCalls", {
|
|
2270
2270
|
enumerable: true,
|
|
2271
|
-
get: function () { return
|
|
2271
|
+
get: function () { return chunkA6DDYQQV_cjs.ToolCalls; }
|
|
2272
2272
|
});
|
|
2273
2273
|
Object.defineProperty(exports, "createId", {
|
|
2274
2274
|
enumerable: true,
|
|
2275
|
-
get: function () { return
|
|
2275
|
+
get: function () { return chunkA6DDYQQV_cjs.createId; }
|
|
2276
2276
|
});
|
|
2277
2277
|
Object.defineProperty(exports, "createTokenBuffer", {
|
|
2278
2278
|
enumerable: true,
|
|
2279
|
-
get: function () { return
|
|
2279
|
+
get: function () { return chunkA6DDYQQV_cjs.createTokenBuffer; }
|
|
2280
2280
|
});
|
|
2281
2281
|
Object.defineProperty(exports, "deriveInitials", {
|
|
2282
2282
|
enumerable: true,
|
|
2283
|
-
get: function () { return
|
|
2283
|
+
get: function () { return chunkA6DDYQQV_cjs.deriveInitials; }
|
|
2284
2284
|
});
|
|
2285
2285
|
Object.defineProperty(exports, "getChatLogger", {
|
|
2286
2286
|
enumerable: true,
|
|
2287
|
-
get: function () { return
|
|
2287
|
+
get: function () { return chunkA6DDYQQV_cjs.getChatLogger; }
|
|
2288
2288
|
});
|
|
2289
2289
|
Object.defineProperty(exports, "initialState", {
|
|
2290
2290
|
enumerable: true,
|
|
2291
|
-
get: function () { return
|
|
2291
|
+
get: function () { return chunkA6DDYQQV_cjs.initialState; }
|
|
2292
2292
|
});
|
|
2293
2293
|
Object.defineProperty(exports, "reducer", {
|
|
2294
2294
|
enumerable: true,
|
|
2295
|
-
get: function () { return
|
|
2295
|
+
get: function () { return chunkA6DDYQQV_cjs.reducer; }
|
|
2296
2296
|
});
|
|
2297
2297
|
Object.defineProperty(exports, "resolvePersona", {
|
|
2298
2298
|
enumerable: true,
|
|
2299
|
-
get: function () { return
|
|
2299
|
+
get: function () { return chunkA6DDYQQV_cjs.resolvePersona; }
|
|
2300
2300
|
});
|
|
2301
2301
|
Object.defineProperty(exports, "useChat", {
|
|
2302
2302
|
enumerable: true,
|
|
2303
|
-
get: function () { return
|
|
2303
|
+
get: function () { return chunkA6DDYQQV_cjs.useChat; }
|
|
2304
2304
|
});
|
|
2305
2305
|
Object.defineProperty(exports, "useChatAudio", {
|
|
2306
2306
|
enumerable: true,
|
|
2307
|
-
get: function () { return
|
|
2307
|
+
get: function () { return chunkA6DDYQQV_cjs.useChatAudio; }
|
|
2308
2308
|
});
|
|
2309
2309
|
Object.defineProperty(exports, "useChatAudioPrefs", {
|
|
2310
2310
|
enumerable: true,
|
|
2311
|
-
get: function () { return
|
|
2311
|
+
get: function () { return chunkA6DDYQQV_cjs.useChatAudioPrefs; }
|
|
2312
2312
|
});
|
|
2313
2313
|
Object.defineProperty(exports, "useChatComposer", {
|
|
2314
2314
|
enumerable: true,
|
|
2315
|
-
get: function () { return
|
|
2315
|
+
get: function () { return chunkA6DDYQQV_cjs.useChatComposer; }
|
|
2316
2316
|
});
|
|
2317
2317
|
Object.defineProperty(exports, "useChatContext", {
|
|
2318
2318
|
enumerable: true,
|
|
2319
|
-
get: function () { return
|
|
2319
|
+
get: function () { return chunkA6DDYQQV_cjs.useChatContext; }
|
|
2320
2320
|
});
|
|
2321
2321
|
Object.defineProperty(exports, "useChatContextOptional", {
|
|
2322
2322
|
enumerable: true,
|
|
2323
|
-
get: function () { return
|
|
2323
|
+
get: function () { return chunkA6DDYQQV_cjs.useChatContextOptional; }
|
|
2324
2324
|
});
|
|
2325
2325
|
Object.defineProperty(exports, "useChatLayout", {
|
|
2326
2326
|
enumerable: true,
|
|
2327
|
-
get: function () { return
|
|
2327
|
+
get: function () { return chunkA6DDYQQV_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-KSBMKHYY.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-KSBMKHYY.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-2WNYE2V5.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.372",
|
|
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.372",
|
|
160
|
+
"@djangocfg/ui-core": "^2.1.372",
|
|
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.372",
|
|
215
215
|
"@djangocfg/playground": "workspace:*",
|
|
216
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
217
|
-
"@djangocfg/ui-core": "^2.1.
|
|
216
|
+
"@djangocfg/typescript-config": "^2.1.372",
|
|
217
|
+
"@djangocfg/ui-core": "^2.1.372",
|
|
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",
|
|
@@ -96,6 +96,14 @@ export const MessageList = forwardRef<MessageListHandle, MessageListProps>(funct
|
|
|
96
96
|
const { copyToClipboard } = useCopy();
|
|
97
97
|
|
|
98
98
|
const virtuosoRef = useRef<VirtuosoHandle | null>(null);
|
|
99
|
+
// Track whether we've already landed on the bottom for the initial
|
|
100
|
+
// history. Virtuoso's `initialTopMostItemIndex` only fires on first
|
|
101
|
+
// mount and uses the `messages` length at that moment. Chats almost
|
|
102
|
+
// always mount with `messages=[]` and then receive history one
|
|
103
|
+
// dispatch later — so we ALSO fire an imperative scroll when the
|
|
104
|
+
// first non-empty batch arrives. Subsequent updates fall through to
|
|
105
|
+
// `followOutput` (sticky-bottom while the user is at bottom).
|
|
106
|
+
const didInitialScrollRef = useRef(false);
|
|
99
107
|
|
|
100
108
|
useImperativeHandle(
|
|
101
109
|
ref,
|
|
@@ -132,6 +140,24 @@ export const MessageList = forwardRef<MessageListHandle, MessageListProps>(funct
|
|
|
132
140
|
);
|
|
133
141
|
|
|
134
142
|
const itemRenderer = renderItem ?? defaultRenderItem;
|
|
143
|
+
// Jump to bottom on the first non-empty messages batch. Wrapped in
|
|
144
|
+
// rAF so virtuoso has measured the new items before we ask it to
|
|
145
|
+
// scroll — otherwise the call happens while the list is still
|
|
146
|
+
// mid-layout and lands on the wrong offset.
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
if (didInitialScrollRef.current) return;
|
|
149
|
+
if (messages.length === 0) return;
|
|
150
|
+
didInitialScrollRef.current = true;
|
|
151
|
+
const id = requestAnimationFrame(() => {
|
|
152
|
+
virtuosoRef.current?.scrollToIndex({
|
|
153
|
+
index: 'LAST',
|
|
154
|
+
align: 'end',
|
|
155
|
+
behavior: 'auto',
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
return () => cancelAnimationFrame(id);
|
|
159
|
+
}, [messages.length]);
|
|
160
|
+
|
|
135
161
|
// Virtuoso may invoke `computeItemKey` for an index briefly out of
|
|
136
162
|
// sync with `data` during fast state churn (streaming chunks +
|
|
137
163
|
// Strict Mode double-mount). `m` arrives undefined in that window.
|
|
@@ -213,6 +239,13 @@ export const MessageList = forwardRef<MessageListHandle, MessageListProps>(funct
|
|
|
213
239
|
computeItemKey={computeItemKey}
|
|
214
240
|
itemContent={(index, m) => (m ? itemRenderer(m, index) : null)}
|
|
215
241
|
defaultItemHeight={defaultItemHeight}
|
|
242
|
+
// Land on the latest message when the list first mounts. Without
|
|
243
|
+
// this, Virtuoso renders index 0 (top of history) and the user
|
|
244
|
+
// sees the oldest message instead of the most recent — chat
|
|
245
|
+
// convention is "latest at the bottom, ready to read". Re-evaluated
|
|
246
|
+
// only on mount; subsequent updates respect the user's scroll
|
|
247
|
+
// position via `followOutput` + `atBottomStateChange`.
|
|
248
|
+
initialTopMostItemIndex={messages.length > 0 ? messages.length - 1 : 0}
|
|
216
249
|
// Sticky-bottom: keep the viewport anchored to the latest message
|
|
217
250
|
// unless the user scrolled up. `'smooth'` while streaming would
|
|
218
251
|
// jank; Virtuoso defaults to `'auto'` which is what we want.
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunk2SKR4U5S_cjs = require('./chunk-2SKR4U5S.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 chunk2SKR4U5S_cjs.ChatRoot; }
|
|
12
|
-
});
|
|
13
|
-
//# sourceMappingURL=ChatRoot-HOQ37WRE.cjs.map
|
|
14
|
-
//# sourceMappingURL=ChatRoot-HOQ37WRE.cjs.map
|