@admin-layout/tailwind-chat-pro 12.2.4-alpha.87 → 12.2.4-alpha.89
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 +111 -430
- package/lib/components/messages-container-ui/ModernMessageGroup.js.map +1 -1
- package/package.json +2 -2
- package/src/components/messages-container-ui/ModernMessageGroup.tsx +117 -458
|
@@ -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,347 +350,31 @@ const htmlContentStyles = `
|
|
|
347
350
|
box-shadow: none !important;
|
|
348
351
|
}
|
|
349
352
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
|
|
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;
|
|
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;
|
|
431
360
|
}
|
|
432
361
|
|
|
433
|
-
.
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
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;
|
|
362
|
+
/* Assistant replies must read as plain text on the page — no card. A shared
|
|
363
|
+
global class (.message-container, from @messenger-box/tailwind-ui-inbox)
|
|
364
|
+
ships its own pill background/padding; neutralize it here the same way the
|
|
365
|
+
user bubble already does above. */
|
|
366
|
+
.${ASSISTANT_RESPONSE_THEME_CLASS},
|
|
367
|
+
.${ASSISTANT_RESPONSE_CLASS},
|
|
368
|
+
.${ASSISTANT_RESPONSE_BUBBLE_CLASS},
|
|
369
|
+
.${ASSISTANT_RESPONSE_THEME_CLASS} .message-container {
|
|
370
|
+
background: transparent !important;
|
|
371
|
+
box-shadow: none !important;
|
|
522
372
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
border-top: 1px solid #e5e7eb;
|
|
527
|
-
color: #374151;
|
|
373
|
+
.${ASSISTANT_RESPONSE_THEME_CLASS} .message-container {
|
|
374
|
+
padding: 0 !important;
|
|
375
|
+
margin: 0 !important;
|
|
528
376
|
}
|
|
529
377
|
|
|
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
378
|
/* Code block container styling */
|
|
692
379
|
.code-block-container {
|
|
693
380
|
background: #ffffff;
|
|
@@ -709,38 +396,6 @@ const htmlContentStyles = `
|
|
|
709
396
|
letter-spacing: 0.05em;
|
|
710
397
|
}
|
|
711
398
|
|
|
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
399
|
`;
|
|
745
400
|
// Hook to inject CSS styles
|
|
746
401
|
const useInjectStyles = () => {
|
|
@@ -1185,7 +840,7 @@ const CodeFormatter = ({
|
|
|
1185
840
|
}
|
|
1186
841
|
// Regular text content
|
|
1187
842
|
return jsx("div", {
|
|
1188
|
-
className: `${variant === 'user' ? USER_MESSAGE_TEXT_SIZE_CLASS : 'text-sm'} ${variant === 'user' ?
|
|
843
|
+
className: `${variant === 'user' ? USER_MESSAGE_TEXT_SIZE_CLASS : 'text-sm'} ${variant === 'user' ? 'text-foreground' : 'text-gray-700'} leading-relaxed whitespace-pre-wrap break-words`,
|
|
1189
844
|
children: section.trim()
|
|
1190
845
|
}, index);
|
|
1191
846
|
})
|
|
@@ -1262,52 +917,52 @@ const FormattedMessageContent = ({
|
|
|
1262
917
|
};
|
|
1263
918
|
}
|
|
1264
919
|
}, [content]);
|
|
1265
|
-
const userMarkdownClasses = `${USER_MESSAGE_TEXT_SIZE_CLASS} prose ${USER_MESSAGE_PROSE_SIZE_CLASS} max-w-none leading-relaxed break-words
|
|
1266
|
-
prose-p:my-2 prose-p:text-
|
|
920
|
+
const userMarkdownClasses = `${USER_MESSAGE_TEXT_SIZE_CLASS} prose ${USER_MESSAGE_PROSE_SIZE_CLASS} max-w-none leading-relaxed break-words
|
|
921
|
+
prose-p:my-2 prose-p:text-foreground
|
|
1267
922
|
prose-pre:my-2 prose-pre:bg-transparent prose-pre:border-0 prose-pre:p-0
|
|
1268
|
-
prose-ul:my-2 prose-ol:my-2
|
|
1269
|
-
prose-code:break-words prose-code:bg-
|
|
1270
|
-
prose-headings:font-semibold prose-headings:text-
|
|
1271
|
-
prose-h1:text-2xl prose-h1:border-b prose-h1:border-
|
|
1272
|
-
prose-h2:text-xl prose-h2:border-b prose-h2:border-
|
|
923
|
+
prose-ul:my-2 prose-ol:my-2
|
|
924
|
+
prose-code:break-words prose-code:bg-muted prose-code:text-foreground prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-sm prose-code:font-mono
|
|
925
|
+
prose-headings:font-semibold prose-headings:text-foreground prose-headings:mt-4 prose-headings:mb-2
|
|
926
|
+
prose-h1:text-2xl prose-h1:border-b prose-h1:border-border prose-h1:pb-2
|
|
927
|
+
prose-h2:text-xl prose-h2:border-b prose-h2:border-border prose-h2:pb-1
|
|
1273
928
|
prose-h3:text-lg
|
|
1274
929
|
prose-h4:text-base
|
|
1275
|
-
prose-a:text-
|
|
1276
|
-
prose-strong:font-semibold prose-strong:text-
|
|
1277
|
-
prose-em:text-
|
|
1278
|
-
prose-blockquote:border-l-
|
|
1279
|
-
prose-table:w-full prose-table:border prose-table:border-
|
|
1280
|
-
prose-th:px-3 prose-th:py-2 prose-th:text-left prose-th:font-semibold prose-th:bg-
|
|
1281
|
-
prose-td:px-3 prose-td:py-2 prose-td:border prose-td:border-
|
|
1282
|
-
prose-li:my-1 prose-li:text-
|
|
1283
|
-
prose-hr:my-4 prose-hr:border-
|
|
1284
|
-
|
|
1285
|
-
const userHtmlClasses = `${USER_MESSAGE_TEXT_SIZE_CLASS} prose ${USER_MESSAGE_PROSE_SIZE_CLASS} max-w-none leading-relaxed break-words
|
|
1286
|
-
prose-p:my-2 prose-p:text-
|
|
1287
|
-
prose-pre:my-2 prose-pre:bg-
|
|
1288
|
-
prose-ul:my-2 prose-ol:my-2
|
|
930
|
+
prose-a:text-foreground prose-a:underline hover:prose-a:text-foreground
|
|
931
|
+
prose-strong:font-semibold prose-strong:text-foreground
|
|
932
|
+
prose-em:text-muted-foreground
|
|
933
|
+
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
|
|
934
|
+
prose-table:w-full prose-table:border prose-table:border-border prose-table:rounded-md prose-table:my-4
|
|
935
|
+
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
|
|
936
|
+
prose-td:px-3 prose-td:py-2 prose-td:border prose-td:border-border prose-td:text-foreground
|
|
937
|
+
prose-li:my-1 prose-li:text-foreground
|
|
938
|
+
prose-hr:my-4 prose-hr:border-border
|
|
939
|
+
!prose-p:text-foreground !prose-li:text-foreground !prose-strong:text-foreground !prose-em:text-muted-foreground !prose-a:text-foreground !prose-code:text-foreground`;
|
|
940
|
+
const userHtmlClasses = `${USER_MESSAGE_TEXT_SIZE_CLASS} prose ${USER_MESSAGE_PROSE_SIZE_CLASS} max-w-none leading-relaxed break-words
|
|
941
|
+
prose-p:my-2 prose-p:text-foreground
|
|
942
|
+
prose-pre:my-2 prose-pre:bg-muted prose-pre:border prose-pre:border-border prose-pre:rounded prose-pre:p-3
|
|
943
|
+
prose-ul:my-2 prose-ol:my-2
|
|
1289
944
|
prose-pre:whitespace-pre-wrap prose-pre:break-words prose-pre:overflow-x-auto
|
|
1290
|
-
prose-code:break-words prose-code:bg-
|
|
1291
|
-
prose-headings:font-semibold prose-headings:text-
|
|
1292
|
-
prose-h1:text-2xl prose-h1:border-b prose-h1:border-
|
|
1293
|
-
prose-h2:text-xl prose-h2:border-b prose-h2:border-
|
|
945
|
+
prose-code:break-words prose-code:bg-muted prose-code:text-foreground prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-sm prose-code:font-mono
|
|
946
|
+
prose-headings:font-semibold prose-headings:text-foreground prose-headings:mt-4 prose-headings:mb-2
|
|
947
|
+
prose-h1:text-2xl prose-h1:border-b prose-h1:border-border prose-h1:pb-2
|
|
948
|
+
prose-h2:text-xl prose-h2:border-b prose-h2:border-border prose-h2:pb-1
|
|
1294
949
|
prose-h3:text-lg
|
|
1295
950
|
prose-h4:text-base
|
|
1296
|
-
prose-a:text-
|
|
1297
|
-
prose-strong:font-semibold prose-strong:text-
|
|
1298
|
-
prose-em:text-
|
|
1299
|
-
prose-blockquote:border-l-
|
|
1300
|
-
prose-table:w-full prose-table:border prose-table:border-
|
|
1301
|
-
prose-th:px-3 prose-th:py-2 prose-th:text-left prose-th:font-semibold prose-th:bg-
|
|
1302
|
-
prose-td:px-3 prose-td:py-2 prose-td:border prose-td:border-
|
|
1303
|
-
prose-li:my-1 prose-li:text-
|
|
1304
|
-
prose-hr:my-4 prose-hr:border-
|
|
1305
|
-
|
|
951
|
+
prose-a:text-foreground prose-a:underline hover:prose-a:text-foreground
|
|
952
|
+
prose-strong:font-semibold prose-strong:text-foreground
|
|
953
|
+
prose-em:text-muted-foreground
|
|
954
|
+
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
|
|
955
|
+
prose-table:w-full prose-table:border prose-table:border-border prose-table:rounded-md prose-table:my-4
|
|
956
|
+
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
|
|
957
|
+
prose-td:px-3 prose-td:py-2 prose-td:border prose-td:border-border prose-td:text-foreground
|
|
958
|
+
prose-li:my-1 prose-li:text-foreground
|
|
959
|
+
prose-hr:my-4 prose-hr:border-border
|
|
960
|
+
!prose-p:text-foreground !prose-li:text-foreground !prose-strong:text-foreground !prose-em:text-muted-foreground !prose-a:text-foreground !prose-code:text-foreground`;
|
|
1306
961
|
const markdownComponents = useMemo(() => {
|
|
1307
962
|
const isUserVariant = variant === 'user';
|
|
1308
|
-
const userTextClass =
|
|
1309
|
-
const userMutedTextClass =
|
|
1310
|
-
const userLinkClass =
|
|
963
|
+
const userTextClass = 'text-foreground';
|
|
964
|
+
const userMutedTextClass = 'text-muted-foreground';
|
|
965
|
+
const userLinkClass = 'text-foreground underline underline-offset-2 hover:text-foreground/80';
|
|
1311
966
|
return {
|
|
1312
967
|
p: ({
|
|
1313
968
|
children
|
|
@@ -1352,24 +1007,24 @@ const FormattedMessageContent = ({
|
|
|
1352
1007
|
blockquote: ({
|
|
1353
1008
|
children
|
|
1354
1009
|
}) => isUserVariant ? jsx("blockquote", {
|
|
1355
|
-
className: `border-l-
|
|
1010
|
+
className: `border-l-2 border-border pl-4 py-2 bg-transparent my-3 italic ${userMutedTextClass}`,
|
|
1356
1011
|
children: children
|
|
1357
1012
|
}) : jsx("blockquote", {
|
|
1358
1013
|
children: children
|
|
1359
1014
|
}),
|
|
1360
1015
|
hr: () => isUserVariant ? jsx("hr", {
|
|
1361
|
-
className: "my-4 border-
|
|
1016
|
+
className: "my-4 border-border"
|
|
1362
1017
|
}) : jsx("hr", {}),
|
|
1363
1018
|
ul: ({
|
|
1364
1019
|
children
|
|
1365
1020
|
}) => jsx("ul", {
|
|
1366
|
-
className: isUserVariant ? `list-disc pl-5 mb-4 space-y-1.5 marker:text-
|
|
1021
|
+
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',
|
|
1367
1022
|
children: children
|
|
1368
1023
|
}),
|
|
1369
1024
|
ol: ({
|
|
1370
1025
|
children
|
|
1371
1026
|
}) => jsx("ol", {
|
|
1372
|
-
className: isUserVariant ? `list-decimal pl-5 mb-4 space-y-1.5 marker:text-
|
|
1027
|
+
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',
|
|
1373
1028
|
children: children
|
|
1374
1029
|
}),
|
|
1375
1030
|
li: ({
|
|
@@ -1393,7 +1048,7 @@ const FormattedMessageContent = ({
|
|
|
1393
1048
|
children,
|
|
1394
1049
|
...props
|
|
1395
1050
|
}) => isUserVariant ? jsx("div", {
|
|
1396
|
-
className: "overflow-x-auto my-4 w-full rounded-md border border-
|
|
1051
|
+
className: "overflow-x-auto my-4 w-full rounded-md border border-border",
|
|
1397
1052
|
children: jsx("table", {
|
|
1398
1053
|
className: "w-full text-sm",
|
|
1399
1054
|
...props,
|
|
@@ -1409,7 +1064,7 @@ const FormattedMessageContent = ({
|
|
|
1409
1064
|
thead: ({
|
|
1410
1065
|
children
|
|
1411
1066
|
}) => isUserVariant ? jsx("thead", {
|
|
1412
|
-
className: "bg-
|
|
1067
|
+
className: "bg-muted text-left",
|
|
1413
1068
|
children: children
|
|
1414
1069
|
}) : jsx("thead", {
|
|
1415
1070
|
children: children
|
|
@@ -1463,7 +1118,7 @@ const FormattedMessageContent = ({
|
|
|
1463
1118
|
});
|
|
1464
1119
|
}
|
|
1465
1120
|
return jsx("code", {
|
|
1466
|
-
className: isUserVariant ? `rounded px-1.5 py-0.5 text-sm font-mono bg-
|
|
1121
|
+
className: isUserVariant ? `rounded px-1.5 py-0.5 text-sm font-mono bg-muted text-foreground break-words ${className || ''}` : `llm-inline-code break-words ${className || ''}`,
|
|
1467
1122
|
...rest,
|
|
1468
1123
|
children: children
|
|
1469
1124
|
});
|
|
@@ -1514,7 +1169,7 @@ const FormattedMessageContent = ({
|
|
|
1514
1169
|
}
|
|
1515
1170
|
// For plain text content
|
|
1516
1171
|
return variant === 'user' ? jsx("p", {
|
|
1517
|
-
className: `${USER_MESSAGE_TEXT_SIZE_CLASS} leading-relaxed whitespace-pre-wrap break-words
|
|
1172
|
+
className: `${USER_MESSAGE_TEXT_SIZE_CLASS} leading-relaxed whitespace-pre-wrap break-words text-foreground`,
|
|
1518
1173
|
children: content
|
|
1519
1174
|
}) : jsx(AssistantResponseWrapper, {
|
|
1520
1175
|
children: jsx("div", {
|
|
@@ -1659,9 +1314,12 @@ const ModernMessageBubble = ({
|
|
|
1659
1314
|
const handleClick = () => {
|
|
1660
1315
|
onMessageClick?.(message);
|
|
1661
1316
|
};
|
|
1317
|
+
const [expanded, setExpanded] = useState(false);
|
|
1662
1318
|
const isAssistantRole = message?.propsConfiguration?.contents?.role === AiAgentMessageRole.Assistant;
|
|
1663
1319
|
const messageMode = message?.propsConfiguration?.contents?.mode ?? message?.propsConfiguration?.content?.mode ?? message?.props?.mode;
|
|
1664
1320
|
const isPlanMode = messageMode === 'plan';
|
|
1321
|
+
const isLongUserMessage = !isAssistantRole && (message?.message?.length ?? 0) > USER_MESSAGE_COLLAPSE_CHAR_THRESHOLD;
|
|
1322
|
+
const isCollapsed = isLongUserMessage && !expanded;
|
|
1665
1323
|
// For user messages, create a right-aligned layout with avatar and name
|
|
1666
1324
|
if (isOwnMessage) {
|
|
1667
1325
|
const authorName = message.author?.givenName && message.author?.familyName ? `${message.author.givenName} ${message.author.familyName}` : message.author?.username || 'You';
|
|
@@ -1670,23 +1328,26 @@ const ModernMessageBubble = ({
|
|
|
1670
1328
|
children: jsxs("div", {
|
|
1671
1329
|
className: "flex items-start justify-end gap-2",
|
|
1672
1330
|
children: [jsxs("div", {
|
|
1673
|
-
className: "flex flex-col items-end max-w-[85%]",
|
|
1331
|
+
className: "flex flex-col items-end max-w-[85%] min-w-0",
|
|
1674
1332
|
children: [showAuthorName && jsx("div", {
|
|
1675
1333
|
className: "flex items-end space-x-2 mb-0.5",
|
|
1676
1334
|
children: jsx("span", {
|
|
1677
|
-
className: "text-sm font-semibold text-
|
|
1335
|
+
className: "text-sm font-semibold text-foreground",
|
|
1678
1336
|
children: authorName
|
|
1679
1337
|
})
|
|
1680
1338
|
}), jsxs("div", {
|
|
1681
|
-
className: `${isAssistantRole ? 'text-sm' : USER_MESSAGE_TEXT_SIZE_CLASS} ${isAssistantRole ? 'cursor-pointer rounded-2xl border border-
|
|
1682
|
-
// : 'user-message rounded-[22px] rounded-br-[4px] px-4 py-3 bg-primary text-primary-foreground shadow-sm'
|
|
1683
|
-
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 '}`,
|
|
1339
|
+
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'}`,
|
|
1684
1340
|
onClick: isAssistantRole ? handleClick : undefined,
|
|
1685
1341
|
dir: detectTextDirection(message?.message || ''),
|
|
1686
1342
|
lang: detectLanguageTag(message?.message || ''),
|
|
1687
|
-
children: [message.message &&
|
|
1688
|
-
className:
|
|
1689
|
-
|
|
1343
|
+
children: [message.message && jsxs("div", {
|
|
1344
|
+
className: `max-w-none ${isCollapsed ? 'relative overflow-hidden' : ''}`,
|
|
1345
|
+
style: isCollapsed ? {
|
|
1346
|
+
maxHeight: USER_MESSAGE_COLLAPSED_MAX_HEIGHT
|
|
1347
|
+
} : undefined,
|
|
1348
|
+
children: [isCollapsed && jsx("div", {
|
|
1349
|
+
className: "pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-muted to-transparent"
|
|
1350
|
+
}), (() => {
|
|
1690
1351
|
const contentType = detectContentType(message.message);
|
|
1691
1352
|
if (contentType === 'code') {
|
|
1692
1353
|
return jsx(CodeFormatter, {
|
|
@@ -1707,7 +1368,7 @@ const ModernMessageBubble = ({
|
|
|
1707
1368
|
});
|
|
1708
1369
|
}
|
|
1709
1370
|
return jsx("div", {
|
|
1710
|
-
className:
|
|
1371
|
+
className: "text-foreground html-content",
|
|
1711
1372
|
dangerouslySetInnerHTML: {
|
|
1712
1373
|
__html: prettifyHtmlContent(sanitizeHtml(message.message))
|
|
1713
1374
|
}
|
|
@@ -1720,7 +1381,27 @@ const ModernMessageBubble = ({
|
|
|
1720
1381
|
showCopyDownloadOnCodeBlock: showCopyDownloadOnCodeBlock
|
|
1721
1382
|
});
|
|
1722
1383
|
}
|
|
1723
|
-
})()
|
|
1384
|
+
})()]
|
|
1385
|
+
}), isLongUserMessage && jsxs("button", {
|
|
1386
|
+
type: "button",
|
|
1387
|
+
onClick: e => {
|
|
1388
|
+
e.stopPropagation();
|
|
1389
|
+
setExpanded(v => !v);
|
|
1390
|
+
},
|
|
1391
|
+
className: "mt-1 flex items-center gap-1 text-sm font-medium text-muted-foreground hover:text-foreground",
|
|
1392
|
+
children: [expanded ? 'Show less' : 'Show more', jsx("svg", {
|
|
1393
|
+
viewBox: "0 0 24 24",
|
|
1394
|
+
fill: "none",
|
|
1395
|
+
stroke: "currentColor",
|
|
1396
|
+
strokeWidth: 2,
|
|
1397
|
+
strokeLinecap: "round",
|
|
1398
|
+
strokeLinejoin: "round",
|
|
1399
|
+
className: `h-3.5 w-3.5 transition-transform ${expanded ? 'rotate-180' : ''}`,
|
|
1400
|
+
"aria-hidden": true,
|
|
1401
|
+
children: jsx("path", {
|
|
1402
|
+
d: "M6 9l6 6 6-6"
|
|
1403
|
+
})
|
|
1404
|
+
})]
|
|
1724
1405
|
}), tryExtractBuilderBlocks(message?.message)?.length ? jsx("div", {
|
|
1725
1406
|
className: "mt-2",
|
|
1726
1407
|
children: jsx(BuilderLikeRenderer, {
|
|
@@ -1738,7 +1419,7 @@ const ModernMessageBubble = ({
|
|
|
1738
1419
|
files: message.files.data
|
|
1739
1420
|
})
|
|
1740
1421
|
}), showTimestamp ? jsx("div", {
|
|
1741
|
-
className:
|
|
1422
|
+
className: "text-[10px] mt-1 text-right text-muted-foreground",
|
|
1742
1423
|
children: formatTime(message.createdAt)
|
|
1743
1424
|
}) : null]
|
|
1744
1425
|
})]
|