@hef2024/llmasaservice-ui 0.22.8 → 0.22.9

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,13 +4338,7 @@ var AIChatPanel = ({
4338
4338
  }
4339
4339
  }), [thumbsDownClick, interactionClicked]);
4340
4340
  const scrollToBottom = (0, import_react12.useCallback)((force = false) => {
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
- });
4341
+ var _a2;
4348
4342
  if (scrollRAFRef.current) {
4349
4343
  cancelAnimationFrame(scrollRAFRef.current);
4350
4344
  }
@@ -4355,19 +4349,10 @@ var AIChatPanel = ({
4355
4349
  const scrollHeight = scrollElement.scrollHeight;
4356
4350
  const clientHeight = scrollElement.clientHeight;
4357
4351
  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
- });
4365
4352
  if (!isNearBottom) {
4366
- console.log("\u{1F535} scrollToBottom: CANCELLED (not near bottom)");
4367
4353
  return;
4368
4354
  }
4369
4355
  }
4370
- console.log("\u{1F535} scrollToBottom: EXECUTING SCROLL", { force });
4371
4356
  const now = Date.now();
4372
4357
  if (now - lastScrollTimeRef.current < 100) {
4373
4358
  scrollRAFRef.current = requestAnimationFrame(() => {
@@ -4377,11 +4362,10 @@ var AIChatPanel = ({
4377
4362
  });
4378
4363
  return;
4379
4364
  }
4380
- (_b = bottomRef.current) == null ? void 0 : _b.scrollIntoView({ behavior: "auto" });
4365
+ (_a2 = bottomRef.current) == null ? void 0 : _a2.scrollIntoView({ behavior: "auto" });
4381
4366
  lastScrollTimeRef.current = now;
4382
4367
  }, []);
4383
4368
  const continueChat = (0, import_react12.useCallback)((promptText) => {
4384
- console.log("AIChatPanel.continueChat called with:", promptText);
4385
4369
  setThinkingBlocks([]);
4386
4370
  setCurrentThinkingIndex(0);
4387
4371
  setError(null);
@@ -4597,31 +4581,15 @@ var AIChatPanel = ({
4597
4581
  userHasScrolledRef.current = userHasScrolled;
4598
4582
  }, [userHasScrolled]);
4599
4583
  (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
- });
4605
4584
  if (idle) {
4606
- console.log("AIChatPanel - Auto-scroll effect: SKIPPED (idle=true)");
4607
4585
  return;
4608
4586
  }
4609
4587
  const currentResponseLength = response.length;
4610
4588
  const responseGotLonger = currentResponseLength > prevResponseLengthRef.current;
4611
- console.log("AIChatPanel - Auto-scroll checks:", {
4612
- currentResponseLength,
4613
- prevLength: prevResponseLengthRef.current,
4614
- responseGotLonger,
4615
- userHasScrolled: userHasScrolledRef.current,
4616
- scrollToEnd: scrollToEndRef.current
4617
- });
4618
4589
  prevResponseLengthRef.current = currentResponseLength;
4619
4590
  const shouldAutoScroll = scrollToEndRef.current || !userHasScrolledRef.current;
4620
4591
  if (shouldAutoScroll && response && responseGotLonger) {
4621
- console.log("AIChatPanel - \u2705 SCROLLING TO BOTTOM");
4622
4592
  scrollToBottom(false);
4623
- } else {
4624
- console.log("AIChatPanel - \u274C NOT scrolling (conditions not met)");
4625
4593
  }
4626
4594
  }, [response, idle]);
4627
4595
  const idleRef = (0, import_react12.useRef)(idle);
