@djangocfg/ui-tools 2.1.337 → 2.1.339
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-BT3CLXI4.cjs +14 -0
- package/dist/{ChatRoot-XV2QXMV4.mjs.map → ChatRoot-BT3CLXI4.cjs.map} +1 -1
- package/dist/ChatRoot-R5YQTOLP.mjs +5 -0
- package/dist/{ChatRoot-YX4RLHQX.cjs.map → ChatRoot-R5YQTOLP.mjs.map} +1 -1
- package/dist/{chunk-ZWPBBAR2.cjs → chunk-5T4K3VUV.cjs} +16 -17
- package/dist/chunk-5T4K3VUV.cjs.map +1 -0
- package/dist/{chunk-YWSQDBNU.mjs → chunk-QE25H6DP.mjs} +16 -17
- package/dist/chunk-QE25H6DP.mjs.map +1 -0
- package/dist/index.cjs +46 -46
- package/dist/index.mjs +3 -3
- package/package.json +6 -6
- package/src/tools/Chat/hooks/useChat.ts +33 -19
- package/dist/ChatRoot-XV2QXMV4.mjs +0 -5
- package/dist/ChatRoot-YX4RLHQX.cjs +0 -14
- package/dist/chunk-YWSQDBNU.mjs.map +0 -1
- package/dist/chunk-ZWPBBAR2.cjs.map +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk5T4K3VUV_cjs = require('./chunk-5T4K3VUV.cjs');
|
|
4
|
+
require('./chunk-B5AWZOHJ.cjs');
|
|
5
|
+
require('./chunk-OLISEQHS.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "ChatRoot", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunk5T4K3VUV_cjs.ChatRoot; }
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=ChatRoot-BT3CLXI4.cjs.map
|
|
14
|
+
//# sourceMappingURL=ChatRoot-BT3CLXI4.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-BT3CLXI4.cjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-R5YQTOLP.mjs"}
|
|
@@ -368,15 +368,15 @@ function useChat(config) {
|
|
|
368
368
|
stateRef.current = state;
|
|
369
369
|
const abortRef = react.useRef(null);
|
|
370
370
|
const lastErrorRef = react.useRef(null);
|
|
371
|
-
const initRef = react.useRef(false);
|
|
372
371
|
const streamingMsgIdRef = react.useRef(null);
|
|
373
372
|
const bootstrapRef = react.useRef(null);
|
|
374
373
|
const { transport, autoCreateSession = true, streaming = true, pageSize = LIMITS.pageSize } = config;
|
|
375
374
|
const log = getChatLogger(config.debug);
|
|
376
375
|
react.useEffect(() => {
|
|
377
|
-
if (initRef.current) return;
|
|
378
|
-
initRef.current = true;
|
|
379
376
|
let cancelled = false;
|
|
377
|
+
if (stateRef.current.sessionId) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
380
|
if (config.initialSessionId || autoCreateSession) {
|
|
381
381
|
dispatch({ type: "HISTORY_LOAD_START" });
|
|
382
382
|
}
|
|
@@ -388,14 +388,16 @@ function useChat(config) {
|
|
|
388
388
|
const t0 = performance.now();
|
|
389
389
|
try {
|
|
390
390
|
if (config.initialSessionId) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
391
|
+
if (!cancelled) {
|
|
392
|
+
dispatch({
|
|
393
|
+
type: "SESSION_SET",
|
|
394
|
+
sessionId: config.initialSessionId
|
|
395
|
+
});
|
|
396
|
+
}
|
|
395
397
|
const page = await transport.loadHistory(config.initialSessionId, null, pageSize);
|
|
396
398
|
if (cancelled) {
|
|
397
399
|
log.bootstrap.debug("cancelled (post-loadHistory)");
|
|
398
|
-
return
|
|
400
|
+
return config.initialSessionId;
|
|
399
401
|
}
|
|
400
402
|
dispatch({
|
|
401
403
|
type: "HISTORY_LOAD_DONE",
|
|
@@ -413,10 +415,6 @@ function useChat(config) {
|
|
|
413
415
|
}
|
|
414
416
|
if (autoCreateSession) {
|
|
415
417
|
const info = await transport.createSession({ metadata: config.metadata });
|
|
416
|
-
if (cancelled) {
|
|
417
|
-
log.bootstrap.debug("cancelled (post-createSession)");
|
|
418
|
-
return null;
|
|
419
|
-
}
|
|
420
418
|
dispatch({
|
|
421
419
|
type: "SESSION_SET",
|
|
422
420
|
sessionId: info.sessionId,
|
|
@@ -430,9 +428,10 @@ function useChat(config) {
|
|
|
430
428
|
hasMore: info.hasMore ?? false,
|
|
431
429
|
cursor: info.cursor ?? null
|
|
432
430
|
});
|
|
433
|
-
log.bootstrap.success("created", {
|
|
431
|
+
log.bootstrap.success(cancelled ? "created (post-cancel)" : "created", {
|
|
434
432
|
sessionId: info.sessionId,
|
|
435
433
|
resumed: info.resumed ?? false,
|
|
434
|
+
cancelled,
|
|
436
435
|
elapsedMs: Math.round(performance.now() - t0)
|
|
437
436
|
});
|
|
438
437
|
return info.sessionId;
|
|
@@ -440,11 +439,11 @@ function useChat(config) {
|
|
|
440
439
|
log.bootstrap.debug("idle (no initialSessionId, autoCreateSession=false)");
|
|
441
440
|
return null;
|
|
442
441
|
} catch (err) {
|
|
442
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
443
443
|
if (cancelled) {
|
|
444
|
-
log.bootstrap.debug("cancelled (in catch)");
|
|
444
|
+
log.bootstrap.debug("cancelled (in catch)", { message: e.message });
|
|
445
445
|
return null;
|
|
446
446
|
}
|
|
447
|
-
const e = err instanceof Error ? err : new Error(String(err));
|
|
448
447
|
lastErrorRef.current = e;
|
|
449
448
|
dispatch({ type: "ERROR_SET", error: e.message });
|
|
450
449
|
config.onError?.(e);
|
|
@@ -2375,5 +2374,5 @@ exports.useChatContextOptional = useChatContextOptional;
|
|
|
2375
2374
|
exports.useChatHistory = useChatHistory;
|
|
2376
2375
|
exports.useChatLayout = useChatLayout;
|
|
2377
2376
|
exports.useChatScroll = useChatScroll;
|
|
2378
|
-
//# sourceMappingURL=chunk-
|
|
2379
|
-
//# sourceMappingURL=chunk-
|
|
2377
|
+
//# sourceMappingURL=chunk-5T4K3VUV.cjs.map
|
|
2378
|
+
//# sourceMappingURL=chunk-5T4K3VUV.cjs.map
|