@memori.ai/memori-react 7.32.2 → 7.32.4

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/components/Chat/Chat.d.ts +0 -1
  3. package/dist/components/Chat/Chat.js +4 -4
  4. package/dist/components/Chat/Chat.js.map +1 -1
  5. package/dist/components/ChatBubble/ChatBubble.css +8 -0
  6. package/dist/components/ChatBubble/ChatBubble.js +33 -6
  7. package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
  8. package/dist/components/ChatHistoryDrawer/ChatHistory.js +2 -2
  9. package/dist/components/ChatHistoryDrawer/ChatHistory.js.map +1 -1
  10. package/dist/components/MediaWidget/LinkItemWidget.css +10 -1
  11. package/dist/components/MediaWidget/LinkItemWidget.d.ts +1 -0
  12. package/dist/components/MediaWidget/LinkItemWidget.js +5 -2
  13. package/dist/components/MediaWidget/LinkItemWidget.js.map +1 -1
  14. package/dist/components/MediaWidget/MediaItemWidget.css +122 -6
  15. package/dist/components/MediaWidget/MediaItemWidget.d.ts +2 -0
  16. package/dist/components/MediaWidget/MediaItemWidget.js +22 -3
  17. package/dist/components/MediaWidget/MediaItemWidget.js.map +1 -1
  18. package/dist/components/MediaWidget/MediaWidget.d.ts +1 -0
  19. package/dist/components/MediaWidget/MediaWidget.js +2 -2
  20. package/dist/components/MediaWidget/MediaWidget.js.map +1 -1
  21. package/dist/components/MemoriWidget/MemoriWidget.js +6 -2
  22. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  23. package/dist/helpers/error.js +31 -6
  24. package/dist/helpers/error.js.map +1 -1
  25. package/dist/helpers/message.js +1 -1
  26. package/dist/helpers/message.js.map +1 -1
  27. package/dist/locales/de.json +32 -1
  28. package/dist/locales/en.json +32 -1
  29. package/dist/locales/es.json +32 -1
  30. package/dist/locales/fr.json +33 -1
  31. package/dist/locales/it.json +32 -1
  32. package/esm/components/Chat/Chat.d.ts +0 -1
  33. package/esm/components/Chat/Chat.js +4 -4
  34. package/esm/components/Chat/Chat.js.map +1 -1
  35. package/esm/components/ChatBubble/ChatBubble.css +8 -0
  36. package/esm/components/ChatBubble/ChatBubble.js +33 -6
  37. package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
  38. package/esm/components/ChatHistoryDrawer/ChatHistory.js +3 -3
  39. package/esm/components/ChatHistoryDrawer/ChatHistory.js.map +1 -1
  40. package/esm/components/MediaWidget/LinkItemWidget.css +10 -1
  41. package/esm/components/MediaWidget/LinkItemWidget.d.ts +1 -0
  42. package/esm/components/MediaWidget/LinkItemWidget.js +5 -2
  43. package/esm/components/MediaWidget/LinkItemWidget.js.map +1 -1
  44. package/esm/components/MediaWidget/MediaItemWidget.css +122 -6
  45. package/esm/components/MediaWidget/MediaItemWidget.d.ts +2 -0
  46. package/esm/components/MediaWidget/MediaItemWidget.js +22 -3
  47. package/esm/components/MediaWidget/MediaItemWidget.js.map +1 -1
  48. package/esm/components/MediaWidget/MediaWidget.d.ts +1 -0
  49. package/esm/components/MediaWidget/MediaWidget.js +2 -2
  50. package/esm/components/MediaWidget/MediaWidget.js.map +1 -1
  51. package/esm/components/MemoriWidget/MemoriWidget.js +6 -2
  52. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  53. package/esm/helpers/error.js +31 -6
  54. package/esm/helpers/error.js.map +1 -1
  55. package/esm/helpers/message.js +1 -1
  56. package/esm/helpers/message.js.map +1 -1
  57. package/esm/locales/de.json +32 -1
  58. package/esm/locales/en.json +32 -1
  59. package/esm/locales/es.json +32 -1
  60. package/esm/locales/fr.json +33 -1
  61. package/esm/locales/it.json +32 -1
  62. package/package.json +1 -1
  63. package/src/components/Chat/Chat.stories.tsx +153 -0
  64. package/src/components/Chat/Chat.test.tsx +0 -9
  65. package/src/components/Chat/Chat.tsx +4 -6
  66. package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +1149 -37
  67. package/src/components/ChatBubble/ChatBubble.css +8 -0
  68. package/src/components/ChatBubble/ChatBubble.stories.tsx +26 -0
  69. package/src/components/ChatBubble/ChatBubble.test.tsx +29 -0
  70. package/src/components/ChatBubble/ChatBubble.tsx +66 -6
  71. package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +198 -0
  72. package/src/components/ChatHistoryDrawer/ChatHistory.tsx +2 -3
  73. package/src/components/MediaWidget/LinkItemWidget.css +10 -1
  74. package/src/components/MediaWidget/LinkItemWidget.tsx +6 -1
  75. package/src/components/MediaWidget/MediaItemWidget.css +122 -6
  76. package/src/components/MediaWidget/MediaItemWidget.tsx +39 -2
  77. package/src/components/MediaWidget/MediaWidget.tsx +4 -1
  78. package/src/components/MediaWidget/__snapshots__/LinkItemWidget.test.tsx.snap +4 -4
  79. package/src/components/MediaWidget/__snapshots__/MediaItemWidget.test.tsx.snap +4 -4
  80. package/src/components/MediaWidget/__snapshots__/MediaWidget.test.tsx.snap +2 -2
  81. package/src/components/MemoriWidget/MemoriWidget.tsx +8 -2
  82. package/src/helpers/error.ts +35 -6
  83. package/src/helpers/message.ts +2 -1
  84. package/src/index.stories.tsx +13 -25
  85. package/src/locales/de.json +32 -1
  86. package/src/locales/en.json +32 -1
  87. package/src/locales/es.json +32 -1
  88. package/src/locales/fr.json +33 -1
  89. package/src/locales/it.json +32 -1
  90. package/dist/components/ExportHistoryButton/ExportHistoryButton.d.ts +0 -14
  91. package/dist/components/ExportHistoryButton/ExportHistoryButton.js +0 -38
  92. package/dist/components/ExportHistoryButton/ExportHistoryButton.js.map +0 -1
  93. package/esm/components/ExportHistoryButton/ExportHistoryButton.d.ts +0 -14
  94. package/esm/components/ExportHistoryButton/ExportHistoryButton.js +0 -35
  95. package/esm/components/ExportHistoryButton/ExportHistoryButton.js.map +0 -1
