@hef2024/llmasaservice-ui 0.22.4 → 0.22.6
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.js +27 -15
- package/dist/index.mjs +27 -15
- package/package.json +1 -1
- package/src/AIChatPanel.tsx +32 -18
package/dist/index.js
CHANGED
|
@@ -4338,7 +4338,13 @@ var AIChatPanel = ({
|
|
|
4338
4338
|
}
|
|
4339
4339
|
}), [thumbsDownClick, interactionClicked]);
|
|
4340
4340
|
const scrollToBottom = (0, import_react12.useCallback)((force = false) => {
|
|
4341
|
-
var _a2;
|
|
4341
|
+
var _a2, _b;
|
|
4342
|
+
console.log("\u{1F535} scrollToBottom called", {
|
|
4343
|
+
force,
|
|
4344
|
+
idle: idleRef.current,
|
|
4345
|
+
calledAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4346
|
+
stackTrace: (_a2 = new Error().stack) == null ? void 0 : _a2.split("\n").slice(2, 4).join("\n")
|
|
4347
|
+
});
|
|
4342
4348
|
if (scrollRAFRef.current) {
|
|
4343
4349
|
cancelAnimationFrame(scrollRAFRef.current);
|
|
4344
4350
|
}
|
|
@@ -4349,10 +4355,19 @@ var AIChatPanel = ({
|
|
|
4349
4355
|
const scrollHeight = scrollElement.scrollHeight;
|
|
4350
4356
|
const clientHeight = scrollElement.clientHeight;
|
|
4351
4357
|
const isNearBottom = scrollHeight - scrollTop - clientHeight < 100;
|
|
4358
|
+
console.log("\u{1F535} scrollToBottom: checking position", {
|
|
4359
|
+
scrollTop,
|
|
4360
|
+
scrollHeight,
|
|
4361
|
+
clientHeight,
|
|
4362
|
+
distanceFromBottom: scrollHeight - scrollTop - clientHeight,
|
|
4363
|
+
isNearBottom
|
|
4364
|
+
});
|
|
4352
4365
|
if (!isNearBottom) {
|
|
4366
|
+
console.log("\u{1F535} scrollToBottom: CANCELLED (not near bottom)");
|
|
4353
4367
|
return;
|
|
4354
4368
|
}
|
|
4355
4369
|
}
|
|
4370
|
+
console.log("\u{1F535} scrollToBottom: EXECUTING SCROLL", { force });
|
|
4356
4371
|
const now = Date.now();
|
|
4357
4372
|
if (now - lastScrollTimeRef.current < 100) {
|
|
4358
4373
|
scrollRAFRef.current = requestAnimationFrame(() => {
|
|
@@ -4362,7 +4377,7 @@ var AIChatPanel = ({
|
|
|
4362
4377
|
});
|
|
4363
4378
|
return;
|
|
4364
4379
|
}
|
|
4365
|
-
(
|
|
4380
|
+
(_b = bottomRef.current) == null ? void 0 : _b.scrollIntoView({ behavior: "auto" });
|
|
4366
4381
|
lastScrollTimeRef.current = now;
|
|
4367
4382
|
}, []);
|
|
4368
4383
|
const continueChat = (0, import_react12.useCallback)((promptText) => {
|
|
@@ -4582,14 +4597,18 @@ var AIChatPanel = ({
|
|
|
4582
4597
|
userHasScrolledRef.current = userHasScrolled;
|
|
4583
4598
|
}, [userHasScrolled]);
|
|
4584
4599
|
(0, import_react12.useEffect)(() => {
|
|
4600
|
+
console.log("AIChatPanel - Auto-scroll effect triggered", {
|
|
4601
|
+
idle,
|
|
4602
|
+
responseLength: response.length,
|
|
4603
|
+
effectRanAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4604
|
+
});
|
|
4585
4605
|
if (idle) {
|
|
4586
|
-
console.log("AIChatPanel - Auto-scroll effect: SKIPPED (idle)");
|
|
4606
|
+
console.log("AIChatPanel - Auto-scroll effect: SKIPPED (idle=true)");
|
|
4587
4607
|
return;
|
|
4588
4608
|
}
|
|
4589
4609
|
const currentResponseLength = response.length;
|
|
4590
4610
|
const responseGotLonger = currentResponseLength > prevResponseLengthRef.current;
|
|
4591
|
-
console.log("AIChatPanel - Auto-scroll
|
|
4592
|
-
idle,
|
|
4611
|
+
console.log("AIChatPanel - Auto-scroll checks:", {
|
|
4593
4612
|
currentResponseLength,
|
|
4594
4613
|
prevLength: prevResponseLengthRef.current,
|
|
4595
4614
|
responseGotLonger,
|
|
@@ -4599,8 +4618,10 @@ var AIChatPanel = ({
|
|
|
4599
4618
|
prevResponseLengthRef.current = currentResponseLength;
|
|
4600
4619
|
const shouldAutoScroll = scrollToEndRef.current || !userHasScrolledRef.current;
|
|
4601
4620
|
if (shouldAutoScroll && response && responseGotLonger) {
|
|
4602
|
-
console.log("AIChatPanel -
|
|
4621
|
+
console.log("AIChatPanel - \u2705 SCROLLING TO BOTTOM");
|
|
4603
4622
|
scrollToBottom(false);
|
|
4623
|
+
} else {
|
|
4624
|
+
console.log("AIChatPanel - \u274C NOT scrolling (conditions not met)");
|
|
4604
4625
|
}
|
|
4605
4626
|
}, [response, idle]);
|
|
4606
4627
|
const idleRef = (0, import_react12.useRef)(idle);
|
|
@@ -4756,12 +4777,6 @@ var AIChatPanel = ({
|
|
|
4756
4777
|
) : /* @__PURE__ */ import_react12.default.createElement("code", __spreadValues({ className }, props), children);
|
|
4757
4778
|
}, [effectivePrismStyle]);
|
|
4758
4779
|
const AgentSuggestionCard = import_react12.default.memo(({ agentId, agentName, reason }) => {
|
|
4759
|
-
(0, import_react12.useEffect)(() => {
|
|
4760
|
-
const timer = setTimeout(() => {
|
|
4761
|
-
scrollToBottom(true);
|
|
4762
|
-
}, 100);
|
|
4763
|
-
return () => clearTimeout(timer);
|
|
4764
|
-
}, []);
|
|
4765
4780
|
if (!agentId || !onAgentChange) return null;
|
|
4766
4781
|
const isValidUUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(agentId);
|
|
4767
4782
|
const agentOption = agentOptions.find((opt) => opt.value === agentId);
|
|
@@ -4804,9 +4819,6 @@ var AIChatPanel = ({
|
|
|
4804
4819
|
className: "ai-chat-agent-suggestion__button",
|
|
4805
4820
|
onClick: () => {
|
|
4806
4821
|
onAgentChange(agentId);
|
|
4807
|
-
setTimeout(() => {
|
|
4808
|
-
scrollToBottom(true);
|
|
4809
|
-
}, 100);
|
|
4810
4822
|
}
|
|
4811
4823
|
},
|
|
4812
4824
|
"Switch"
|
package/dist/index.mjs
CHANGED
|
@@ -4305,7 +4305,13 @@ var AIChatPanel = ({
|
|
|
4305
4305
|
}
|
|
4306
4306
|
}), [thumbsDownClick, interactionClicked]);
|
|
4307
4307
|
const scrollToBottom = useCallback2((force = false) => {
|
|
4308
|
-
var _a2;
|
|
4308
|
+
var _a2, _b;
|
|
4309
|
+
console.log("\u{1F535} scrollToBottom called", {
|
|
4310
|
+
force,
|
|
4311
|
+
idle: idleRef.current,
|
|
4312
|
+
calledAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4313
|
+
stackTrace: (_a2 = new Error().stack) == null ? void 0 : _a2.split("\n").slice(2, 4).join("\n")
|
|
4314
|
+
});
|
|
4309
4315
|
if (scrollRAFRef.current) {
|
|
4310
4316
|
cancelAnimationFrame(scrollRAFRef.current);
|
|
4311
4317
|
}
|
|
@@ -4316,10 +4322,19 @@ var AIChatPanel = ({
|
|
|
4316
4322
|
const scrollHeight = scrollElement.scrollHeight;
|
|
4317
4323
|
const clientHeight = scrollElement.clientHeight;
|
|
4318
4324
|
const isNearBottom = scrollHeight - scrollTop - clientHeight < 100;
|
|
4325
|
+
console.log("\u{1F535} scrollToBottom: checking position", {
|
|
4326
|
+
scrollTop,
|
|
4327
|
+
scrollHeight,
|
|
4328
|
+
clientHeight,
|
|
4329
|
+
distanceFromBottom: scrollHeight - scrollTop - clientHeight,
|
|
4330
|
+
isNearBottom
|
|
4331
|
+
});
|
|
4319
4332
|
if (!isNearBottom) {
|
|
4333
|
+
console.log("\u{1F535} scrollToBottom: CANCELLED (not near bottom)");
|
|
4320
4334
|
return;
|
|
4321
4335
|
}
|
|
4322
4336
|
}
|
|
4337
|
+
console.log("\u{1F535} scrollToBottom: EXECUTING SCROLL", { force });
|
|
4323
4338
|
const now = Date.now();
|
|
4324
4339
|
if (now - lastScrollTimeRef.current < 100) {
|
|
4325
4340
|
scrollRAFRef.current = requestAnimationFrame(() => {
|
|
@@ -4329,7 +4344,7 @@ var AIChatPanel = ({
|
|
|
4329
4344
|
});
|
|
4330
4345
|
return;
|
|
4331
4346
|
}
|
|
4332
|
-
(
|
|
4347
|
+
(_b = bottomRef.current) == null ? void 0 : _b.scrollIntoView({ behavior: "auto" });
|
|
4333
4348
|
lastScrollTimeRef.current = now;
|
|
4334
4349
|
}, []);
|
|
4335
4350
|
const continueChat = useCallback2((promptText) => {
|
|
@@ -4549,14 +4564,18 @@ var AIChatPanel = ({
|
|
|
4549
4564
|
userHasScrolledRef.current = userHasScrolled;
|
|
4550
4565
|
}, [userHasScrolled]);
|
|
4551
4566
|
useEffect7(() => {
|
|
4567
|
+
console.log("AIChatPanel - Auto-scroll effect triggered", {
|
|
4568
|
+
idle,
|
|
4569
|
+
responseLength: response.length,
|
|
4570
|
+
effectRanAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4571
|
+
});
|
|
4552
4572
|
if (idle) {
|
|
4553
|
-
console.log("AIChatPanel - Auto-scroll effect: SKIPPED (idle)");
|
|
4573
|
+
console.log("AIChatPanel - Auto-scroll effect: SKIPPED (idle=true)");
|
|
4554
4574
|
return;
|
|
4555
4575
|
}
|
|
4556
4576
|
const currentResponseLength = response.length;
|
|
4557
4577
|
const responseGotLonger = currentResponseLength > prevResponseLengthRef.current;
|
|
4558
|
-
console.log("AIChatPanel - Auto-scroll
|
|
4559
|
-
idle,
|
|
4578
|
+
console.log("AIChatPanel - Auto-scroll checks:", {
|
|
4560
4579
|
currentResponseLength,
|
|
4561
4580
|
prevLength: prevResponseLengthRef.current,
|
|
4562
4581
|
responseGotLonger,
|
|
@@ -4566,8 +4585,10 @@ var AIChatPanel = ({
|
|
|
4566
4585
|
prevResponseLengthRef.current = currentResponseLength;
|
|
4567
4586
|
const shouldAutoScroll = scrollToEndRef.current || !userHasScrolledRef.current;
|
|
4568
4587
|
if (shouldAutoScroll && response && responseGotLonger) {
|
|
4569
|
-
console.log("AIChatPanel -
|
|
4588
|
+
console.log("AIChatPanel - \u2705 SCROLLING TO BOTTOM");
|
|
4570
4589
|
scrollToBottom(false);
|
|
4590
|
+
} else {
|
|
4591
|
+
console.log("AIChatPanel - \u274C NOT scrolling (conditions not met)");
|
|
4571
4592
|
}
|
|
4572
4593
|
}, [response, idle]);
|
|
4573
4594
|
const idleRef = useRef5(idle);
|
|
@@ -4723,12 +4744,6 @@ var AIChatPanel = ({
|
|
|
4723
4744
|
) : /* @__PURE__ */ React12.createElement("code", __spreadValues({ className }, props), children);
|
|
4724
4745
|
}, [effectivePrismStyle]);
|
|
4725
4746
|
const AgentSuggestionCard = React12.memo(({ agentId, agentName, reason }) => {
|
|
4726
|
-
useEffect7(() => {
|
|
4727
|
-
const timer = setTimeout(() => {
|
|
4728
|
-
scrollToBottom(true);
|
|
4729
|
-
}, 100);
|
|
4730
|
-
return () => clearTimeout(timer);
|
|
4731
|
-
}, []);
|
|
4732
4747
|
if (!agentId || !onAgentChange) return null;
|
|
4733
4748
|
const isValidUUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(agentId);
|
|
4734
4749
|
const agentOption = agentOptions.find((opt) => opt.value === agentId);
|
|
@@ -4771,9 +4786,6 @@ var AIChatPanel = ({
|
|
|
4771
4786
|
className: "ai-chat-agent-suggestion__button",
|
|
4772
4787
|
onClick: () => {
|
|
4773
4788
|
onAgentChange(agentId);
|
|
4774
|
-
setTimeout(() => {
|
|
4775
|
-
scrollToBottom(true);
|
|
4776
|
-
}, 100);
|
|
4777
4789
|
}
|
|
4778
4790
|
},
|
|
4779
4791
|
"Switch"
|
package/package.json
CHANGED
package/src/AIChatPanel.tsx
CHANGED
|
@@ -1474,6 +1474,13 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
|
|
|
1474
1474
|
|
|
1475
1475
|
// Scroll to bottom - throttled using RAF to prevent layout thrashing
|
|
1476
1476
|
const scrollToBottom = useCallback((force: boolean = false) => {
|
|
1477
|
+
console.log('🔵 scrollToBottom called', {
|
|
1478
|
+
force,
|
|
1479
|
+
idle: idleRef.current,
|
|
1480
|
+
calledAt: new Date().toISOString(),
|
|
1481
|
+
stackTrace: new Error().stack?.split('\n').slice(2, 4).join('\n')
|
|
1482
|
+
});
|
|
1483
|
+
|
|
1477
1484
|
// Cancel any pending scroll
|
|
1478
1485
|
if (scrollRAFRef.current) {
|
|
1479
1486
|
cancelAnimationFrame(scrollRAFRef.current);
|
|
@@ -1489,12 +1496,23 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
|
|
|
1489
1496
|
const clientHeight = scrollElement.clientHeight;
|
|
1490
1497
|
const isNearBottom = scrollHeight - scrollTop - clientHeight < 100;
|
|
1491
1498
|
|
|
1499
|
+
console.log('🔵 scrollToBottom: checking position', {
|
|
1500
|
+
scrollTop,
|
|
1501
|
+
scrollHeight,
|
|
1502
|
+
clientHeight,
|
|
1503
|
+
distanceFromBottom: scrollHeight - scrollTop - clientHeight,
|
|
1504
|
+
isNearBottom
|
|
1505
|
+
});
|
|
1506
|
+
|
|
1492
1507
|
// If user is not near bottom, don't scroll (prevents scroll on layout changes like toast)
|
|
1493
1508
|
if (!isNearBottom) {
|
|
1509
|
+
console.log('🔵 scrollToBottom: CANCELLED (not near bottom)');
|
|
1494
1510
|
return;
|
|
1495
1511
|
}
|
|
1496
1512
|
}
|
|
1497
1513
|
|
|
1514
|
+
console.log('🔵 scrollToBottom: EXECUTING SCROLL', { force });
|
|
1515
|
+
|
|
1498
1516
|
// Throttle to max once per 100ms to prevent performance issues during streaming
|
|
1499
1517
|
const now = Date.now();
|
|
1500
1518
|
if (now - lastScrollTimeRef.current < 100) {
|
|
@@ -1835,9 +1853,15 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
|
|
|
1835
1853
|
// Auto-scroll to bottom - only while streaming and user hasn't manually scrolled
|
|
1836
1854
|
// CRITICAL: Only depends on response and idle to avoid re-running on layout changes
|
|
1837
1855
|
useEffect(() => {
|
|
1856
|
+
console.log('AIChatPanel - Auto-scroll effect triggered', {
|
|
1857
|
+
idle,
|
|
1858
|
+
responseLength: response.length,
|
|
1859
|
+
effectRanAt: new Date().toISOString(),
|
|
1860
|
+
});
|
|
1861
|
+
|
|
1838
1862
|
// CRITICAL: Skip entirely if idle - no scrolling when not streaming
|
|
1839
1863
|
if (idle) {
|
|
1840
|
-
console.log('AIChatPanel - Auto-scroll effect: SKIPPED (idle)');
|
|
1864
|
+
console.log('AIChatPanel - Auto-scroll effect: SKIPPED (idle=true)');
|
|
1841
1865
|
return;
|
|
1842
1866
|
}
|
|
1843
1867
|
|
|
@@ -1849,8 +1873,7 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
|
|
|
1849
1873
|
const currentResponseLength = response.length;
|
|
1850
1874
|
const responseGotLonger = currentResponseLength > prevResponseLengthRef.current;
|
|
1851
1875
|
|
|
1852
|
-
console.log('AIChatPanel - Auto-scroll
|
|
1853
|
-
idle,
|
|
1876
|
+
console.log('AIChatPanel - Auto-scroll checks:', {
|
|
1854
1877
|
currentResponseLength,
|
|
1855
1878
|
prevLength: prevResponseLengthRef.current,
|
|
1856
1879
|
responseGotLonger,
|
|
@@ -1863,9 +1886,11 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
|
|
|
1863
1886
|
// Only scroll if response actually grew - use refs to avoid unnecessary effect runs
|
|
1864
1887
|
const shouldAutoScroll = scrollToEndRef.current || !userHasScrolledRef.current;
|
|
1865
1888
|
if (shouldAutoScroll && response && responseGotLonger) {
|
|
1866
|
-
console.log('AIChatPanel -
|
|
1889
|
+
console.log('AIChatPanel - ✅ SCROLLING TO BOTTOM');
|
|
1867
1890
|
// Use non-forced scroll - will only scroll if near bottom
|
|
1868
1891
|
scrollToBottom(false);
|
|
1892
|
+
} else {
|
|
1893
|
+
console.log('AIChatPanel - ❌ NOT scrolling (conditions not met)');
|
|
1869
1894
|
}
|
|
1870
1895
|
}, [response, idle]); // ONLY response and idle - no other dependencies!
|
|
1871
1896
|
|
|
@@ -2087,15 +2112,8 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
|
|
|
2087
2112
|
agentName: string;
|
|
2088
2113
|
reason: string;
|
|
2089
2114
|
}) => {
|
|
2090
|
-
//
|
|
2091
|
-
|
|
2092
|
-
// Small delay to ensure the card is fully rendered in the DOM
|
|
2093
|
-
// Force scroll since this is new content being added
|
|
2094
|
-
const timer = setTimeout(() => {
|
|
2095
|
-
scrollToBottom(true);
|
|
2096
|
-
}, 100);
|
|
2097
|
-
return () => clearTimeout(timer);
|
|
2098
|
-
}, []); // Empty deps - only run on mount
|
|
2115
|
+
// Note: Removed auto-scroll on card appearance - it was causing unwanted scrolling
|
|
2116
|
+
// The card appears as part of streaming response, which handles its own scrolling
|
|
2099
2117
|
|
|
2100
2118
|
if (!agentId || !onAgentChange) return null;
|
|
2101
2119
|
|
|
@@ -2211,11 +2229,7 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
|
|
|
2211
2229
|
className="ai-chat-agent-suggestion__button"
|
|
2212
2230
|
onClick={() => {
|
|
2213
2231
|
onAgentChange(agentId);
|
|
2214
|
-
//
|
|
2215
|
-
// Force scroll since this is a user-initiated action
|
|
2216
|
-
setTimeout(() => {
|
|
2217
|
-
scrollToBottom(true);
|
|
2218
|
-
}, 100);
|
|
2232
|
+
// Note: Removed forced scroll - switching agents shouldn't scroll the chat
|
|
2219
2233
|
}}
|
|
2220
2234
|
>
|
|
2221
2235
|
Switch
|