@@ -6311,40 +6279,12 @@ var AIAgentPanel = import_react14.default.forwardRef(({
6311
6279
  null,
6312
6280
  0
6313
6281
  );
6314
- console.log("AIAgentPanel - Context effect running", {
6315
- sectionsCount: mergedContext.sections.length,
6316
- sectionIds: mergedContext.sections.map((s) => s.id),
6317
- contextLength: contextString.length,
6318
- contextHash: contextString.substring(0, 50) + "..." + contextString.substring(contextString.length - 50)
6319
- });
6320
6282
  if (prevContextRef.current === null) {
6321
- console.log("AIAgentPanel - First render, initializing context ref");
6322
6283
  prevContextRef.current = contextString;
6323
6284
  return;
6324
6285
  }
6325
6286
  const changed = prevContextRef.current !== contextString;
6326
6287
  if (changed) {
6327
- console.log("AIAgentPanel - \u2705 Context CHANGED, showing notification");
6328
- console.log("AIAgentPanel - String length old/new:", prevContextRef.current.length, contextString.length);
6329
- if (prevContextRef.current.length !== contextString.length) {
6330
- console.log("AIAgentPanel - Length difference:", contextString.length - prevContextRef.current.length);
6331
- }
6332
- try {
6333
- const oldSections = JSON.parse(prevContextRef.current);
6334
- const newSections = JSON.parse(contextString);
6335
- console.log("AIAgentPanel - Section count old/new:", oldSections.length, newSections.length);
6336
- newSections.forEach((newSec, idx) => {
6337
- const oldSec = oldSections[idx];
6338
- if (!oldSec || JSON.stringify(oldSec.data) !== JSON.stringify(newSec.data)) {
6339
- console.log(`AIAgentPanel - Section "${newSec.id}" changed:`, {
6340
- oldDataLength: oldSec ? JSON.stringify(oldSec.data).length : 0,
6341
- newDataLength: JSON.stringify(newSec.data).length
6342
- });
6343
- }
6344
- });
6345
- } catch (e) {
6346
- console.log("AIAgentPanel - Could not parse for diff:", e);
6347
- }
6348
6288
  prevContextRef.current = contextString;
6349
6289
  if (contextNotificationTimeoutRef.current) {
6350
6290
  clearTimeout(contextNotificationTimeoutRef.current);
@@ -6355,17 +6295,6 @@ var AIAgentPanel = import_react14.default.forwardRef(({
6355
6295
  setShowContextNotification(false);
6356
6296
  contextNotificationTimeoutRef.current = null;
6357
6297
  }, 3e3);
6358
- } else {
6359
- console.log("AIAgentPanel - \u274C Context UNCHANGED (strings match)");
6360
- console.log("AIAgentPanel - Current context data:", mergedContext.sections.map((s) => ({
6361
- id: s.id,
6362
- dataKeys: Object.keys(s.data || {}),
6363
- dataLength: JSON.stringify(s.data).length,
6364
- dataPreview: JSON.stringify(s.data).substring(0, 200)
6365
- })));
6366
- console.log("AIAgentPanel - prevContextRef length:", prevContextRef.current.length);
6367
- console.log("AIAgentPanel - new contextString length:", contextString.length);
6368
- console.log("AIAgentPanel - Are they identical?", prevContextRef.current === contextString);
6369
6298
  }
6370
6299
  }, [mergedContext.sections]);
6371
6300
  (0, import_react14.useEffect)(() => {
package/dist/index.mjs CHANGED
@@ -4305,13 +4305,7 @@ var AIChatPanel = ({
4305
4305
  }
4306
4306
  }), [thumbsDownClick, interactionClicked]);
4307
4307
  const scrollToBottom = useCallback2((force = false) => {
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
- });
4308
+ var _a2;
4315
4309
  if (scrollRAFRef.current) {
4316
4310
  cancelAnimationFrame(scrollRAFRef.current);
4317
4311
  }
@@ -4322,19 +4316,10 @@ var AIChatPanel = ({
4322
4316
  const scrollHeight = scrollElement.scrollHeight;
4323
4317
  const clientHeight = scrollElement.clientHeight;
4324
4318
  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
- });
4332
4319
  if (!isNearBottom) {
4333
- console.log("\u{1F535} scrollToBottom: CANCELLED (not near bottom)");
4334
4320
  return;
4335
4321
  }
4336
4322
  }
4337
- console.log("\u{1F535} scrollToBottom: EXECUTING SCROLL", { force });
4338
4323
  const now = Date.now();
4339
4324
  if (now - lastScrollTimeRef.current < 100) {
4340
4325
  scrollRAFRef.current = requestAnimationFrame(() => {
@@ -4344,11 +4329,10 @@ var AIChatPanel = ({
4344
4329
  });
4345
4330
  return;
4346
4331
  }
4347
- (_b = bottomRef.current) == null ? void 0 : _b.scrollIntoView({ behavior: "auto" });
4332
+ (_a2 = bottomRef.current) == null ? void 0 : _a2.scrollIntoView({ behavior: "auto" });
4348
4333
  lastScrollTimeRef.current = now;
4349
4334
  }, []);
4350
4335
  const continueChat = useCallback2((promptText) => {
4351
- console.log("AIChatPanel.continueChat called with:", promptText);
4352
4336
  setThinkingBlocks([]);
4353
4337
  setCurrentThinkingIndex(0);
4354
4338
  setError(null);
@@ -4564,31 +4548,15 @@ var AIChatPanel = ({
4564
4548
  userHasScrolledRef.current = userHasScrolled;
4565
4549
  }, [userHasScrolled]);
4566
4550
  useEffect7(() => {
4567
- console.log("AIChatPanel - Auto-scroll effect triggered", {
4568
- idle,
4569
- responseLength: response.length,
4570
- effectRanAt: (/* @__PURE__ */ new Date()).toISOString()
4571
- });
4572
4551
  if (idle) {
4573
- console.log("AIChatPanel - Auto-scroll effect: SKIPPED (idle=true)");
4574
4552
  return;
4575
4553
  }
4576
4554
  const currentResponseLength = response.length;
4577
4555
  const responseGotLonger = currentResponseLength > prevResponseLengthRef.current;
4578
- console.log("AIChatPanel - Auto-scroll checks:", {
4579
- currentResponseLength,
4580
- prevLength: prevResponseLengthRef.current,
4581
- responseGotLonger,
4582
- userHasScrolled: userHasScrolledRef.current,
4583
- scrollToEnd: scrollToEndRef.current
4584
- });
4585
4556
  prevResponseLengthRef.current = currentResponseLength;
4586
4557
  const shouldAutoScroll = scrollToEndRef.current || !userHasScrolledRef.current;
4587
4558
  if (shouldAutoScroll && response && responseGotLonger) {
4588
- console.log("AIChatPanel - \u2705 SCROLLING TO BOTTOM");
4589
4559
  scrollToBottom(false);
4590
- } else {
4591
- console.log("AIChatPanel - \u274C NOT scrolling (conditions not met)");
4592
4560
  }
4593
4561
  }, [response, idle]);
4594
4562
  const idleRef = useRef5(idle);
@@ -6278,40 +6246,12 @@ var AIAgentPanel = React13.forwardRef(({
6278
6246
  null,
6279
6247
  0
6280
6248
  );
6281
- console.log("AIAgentPanel - Context effect running", {
6282
- sectionsCount: mergedContext.sections.length,
6283
- sectionIds: mergedContext.sections.map((s) => s.id),
6284
- contextLength: contextString.length,
6285
- contextHash: contextString.substring(0, 50) + "..." + contextString.substring(contextString.length - 50)
6286
- });
6287
6249
  if (prevContextRef.current === null) {
6288
- console.log("AIAgentPanel - First render, initializing context ref");
6289
6250
  prevContextRef.current = contextString;
6290
6251
  return;
6291
6252
  }
6292
6253
  const changed = prevContextRef.current !== contextString;
6293
6254
  if (changed) {
6294
- console.log("AIAgentPanel - \u2705 Context CHANGED, showing notification");
6295
- console.log("AIAgentPanel - String length old/new:", prevContextRef.current.length, contextString.length);
6296
- if (prevContextRef.current.length !== contextString.length) {
6297
- console.log("AIAgentPanel - Length difference:", contextString.length - prevContextRef.current.length);
6298
- }
6299
- try {
6300
- const oldSections = JSON.parse(prevContextRef.current);
6301
- const newSections = JSON.parse(contextString);
6302
- console.log("AIAgentPanel - Section count old/new:", oldSections.length, newSections.length);
6303
- newSections.forEach((newSec, idx) => {
6304
- const oldSec = oldSections[idx];
6305
- if (!oldSec || JSON.stringify(oldSec.data) !== JSON.stringify(newSec.data)) {
6306
- console.log(`AIAgentPanel - Section "${newSec.id}" changed:`, {
6307
- oldDataLength: oldSec ? JSON.stringify(oldSec.data).length : 0,
6308
- newDataLength: JSON.stringify(newSec.data).length
6309
- });
6310
- }
6311
- });
6312
- } catch (e) {
6313
- console.log("AIAgentPanel - Could not parse for diff:", e);
6314
- }
6315
6255
  prevContextRef.current = contextString;
6316
6256
  if (contextNotificationTimeoutRef.current) {
6317
6257
  clearTimeout(contextNotificationTimeoutRef.current);
@@ -6322,17 +6262,6 @@ var AIAgentPanel = React13.forwardRef(({
6322
6262
  setShowContextNotification(false);
6323
6263
  contextNotificationTimeoutRef.current = null;
6324
6264
  }, 3e3);
6325
- } else {
6326
- console.log("AIAgentPanel - \u274C Context UNCHANGED (strings match)");
6327
- console.log("AIAgentPanel - Current context data:", mergedContext.sections.map((s) => ({
6328
- id: s.id,
6329
- dataKeys: Object.keys(s.data || {}),
6330
- dataLength: JSON.stringify(s.data).length,
6331
- dataPreview: JSON.stringify(s.data).substring(0, 200)
6332
- })));
6333
- console.log("AIAgentPanel - prevContextRef length:", prevContextRef.current.length);
6334
- console.log("AIAgentPanel - new contextString length:", contextString.length);
6335
- console.log("AIAgentPanel - Are they identical?", prevContextRef.current === contextString);
6336
6265
  }
6337
6266
  }, [mergedContext.sections]);
6338
6267
  useEffect9(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hef2024/llmasaservice-ui",
3
- "version": "0.22.8",
3
+ "version": "0.22.9",
4
4
  "description": "Prebuilt UI components for LLMAsAService.io",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1541,16 +1541,8 @@ const AIAgentPanel = React.forwardRef<AIAgentPanelHandle, AIAgentPanelProps>(({
1541
1541
  0
1542
1542
  );
1543
1543
 
1544
- console.log('AIAgentPanel - Context effect running', {
1545
- sectionsCount: mergedContext.sections.length,
1546
- sectionIds: mergedContext.sections.map(s => s.id),
1547
- contextLength: contextString.length,
1548
- contextHash: contextString.substring(0, 50) + '...' + contextString.substring(contextString.length - 50)
1549
- });
1550
-
1551
1544
  // Skip on first render
1552
1545
  if (prevContextRef.current === null) {
1553
- console.log('AIAgentPanel - First render, initializing context ref');
1554
1546
  prevContextRef.current = contextString;
1555
1547
  return;
1556
1548
  }
@@ -1559,32 +1551,6 @@ const AIAgentPanel = React.forwardRef<AIAgentPanelHandle, AIAgentPanelProps>(({
1559
1551
  const changed = prevContextRef.current !== contextString;
1560
1552
 
1561
1553
  if (changed) {
1562
- console.log('AIAgentPanel - ✅ Context CHANGED, showing notification');
1563
- console.log('AIAgentPanel - String length old/new:', prevContextRef.current.length, contextString.length);
1564
-
1565
- // Find what changed
1566
- if (prevContextRef.current.length !== contextString.length) {
1567
- console.log('AIAgentPanel - Length difference:', contextString.length - prevContextRef.current.length);
1568
- }
1569
-
1570
- // Show detailed diff for debugging
1571
- try {
1572
- const oldSections = JSON.parse(prevContextRef.current);
1573
- const newSections = JSON.parse(contextString);
1574
- console.log('AIAgentPanel - Section count old/new:', oldSections.length, newSections.length);
1575
- newSections.forEach((newSec: any, idx: number) => {
1576
- const oldSec = oldSections[idx];
1577
- if (!oldSec || JSON.stringify(oldSec.data) !== JSON.stringify(newSec.data)) {
1578
- console.log(`AIAgentPanel - Section "${newSec.id}" changed:`, {
1579
- oldDataLength: oldSec ? JSON.stringify(oldSec.data).length : 0,
1580
- newDataLength: JSON.stringify(newSec.data).length
1581
- });
1582
- }
1583
- });
1584
- } catch (e) {
1585
- console.log('AIAgentPanel - Could not parse for diff:', e);
1586
- }
1587
-
1588
1554
  prevContextRef.current = contextString;
1589
1555
 
1590
1556
  // Clear any existing timeout before setting a new one
@@ -1601,21 +1567,7 @@ const AIAgentPanel = React.forwardRef<AIAgentPanelHandle, AIAgentPanelProps>(({
1601
1567
  setShowContextNotification(false);
1602
1568
  contextNotificationTimeoutRef.current = null;
1603
1569
  }, 3000);
1604
- } else {
1605
- console.log('AIAgentPanel - ❌ Context UNCHANGED (strings match)');
1606
- console.log('AIAgentPanel - Current context data:', mergedContext.sections.map(s => ({
1607
- id: s.id,
1608
- dataKeys: Object.keys(s.data || {}),
1609
- dataLength: JSON.stringify(s.data).length,
1610
- dataPreview: JSON.stringify(s.data).substring(0, 200)
1611
- })));
1612
- console.log('AIAgentPanel - prevContextRef length:', prevContextRef.current.length);
1613
- console.log('AIAgentPanel - new contextString length:', contextString.length);
1614
- console.log('AIAgentPanel - Are they identical?', prevContextRef.current === contextString);
1615
1570
  }
1616
-
1617
- // Note: No cleanup on every re-render - only clear timeout when context changes
1618
- // This prevents race conditions when switching rapidly
1619
1571
  }, [mergedContext.sections]);
1620
1572
 
1621
1573
  // Separate cleanup effect for unmount only
@@ -1474,13 +1474,6 @@ 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
-
1484
1477
  // Cancel any pending scroll
1485
1478
  if (scrollRAFRef.current) {
1486
1479
  cancelAnimationFrame(scrollRAFRef.current);
@@ -1496,23 +1489,12 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
1496
1489
  const clientHeight = scrollElement.clientHeight;
1497
1490
  const isNearBottom = scrollHeight - scrollTop - clientHeight < 100;
1498
1491
 
1499
- console.log('🔵 scrollToBottom: checking position', {
1500
- scrollTop,
1501
- scrollHeight,
1502
- clientHeight,
1503
- distanceFromBottom: scrollHeight - scrollTop - clientHeight,
1504
- isNearBottom
1505
- });
1506
-
1507
1492
  // If user is not near bottom, don't scroll (prevents scroll on layout changes like toast)
1508
1493
  if (!isNearBottom) {
1509
- console.log('🔵 scrollToBottom: CANCELLED (not near bottom)');
1510
1494
  return;
1511
1495
  }
1512
1496
  }
1513
1497
 
1514
- console.log('🔵 scrollToBottom: EXECUTING SCROLL', { force });
1515
-
1516
1498
  // Throttle to max once per 100ms to prevent performance issues during streaming
1517
1499
  const now = Date.now();
1518
1500
  if (now - lastScrollTimeRef.current < 100) {
@@ -1532,7 +1514,6 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
1532
1514
  // Continue chat (send message) - matches ChatPanel behavior exactly
1533
1515
  // promptText is now required - comes from the isolated ChatInput component
1534
1516
  const continueChat = useCallback((promptText: string) => {
1535
- console.log('AIChatPanel.continueChat called with:', promptText);
1536
1517
  // Clear thinking blocks for new response
1537
1518
  setThinkingBlocks([]);
1538
1519
  setCurrentThinkingIndex(0);
@@ -1853,15 +1834,8 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
1853
1834
  // Auto-scroll to bottom - only while streaming and user hasn't manually scrolled
1854
1835
  // CRITICAL: Only depends on response and idle to avoid re-running on layout changes
1855
1836
  useEffect(() => {
1856
- console.log('AIChatPanel - Auto-scroll effect triggered', {
1857
- idle,
1858
- responseLength: response.length,
1859
- effectRanAt: new Date().toISOString(),
1860
- });
1861
-
1862
1837
  // CRITICAL: Skip entirely if idle - no scrolling when not streaming
1863
1838
  if (idle) {
1864
- console.log('AIChatPanel - Auto-scroll effect: SKIPPED (idle=true)');
1865
1839
  return;
1866
1840
  }
1867
1841
 
@@ -1873,24 +1847,13 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
1873
1847
  const currentResponseLength = response.length;
1874
1848
  const responseGotLonger = currentResponseLength > prevResponseLengthRef.current;
1875
1849
 
1876
- console.log('AIChatPanel - Auto-scroll checks:', {
1877
- currentResponseLength,
1878
- prevLength: prevResponseLengthRef.current,
1879
- responseGotLonger,
1880
- userHasScrolled: userHasScrolledRef.current,
1881
- scrollToEnd: scrollToEndRef.current,
1882
- });
1883
-
1884
1850
  prevResponseLengthRef.current = currentResponseLength;
1885
1851
 
1886
1852
  // Only scroll if response actually grew - use refs to avoid unnecessary effect runs
1887
1853
  const shouldAutoScroll = scrollToEndRef.current || !userHasScrolledRef.current;
1888
1854
  if (shouldAutoScroll && response && responseGotLonger) {
1889
- console.log('AIChatPanel - ✅ SCROLLING TO BOTTOM');
1890
1855
  // Use non-forced scroll - will only scroll if near bottom
1891
1856
  scrollToBottom(false);
1892
- } else {
1893
- console.log('AIChatPanel - ❌ NOT scrolling (conditions not met)');
1894
1857
  }
1895
1858
  }, [response, idle]); // ONLY response and idle - no other dependencies!
1896
1859