@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
|
@@ -2,7 +2,7 @@ import { Slot } from '@common-stack/components-pro';
|
|
|
2
2
|
import { AiAgentMessageRole, IAuthUser, IPost } from 'common';
|
|
3
3
|
import { differenceInMinutes, format } from 'date-fns';
|
|
4
4
|
import { marked } from 'marked';
|
|
5
|
-
import React, { useEffect, useMemo } from 'react';
|
|
5
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
6
6
|
import ReactMarkdown from 'react-markdown';
|
|
7
7
|
import remarkBreaks from 'remark-breaks';
|
|
8
8
|
import remarkGfm from 'remark-gfm';
|
|
@@ -24,6 +24,9 @@ const ASSISTANT_RESPONSE_BUBBLE_CLASS = 'llm-response__bubble';
|
|
|
24
24
|
const ASSISTANT_RESPONSE_MARKDOWN_CLASS = 'llm-response__markdown';
|
|
25
25
|
const USER_MESSAGE_TEXT_SIZE_CLASS = 'text-base';
|
|
26
26
|
const USER_MESSAGE_PROSE_SIZE_CLASS = 'prose-base';
|
|
27
|
+
/** Pasted queries longer than this collapse behind a "Show more" toggle. */
|
|
28
|
+
const USER_MESSAGE_COLLAPSE_CHAR_THRESHOLD = 600;
|
|
29
|
+
const USER_MESSAGE_COLLAPSED_MAX_HEIGHT = 220;
|
|
27
30
|
|
|
28
31
|
function getAssistantResponseClasses(innerClassName?: string): string {
|
|
29
32
|
return [ASSISTANT_RESPONSE_MARKDOWN_CLASS, innerClassName].filter(Boolean).join(' ');
|
|
@@ -52,15 +55,15 @@ const htmlContentStyles = `
|
|
|
52
55
|
.html-content {
|
|
53
56
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
54
57
|
line-height: 1.6;
|
|
55
|
-
color:
|
|
58
|
+
color: inherit;
|
|
56
59
|
}
|
|
57
|
-
|
|
60
|
+
|
|
58
61
|
.html-content h1, .html-content h2, .html-content h3, .html-content h4, .html-content h5, .html-content h6 {
|
|
59
62
|
margin-top: 1.5rem;
|
|
60
63
|
margin-bottom: 1rem;
|
|
61
64
|
font-weight: 600;
|
|
62
65
|
line-height: 1.25;
|
|
63
|
-
color:
|
|
66
|
+
color: inherit;
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
.html-content h1 {
|
|
@@ -362,6 +365,15 @@ const htmlContentStyles = `
|
|
|
362
365
|
box-shadow: none !important;
|
|
363
366
|
}
|
|
364
367
|
|
|
368
|
+
/* Safety net: long unbroken tokens (file paths, CSS selectors, URLs) inside a
|
|
369
|
+
pasted user query must never push the bubble past its own width — wrap
|
|
370
|
+
anywhere rather than overflow the card. */
|
|
371
|
+
.user-message,
|
|
372
|
+
.user-message * {
|
|
373
|
+
max-width: 100%;
|
|
374
|
+
overflow-wrap: anywhere;
|
|
375
|
+
}
|
|
376
|
+
|
|
365
377
|
.assistant-message-container {
|
|
366
378
|
background: transparent;
|
|
367
379
|
padding-top: 0;
|
|
@@ -371,338 +383,6 @@ const htmlContentStyles = `
|
|
|
371
383
|
box-shadow: none;
|
|
372
384
|
}
|
|
373
385
|
|
|
374
|
-
.assistant-html-content {
|
|
375
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
376
|
-
line-height: 1.6;
|
|
377
|
-
color: #374151;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
.assistant-html-content h1,
|
|
381
|
-
.assistant-html-content h2,
|
|
382
|
-
.assistant-html-content h3,
|
|
383
|
-
.assistant-html-content h4,
|
|
384
|
-
.assistant-html-content h5,
|
|
385
|
-
.assistant-html-content h6 {
|
|
386
|
-
font-weight: 600;
|
|
387
|
-
line-height: 1.25;
|
|
388
|
-
color: #111827;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
.assistant-html-content h1 {
|
|
392
|
-
font-size: 1.875rem;
|
|
393
|
-
margin-top: 2rem;
|
|
394
|
-
margin-bottom: 1rem;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
.assistant-html-content h2 {
|
|
398
|
-
font-size: 1.5rem;
|
|
399
|
-
margin-top: 2rem;
|
|
400
|
-
margin-bottom: 1rem;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
.assistant-html-content h3 {
|
|
404
|
-
font-size: 1.25rem;
|
|
405
|
-
margin-top: 1.5rem;
|
|
406
|
-
margin-bottom: 1rem;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
.assistant-html-content h4 {
|
|
410
|
-
font-size: 1.125rem;
|
|
411
|
-
margin-top: 1rem;
|
|
412
|
-
margin-bottom: 0.5rem;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
.assistant-html-content p {
|
|
416
|
-
margin-top: 0;
|
|
417
|
-
margin-bottom: 1rem;
|
|
418
|
-
line-height: 1.625;
|
|
419
|
-
color: #374151;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
.assistant-html-content ul,
|
|
423
|
-
.assistant-html-content ol {
|
|
424
|
-
margin: 1rem 0;
|
|
425
|
-
padding-left: 1.25rem;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
.assistant-html-content ul {
|
|
429
|
-
list-style-type: disc;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
.assistant-html-content ol {
|
|
433
|
-
list-style-type: decimal;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
.assistant-html-content li {
|
|
437
|
-
margin-bottom: 0.375rem;
|
|
438
|
-
line-height: 1.625;
|
|
439
|
-
color: #374151;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
.assistant-html-content li > ul,
|
|
443
|
-
.assistant-html-content li > ol {
|
|
444
|
-
margin-top: 0.375rem;
|
|
445
|
-
margin-bottom: 0.375rem;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
.assistant-html-content a {
|
|
449
|
-
color: #2563eb;
|
|
450
|
-
text-decoration: none;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
.assistant-html-content a:hover {
|
|
454
|
-
color: #1d4ed8;
|
|
455
|
-
text-decoration: underline;
|
|
456
|
-
text-underline-offset: 2px;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
.assistant-html-content strong,
|
|
460
|
-
.assistant-html-content b {
|
|
461
|
-
font-weight: 600;
|
|
462
|
-
color: #111827;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
.assistant-html-content em,
|
|
466
|
-
.assistant-html-content i {
|
|
467
|
-
font-style: italic;
|
|
468
|
-
color: #4b5563;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
.assistant-html-content code {
|
|
472
|
-
background-color: #f3f4f6;
|
|
473
|
-
padding: 0.25rem 0.5rem;
|
|
474
|
-
border-radius: 0.375rem;
|
|
475
|
-
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
476
|
-
font-size: 0.875rem;
|
|
477
|
-
color: #dc2626;
|
|
478
|
-
border: 1px solid #e5e7eb;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
.assistant-html-content pre {
|
|
482
|
-
background-color: #f9fafb;
|
|
483
|
-
padding: 1rem;
|
|
484
|
-
border-radius: 0.5rem;
|
|
485
|
-
overflow-x: auto;
|
|
486
|
-
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
487
|
-
font-size: 0.875rem;
|
|
488
|
-
line-height: 1.5;
|
|
489
|
-
border: 1px solid #e5e7eb;
|
|
490
|
-
margin: 1.5rem 0;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
.assistant-html-content pre code {
|
|
494
|
-
background-color: transparent;
|
|
495
|
-
padding: 0;
|
|
496
|
-
border: none;
|
|
497
|
-
color: #374151;
|
|
498
|
-
font-size: inherit;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
.assistant-html-content blockquote {
|
|
502
|
-
margin: 1.5rem 0;
|
|
503
|
-
padding: 0 0 0 1rem;
|
|
504
|
-
border-left: 4px solid #d1d5db;
|
|
505
|
-
font-style: italic;
|
|
506
|
-
color: #6b7280;
|
|
507
|
-
background-color: transparent;
|
|
508
|
-
border-radius: 0;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
.assistant-html-content blockquote p {
|
|
512
|
-
margin-bottom: 0;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
.assistant-html-content table {
|
|
516
|
-
border-collapse: collapse;
|
|
517
|
-
border: 1px solid #e5e7eb;
|
|
518
|
-
width: 100%;
|
|
519
|
-
margin: 1rem 0;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
.assistant-html-content th,
|
|
523
|
-
.assistant-html-content td {
|
|
524
|
-
text-align: left;
|
|
525
|
-
vertical-align: top;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
.assistant-html-content th {
|
|
529
|
-
padding: 0.5rem 1rem;
|
|
530
|
-
background-color: #f9fafb;
|
|
531
|
-
border: 1px solid #e5e7eb;
|
|
532
|
-
font-weight: 500;
|
|
533
|
-
font-size: 0.75rem;
|
|
534
|
-
letter-spacing: 0.04em;
|
|
535
|
-
text-transform: uppercase;
|
|
536
|
-
color: #4b5563;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
.assistant-html-content td {
|
|
540
|
-
padding: 0.5rem 1rem;
|
|
541
|
-
border-top: 1px solid #e5e7eb;
|
|
542
|
-
color: #374151;
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
.assistant-html-content hr {
|
|
546
|
-
border: none;
|
|
547
|
-
border-top: 1px solid #e5e7eb;
|
|
548
|
-
margin: 2rem 0;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
/* Markdown content styling */
|
|
552
|
-
.markdown-content {
|
|
553
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
554
|
-
line-height: 1.6;
|
|
555
|
-
color: #374151;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
.markdown-content h1 {
|
|
559
|
-
font-size: 1.5rem;
|
|
560
|
-
font-weight: 700;
|
|
561
|
-
margin-top: 1.5rem;
|
|
562
|
-
margin-bottom: 1rem;
|
|
563
|
-
color: #111827;
|
|
564
|
-
padding-bottom: 0.5rem;
|
|
565
|
-
border-bottom: 2px solid #e5e7eb;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
.markdown-content h2 {
|
|
569
|
-
font-size: 1.25rem;
|
|
570
|
-
font-weight: 600;
|
|
571
|
-
margin-top: 1.25rem;
|
|
572
|
-
margin-bottom: 0.75rem;
|
|
573
|
-
color: #1f2937;
|
|
574
|
-
padding-bottom: 0.375rem;
|
|
575
|
-
border-bottom: 1px solid #e5e7eb;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
.markdown-content h3 {
|
|
579
|
-
font-size: 1.125rem;
|
|
580
|
-
font-weight: 600;
|
|
581
|
-
margin-top: 1rem;
|
|
582
|
-
margin-bottom: 0.5rem;
|
|
583
|
-
color: #374151;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
.markdown-content p {
|
|
587
|
-
margin-bottom: 0.75rem;
|
|
588
|
-
line-height: 1.6;
|
|
589
|
-
color: #4b5563;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
.markdown-content ul, .markdown-content ol {
|
|
593
|
-
margin: 1rem 0;
|
|
594
|
-
padding-left: 1.5rem;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
.markdown-content li {
|
|
598
|
-
margin-bottom: 0.5rem;
|
|
599
|
-
line-height: 1.6;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
.markdown-content code {
|
|
603
|
-
background-color: #f3f4f6;
|
|
604
|
-
padding: 0.125rem 0.375rem;
|
|
605
|
-
border-radius: 0.25rem;
|
|
606
|
-
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
607
|
-
font-size: 0.875rem;
|
|
608
|
-
color: #dc2626;
|
|
609
|
-
border: 1px solid #e5e7eb;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
.markdown-content pre {
|
|
613
|
-
color: #1f2937;
|
|
614
|
-
border-radius: 8px;
|
|
615
|
-
overflow-x: auto;
|
|
616
|
-
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
617
|
-
font-size: 0.875rem;
|
|
618
|
-
line-height: 1.5;
|
|
619
|
-
margin: 1rem 0;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
.markdown-content pre code {
|
|
623
|
-
background-color: transparent;
|
|
624
|
-
padding: 0;
|
|
625
|
-
border: none;
|
|
626
|
-
color: #1f2937;
|
|
627
|
-
font-size: inherit;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
.markdown-content blockquote {
|
|
631
|
-
border-left: 4px solid #3b82f6;
|
|
632
|
-
background-color: #f8fafc;
|
|
633
|
-
padding: 1rem;
|
|
634
|
-
margin: 1rem 0;
|
|
635
|
-
border-radius: 6px;
|
|
636
|
-
font-style: italic;
|
|
637
|
-
color: #475569;
|
|
638
|
-
border-top: 1px solid #e5e7eb;
|
|
639
|
-
border-right: 1px solid #e5e7eb;
|
|
640
|
-
border-bottom: 1px solid #e5e7eb;
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
.markdown-content table {
|
|
644
|
-
border-collapse: collapse;
|
|
645
|
-
border: 1px solid #e5e7eb;
|
|
646
|
-
width: 100%;
|
|
647
|
-
margin: 1rem 0;
|
|
648
|
-
border-radius: 8px;
|
|
649
|
-
overflow: hidden;
|
|
650
|
-
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
.markdown-content th {
|
|
654
|
-
background-color: #f9fafb;
|
|
655
|
-
color: #374151;
|
|
656
|
-
font-weight: 600;
|
|
657
|
-
padding: 0.75rem;
|
|
658
|
-
text-align: left;
|
|
659
|
-
border-bottom: 1px solid #e5e7eb;
|
|
660
|
-
font-size: 0.875rem;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
.markdown-content td {
|
|
664
|
-
border: 1px solid #e5e7eb;
|
|
665
|
-
padding: 0.75rem;
|
|
666
|
-
text-align: left;
|
|
667
|
-
vertical-align: top;
|
|
668
|
-
background-color: white;
|
|
669
|
-
font-size: 0.875rem;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
.markdown-content tr:nth-child(even) td {
|
|
673
|
-
background-color: #f9fafb;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
.markdown-content tr:hover td {
|
|
677
|
-
background-color: #f3f4f6;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
/* Enhanced list styling */
|
|
681
|
-
.markdown-content ul li {
|
|
682
|
-
position: relative;
|
|
683
|
-
padding-left: 0.5rem;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
.markdown-content ul li::before {
|
|
687
|
-
content: "•";
|
|
688
|
-
color: #000;
|
|
689
|
-
font-weight: bold;
|
|
690
|
-
position: absolute;
|
|
691
|
-
left: -1rem;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
.markdown-content ol li {
|
|
695
|
-
position: relative;
|
|
696
|
-
padding-left: 0.5rem;
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
.markdown-content ol li::before {
|
|
700
|
-
content: counter(list-item) ".";
|
|
701
|
-
font-weight: 600;
|
|
702
|
-
position: absolute;
|
|
703
|
-
left: -1.5rem;
|
|
704
|
-
}
|
|
705
|
-
|
|
706
386
|
/* Code block container styling */
|
|
707
387
|
.code-block-container {
|
|
708
388
|
background: #ffffff;
|
|
@@ -724,38 +404,6 @@ const htmlContentStyles = `
|
|
|
724
404
|
letter-spacing: 0.05em;
|
|
725
405
|
}
|
|
726
406
|
|
|
727
|
-
.code-block-content {
|
|
728
|
-
padding: 1rem;
|
|
729
|
-
overflow-x: auto;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
/* Enhanced prose styling for markdown content */
|
|
733
|
-
.prose pre {
|
|
734
|
-
background-color: #f9fafb;
|
|
735
|
-
border: 1px solid #e5e7eb;
|
|
736
|
-
border-radius: 0.5rem;
|
|
737
|
-
padding: 1rem;
|
|
738
|
-
overflow-x: auto;
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
.prose code {
|
|
742
|
-
background-color: #f3f4f6;
|
|
743
|
-
padding: 0.125rem 0.375rem;
|
|
744
|
-
border-radius: 0.25rem;
|
|
745
|
-
font-size: 0.875rem;
|
|
746
|
-
border: 1px solid #e5e7eb;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
.prose pre code {
|
|
750
|
-
background-color: transparent;
|
|
751
|
-
padding: 0;
|
|
752
|
-
border: none;
|
|
753
|
-
color:#000;
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
.hover\:bg-gray-100:hover {
|
|
757
|
-
background-color: transparent !important;
|
|
758
|
-
}
|
|
759
407
|
`;
|
|
760
408
|
|
|
761
409
|
// Hook to inject CSS styles
|
|
@@ -929,6 +577,9 @@ const getMessageSlotName = (type: string | undefined): string | null => {
|
|
|
929
577
|
if (t === 'MEDIA') return MessengerSlotFillNameEnum.MEDIA_NAME;
|
|
930
578
|
if (t === 'WORKFLOW') return MessengerSlotFillNameEnum.WORKFLOW_NAME;
|
|
931
579
|
if (t === 'CONNECTOR') return MessengerSlotFillNameEnum.CONNECTOR_NAME;
|
|
580
|
+
// Shared catch-all card (shopping, design, page/resume, …). Routes type:'generic' to the
|
|
581
|
+
// registered `generic` Fill (MessageGeneric); without this the generic Fill never mounts.
|
|
582
|
+
if (t === 'GENERIC') return MessengerSlotFillNameEnum.GENERIC_NAME;
|
|
932
583
|
return null;
|
|
933
584
|
};
|
|
934
585
|
|
|
@@ -1315,11 +966,7 @@ export const CodeFormatter: React.FC<{
|
|
|
1315
966
|
<div
|
|
1316
967
|
key={index}
|
|
1317
968
|
className={`${variant === 'user' ? USER_MESSAGE_TEXT_SIZE_CLASS : 'text-sm'} ${
|
|
1318
|
-
variant === 'user'
|
|
1319
|
-
? planMode
|
|
1320
|
-
? 'text-primary-foreground'
|
|
1321
|
-
: 'text-gray-900'
|
|
1322
|
-
: 'text-gray-700'
|
|
969
|
+
variant === 'user' ? 'text-foreground' : 'text-gray-700'
|
|
1323
970
|
} leading-relaxed whitespace-pre-wrap break-words`}
|
|
1324
971
|
>
|
|
1325
972
|
{section.trim()}
|
|
@@ -1390,64 +1037,54 @@ export const FormattedMessageContent: React.FC<{
|
|
|
1390
1037
|
}
|
|
1391
1038
|
}, [content]);
|
|
1392
1039
|
|
|
1393
|
-
const userMarkdownClasses = `${USER_MESSAGE_TEXT_SIZE_CLASS} prose ${USER_MESSAGE_PROSE_SIZE_CLASS} max-w-none leading-relaxed break-words
|
|
1394
|
-
prose-p:my-2 prose-p:text-
|
|
1040
|
+
const userMarkdownClasses = `${USER_MESSAGE_TEXT_SIZE_CLASS} prose ${USER_MESSAGE_PROSE_SIZE_CLASS} max-w-none leading-relaxed break-words
|
|
1041
|
+
prose-p:my-2 prose-p:text-foreground
|
|
1395
1042
|
prose-pre:my-2 prose-pre:bg-transparent prose-pre:border-0 prose-pre:p-0
|
|
1396
|
-
prose-ul:my-2 prose-ol:my-2
|
|
1397
|
-
prose-code:break-words prose-code:bg-
|
|
1398
|
-
prose-headings:font-semibold prose-headings:text-
|
|
1399
|
-
prose-h1:text-2xl prose-h1:border-b prose-h1:border-
|
|
1400
|
-
prose-h2:text-xl prose-h2:border-b prose-h2:border-
|
|
1043
|
+
prose-ul:my-2 prose-ol:my-2
|
|
1044
|
+
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
|
|
1045
|
+
prose-headings:font-semibold prose-headings:text-foreground prose-headings:mt-4 prose-headings:mb-2
|
|
1046
|
+
prose-h1:text-2xl prose-h1:border-b prose-h1:border-border prose-h1:pb-2
|
|
1047
|
+
prose-h2:text-xl prose-h2:border-b prose-h2:border-border prose-h2:pb-1
|
|
1401
1048
|
prose-h3:text-lg
|
|
1402
1049
|
prose-h4:text-base
|
|
1403
|
-
prose-a:text-
|
|
1404
|
-
prose-strong:font-semibold prose-strong:text-
|
|
1405
|
-
prose-em:text-
|
|
1406
|
-
prose-blockquote:border-l-
|
|
1407
|
-
prose-table:w-full prose-table:border prose-table:border-
|
|
1408
|
-
prose-th:px-3 prose-th:py-2 prose-th:text-left prose-th:font-semibold prose-th:bg-
|
|
1409
|
-
prose-td:px-3 prose-td:py-2 prose-td:border prose-td:border-
|
|
1410
|
-
prose-li:my-1 prose-li:text-
|
|
1411
|
-
prose-hr:my-4 prose-hr:border-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
const userHtmlClasses = `${USER_MESSAGE_TEXT_SIZE_CLASS} prose ${USER_MESSAGE_PROSE_SIZE_CLASS} max-w-none leading-relaxed break-words
|
|
1419
|
-
prose-p:my-2 prose-p:text-gray-700
|
|
1420
|
-
prose-pre:my-2 prose-pre:bg-gray-50 prose-pre:border prose-pre:border-gray-200 prose-pre:rounded prose-pre:p-3
|
|
1421
|
-
prose-ul:my-2 prose-ol:my-2
|
|
1050
|
+
prose-a:text-foreground prose-a:underline hover:prose-a:text-foreground
|
|
1051
|
+
prose-strong:font-semibold prose-strong:text-foreground
|
|
1052
|
+
prose-em:text-muted-foreground
|
|
1053
|
+
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
|
|
1054
|
+
prose-table:w-full prose-table:border prose-table:border-border prose-table:rounded-md prose-table:my-4
|
|
1055
|
+
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
|
|
1056
|
+
prose-td:px-3 prose-td:py-2 prose-td:border prose-td:border-border prose-td:text-foreground
|
|
1057
|
+
prose-li:my-1 prose-li:text-foreground
|
|
1058
|
+
prose-hr:my-4 prose-hr:border-border
|
|
1059
|
+
!prose-p:text-foreground !prose-li:text-foreground !prose-strong:text-foreground !prose-em:text-muted-foreground !prose-a:text-foreground`;
|
|
1060
|
+
|
|
1061
|
+
const userHtmlClasses = `${USER_MESSAGE_TEXT_SIZE_CLASS} prose ${USER_MESSAGE_PROSE_SIZE_CLASS} max-w-none leading-relaxed break-words
|
|
1062
|
+
prose-p:my-2 prose-p:text-foreground
|
|
1063
|
+
prose-pre:my-2 prose-pre:bg-muted prose-pre:border prose-pre:border-border prose-pre:rounded prose-pre:p-3
|
|
1064
|
+
prose-ul:my-2 prose-ol:my-2
|
|
1422
1065
|
prose-pre:whitespace-pre-wrap prose-pre:break-words prose-pre:overflow-x-auto
|
|
1423
|
-
prose-code:break-words prose-code:bg-
|
|
1424
|
-
prose-headings:font-semibold prose-headings:text-
|
|
1425
|
-
prose-h1:text-2xl prose-h1:border-b prose-h1:border-
|
|
1426
|
-
prose-h2:text-xl prose-h2:border-b prose-h2:border-
|
|
1066
|
+
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
|
|
1067
|
+
prose-headings:font-semibold prose-headings:text-foreground prose-headings:mt-4 prose-headings:mb-2
|
|
1068
|
+
prose-h1:text-2xl prose-h1:border-b prose-h1:border-border prose-h1:pb-2
|
|
1069
|
+
prose-h2:text-xl prose-h2:border-b prose-h2:border-border prose-h2:pb-1
|
|
1427
1070
|
prose-h3:text-lg
|
|
1428
1071
|
prose-h4:text-base
|
|
1429
|
-
prose-a:text-
|
|
1430
|
-
prose-strong:font-semibold prose-strong:text-
|
|
1431
|
-
prose-em:text-
|
|
1432
|
-
prose-blockquote:border-l-
|
|
1433
|
-
prose-table:w-full prose-table:border prose-table:border-
|
|
1434
|
-
prose-th:px-3 prose-th:py-2 prose-th:text-left prose-th:font-semibold prose-th:bg-
|
|
1435
|
-
prose-td:px-3 prose-td:py-2 prose-td:border prose-td:border-
|
|
1436
|
-
prose-li:my-1 prose-li:text-
|
|
1437
|
-
prose-hr:my-4 prose-hr:border-
|
|
1438
|
-
|
|
1439
|
-
planMode
|
|
1440
|
-
? '!prose-p:text-primary-foreground !prose-li:text-primary-foreground !prose-strong:text-primary-foreground !prose-em:text-primary-foreground !prose-a:text-primary-foreground'
|
|
1441
|
-
: '!prose-p:text-gray-900 !prose-li:text-gray-900 !prose-strong:text-gray-900 !prose-em:text-gray-700 !prose-a:text-blue-600'
|
|
1442
|
-
}`;
|
|
1072
|
+
prose-a:text-foreground prose-a:underline hover:prose-a:text-foreground
|
|
1073
|
+
prose-strong:font-semibold prose-strong:text-foreground
|
|
1074
|
+
prose-em:text-muted-foreground
|
|
1075
|
+
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
|
|
1076
|
+
prose-table:w-full prose-table:border prose-table:border-border prose-table:rounded-md prose-table:my-4
|
|
1077
|
+
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
|
|
1078
|
+
prose-td:px-3 prose-td:py-2 prose-td:border prose-td:border-border prose-td:text-foreground
|
|
1079
|
+
prose-li:my-1 prose-li:text-foreground
|
|
1080
|
+
prose-hr:my-4 prose-hr:border-border
|
|
1081
|
+
!prose-p:text-foreground !prose-li:text-foreground !prose-strong:text-foreground !prose-em:text-muted-foreground !prose-a:text-foreground`;
|
|
1443
1082
|
|
|
1444
1083
|
const markdownComponents = useMemo(() => {
|
|
1445
1084
|
const isUserVariant = variant === 'user';
|
|
1446
|
-
const userTextClass =
|
|
1447
|
-
const userMutedTextClass =
|
|
1448
|
-
const userLinkClass =
|
|
1449
|
-
? 'text-primary-foreground underline underline-offset-2'
|
|
1450
|
-
: 'text-blue-600 hover:underline underline-offset-2';
|
|
1085
|
+
const userTextClass = 'text-foreground';
|
|
1086
|
+
const userMutedTextClass = 'text-muted-foreground';
|
|
1087
|
+
const userLinkClass = 'text-foreground underline underline-offset-2 hover:text-foreground/80';
|
|
1451
1088
|
|
|
1452
1089
|
return {
|
|
1453
1090
|
p: ({ children }: { children?: React.ReactNode }) =>
|
|
@@ -1483,19 +1120,19 @@ export const FormattedMessageContent: React.FC<{
|
|
|
1483
1120
|
blockquote: ({ children }: { children?: React.ReactNode }) =>
|
|
1484
1121
|
isUserVariant ? (
|
|
1485
1122
|
<blockquote
|
|
1486
|
-
className={`border-l-
|
|
1123
|
+
className={`border-l-2 border-border pl-4 py-2 bg-transparent my-3 italic ${userMutedTextClass}`}
|
|
1487
1124
|
>
|
|
1488
1125
|
{children}
|
|
1489
1126
|
</blockquote>
|
|
1490
1127
|
) : (
|
|
1491
1128
|
<blockquote>{children}</blockquote>
|
|
1492
1129
|
),
|
|
1493
|
-
hr: () => (isUserVariant ? <hr className="my-4 border-
|
|
1130
|
+
hr: () => (isUserVariant ? <hr className="my-4 border-border" /> : <hr />),
|
|
1494
1131
|
ul: ({ children }: { children?: React.ReactNode }) => (
|
|
1495
1132
|
<ul
|
|
1496
1133
|
className={
|
|
1497
1134
|
isUserVariant
|
|
1498
|
-
? `list-disc pl-5 mb-4 space-y-1.5 marker:text-
|
|
1135
|
+
? `list-disc pl-5 mb-4 space-y-1.5 marker:text-muted-foreground [&_ul]:mt-1.5 [&_ol]:mt-1.5 ${userTextClass}`
|
|
1499
1136
|
: 'list-disc pl-5'
|
|
1500
1137
|
}
|
|
1501
1138
|
>
|
|
@@ -1506,7 +1143,7 @@ export const FormattedMessageContent: React.FC<{
|
|
|
1506
1143
|
<ol
|
|
1507
1144
|
className={
|
|
1508
1145
|
isUserVariant
|
|
1509
|
-
? `list-decimal pl-5 mb-4 space-y-1.5 marker:text-
|
|
1146
|
+
? `list-decimal pl-5 mb-4 space-y-1.5 marker:text-muted-foreground [&_ul]:mt-1.5 [&_ol]:mt-1.5 ${userTextClass}`
|
|
1510
1147
|
: 'list-decimal pl-5'
|
|
1511
1148
|
}
|
|
1512
1149
|
>
|
|
@@ -1537,7 +1174,7 @@ export const FormattedMessageContent: React.FC<{
|
|
|
1537
1174
|
...props
|
|
1538
1175
|
}: React.TableHTMLAttributes<HTMLTableElement> & { children?: React.ReactNode }) =>
|
|
1539
1176
|
isUserVariant ? (
|
|
1540
|
-
<div className="overflow-x-auto my-4 w-full rounded-md border border-
|
|
1177
|
+
<div className="overflow-x-auto my-4 w-full rounded-md border border-border">
|
|
1541
1178
|
<table className="w-full text-sm" {...props}>
|
|
1542
1179
|
{children}
|
|
1543
1180
|
</table>
|
|
@@ -1548,7 +1185,7 @@ export const FormattedMessageContent: React.FC<{
|
|
|
1548
1185
|
</div>
|
|
1549
1186
|
),
|
|
1550
1187
|
thead: ({ children }: { children?: React.ReactNode }) =>
|
|
1551
|
-
isUserVariant ? <thead className="bg-
|
|
1188
|
+
isUserVariant ? <thead className="bg-muted text-left">{children}</thead> : <thead>{children}</thead>,
|
|
1552
1189
|
th: ({ children }: { children?: React.ReactNode }) =>
|
|
1553
1190
|
isUserVariant ? (
|
|
1554
1191
|
<th className={`px-3 py-2 text-left font-semibold ${userTextClass}`}>{children}</th>
|
|
@@ -1587,7 +1224,7 @@ export const FormattedMessageContent: React.FC<{
|
|
|
1587
1224
|
<code
|
|
1588
1225
|
className={
|
|
1589
1226
|
isUserVariant
|
|
1590
|
-
? `rounded px-1.5 py-0.5 text-sm font-mono bg-
|
|
1227
|
+
? `rounded px-1.5 py-0.5 text-sm font-mono bg-muted break-words ${className || ''}`
|
|
1591
1228
|
: `llm-inline-code break-words ${className || ''}`
|
|
1592
1229
|
}
|
|
1593
1230
|
{...rest}
|
|
@@ -1641,9 +1278,7 @@ export const FormattedMessageContent: React.FC<{
|
|
|
1641
1278
|
// For plain text content
|
|
1642
1279
|
return variant === 'user' ? (
|
|
1643
1280
|
<p
|
|
1644
|
-
className={`${USER_MESSAGE_TEXT_SIZE_CLASS} leading-relaxed whitespace-pre-wrap break-words
|
|
1645
|
-
planMode ? 'text-primary-foreground' : 'text-gray-900'
|
|
1646
|
-
}`}
|
|
1281
|
+
className={`${USER_MESSAGE_TEXT_SIZE_CLASS} leading-relaxed whitespace-pre-wrap break-words text-foreground`}
|
|
1647
1282
|
>
|
|
1648
1283
|
{content}
|
|
1649
1284
|
</p>
|
|
@@ -1870,6 +1505,7 @@ const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
|
1870
1505
|
const handleClick = () => {
|
|
1871
1506
|
onMessageClick?.(message);
|
|
1872
1507
|
};
|
|
1508
|
+
const [expanded, setExpanded] = useState(false);
|
|
1873
1509
|
|
|
1874
1510
|
const isAssistantRole = (message as any)?.propsConfiguration?.contents?.role === AiAgentMessageRole.Assistant;
|
|
1875
1511
|
const messageMode =
|
|
@@ -1877,6 +1513,9 @@ const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
|
1877
1513
|
(message as any)?.propsConfiguration?.content?.mode ??
|
|
1878
1514
|
(message as any)?.props?.mode;
|
|
1879
1515
|
const isPlanMode = messageMode === 'plan';
|
|
1516
|
+
const isLongUserMessage =
|
|
1517
|
+
!isAssistantRole && ((message as any)?.message?.length ?? 0) > USER_MESSAGE_COLLAPSE_CHAR_THRESHOLD;
|
|
1518
|
+
const isCollapsed = isLongUserMessage && !expanded;
|
|
1880
1519
|
// For user messages, create a right-aligned layout with avatar and name
|
|
1881
1520
|
if (isOwnMessage) {
|
|
1882
1521
|
const authorName =
|
|
@@ -1887,10 +1526,10 @@ const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
|
1887
1526
|
return (
|
|
1888
1527
|
<div className="py-1 px-1 sm:px-2 -mx-1 sm:-mx-2 group">
|
|
1889
1528
|
<div className="flex items-start justify-end gap-2">
|
|
1890
|
-
<div className="flex flex-col items-end max-w-[85%]">
|
|
1529
|
+
<div className="flex flex-col items-end max-w-[85%] min-w-0">
|
|
1891
1530
|
{showAuthorName && (
|
|
1892
1531
|
<div className="flex items-end space-x-2 mb-0.5">
|
|
1893
|
-
<span className="text-sm font-semibold text-
|
|
1532
|
+
<span className="text-sm font-semibold text-foreground">{authorName}</span>
|
|
1894
1533
|
</div>
|
|
1895
1534
|
)}
|
|
1896
1535
|
|
|
@@ -1898,18 +1537,21 @@ const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
|
1898
1537
|
<div
|
|
1899
1538
|
className={`${isAssistantRole ? 'text-sm' : USER_MESSAGE_TEXT_SIZE_CLASS} ${
|
|
1900
1539
|
isAssistantRole
|
|
1901
|
-
? 'cursor-pointer rounded-2xl border border-
|
|
1902
|
-
:
|
|
1903
|
-
isPlanMode
|
|
1904
|
-
? 'user-message rounded-[22px] rounded-br-[4px] px-4 py-3 bg-primary text-primary-foreground shadow-sm'
|
|
1905
|
-
: 'user-message rounded-[22px] rounded-br-[4px] px-4 py-3 '
|
|
1540
|
+
? 'cursor-pointer rounded-2xl border border-border bg-muted text-foreground px-4 py-2.5'
|
|
1541
|
+
: 'user-message rounded-[22px] rounded-br-[4px] px-4 py-3 bg-muted text-foreground shadow-sm'
|
|
1906
1542
|
}`}
|
|
1907
1543
|
onClick={isAssistantRole ? handleClick : undefined}
|
|
1908
1544
|
dir={detectTextDirection((message as any)?.message || '')}
|
|
1909
1545
|
lang={detectLanguageTag((message as any)?.message || '')}
|
|
1910
1546
|
>
|
|
1911
1547
|
{message.message && (
|
|
1912
|
-
<div
|
|
1548
|
+
<div
|
|
1549
|
+
className={`max-w-none ${isCollapsed ? 'relative overflow-hidden' : ''}`}
|
|
1550
|
+
style={isCollapsed ? { maxHeight: USER_MESSAGE_COLLAPSED_MAX_HEIGHT } : undefined}
|
|
1551
|
+
>
|
|
1552
|
+
{isCollapsed && (
|
|
1553
|
+
<div className="pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-muted to-transparent" />
|
|
1554
|
+
)}
|
|
1913
1555
|
{(() => {
|
|
1914
1556
|
const contentType = detectContentType(message.message);
|
|
1915
1557
|
|
|
@@ -1940,11 +1582,7 @@ const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
|
1940
1582
|
|
|
1941
1583
|
return (
|
|
1942
1584
|
<div
|
|
1943
|
-
className=
|
|
1944
|
-
isPlanMode
|
|
1945
|
-
? '!text-primary-foreground html-content'
|
|
1946
|
-
: 'text-gray-900 html-content'
|
|
1947
|
-
}
|
|
1585
|
+
className="text-foreground html-content"
|
|
1948
1586
|
dangerouslySetInnerHTML={{
|
|
1949
1587
|
__html: prettifyHtmlContent(sanitizeHtml(message.message)),
|
|
1950
1588
|
}}
|
|
@@ -1964,6 +1602,31 @@ const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
|
1964
1602
|
</div>
|
|
1965
1603
|
)}
|
|
1966
1604
|
|
|
1605
|
+
{isLongUserMessage && (
|
|
1606
|
+
<button
|
|
1607
|
+
type="button"
|
|
1608
|
+
onClick={(e) => {
|
|
1609
|
+
e.stopPropagation();
|
|
1610
|
+
setExpanded((v) => !v);
|
|
1611
|
+
}}
|
|
1612
|
+
className="mt-1 flex items-center gap-1 text-sm font-medium text-muted-foreground hover:text-foreground"
|
|
1613
|
+
>
|
|
1614
|
+
{expanded ? 'Show less' : 'Show more'}
|
|
1615
|
+
<svg
|
|
1616
|
+
viewBox="0 0 24 24"
|
|
1617
|
+
fill="none"
|
|
1618
|
+
stroke="currentColor"
|
|
1619
|
+
strokeWidth={2}
|
|
1620
|
+
strokeLinecap="round"
|
|
1621
|
+
strokeLinejoin="round"
|
|
1622
|
+
className={`h-3.5 w-3.5 transition-transform ${expanded ? 'rotate-180' : ''}`}
|
|
1623
|
+
aria-hidden
|
|
1624
|
+
>
|
|
1625
|
+
<path d="M6 9l6 6 6-6" />
|
|
1626
|
+
</svg>
|
|
1627
|
+
</button>
|
|
1628
|
+
)}
|
|
1629
|
+
|
|
1967
1630
|
{tryExtractBuilderBlocks((message as any)?.message)?.length ? (
|
|
1968
1631
|
<div className="mt-2">
|
|
1969
1632
|
<BuilderLikeRenderer blocks={tryExtractBuilderBlocks((message as any)?.message)} />
|
|
@@ -1982,15 +1645,7 @@ const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
|
1982
1645
|
</div>
|
|
1983
1646
|
)}
|
|
1984
1647
|
{showTimestamp ? (
|
|
1985
|
-
<div
|
|
1986
|
-
className={`text-[10px] mt-1 text-right ${
|
|
1987
|
-
isAssistantRole
|
|
1988
|
-
? 'text-gray-500'
|
|
1989
|
-
: isPlanMode
|
|
1990
|
-
? 'text-primary-foreground/80'
|
|
1991
|
-
: 'text-gray-500'
|
|
1992
|
-
}`}
|
|
1993
|
-
>
|
|
1648
|
+
<div className="text-[10px] mt-1 text-right text-muted-foreground">
|
|
1994
1649
|
{formatTime(message.createdAt)}
|
|
1995
1650
|
</div>
|
|
1996
1651
|
) : null}
|