@admin-layout/tailwind-chat-pro 12.2.4-alpha.86 → 12.2.4-alpha.88
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/CHANGELOG.md +8 -0
- package/lib/components/messages-container-ui/ModernMessageGroup.d.ts.map +1 -1
- package/lib/components/messages-container-ui/ModernMessageGroup.js +103 -426
- package/lib/components/messages-container-ui/ModernMessageGroup.js.map +1 -1
- package/lib/components/messages-container-ui/messenger-slot-fill-name-enum.d.ts +2 -1
- package/lib/components/messages-container-ui/messenger-slot-fill-name-enum.d.ts.map +1 -1
- package/lib/components/messages-container-ui/messenger-slot-fill-name-enum.js +1 -0
- package/lib/components/messages-container-ui/messenger-slot-fill-name-enum.js.map +1 -1
- package/package.json +2 -2
- package/src/components/messages-container-ui/ModernMessageGroup.tsx +109 -454
- package/src/components/messages-container-ui/messenger-slot-fill-name-enum.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {Slot}from'@common-stack/components-pro';import {AiAgentMessageRole}from'common';import {format,differenceInMinutes}from'date-fns';import {marked}from'marked';import React,{useMemo,useEffect}from'react';import ReactMarkdown from'react-markdown';import remarkBreaks from'remark-breaks';import remarkGfm from'remark-gfm';import {MessengerSlotFillNameEnum}from'./messenger-slot-fill-name-enum.js';import {FilesList}from'./FilesList.js';import {ErrorFixCard}from'./ErrorFixCard.js';// Configure marked for better markdown rendering
|
|
1
|
+
import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {Slot}from'@common-stack/components-pro';import {AiAgentMessageRole}from'common';import {format,differenceInMinutes}from'date-fns';import {marked}from'marked';import React,{useMemo,useEffect,useState}from'react';import ReactMarkdown from'react-markdown';import remarkBreaks from'remark-breaks';import remarkGfm from'remark-gfm';import {MessengerSlotFillNameEnum}from'./messenger-slot-fill-name-enum.js';import {FilesList}from'./FilesList.js';import {ErrorFixCard}from'./ErrorFixCard.js';// Configure marked for better markdown rendering
|
|
2
2
|
marked.setOptions({
|
|
3
3
|
breaks: true,
|
|
4
4
|
// Convert line breaks to <br>
|
|
@@ -14,6 +14,9 @@ const ASSISTANT_RESPONSE_BUBBLE_CLASS = 'llm-response__bubble';
|
|
|
14
14
|
const ASSISTANT_RESPONSE_MARKDOWN_CLASS = 'llm-response__markdown';
|
|
15
15
|
const USER_MESSAGE_TEXT_SIZE_CLASS = 'text-base';
|
|
16
16
|
const USER_MESSAGE_PROSE_SIZE_CLASS = 'prose-base';
|
|
17
|
+
/** Pasted queries longer than this collapse behind a "Show more" toggle. */
|
|
18
|
+
const USER_MESSAGE_COLLAPSE_CHAR_THRESHOLD = 600;
|
|
19
|
+
const USER_MESSAGE_COLLAPSED_MAX_HEIGHT = 220;
|
|
17
20
|
function getAssistantResponseClasses(innerClassName) {
|
|
18
21
|
return [ASSISTANT_RESPONSE_MARKDOWN_CLASS, innerClassName].filter(Boolean).join(' ');
|
|
19
22
|
}
|
|
@@ -37,15 +40,15 @@ const htmlContentStyles = `
|
|
|
37
40
|
.html-content {
|
|
38
41
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
39
42
|
line-height: 1.6;
|
|
40
|
-
color:
|
|
43
|
+
color: inherit;
|
|
41
44
|
}
|
|
42
|
-
|
|
45
|
+
|
|
43
46
|
.html-content h1, .html-content h2, .html-content h3, .html-content h4, .html-content h5, .html-content h6 {
|
|
44
47
|
margin-top: 1.5rem;
|
|
45
48
|
margin-bottom: 1rem;
|
|
46
49
|
font-weight: 600;
|
|
47
50
|
line-height: 1.25;
|
|
48
|
-
color:
|
|
51
|
+
color: inherit;
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
.html-content h1 {
|
|
@@ -347,6 +350,15 @@ const htmlContentStyles = `
|
|
|
347
350
|
box-shadow: none !important;
|
|
348
351
|
}
|
|
349
352
|
|
|
353
|
+
/* Safety net: long unbroken tokens (file paths, CSS selectors, URLs) inside a
|
|
354
|
+
pasted user query must never push the bubble past its own width — wrap
|
|
355
|
+
anywhere rather than overflow the card. */
|
|
356
|
+
.user-message,
|
|
357
|
+
.user-message * {
|
|
358
|
+
max-width: 100%;
|
|
359
|
+
overflow-wrap: anywhere;
|
|
360
|
+
}
|
|
361
|
+
|
|
350
362
|
.assistant-message-container {
|
|
351
363
|
background: transparent;
|
|
352
364
|
padding-top: 0;
|
|
@@ -356,338 +368,6 @@ const htmlContentStyles = `
|
|
|
356
368
|
box-shadow: none;
|
|
357
369
|
}
|
|
358
370
|
|
|
359
|
-
.assistant-html-content {
|
|
360
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
361
|
-
line-height: 1.6;
|
|
362
|
-
color: #374151;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
.assistant-html-content h1,
|
|
366
|
-
.assistant-html-content h2,
|
|
367
|
-
.assistant-html-content h3,
|
|
368
|
-
.assistant-html-content h4,
|
|
369
|
-
.assistant-html-content h5,
|
|
370
|
-
.assistant-html-content h6 {
|
|
371
|
-
font-weight: 600;
|
|
372
|
-
line-height: 1.25;
|
|
373
|
-
color: #111827;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
.assistant-html-content h1 {
|
|
377
|
-
font-size: 1.875rem;
|
|
378
|
-
margin-top: 2rem;
|
|
379
|
-
margin-bottom: 1rem;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
.assistant-html-content h2 {
|
|
383
|
-
font-size: 1.5rem;
|
|
384
|
-
margin-top: 2rem;
|
|
385
|
-
margin-bottom: 1rem;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
.assistant-html-content h3 {
|
|
389
|
-
font-size: 1.25rem;
|
|
390
|
-
margin-top: 1.5rem;
|
|
391
|
-
margin-bottom: 1rem;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
.assistant-html-content h4 {
|
|
395
|
-
font-size: 1.125rem;
|
|
396
|
-
margin-top: 1rem;
|
|
397
|
-
margin-bottom: 0.5rem;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
.assistant-html-content p {
|
|
401
|
-
margin-top: 0;
|
|
402
|
-
margin-bottom: 1rem;
|
|
403
|
-
line-height: 1.625;
|
|
404
|
-
color: #374151;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
.assistant-html-content ul,
|
|
408
|
-
.assistant-html-content ol {
|
|
409
|
-
margin: 1rem 0;
|
|
410
|
-
padding-left: 1.25rem;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
.assistant-html-content ul {
|
|
414
|
-
list-style-type: disc;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
.assistant-html-content ol {
|
|
418
|
-
list-style-type: decimal;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
.assistant-html-content li {
|
|
422
|
-
margin-bottom: 0.375rem;
|
|
423
|
-
line-height: 1.625;
|
|
424
|
-
color: #374151;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
.assistant-html-content li > ul,
|
|
428
|
-
.assistant-html-content li > ol {
|
|
429
|
-
margin-top: 0.375rem;
|
|
430
|
-
margin-bottom: 0.375rem;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
.assistant-html-content a {
|
|
434
|
-
color: #2563eb;
|
|
435
|
-
text-decoration: none;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
.assistant-html-content a:hover {
|
|
439
|
-
color: #1d4ed8;
|
|
440
|
-
text-decoration: underline;
|
|
441
|
-
text-underline-offset: 2px;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
.assistant-html-content strong,
|
|
445
|
-
.assistant-html-content b {
|
|
446
|
-
font-weight: 600;
|
|
447
|
-
color: #111827;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
.assistant-html-content em,
|
|
451
|
-
.assistant-html-content i {
|
|
452
|
-
font-style: italic;
|
|
453
|
-
color: #4b5563;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
.assistant-html-content code {
|
|
457
|
-
background-color: #f3f4f6;
|
|
458
|
-
padding: 0.25rem 0.5rem;
|
|
459
|
-
border-radius: 0.375rem;
|
|
460
|
-
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
461
|
-
font-size: 0.875rem;
|
|
462
|
-
color: #dc2626;
|
|
463
|
-
border: 1px solid #e5e7eb;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
.assistant-html-content pre {
|
|
467
|
-
background-color: #f9fafb;
|
|
468
|
-
padding: 1rem;
|
|
469
|
-
border-radius: 0.5rem;
|
|
470
|
-
overflow-x: auto;
|
|
471
|
-
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
472
|
-
font-size: 0.875rem;
|
|
473
|
-
line-height: 1.5;
|
|
474
|
-
border: 1px solid #e5e7eb;
|
|
475
|
-
margin: 1.5rem 0;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
.assistant-html-content pre code {
|
|
479
|
-
background-color: transparent;
|
|
480
|
-
padding: 0;
|
|
481
|
-
border: none;
|
|
482
|
-
color: #374151;
|
|
483
|
-
font-size: inherit;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
.assistant-html-content blockquote {
|
|
487
|
-
margin: 1.5rem 0;
|
|
488
|
-
padding: 0 0 0 1rem;
|
|
489
|
-
border-left: 4px solid #d1d5db;
|
|
490
|
-
font-style: italic;
|
|
491
|
-
color: #6b7280;
|
|
492
|
-
background-color: transparent;
|
|
493
|
-
border-radius: 0;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
.assistant-html-content blockquote p {
|
|
497
|
-
margin-bottom: 0;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
.assistant-html-content table {
|
|
501
|
-
border-collapse: collapse;
|
|
502
|
-
border: 1px solid #e5e7eb;
|
|
503
|
-
width: 100%;
|
|
504
|
-
margin: 1rem 0;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
.assistant-html-content th,
|
|
508
|
-
.assistant-html-content td {
|
|
509
|
-
text-align: left;
|
|
510
|
-
vertical-align: top;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
.assistant-html-content th {
|
|
514
|
-
padding: 0.5rem 1rem;
|
|
515
|
-
background-color: #f9fafb;
|
|
516
|
-
border: 1px solid #e5e7eb;
|
|
517
|
-
font-weight: 500;
|
|
518
|
-
font-size: 0.75rem;
|
|
519
|
-
letter-spacing: 0.04em;
|
|
520
|
-
text-transform: uppercase;
|
|
521
|
-
color: #4b5563;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
.assistant-html-content td {
|
|
525
|
-
padding: 0.5rem 1rem;
|
|
526
|
-
border-top: 1px solid #e5e7eb;
|
|
527
|
-
color: #374151;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
.assistant-html-content hr {
|
|
531
|
-
border: none;
|
|
532
|
-
border-top: 1px solid #e5e7eb;
|
|
533
|
-
margin: 2rem 0;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
/* Markdown content styling */
|
|
537
|
-
.markdown-content {
|
|
538
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
539
|
-
line-height: 1.6;
|
|
540
|
-
color: #374151;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
.markdown-content h1 {
|
|
544
|
-
font-size: 1.5rem;
|
|
545
|
-
font-weight: 700;
|
|
546
|
-
margin-top: 1.5rem;
|
|
547
|
-
margin-bottom: 1rem;
|
|
548
|
-
color: #111827;
|
|
549
|
-
padding-bottom: 0.5rem;
|
|
550
|
-
border-bottom: 2px solid #e5e7eb;
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
.markdown-content h2 {
|
|
554
|
-
font-size: 1.25rem;
|
|
555
|
-
font-weight: 600;
|
|
556
|
-
margin-top: 1.25rem;
|
|
557
|
-
margin-bottom: 0.75rem;
|
|
558
|
-
color: #1f2937;
|
|
559
|
-
padding-bottom: 0.375rem;
|
|
560
|
-
border-bottom: 1px solid #e5e7eb;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
.markdown-content h3 {
|
|
564
|
-
font-size: 1.125rem;
|
|
565
|
-
font-weight: 600;
|
|
566
|
-
margin-top: 1rem;
|
|
567
|
-
margin-bottom: 0.5rem;
|
|
568
|
-
color: #374151;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
.markdown-content p {
|
|
572
|
-
margin-bottom: 0.75rem;
|
|
573
|
-
line-height: 1.6;
|
|
574
|
-
color: #4b5563;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
.markdown-content ul, .markdown-content ol {
|
|
578
|
-
margin: 1rem 0;
|
|
579
|
-
padding-left: 1.5rem;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
.markdown-content li {
|
|
583
|
-
margin-bottom: 0.5rem;
|
|
584
|
-
line-height: 1.6;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
.markdown-content code {
|
|
588
|
-
background-color: #f3f4f6;
|
|
589
|
-
padding: 0.125rem 0.375rem;
|
|
590
|
-
border-radius: 0.25rem;
|
|
591
|
-
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
592
|
-
font-size: 0.875rem;
|
|
593
|
-
color: #dc2626;
|
|
594
|
-
border: 1px solid #e5e7eb;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
.markdown-content pre {
|
|
598
|
-
color: #1f2937;
|
|
599
|
-
border-radius: 8px;
|
|
600
|
-
overflow-x: auto;
|
|
601
|
-
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
602
|
-
font-size: 0.875rem;
|
|
603
|
-
line-height: 1.5;
|
|
604
|
-
margin: 1rem 0;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
.markdown-content pre code {
|
|
608
|
-
background-color: transparent;
|
|
609
|
-
padding: 0;
|
|
610
|
-
border: none;
|
|
611
|
-
color: #1f2937;
|
|
612
|
-
font-size: inherit;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
.markdown-content blockquote {
|
|
616
|
-
border-left: 4px solid #3b82f6;
|
|
617
|
-
background-color: #f8fafc;
|
|
618
|
-
padding: 1rem;
|
|
619
|
-
margin: 1rem 0;
|
|
620
|
-
border-radius: 6px;
|
|
621
|
-
font-style: italic;
|
|
622
|
-
color: #475569;
|
|
623
|
-
border-top: 1px solid #e5e7eb;
|
|
624
|
-
border-right: 1px solid #e5e7eb;
|
|
625
|
-
border-bottom: 1px solid #e5e7eb;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
.markdown-content table {
|
|
629
|
-
border-collapse: collapse;
|
|
630
|
-
border: 1px solid #e5e7eb;
|
|
631
|
-
width: 100%;
|
|
632
|
-
margin: 1rem 0;
|
|
633
|
-
border-radius: 8px;
|
|
634
|
-
overflow: hidden;
|
|
635
|
-
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
.markdown-content th {
|
|
639
|
-
background-color: #f9fafb;
|
|
640
|
-
color: #374151;
|
|
641
|
-
font-weight: 600;
|
|
642
|
-
padding: 0.75rem;
|
|
643
|
-
text-align: left;
|
|
644
|
-
border-bottom: 1px solid #e5e7eb;
|
|
645
|
-
font-size: 0.875rem;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
.markdown-content td {
|
|
649
|
-
border: 1px solid #e5e7eb;
|
|
650
|
-
padding: 0.75rem;
|
|
651
|
-
text-align: left;
|
|
652
|
-
vertical-align: top;
|
|
653
|
-
background-color: white;
|
|
654
|
-
font-size: 0.875rem;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
.markdown-content tr:nth-child(even) td {
|
|
658
|
-
background-color: #f9fafb;
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
.markdown-content tr:hover td {
|
|
662
|
-
background-color: #f3f4f6;
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
/* Enhanced list styling */
|
|
666
|
-
.markdown-content ul li {
|
|
667
|
-
position: relative;
|
|
668
|
-
padding-left: 0.5rem;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
.markdown-content ul li::before {
|
|
672
|
-
content: "•";
|
|
673
|
-
color: #000;
|
|
674
|
-
font-weight: bold;
|
|
675
|
-
position: absolute;
|
|
676
|
-
left: -1rem;
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
.markdown-content ol li {
|
|
680
|
-
position: relative;
|
|
681
|
-
padding-left: 0.5rem;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
.markdown-content ol li::before {
|
|
685
|
-
content: counter(list-item) ".";
|
|
686
|
-
font-weight: 600;
|
|
687
|
-
position: absolute;
|
|
688
|
-
left: -1.5rem;
|
|
689
|
-
}
|
|
690
|
-
|
|
691
371
|
/* Code block container styling */
|
|
692
372
|
.code-block-container {
|
|
693
373
|
background: #ffffff;
|
|
@@ -709,38 +389,6 @@ const htmlContentStyles = `
|
|
|
709
389
|
letter-spacing: 0.05em;
|
|
710
390
|
}
|
|
711
391
|
|
|
712
|
-
.code-block-content {
|
|
713
|
-
padding: 1rem;
|
|
714
|
-
overflow-x: auto;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
/* Enhanced prose styling for markdown content */
|
|
718
|
-
.prose pre {
|
|
719
|
-
background-color: #f9fafb;
|
|
720
|
-
border: 1px solid #e5e7eb;
|
|
721
|
-
border-radius: 0.5rem;
|
|
722
|
-
padding: 1rem;
|
|
723
|
-
overflow-x: auto;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
.prose code {
|
|
727
|
-
background-color: #f3f4f6;
|
|
728
|
-
padding: 0.125rem 0.375rem;
|
|
729
|
-
border-radius: 0.25rem;
|
|
730
|
-
font-size: 0.875rem;
|
|
731
|
-
border: 1px solid #e5e7eb;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
.prose pre code {
|
|
735
|
-
background-color: transparent;
|
|
736
|
-
padding: 0;
|
|
737
|
-
border: none;
|
|
738
|
-
color:#000;
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
.hover\:bg-gray-100:hover {
|
|
742
|
-
background-color: transparent !important;
|
|
743
|
-
}
|
|
744
392
|
`;
|
|
745
393
|
// Hook to inject CSS styles
|
|
746
394
|
const useInjectStyles = () => {
|
|
@@ -861,6 +509,9 @@ const getMessageSlotName = type => {
|
|
|
861
509
|
if (t === 'MEDIA') return MessengerSlotFillNameEnum.MEDIA_NAME;
|
|
862
510
|
if (t === 'WORKFLOW') return MessengerSlotFillNameEnum.WORKFLOW_NAME;
|
|
863
511
|
if (t === 'CONNECTOR') return MessengerSlotFillNameEnum.CONNECTOR_NAME;
|
|
512
|
+
// Shared catch-all card (shopping, design, page/resume, …). Routes type:'generic' to the
|
|
513
|
+
// registered `generic` Fill (MessageGeneric); without this the generic Fill never mounts.
|
|
514
|
+
if (t === 'GENERIC') return MessengerSlotFillNameEnum.GENERIC_NAME;
|
|
864
515
|
return null;
|
|
865
516
|
};
|
|
866
517
|
// Enhanced sanitizer that allows most HTML tags while maintaining security
|
|
@@ -1182,7 +833,7 @@ const CodeFormatter = ({
|
|
|
1182
833
|
}
|
|
1183
834
|
// Regular text content
|
|
1184
835
|
return jsx("div", {
|
|
1185
|
-
className: `${variant === 'user' ? USER_MESSAGE_TEXT_SIZE_CLASS : 'text-sm'} ${variant === 'user' ?
|
|
836
|
+
className: `${variant === 'user' ? USER_MESSAGE_TEXT_SIZE_CLASS : 'text-sm'} ${variant === 'user' ? 'text-foreground' : 'text-gray-700'} leading-relaxed whitespace-pre-wrap break-words`,
|
|
1186
837
|
children: section.trim()
|
|
1187
838
|
}, index);
|
|
1188
839
|
})
|
|
@@ -1259,52 +910,52 @@ const FormattedMessageContent = ({
|
|
|
1259
910
|
};
|
|
1260
911
|
}
|
|
1261
912
|
}, [content]);
|
|
1262
|
-
const userMarkdownClasses = `${USER_MESSAGE_TEXT_SIZE_CLASS} prose ${USER_MESSAGE_PROSE_SIZE_CLASS} max-w-none leading-relaxed break-words
|
|
1263
|
-
prose-p:my-2 prose-p:text-
|
|
913
|
+
const userMarkdownClasses = `${USER_MESSAGE_TEXT_SIZE_CLASS} prose ${USER_MESSAGE_PROSE_SIZE_CLASS} max-w-none leading-relaxed break-words
|
|
914
|
+
prose-p:my-2 prose-p:text-foreground
|
|
1264
915
|
prose-pre:my-2 prose-pre:bg-transparent prose-pre:border-0 prose-pre:p-0
|
|
1265
|
-
prose-ul:my-2 prose-ol:my-2
|
|
1266
|
-
prose-code:break-words prose-code:bg-
|
|
1267
|
-
prose-headings:font-semibold prose-headings:text-
|
|
1268
|
-
prose-h1:text-2xl prose-h1:border-b prose-h1:border-
|
|
1269
|
-
prose-h2:text-xl prose-h2:border-b prose-h2:border-
|
|
916
|
+
prose-ul:my-2 prose-ol:my-2
|
|
917
|
+
prose-code:break-words prose-code:bg-muted prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-sm prose-code:font-mono
|
|
918
|
+
prose-headings:font-semibold prose-headings:text-foreground prose-headings:mt-4 prose-headings:mb-2
|
|
919
|
+
prose-h1:text-2xl prose-h1:border-b prose-h1:border-border prose-h1:pb-2
|
|
920
|
+
prose-h2:text-xl prose-h2:border-b prose-h2:border-border prose-h2:pb-1
|
|
1270
921
|
prose-h3:text-lg
|
|
1271
922
|
prose-h4:text-base
|
|
1272
|
-
prose-a:text-
|
|
1273
|
-
prose-strong:font-semibold prose-strong:text-
|
|
1274
|
-
prose-em:text-
|
|
1275
|
-
prose-blockquote:border-l-
|
|
1276
|
-
prose-table:w-full prose-table:border prose-table:border-
|
|
1277
|
-
prose-th:px-3 prose-th:py-2 prose-th:text-left prose-th:font-semibold prose-th:bg-
|
|
1278
|
-
prose-td:px-3 prose-td:py-2 prose-td:border prose-td:border-
|
|
1279
|
-
prose-li:my-1 prose-li:text-
|
|
1280
|
-
prose-hr:my-4 prose-hr:border-
|
|
1281
|
-
|
|
1282
|
-
const userHtmlClasses = `${USER_MESSAGE_TEXT_SIZE_CLASS} prose ${USER_MESSAGE_PROSE_SIZE_CLASS} max-w-none leading-relaxed break-words
|
|
1283
|
-
prose-p:my-2 prose-p:text-
|
|
1284
|
-
prose-pre:my-2 prose-pre:bg-
|
|
1285
|
-
prose-ul:my-2 prose-ol:my-2
|
|
923
|
+
prose-a:text-foreground prose-a:underline hover:prose-a:text-foreground
|
|
924
|
+
prose-strong:font-semibold prose-strong:text-foreground
|
|
925
|
+
prose-em:text-muted-foreground
|
|
926
|
+
prose-blockquote:border-l-2 prose-blockquote:border-border prose-blockquote:pl-4 prose-blockquote:py-2 prose-blockquote:bg-transparent prose-blockquote:my-3 prose-blockquote:italic prose-blockquote:text-muted-foreground
|
|
927
|
+
prose-table:w-full prose-table:border prose-table:border-border prose-table:rounded-md prose-table:my-4
|
|
928
|
+
prose-th:px-3 prose-th:py-2 prose-th:text-left prose-th:font-semibold prose-th:bg-muted prose-th:border prose-th:border-border
|
|
929
|
+
prose-td:px-3 prose-td:py-2 prose-td:border prose-td:border-border prose-td:text-foreground
|
|
930
|
+
prose-li:my-1 prose-li:text-foreground
|
|
931
|
+
prose-hr:my-4 prose-hr:border-border
|
|
932
|
+
!prose-p:text-foreground !prose-li:text-foreground !prose-strong:text-foreground !prose-em:text-muted-foreground !prose-a:text-foreground`;
|
|
933
|
+
const userHtmlClasses = `${USER_MESSAGE_TEXT_SIZE_CLASS} prose ${USER_MESSAGE_PROSE_SIZE_CLASS} max-w-none leading-relaxed break-words
|
|
934
|
+
prose-p:my-2 prose-p:text-foreground
|
|
935
|
+
prose-pre:my-2 prose-pre:bg-muted prose-pre:border prose-pre:border-border prose-pre:rounded prose-pre:p-3
|
|
936
|
+
prose-ul:my-2 prose-ol:my-2
|
|
1286
937
|
prose-pre:whitespace-pre-wrap prose-pre:break-words prose-pre:overflow-x-auto
|
|
1287
|
-
prose-code:break-words prose-code:bg-
|
|
1288
|
-
prose-headings:font-semibold prose-headings:text-
|
|
1289
|
-
prose-h1:text-2xl prose-h1:border-b prose-h1:border-
|
|
1290
|
-
prose-h2:text-xl prose-h2:border-b prose-h2:border-
|
|
938
|
+
prose-code:break-words prose-code:bg-muted prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-sm prose-code:font-mono
|
|
939
|
+
prose-headings:font-semibold prose-headings:text-foreground prose-headings:mt-4 prose-headings:mb-2
|
|
940
|
+
prose-h1:text-2xl prose-h1:border-b prose-h1:border-border prose-h1:pb-2
|
|
941
|
+
prose-h2:text-xl prose-h2:border-b prose-h2:border-border prose-h2:pb-1
|
|
1291
942
|
prose-h3:text-lg
|
|
1292
943
|
prose-h4:text-base
|
|
1293
|
-
prose-a:text-
|
|
1294
|
-
prose-strong:font-semibold prose-strong:text-
|
|
1295
|
-
prose-em:text-
|
|
1296
|
-
prose-blockquote:border-l-
|
|
1297
|
-
prose-table:w-full prose-table:border prose-table:border-
|
|
1298
|
-
prose-th:px-3 prose-th:py-2 prose-th:text-left prose-th:font-semibold prose-th:bg-
|
|
1299
|
-
prose-td:px-3 prose-td:py-2 prose-td:border prose-td:border-
|
|
1300
|
-
prose-li:my-1 prose-li:text-
|
|
1301
|
-
prose-hr:my-4 prose-hr:border-
|
|
1302
|
-
|
|
944
|
+
prose-a:text-foreground prose-a:underline hover:prose-a:text-foreground
|
|
945
|
+
prose-strong:font-semibold prose-strong:text-foreground
|
|
946
|
+
prose-em:text-muted-foreground
|
|
947
|
+
prose-blockquote:border-l-2 prose-blockquote:border-border prose-blockquote:pl-4 prose-blockquote:py-2 prose-blockquote:bg-transparent prose-blockquote:my-3 prose-blockquote:italic prose-blockquote:text-muted-foreground
|
|
948
|
+
prose-table:w-full prose-table:border prose-table:border-border prose-table:rounded-md prose-table:my-4
|
|
949
|
+
prose-th:px-3 prose-th:py-2 prose-th:text-left prose-th:font-semibold prose-th:bg-muted prose-th:border prose-th:border-border
|
|
950
|
+
prose-td:px-3 prose-td:py-2 prose-td:border prose-td:border-border prose-td:text-foreground
|
|
951
|
+
prose-li:my-1 prose-li:text-foreground
|
|
952
|
+
prose-hr:my-4 prose-hr:border-border
|
|
953
|
+
!prose-p:text-foreground !prose-li:text-foreground !prose-strong:text-foreground !prose-em:text-muted-foreground !prose-a:text-foreground`;
|
|
1303
954
|
const markdownComponents = useMemo(() => {
|
|
1304
955
|
const isUserVariant = variant === 'user';
|
|
1305
|
-
const userTextClass =
|
|
1306
|
-
const userMutedTextClass =
|
|
1307
|
-
const userLinkClass =
|
|
956
|
+
const userTextClass = 'text-foreground';
|
|
957
|
+
const userMutedTextClass = 'text-muted-foreground';
|
|
958
|
+
const userLinkClass = 'text-foreground underline underline-offset-2 hover:text-foreground/80';
|
|
1308
959
|
return {
|
|
1309
960
|
p: ({
|
|
1310
961
|
children
|
|
@@ -1349,24 +1000,24 @@ const FormattedMessageContent = ({
|
|
|
1349
1000
|
blockquote: ({
|
|
1350
1001
|
children
|
|
1351
1002
|
}) => isUserVariant ? jsx("blockquote", {
|
|
1352
|
-
className: `border-l-
|
|
1003
|
+
className: `border-l-2 border-border pl-4 py-2 bg-transparent my-3 italic ${userMutedTextClass}`,
|
|
1353
1004
|
children: children
|
|
1354
1005
|
}) : jsx("blockquote", {
|
|
1355
1006
|
children: children
|
|
1356
1007
|
}),
|
|
1357
1008
|
hr: () => isUserVariant ? jsx("hr", {
|
|
1358
|
-
className: "my-4 border-
|
|
1009
|
+
className: "my-4 border-border"
|
|
1359
1010
|
}) : jsx("hr", {}),
|
|
1360
1011
|
ul: ({
|
|
1361
1012
|
children
|
|
1362
1013
|
}) => jsx("ul", {
|
|
1363
|
-
className: isUserVariant ? `list-disc pl-5 mb-4 space-y-1.5 marker:text-
|
|
1014
|
+
className: isUserVariant ? `list-disc pl-5 mb-4 space-y-1.5 marker:text-muted-foreground [&_ul]:mt-1.5 [&_ol]:mt-1.5 ${userTextClass}` : 'list-disc pl-5',
|
|
1364
1015
|
children: children
|
|
1365
1016
|
}),
|
|
1366
1017
|
ol: ({
|
|
1367
1018
|
children
|
|
1368
1019
|
}) => jsx("ol", {
|
|
1369
|
-
className: isUserVariant ? `list-decimal pl-5 mb-4 space-y-1.5 marker:text-
|
|
1020
|
+
className: isUserVariant ? `list-decimal pl-5 mb-4 space-y-1.5 marker:text-muted-foreground [&_ul]:mt-1.5 [&_ol]:mt-1.5 ${userTextClass}` : 'list-decimal pl-5',
|
|
1370
1021
|
children: children
|
|
1371
1022
|
}),
|
|
1372
1023
|
li: ({
|
|
@@ -1390,7 +1041,7 @@ const FormattedMessageContent = ({
|
|
|
1390
1041
|
children,
|
|
1391
1042
|
...props
|
|
1392
1043
|
}) => isUserVariant ? jsx("div", {
|
|
1393
|
-
className: "overflow-x-auto my-4 w-full rounded-md border border-
|
|
1044
|
+
className: "overflow-x-auto my-4 w-full rounded-md border border-border",
|
|
1394
1045
|
children: jsx("table", {
|
|
1395
1046
|
className: "w-full text-sm",
|
|
1396
1047
|
...props,
|
|
@@ -1406,7 +1057,7 @@ const FormattedMessageContent = ({
|
|
|
1406
1057
|
thead: ({
|
|
1407
1058
|
children
|
|
1408
1059
|
}) => isUserVariant ? jsx("thead", {
|
|
1409
|
-
className: "bg-
|
|
1060
|
+
className: "bg-muted text-left",
|
|
1410
1061
|
children: children
|
|
1411
1062
|
}) : jsx("thead", {
|
|
1412
1063
|
children: children
|
|
@@ -1460,7 +1111,7 @@ const FormattedMessageContent = ({
|
|
|
1460
1111
|
});
|
|
1461
1112
|
}
|
|
1462
1113
|
return jsx("code", {
|
|
1463
|
-
className: isUserVariant ? `rounded px-1.5 py-0.5 text-sm font-mono bg-
|
|
1114
|
+
className: isUserVariant ? `rounded px-1.5 py-0.5 text-sm font-mono bg-muted break-words ${className || ''}` : `llm-inline-code break-words ${className || ''}`,
|
|
1464
1115
|
...rest,
|
|
1465
1116
|
children: children
|
|
1466
1117
|
});
|
|
@@ -1511,7 +1162,7 @@ const FormattedMessageContent = ({
|
|
|
1511
1162
|
}
|
|
1512
1163
|
// For plain text content
|
|
1513
1164
|
return variant === 'user' ? jsx("p", {
|
|
1514
|
-
className: `${USER_MESSAGE_TEXT_SIZE_CLASS} leading-relaxed whitespace-pre-wrap break-words
|
|
1165
|
+
className: `${USER_MESSAGE_TEXT_SIZE_CLASS} leading-relaxed whitespace-pre-wrap break-words text-foreground`,
|
|
1515
1166
|
children: content
|
|
1516
1167
|
}) : jsx(AssistantResponseWrapper, {
|
|
1517
1168
|
children: jsx("div", {
|
|
@@ -1656,9 +1307,12 @@ const ModernMessageBubble = ({
|
|
|
1656
1307
|
const handleClick = () => {
|
|
1657
1308
|
onMessageClick?.(message);
|
|
1658
1309
|
};
|
|
1310
|
+
const [expanded, setExpanded] = useState(false);
|
|
1659
1311
|
const isAssistantRole = message?.propsConfiguration?.contents?.role === AiAgentMessageRole.Assistant;
|
|
1660
1312
|
const messageMode = message?.propsConfiguration?.contents?.mode ?? message?.propsConfiguration?.content?.mode ?? message?.props?.mode;
|
|
1661
1313
|
const isPlanMode = messageMode === 'plan';
|
|
1314
|
+
const isLongUserMessage = !isAssistantRole && (message?.message?.length ?? 0) > USER_MESSAGE_COLLAPSE_CHAR_THRESHOLD;
|
|
1315
|
+
const isCollapsed = isLongUserMessage && !expanded;
|
|
1662
1316
|
// For user messages, create a right-aligned layout with avatar and name
|
|
1663
1317
|
if (isOwnMessage) {
|
|
1664
1318
|
const authorName = message.author?.givenName && message.author?.familyName ? `${message.author.givenName} ${message.author.familyName}` : message.author?.username || 'You';
|
|
@@ -1667,23 +1321,26 @@ const ModernMessageBubble = ({
|
|
|
1667
1321
|
children: jsxs("div", {
|
|
1668
1322
|
className: "flex items-start justify-end gap-2",
|
|
1669
1323
|
children: [jsxs("div", {
|
|
1670
|
-
className: "flex flex-col items-end max-w-[85%]",
|
|
1324
|
+
className: "flex flex-col items-end max-w-[85%] min-w-0",
|
|
1671
1325
|
children: [showAuthorName && jsx("div", {
|
|
1672
1326
|
className: "flex items-end space-x-2 mb-0.5",
|
|
1673
1327
|
children: jsx("span", {
|
|
1674
|
-
className: "text-sm font-semibold text-
|
|
1328
|
+
className: "text-sm font-semibold text-foreground",
|
|
1675
1329
|
children: authorName
|
|
1676
1330
|
})
|
|
1677
1331
|
}), jsxs("div", {
|
|
1678
|
-
className: `${isAssistantRole ? 'text-sm' : USER_MESSAGE_TEXT_SIZE_CLASS} ${isAssistantRole ? 'cursor-pointer rounded-2xl border border-
|
|
1679
|
-
// : 'user-message rounded-[22px] rounded-br-[4px] px-4 py-3 bg-primary text-primary-foreground shadow-sm'
|
|
1680
|
-
isPlanMode ? 'user-message rounded-[22px] rounded-br-[4px] px-4 py-3 bg-primary text-primary-foreground shadow-sm' : 'user-message rounded-[22px] rounded-br-[4px] px-4 py-3 '}`,
|
|
1332
|
+
className: `${isAssistantRole ? 'text-sm' : USER_MESSAGE_TEXT_SIZE_CLASS} ${isAssistantRole ? 'cursor-pointer rounded-2xl border border-border bg-muted text-foreground px-4 py-2.5' : 'user-message rounded-[22px] rounded-br-[4px] px-4 py-3 bg-muted text-foreground shadow-sm'}`,
|
|
1681
1333
|
onClick: isAssistantRole ? handleClick : undefined,
|
|
1682
1334
|
dir: detectTextDirection(message?.message || ''),
|
|
1683
1335
|
lang: detectLanguageTag(message?.message || ''),
|
|
1684
|
-
children: [message.message &&
|
|
1685
|
-
className:
|
|
1686
|
-
|
|
1336
|
+
children: [message.message && jsxs("div", {
|
|
1337
|
+
className: `max-w-none ${isCollapsed ? 'relative overflow-hidden' : ''}`,
|
|
1338
|
+
style: isCollapsed ? {
|
|
1339
|
+
maxHeight: USER_MESSAGE_COLLAPSED_MAX_HEIGHT
|
|
1340
|
+
} : undefined,
|
|
1341
|
+
children: [isCollapsed && jsx("div", {
|
|
1342
|
+
className: "pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-muted to-transparent"
|
|
1343
|
+
}), (() => {
|
|
1687
1344
|
const contentType = detectContentType(message.message);
|
|
1688
1345
|
if (contentType === 'code') {
|
|
1689
1346
|
return jsx(CodeFormatter, {
|
|
@@ -1704,7 +1361,7 @@ const ModernMessageBubble = ({
|
|
|
1704
1361
|
});
|
|
1705
1362
|
}
|
|
1706
1363
|
return jsx("div", {
|
|
1707
|
-
className:
|
|
1364
|
+
className: "text-foreground html-content",
|
|
1708
1365
|
dangerouslySetInnerHTML: {
|
|
1709
1366
|
__html: prettifyHtmlContent(sanitizeHtml(message.message))
|
|
1710
1367
|
}
|
|
@@ -1717,7 +1374,27 @@ const ModernMessageBubble = ({
|
|
|
1717
1374
|
showCopyDownloadOnCodeBlock: showCopyDownloadOnCodeBlock
|
|
1718
1375
|
});
|
|
1719
1376
|
}
|
|
1720
|
-
})()
|
|
1377
|
+
})()]
|
|
1378
|
+
}), isLongUserMessage && jsxs("button", {
|
|
1379
|
+
type: "button",
|
|
1380
|
+
onClick: e => {
|
|
1381
|
+
e.stopPropagation();
|
|
1382
|
+
setExpanded(v => !v);
|
|
1383
|
+
},
|
|
1384
|
+
className: "mt-1 flex items-center gap-1 text-sm font-medium text-muted-foreground hover:text-foreground",
|
|
1385
|
+
children: [expanded ? 'Show less' : 'Show more', jsx("svg", {
|
|
1386
|
+
viewBox: "0 0 24 24",
|
|
1387
|
+
fill: "none",
|
|
1388
|
+
stroke: "currentColor",
|
|
1389
|
+
strokeWidth: 2,
|
|
1390
|
+
strokeLinecap: "round",
|
|
1391
|
+
strokeLinejoin: "round",
|
|
1392
|
+
className: `h-3.5 w-3.5 transition-transform ${expanded ? 'rotate-180' : ''}`,
|
|
1393
|
+
"aria-hidden": true,
|
|
1394
|
+
children: jsx("path", {
|
|
1395
|
+
d: "M6 9l6 6 6-6"
|
|
1396
|
+
})
|
|
1397
|
+
})]
|
|
1721
1398
|
}), tryExtractBuilderBlocks(message?.message)?.length ? jsx("div", {
|
|
1722
1399
|
className: "mt-2",
|
|
1723
1400
|
children: jsx(BuilderLikeRenderer, {
|
|
@@ -1735,7 +1412,7 @@ const ModernMessageBubble = ({
|
|
|
1735
1412
|
files: message.files.data
|
|
1736
1413
|
})
|
|
1737
1414
|
}), showTimestamp ? jsx("div", {
|
|
1738
|
-
className:
|
|
1415
|
+
className: "text-[10px] mt-1 text-right text-muted-foreground",
|
|
1739
1416
|
children: formatTime(message.createdAt)
|
|
1740
1417
|
}) : null]
|
|
1741
1418
|
})]
|