@@ -179,6 +179,14 @@
179
179
  color: #000;
180
180
  }
181
181
 
182
+ .memori-chat--bubble .memori-chat--bubble-action-icon.memori-chat--bubble-action-icon--debug {
183
+ color: var(--memori-error-color);
184
+ }
185
+
186
+ .memori-chat--bubble .memori-chat--bubble-action-icon.memori-chat--bubble-action-icon--debug svg {
187
+ color: currentColor;
188
+ }
189
+
182
190
  .memori-chat--bubble-addon .memori-chat--feedback {
183
191
  display: flex;
184
192
  align-items: center;
@@ -186,6 +186,32 @@ WithAllAddonsContents.args = {
186
186
  simulateUserPrompt: () => {},
187
187
  };
188
188
 
189
+ export const WithDebugButton = Template.bind({});
190
+ WithDebugButton.args = {
191
+ memori,
192
+ tenant,
193
+ message: {
194
+ fromUser: false,
195
+ text: 'Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.',
196
+ initial: false,
197
+ generatedByAI: true,
198
+ media: [
199
+ {
200
+ mediumID: 'c6851968-5d4d-409a-ae75-f22ec077efcd',
201
+ mimeType: 'text/plain',
202
+ content: 'Lorem ipsum dolor sit amet',
203
+ title: 'Function Cache Lorem ispum',
204
+ properties: {
205
+ functionCache: 'true',
206
+ },
207
+ },
208
+ ],
209
+ },
210
+ showFeedback: true,
211
+ showFunctionCache: true,
212
+ simulateUserPrompt: () => {},
213
+ };
214
+
189
215
  export const FromUserWithAvatar = Template.bind({});
190
216
  FromUserWithAvatar.args = {
191
217
  memori,
@@ -144,6 +144,35 @@ it('renders ChatBubble with msg from BoE expert unchanged', () => {
144
144
  expect(container).toMatchSnapshot();
145
145
  });
146
146
 
147
+ it('renders ChatBubble with debug button unchanged', () => {
148
+ const { container } = render(
149
+ <ChatBubble
150
+ memori={memori}
151
+ tenant={tenant}
152
+ sessionID={sessionID}
153
+ showFunctionCache
154
+ message={{
155
+ fromUser: false,
156
+ text: 'Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.',
157
+ initial: false,
158
+ generatedByAI: true,
159
+ media: [
160
+ {
161
+ mediumID: 'c6851968-5d4d-409a-ae75-f22ec077efcd',
162
+ mimeType: 'text/plain',
163
+ content: 'Lorem ipsum dolor sit amet',
164
+ title: 'Function Cache Lorem ispum',
165
+ properties: {
166
+ functionCache: true,
167
+ },
168
+ },
169
+ ],
170
+ }}
171
+ />
172
+ );
173
+ expect(container).toMatchSnapshot();
174
+ });
175
+
147
176
  it('renders ChatBubble from user with avatar unchanged', () => {
148
177
  const { container } = render(
149
178
  <ChatBubble
@@ -6,6 +6,7 @@ import {
6
6
  Message,
7
7
  Tenant,
8
8
  User,
9
+ Medium,
9
10
  } from '@memori.ai/memori-api-client/dist/types';
10
11
  import { Props as MemoriProps } from '../MemoriWidget/MemoriWidget';
11
12
  import { Transition } from '@headlessui/react';
@@ -26,6 +27,7 @@ import { stripHTML, stripOutputTags } from '../../helpers/utils';
26
27
  import { renderMsg, truncateMessage } from '../../helpers/message';
27
28
  import Expandable from '../ui/Expandable';
28
29
  import Modal from '../ui/Modal';
30
+ import MediaWidget from '../MediaWidget/MediaWidget';
29
31
 
30
32
  // Always import and load MathJax
31
33
  import { installMathJax } from '../../helpers/utils';
@@ -84,6 +86,7 @@ const ChatBubble: React.FC<Props> = ({
84
86
  const lang = i18n.language || 'en';
85
87
  const [showingWhyThisAnswer, setShowingWhyThisAnswer] = useState(false);
86
88
  const [openFunctionCache, setOpenFunctionCache] = useState(false);
89
+ const [documentAttachments, setDocumentAttachments] = useState<(Medium & { type?: string })[]>([]);
87
90
 
88
91
  // Initialize MathJax on component mount
89
92
  useEffect(() => {
@@ -92,14 +95,41 @@ const ChatBubble: React.FC<Props> = ({
92
95
  }
93
96
  }, []);
94
97
 
95
- const text = message.translatedText || message.text;
98
+ // Extract document attachments from text and convert them to media
99
+ useEffect(() => {
100
+ const text = message.translatedText || message.text;
101
+ const documentAttachmentRegex = /<document_attachment filename="([^"]+)" type="([^"]+)">([\s\S]*?)<\/document_attachment>/g;
102
+ const attachments: (Medium & { type?: string })[] = [];
103
+ let match;
104
+
105
+ while ((match = documentAttachmentRegex.exec(text)) !== null) {
106
+ const [, filename, type, content] = match;
107
+ attachments.push({
108
+ mediumID: `doc_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
109
+ url: '',
110
+ mimeType: type,
111
+ title: filename,
112
+ content: content.trim(),
113
+ properties: { isDocumentAttachment: true },
114
+ type: 'document',
115
+ });
116
+ }
117
+
118
+ setDocumentAttachments(attachments);
119
+ }, [message.text, message.translatedText]);
120
+
121
+ // Clean text by removing document_attachment tags before rendering
122
+ const cleanText = (message.translatedText || message.text).replace(
123
+ /<document_attachment filename="([^"]+)" type="([^"]+)">([\s\S]*?)<\/document_attachment>/g,
124
+ ''
125
+ );
96
126
  const { text: renderedText } = renderMsg(
97
- text,
127
+ cleanText,
98
128
  useMathFormatting,
99
129
  t('reasoning') || 'Reasoning...'
100
130
  );
101
131
  const plainText = message.fromUser
102
- ? truncateMessage(text)
132
+ ? truncateMessage(cleanText)
103
133
  : stripHTML(stripOutputTags(renderedText));
104
134
 
105
135
  // Format function cache content
@@ -146,7 +176,9 @@ const ChatBubble: React.FC<Props> = ({
146
176
 
147
177
  return () => clearTimeout(timer);
148
178
  }
149
- }, [message.text, message.fromUser, renderedText]);
179
+ }, [cleanText, message.fromUser, renderedText]);
180
+
181
+ console.log('media',message?.media);
150
182
 
151
183
  return (
152
184
  <>
@@ -281,6 +313,7 @@ const ChatBubble: React.FC<Props> = ({
281
313
 
282
314
  {((!message.fromUser && showCopyButton) ||
283
315
  (message.generatedByAI && showAIicon) ||
316
+ (message.generatedByAI && showFunctionCache) ||
284
317
  (showFeedback && simulateUserPrompt)) && (
285
318
  <div className="memori-chat--bubble-addon">
286
319
  {!message.fromUser && showCopyButton && (
@@ -312,13 +345,15 @@ const ChatBubble: React.FC<Props> = ({
312
345
  {!message.fromUser &&
313
346
  showFunctionCache &&
314
347
  message.media?.some(
315
- m => m.properties?.functionCache === 'true'
348
+ m =>
349
+ Boolean(m.properties?.functionCache) ||
350
+ m.properties?.functionCache === 'true'
316
351
  ) && (
317
352
  <Button
318
353
  ghost
319
354
  shape="circle"
320
355
  title="Debug"
321
- className="memori-chat--bubble-action-icon"
356
+ className="memori-chat--bubble-action-icon memori-chat--bubble-action-icon--debug"
322
357
  icon={<Bug aria-label="Debug" />}
323
358
  onClick={() => setOpenFunctionCache(true)}
324
359
  />
@@ -462,6 +497,31 @@ const ChatBubble: React.FC<Props> = ({
462
497
  )}
463
498
  </Transition>
464
499
 
500
+ {/* Render document attachments as media */}
501
+ {documentAttachments.length > 0 && (
502
+ <MediaWidget
503
+ media={documentAttachments}
504
+ sessionID={sessionID}
505
+ baseUrl={baseUrl}
506
+ apiUrl={apiUrl}
507
+ fromUser={message.fromUser}
508
+ />
509
+ )}
510
+
511
+ {/* Render existing media */}
512
+ {message.media && message.media.length > 0 && (
513
+ <MediaWidget
514
+ media={message.media.filter(
515
+ m => m.mimeType !== 'text/html' && m.mimeType !== 'text/plain'
516
+ )}
517
+ links={message.media.filter(m => m.mimeType === 'text/html')}
518
+ sessionID={sessionID}
519
+ baseUrl={baseUrl}
520
+ apiUrl={apiUrl}
521
+ fromUser={message.fromUser}
522
+ />
523
+ )}
524
+
465
525
  {showingWhyThisAnswer && apiUrl && (
466
526
  <WhyThisAnswer
467
527
  visible={showingWhyThisAnswer}
@@ -6611,6 +6611,204 @@ exports[`renders ChatBubble with copy disabled unchanged 1`] = `
6611
6611
  </div>
6612
6612
  `;
6613
6613
 
6614
+ exports[`renders ChatBubble with debug button unchanged 1`] = `
6615
+ <div>
6616
+ <div
6617
+ class="memori-chat--bubble-container memori-chat--with-addon"
6618
+ >
6619
+ <picture
6620
+ class="memori-chat--bubble-avatar transition ease-in-out duration-300 opacity-0 scale-075 translate-x--15"
6621
+ title="Memori"
6622
+ >
6623
+ <img
6624
+ alt="Memori"
6625
+ class="memori-chat--bubble-avatar-img"
6626
+ src="https://aisuru.com/images/aisuru/square_logo.png"
6627
+ />
6628
+ </picture>
6629
+ <div
6630
+ class="memori-chat--bubble memori-chat--with-addon memori-chat--ai-generated transition ease-in-out duration-300 opacity-0 scale-09 translate-x--30"
6631
+ >
6632
+ <div
6633
+ class="memori-chat--bubble-content"
6634
+ dir="auto"
6635
+ >
6636
+ <p>
6637
+ Proin libero ante, dignissim sit amet turpis a, pretium condimentum dolor.
6638
+ </p>
6639
+ </div>
6640
+ <div
6641
+ class="memori-chat--bubble-addon"
6642
+ >
6643
+ <button
6644
+ class="memori-button memori-button--ghost memori-button--circle memori-button--padded memori-button--icon-only memori-chat--bubble-action-icon"
6645
+ title="copy"
6646
+ >
6647
+ <span
6648
+ class="memori-button--icon"
6649
+ >
6650
+ <svg
6651
+ aria-hidden="true"
6652
+ fill="none"
6653
+ focusable="false"
6654
+ role="img"
6655
+ stroke="currentColor"
6656
+ stroke-linecap="round"
6657
+ stroke-linejoin="round"
6658
+ stroke-width="1.5"
6659
+ viewBox="0 0 24 24"
6660
+ xmlns="http://www.w3.org/2000/svg"
6661
+ >
6662
+ <rect
6663
+ height="14"
6664
+ rx="2"
6665
+ ry="2"
6666
+ width="14"
6667
+ x="8"
6668
+ y="8"
6669
+ />
6670
+ <path
6671
+ d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
6672
+ />
6673
+ </svg>
6674
+ </span>
6675
+ </button>
6676
+ <button
6677
+ class="memori-button memori-button--ghost memori-button--circle memori-button--padded memori-button--icon-only memori-chat--bubble-action-icon memori-chat--bubble-action-icon--debug"
6678
+ title="Debug"
6679
+ >
6680
+ <span
6681
+ class="memori-button--icon"
6682
+ >
6683
+ <svg
6684
+ color="currentColor"
6685
+ fill="none"
6686
+ height="800px"
6687
+ viewBox="0 0 24 24"
6688
+ width="800px"
6689
+ xmlns="http://www.w3.org/2000/svg"
6690
+ >
6691
+ <path
6692
+ d="M19 15V11.9375C19 9.76288 17.2371 8 15.0625 8H8.9375C6.76288 8 5 9.76288 5 11.9375V15C5 18.866 8.13401 22 12 22C15.866 22 19 18.866 19 15Z"
6693
+ stroke="currentColor"
6694
+ stroke-width="1.5"
6695
+ />
6696
+ <path
6697
+ d="M16.5 8.5V7.5C16.5 5.01472 14.4853 3 12 3C9.51472 3 7.5 5.01472 7.5 7.5V8.5"
6698
+ stroke="currentColor"
6699
+ stroke-width="1.5"
6700
+ />
6701
+ <path
6702
+ d="M19 14H22"
6703
+ stroke="currentColor"
6704
+ stroke-linecap="round"
6705
+ stroke-width="1.5"
6706
+ />
6707
+ <path
6708
+ d="M5 14H2"
6709
+ stroke="currentColor"
6710
+ stroke-linecap="round"
6711
+ stroke-width="1.5"
6712
+ />
6713
+ <path
6714
+ d="M14.5 3.5L17 2"
6715
+ stroke="currentColor"
6716
+ stroke-linecap="round"
6717
+ stroke-width="1.5"
6718
+ />
6719
+ <path
6720
+ d="M9.5 3.5L7 2"
6721
+ stroke="currentColor"
6722
+ stroke-linecap="round"
6723
+ stroke-width="1.5"
6724
+ />
6725
+ <path
6726
+ d="M20.5 20.0002L18.5 19.2002"
6727
+ stroke="currentColor"
6728
+ stroke-linecap="round"
6729
+ stroke-width="1.5"
6730
+ />
6731
+ <path
6732
+ d="M20.5 7.9998L18.5 8.7998"
6733
+ stroke="currentColor"
6734
+ stroke-linecap="round"
6735
+ stroke-width="1.5"
6736
+ />
6737
+ <path
6738
+ d="M3.5 20.0002L5.5 19.2002"
6739
+ stroke="currentColor"
6740
+ stroke-linecap="round"
6741
+ stroke-width="1.5"
6742
+ />
6743
+ <path
6744
+ d="M3.5 7.9998L5.5 8.7998"
6745
+ stroke="currentColor"
6746
+ stroke-linecap="round"
6747
+ stroke-width="1.5"
6748
+ />
6749
+ <path
6750
+ d="M12 21.5V15"
6751
+ stroke="currentColor"
6752
+ stroke-linecap="round"
6753
+ stroke-width="1.5"
6754
+ />
6755
+ </svg>
6756
+ </span>
6757
+ </button>
6758
+ <div
6759
+ class="memori-tooltip memori-tooltip--align-left memori-chat--bubble-action-icon memori-chat--bubble-action-icon--ai"
6760
+ >
6761
+ <div
6762
+ class="memori-tooltip--content"
6763
+ >
6764
+ generatedByAI
6765
+ </div>
6766
+ <div
6767
+ class="memori-tooltip--trigger"
6768
+ >
6769
+ <span>
6770
+ <svg
6771
+ aria-label="generatedByAI"
6772
+ fill="none"
6773
+ focusable="false"
6774
+ role="img"
6775
+ viewBox="0 0 24 24"
6776
+ xmlns="http://www.w3.org/2000/svg"
6777
+ >
6778
+ <g
6779
+ clip-rule="evenodd"
6780
+ fill="currentColor"
6781
+ fill-rule="evenodd"
6782
+ >
6783
+ <path
6784
+ clip-rule="evenodd"
6785
+ d="M0 4a4 4 0 014-4h16a4 4 0 014 4v16a4 4 0 01-4 4H4a4 4 0 01-4-4zm4-2.4A2.4 2.4 0 001.6 4v16A2.4 2.4 0 004 22.4h16a2.4 2.4 0 002.4-2.4V4A2.4 2.4 0 0020 1.6z"
6786
+ fill-rule="evenodd"
6787
+ />
6788
+ <path
6789
+ clip-rule="evenodd"
6790
+ d="M9.715 8.442a.798.798 0 00-1.43 0l-3.2 6.4a.799.799 0 101.431.716l.579-1.158h3.811l.578 1.158a.8.8 0 001.431-.716zm.391 4.358L9 10.589 7.894 12.8z"
6791
+ fill-rule="evenodd"
6792
+ />
6793
+ <path
6794
+ clip-rule="evenodd"
6795
+ d="M17 8c.552 0 1 .358 1 .8v6.4c0 .442-.448.8-1 .8s-1-.358-1-.8V8.8c0-.442.448-.8 1-.8z"
6796
+ fill-rule="evenodd"
6797
+ />
6798
+ </g>
6799
+ </svg>
6800
+ </span>
6801
+ </div>
6802
+ </div>
6803
+ </div>
6804
+ </div>
6805
+ </div>
6806
+ <div
6807
+ class="memori-media-widget"
6808
+ />
6809
+ </div>
6810
+ `;
6811
+
6614
6812
  exports[`renders ChatBubble with initial msg unchanged 1`] = `
6615
6813
  <div>
6616
6814
  <div
@@ -693,7 +693,7 @@ const ChatHistoryDrawer = ({
693
693
  <div className="memori-chat-history-drawer--card--content">
694
694
  <div className="memori-chat-history-drawer--card--content--messages">
695
695
  <Chat
696
- key={`${chatLog.lines[0].text}-${chatLog.lines[0].timestamp}`}
696
+ key={`${chatLog.chatLogID}-${chatLog.lines.length}`}
697
697
  baseUrl={baseUrl}
698
698
  apiUrl={apiUrl}
699
699
  memoriTyping={false}
@@ -704,7 +704,7 @@ const ChatHistoryDrawer = ({
704
704
  showCopyButton={false}
705
705
  showInputs={false}
706
706
  history={chatLog.lines.map(line => ({
707
- text: truncateMessage(line.text),
707
+ text: line.text, // Don't truncate to preserve document_attachment tags
708
708
  contextVars: line.contextVars,
709
709
  media: line.media as Medium[],
710
710
  fromUser: line.inbound,
@@ -712,7 +712,6 @@ const ChatHistoryDrawer = ({
712
712
  }))}
713
713
  memori={memori}
714
714
  sessionID={sessionId}
715
- setDialogState={() => {}}
716
715
  pushMessage={() => {}}
717
716
  simulateUserPrompt={() => {}}
718
717
  setSendOnEnter={() => {}}
@@ -1,12 +1,21 @@
1
1
  .memori-link-items--grid {
2
2
  display: grid;
3
3
  padding: 1rem;
4
- direction: rtl;
5
4
  grid-auto-flow: dense;
6
5
  grid-gap: 1rem;
7
6
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
8
7
  }
9
8
 
9
+ /* Allineamento link per messaggi dell'utente */
10
+ .memori-link-items--grid.memori-link-items--user {
11
+ direction: rtl;
12
+ }
13
+
14
+ /* Allineamento link per messaggi dell'agente */
15
+ .memori-link-items--grid.memori-link-items--agent {
16
+ direction: ltr;
17
+ }
18
+
10
19
  .memori-link-item--card {
11
20
  height: 100%;
12
21
  margin-bottom: 1rem;
@@ -26,6 +26,7 @@ export interface Props {
26
26
  baseUrl?: string;
27
27
  descriptionOneLine?: boolean;
28
28
  onLinkPreviewInfo?: (linkPreviewInfo: ILinkPreviewInfo) => void;
29
+ fromUser?: boolean;
29
30
  }
30
31
 
31
32
  const getSiteInfo = async (url: string, baseUrl?: string) => {
@@ -167,10 +168,14 @@ const LinkItemWidget: React.FC<Props> = ({
167
168
  baseUrl,
168
169
  descriptionOneLine = false,
169
170
  onLinkPreviewInfo,
171
+ fromUser = false,
170
172
  }: Props) => {
171
173
  return (
172
174
  <Transition appear show as="div" className="memori-link-items">
173
- <div className="memori-link-items--grid">
175
+ <div className={cx('memori-link-items--grid', {
176
+ 'memori-link-items--user': fromUser,
177
+ 'memori-link-items--agent': !fromUser,
178
+ })}>
174
179
  {items.map((item, index) => (
175
180
  <Transition.Child
176
181
  as="div"
@@ -1,12 +1,21 @@
1
1
  .memori-media-items--grid {
2
2
  display: grid;
3
3
  padding: 1rem;
4
- direction: rtl;
5
4
  grid-auto-flow: dense;
6
5
  grid-gap: 1rem;
7
6
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
8
7
  }
9
8
 
9
+ /* Allineamento media per messaggi dell'utente */
10
+ .memori-media-items--grid.memori-media-items--user {
11
+ direction: rtl;
12
+ }
13
+
14
+ /* Allineamento media per messaggi dell'agente */
15
+ .memori-media-items--grid.memori-media-items--agent {
16
+ direction: ltr;
17
+ }
18
+
10
19
  .memori-media-item--card {
11
20
  margin-bottom: 1rem;
12
21
  }
@@ -146,10 +155,117 @@ a.memori-media-item--link {
146
155
  }
147
156
 
148
157
  .memori-media-item-preview--modal {
149
- z-index: 10000;
158
+ z-index: 1000;
159
+ }
160
+
161
+ .memori-media-item-preview--content {
162
+ max-height: 50vh;
163
+ padding: 1rem;
164
+ border: 1px solid var(--memori-border);
165
+ border-radius: 0.5rem;
166
+ background-color: var(--memori-background-color, #fff);
167
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
168
+ overflow-y: auto;
169
+ }
170
+
171
+ .memori-media-item-preview--text {
172
+ color: var(--memori-color-text);
173
+ font-family: inherit;
174
+ font-size: 0.875rem;
175
+ line-height: 1.6;
176
+ white-space: pre-wrap;
177
+ word-wrap: break-word;
178
+ }
179
+
180
+ .memori-media-item-preview--text h1,
181
+ .memori-media-item-preview--text h2,
182
+ .memori-media-item-preview--text h3,
183
+ .memori-media-item-preview--text h4,
184
+ .memori-media-item-preview--text h5,
185
+ .memori-media-item-preview--text h6 {
186
+ margin-top: 1.5rem;
187
+ margin-bottom: 0.75rem;
188
+ color: var(--memori-color-text);
189
+ font-weight: 600;
190
+ }
191
+
192
+ .memori-media-item-preview--text p {
193
+ margin-bottom: 1rem;
194
+ }
195
+
196
+ .memori-media-item-preview--text ul,
197
+ .memori-media-item-preview--text ol {
198
+ padding-left: 1.5rem;
199
+ margin-bottom: 1rem;
200
+ }
201
+
202
+ .memori-media-item-preview--text li {
203
+ margin-bottom: 0.25rem;
204
+ }
205
+
206
+ .memori-media-item-preview--text code {
207
+ padding: 0.125rem 0.25rem;
208
+ border-radius: 0.25rem;
209
+ background-color: var(--memori-primary-light);
210
+ font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
211
+ font-size: 0.875em;
212
+ }
213
+
214
+ .memori-media-item-preview--text pre {
215
+ padding: 1rem;
216
+ border: 1px solid var(--memori-border);
217
+ border-radius: 0.5rem;
218
+ margin: 1rem 0;
219
+ background-color: var(--memori-primary-light);
220
+ overflow-x: auto;
221
+ }
222
+
223
+ .memori-media-item-preview--text blockquote {
224
+ padding-left: 1rem;
225
+ border-left: 4px solid var(--memori-primary);
226
+ margin: 1rem 0;
227
+ color: var(--memori-color-text-secondary);
228
+ font-style: italic;
229
+ }
230
+
231
+ .memori-media-item-preview--text table {
150
232
  width: 100%;
151
- max-width: 80%;
152
- height: 100%;
153
- max-height: 80%;
154
- background: #fff;
233
+ margin: 1rem 0;
234
+ border-collapse: collapse;
235
+ }
236
+
237
+ .memori-media-item-preview--text th,
238
+ .memori-media-item-preview--text td {
239
+ padding: 0.5rem;
240
+ border: 1px solid var(--memori-border);
241
+ text-align: left;
242
+ }
243
+
244
+ .memori-media-item-preview--text th {
245
+ background-color: var(--memori-primary-light);
246
+ font-weight: 600;
247
+ }
248
+
249
+ .memori-media-item-preview--text a {
250
+ color: var(--memori-primary);
251
+ text-decoration: underline;
252
+ }
253
+
254
+ .memori-media-item-preview--text a:hover {
255
+ text-decoration: none;
256
+ }
257
+
258
+ /* Responsive design */
259
+ @media (max-width: 768px) {
260
+ .memori-media-item-preview--text {
261
+ font-size: 0.8rem;
262
+ }
263
+
264
+ .memori-media-item-preview--text pre {
265
+ padding: 0.75rem;
266
+ }
267
+
268
+ .memori-media-item-preview--content {
269
+ max-height: 40vh;
270
+ }
155
271
  }