@hef2024/llmasaservice-ui 0.22.5 → 0.22.7

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
@@ -4777,12 +4777,6 @@ var AIChatPanel = ({
4777
4777
  ) : /* @__PURE__ */ import_react12.default.createElement("code", __spreadValues({ className }, props), children);
4778
4778
  }, [effectivePrismStyle]);
4779
4779
  const AgentSuggestionCard = import_react12.default.memo(({ agentId, agentName, reason }) => {
4780
- (0, import_react12.useEffect)(() => {
4781
- const timer = setTimeout(() => {
4782
- scrollToBottom(true);
4783
- }, 100);
4784
- return () => clearTimeout(timer);
4785
- }, []);
4786
4780
  if (!agentId || !onAgentChange) return null;
4787
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);
4788
4782
  const agentOption = agentOptions.find((opt) => opt.value === agentId);
@@ -4825,9 +4819,6 @@ var AIChatPanel = ({
4825
4819
  className: "ai-chat-agent-suggestion__button",
4826
4820
  onClick: () => {
4827
4821
  onAgentChange(agentId);
4828
- setTimeout(() => {
4829
- scrollToBottom(true);
4830
- }, 100);
4831
4822
  }
4832
4823
  },
4833
4824
  "Switch"
@@ -6312,17 +6303,32 @@ var AIAgentPanel = import_react14.default.forwardRef(({
6312
6303
  };
6313
6304
  }, [context, sharedContextSections, pageContextSections, contextDataSources]);
6314
6305
  (0, import_react14.useEffect)(() => {
6315
- const contextString = JSON.stringify(mergedContext.sections.map((s) => ({ id: s.id, data: s.data })));
6316
- console.log("AIAgentPanel - Context effect running, sections:", mergedContext.sections.length);
6306
+ const contextString = JSON.stringify(
6307
+ mergedContext.sections.map((s) => ({
6308
+ id: s.id,
6309
+ data: s.data
6310
+ })),
6311
+ null,
6312
+ 0
6313
+ );
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
+ });
6317
6320
  if (prevContextRef.current === null) {
6318
6321
  console.log("AIAgentPanel - First render, initializing context ref");
6319
6322
  prevContextRef.current = contextString;
6320
6323
  return;
6321
6324
  }
6322
- if (prevContextRef.current !== contextString) {
6323
- console.log("AIAgentPanel - Context changed, showing notification");
6324
- console.log("AIAgentPanel - Old context:", prevContextRef.current.substring(0, 100));
6325
- console.log("AIAgentPanel - New context:", contextString.substring(0, 100));
6325
+ const changed = prevContextRef.current !== contextString;
6326
+ 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
+ }
6326
6332
  prevContextRef.current = contextString;
6327
6333
  if (contextNotificationTimeoutRef.current) {
6328
6334
  clearTimeout(contextNotificationTimeoutRef.current);
@@ -6334,9 +6340,9 @@ var AIAgentPanel = import_react14.default.forwardRef(({
6334
6340
  contextNotificationTimeoutRef.current = null;
6335
6341
  }, 3e3);
6336
6342
  } else {
6337
- console.log("AIAgentPanel - Context unchanged");
6343
+ console.log("AIAgentPanel - \u274C Context UNCHANGED (strings match)");
6338
6344
  }
6339
- }, [mergedContext]);
6345
+ }, [mergedContext.sections]);
6340
6346
  (0, import_react14.useEffect)(() => {
6341
6347
  return () => {
6342
6348
  if (contextNotificationTimeoutRef.current) {
package/dist/index.mjs CHANGED
@@ -4744,12 +4744,6 @@ var AIChatPanel = ({
4744
4744
  ) : /* @__PURE__ */ React12.createElement("code", __spreadValues({ className }, props), children);
4745
4745
  }, [effectivePrismStyle]);
4746
4746
  const AgentSuggestionCard = React12.memo(({ agentId, agentName, reason }) => {
4747
- useEffect7(() => {
4748
- const timer = setTimeout(() => {
4749
- scrollToBottom(true);
4750
- }, 100);
4751
- return () => clearTimeout(timer);
4752
- }, []);
4753
4747
  if (!agentId || !onAgentChange) return null;
4754
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);
4755
4749
  const agentOption = agentOptions.find((opt) => opt.value === agentId);
@@ -4792,9 +4786,6 @@ var AIChatPanel = ({
4792
4786
  className: "ai-chat-agent-suggestion__button",
4793
4787
  onClick: () => {
4794
4788
  onAgentChange(agentId);
4795
- setTimeout(() => {
4796
- scrollToBottom(true);
4797
- }, 100);
4798
4789
  }
4799
4790
  },
4800
4791
  "Switch"
@@ -6279,17 +6270,32 @@ var AIAgentPanel = React13.forwardRef(({
6279
6270
  };
6280
6271
  }, [context, sharedContextSections, pageContextSections, contextDataSources]);
6281
6272
  useEffect9(() => {
6282
- const contextString = JSON.stringify(mergedContext.sections.map((s) => ({ id: s.id, data: s.data })));
6283
- console.log("AIAgentPanel - Context effect running, sections:", mergedContext.sections.length);
6273
+ const contextString = JSON.stringify(
6274
+ mergedContext.sections.map((s) => ({
6275
+ id: s.id,
6276
+ data: s.data
6277
+ })),
6278
+ null,
6279
+ 0
6280
+ );
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
+ });
6284
6287
  if (prevContextRef.current === null) {
6285
6288
  console.log("AIAgentPanel - First render, initializing context ref");
6286
6289
  prevContextRef.current = contextString;
6287
6290
  return;
6288
6291
  }
6289
- if (prevContextRef.current !== contextString) {
6290
- console.log("AIAgentPanel - Context changed, showing notification");
6291
- console.log("AIAgentPanel - Old context:", prevContextRef.current.substring(0, 100));
6292
- console.log("AIAgentPanel - New context:", contextString.substring(0, 100));
6292
+ const changed = prevContextRef.current !== contextString;
6293
+ 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
+ }
6293
6299
  prevContextRef.current = contextString;
6294
6300
  if (contextNotificationTimeoutRef.current) {
6295
6301
  clearTimeout(contextNotificationTimeoutRef.current);
@@ -6301,9 +6307,9 @@ var AIAgentPanel = React13.forwardRef(({
6301
6307
  contextNotificationTimeoutRef.current = null;
6302
6308
  }, 3e3);
6303
6309
  } else {
6304
- console.log("AIAgentPanel - Context unchanged");
6310
+ console.log("AIAgentPanel - \u274C Context UNCHANGED (strings match)");
6305
6311
  }
6306
- }, [mergedContext]);
6312
+ }, [mergedContext.sections]);
6307
6313
  useEffect9(() => {
6308
6314
  return () => {
6309
6315
  if (contextNotificationTimeoutRef.current) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hef2024/llmasaservice-ui",
3
- "version": "0.22.5",
3
+ "version": "0.22.7",
4
4
  "description": "Prebuilt UI components for LLMAsAService.io",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1532,9 +1532,21 @@ const AIAgentPanel = React.forwardRef<AIAgentPanelHandle, AIAgentPanelProps>(({
1532
1532
  // Detect context changes and show notification
1533
1533
  useEffect(() => {
1534
1534
  // Create a stable string representation of the context for comparison
1535
- const contextString = JSON.stringify(mergedContext.sections.map(s => ({ id: s.id, data: s.data })));
1535
+ const contextString = JSON.stringify(
1536
+ mergedContext.sections.map(s => ({
1537
+ id: s.id,
1538
+ data: s.data
1539
+ })),
1540
+ null,
1541
+ 0
1542
+ );
1536
1543
 
1537
- console.log('AIAgentPanel - Context effect running, sections:', mergedContext.sections.length);
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
+ });
1538
1550
 
1539
1551
  // Skip on first render
1540
1552
  if (prevContextRef.current === null) {
@@ -1544,10 +1556,17 @@ const AIAgentPanel = React.forwardRef<AIAgentPanelHandle, AIAgentPanelProps>(({
1544
1556
  }
1545
1557
 
1546
1558
  // Check if context actually changed
1547
- if (prevContextRef.current !== contextString) {
1548
- console.log('AIAgentPanel - Context changed, showing notification');
1549
- console.log('AIAgentPanel - Old context:', prevContextRef.current.substring(0, 100));
1550
- console.log('AIAgentPanel - New context:', contextString.substring(0, 100));
1559
+ const changed = prevContextRef.current !== contextString;
1560
+
1561
+ 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
+
1551
1570
  prevContextRef.current = contextString;
1552
1571
 
1553
1572
  // Clear any existing timeout before setting a new one
@@ -1565,12 +1584,12 @@ const AIAgentPanel = React.forwardRef<AIAgentPanelHandle, AIAgentPanelProps>(({
1565
1584
  contextNotificationTimeoutRef.current = null;
1566
1585
  }, 3000);
1567
1586
  } else {
1568
- console.log('AIAgentPanel - Context unchanged');
1587
+ console.log('AIAgentPanel - Context UNCHANGED (strings match)');
1569
1588
  }
1570
1589
 
1571
1590
  // Note: No cleanup on every re-render - only clear timeout when context changes
1572
1591
  // This prevents race conditions when switching rapidly
1573
- }, [mergedContext]);
1592
+ }, [mergedContext.sections]);
1574
1593
 
1575
1594
  // Separate cleanup effect for unmount only
1576
1595
  useEffect(() => {
@@ -2112,15 +2112,8 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
2112
2112
  agentName: string;
2113
2113
  reason: string;
2114
2114
  }) => {
2115
- // Auto-scroll when the agent suggestion card appears
2116
- useEffect(() => {
2117
- // Small delay to ensure the card is fully rendered in the DOM
2118
- // Force scroll since this is new content being added
2119
- const timer = setTimeout(() => {
2120
- scrollToBottom(true);
2121
- }, 100);
2122
- return () => clearTimeout(timer);
2123
- }, []); // 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
2124
2117
 
2125
2118
  if (!agentId || !onAgentChange) return null;
2126
2119
 
@@ -2236,11 +2229,7 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
2236
2229
  className="ai-chat-agent-suggestion__button"
2237
2230
  onClick={() => {
2238
2231
  onAgentChange(agentId);
2239
- // Scroll to bottom after a brief delay to let React re-render
2240
- // Force scroll since this is a user-initiated action
2241
- setTimeout(() => {
2242
- scrollToBottom(true);
2243
- }, 100);
2232
+ // Note: Removed forced scroll - switching agents shouldn't scroll the chat
2244
2233
  }}
2245
2234
  >
2246
2235
  Switch