@hef2024/llmasaservice-ui 0.22.4 → 0.22.5

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 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
- (_a2 = bottomRef.current) == null ? void 0 : _a2.scrollIntoView({ behavior: "auto" });
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 effect:", {
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 - Calling scrollToBottom");
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);
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
- (_a2 = bottomRef.current) == null ? void 0 : _a2.scrollIntoView({ behavior: "auto" });
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 effect:", {
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 - Calling scrollToBottom");
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hef2024/llmasaservice-ui",
3
- "version": "0.22.4",
3
+ "version": "0.22.5",
4
4
  "description": "Prebuilt UI components for LLMAsAService.io",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -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 effect:', {
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 - Calling scrollToBottom');
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