5
5
6
6
// cSpell:ignore blankcolumn
7
7
8
- import { Badge , Button , Col , Popconfirm , Row , Space , Tooltip } from "antd" ;
8
+ import { Badge , Button , Col , Popconfirm , Row , Space } from "antd" ;
9
9
import { List , Map } from "immutable" ;
10
10
import { CSSProperties , useEffect , useLayoutEffect } from "react" ;
11
11
import { useIntl } from "react-intl" ;
@@ -415,7 +415,7 @@ export default function Message({
415
415
< div style = { { width : "100%" , textAlign : "center" } } >
416
416
< Space direction = "horizontal" size = "small" wrap >
417
417
{ showEditButton ? (
418
- < Tooltip
418
+ < Tip
419
419
title = {
420
420
< >
421
421
Edit this message. You can edit < b > any</ b > past message at any
@@ -436,10 +436,10 @@ export default function Message({
436
436
>
437
437
< Icon name = "pencil" /> Edit
438
438
</ Button >
439
- </ Tooltip >
439
+ </ Tip >
440
440
) : undefined }
441
441
{ showDeleteButton && (
442
- < Tooltip
442
+ < Tip
443
443
title = "Delete this message. You can delete any past message by anybody. The deleted message can be view in history."
444
444
placement = "left"
445
445
>
@@ -462,7 +462,7 @@ export default function Message({
462
462
< Icon name = "trash" /> Delete
463
463
</ Button >
464
464
</ Popconfirm >
465
- </ Tooltip >
465
+ </ Tip >
466
466
) }
467
467
{ showEditingStatus && render_editing_status ( isEditing ) }
468
468
{ showHistory && (
@@ -502,9 +502,117 @@ export default function Message({
502
502
) ;
503
503
}
504
504
505
- function contentColumn ( ) {
505
+ function renderMessageBody ( { lighten , message_class } ) {
506
506
const value = newest_content ( message ) ;
507
507
508
+ const feedback = message . getIn ( [ "feedback" , account_id ] ) ;
509
+ const otherFeedback =
510
+ isLLMThread && msgWrittenByLLM ? 0 : message . get ( "feedback" ) ?. size ?? 0 ;
511
+ const showOtherFeedback = otherFeedback > 0 ;
512
+
513
+ return (
514
+ < >
515
+ < span style = { lighten } >
516
+ < Time message = { message } edit = { edit_message } />
517
+ { ! isLLMThread && (
518
+ < Tip
519
+ placement = { "bottom" }
520
+ title = {
521
+ ! showOtherFeedback
522
+ ? undefined
523
+ : ( ) => {
524
+ return (
525
+ < div >
526
+ { Object . keys (
527
+ message . get ( "feedback" ) ?. toJS ( ) ?? { } ,
528
+ ) . map ( ( account_id ) => (
529
+ < div
530
+ key = { account_id }
531
+ style = { { marginBottom : "2px" } }
532
+ >
533
+ < Avatar size = { 24 } account_id = { account_id } /> { " " }
534
+ < User account_id = { account_id } />
535
+ </ div >
536
+ ) ) }
537
+ </ div >
538
+ ) ;
539
+ }
540
+ }
541
+ >
542
+ < Button
543
+ style = { {
544
+ marginRight : "5px" ,
545
+ float : "right" ,
546
+ marginTop : "-4px" ,
547
+ color : ! feedback && is_viewers_message ? "white" : "#888" ,
548
+ fontSize : "12px" ,
549
+ } }
550
+ size = "small"
551
+ type = { feedback ? "dashed" : "text" }
552
+ onClick = { ( ) => {
553
+ actions ?. feedback ( message , feedback ? null : "positive" ) ;
554
+ } }
555
+ >
556
+ { showOtherFeedback ? (
557
+ < Badge count = { otherFeedback } color = "darkblue" size = "small" />
558
+ ) : (
559
+ ""
560
+ ) }
561
+ < Tip
562
+ placement = { "bottom" }
563
+ title = { showOtherFeedback ? undefined : "Like this" }
564
+ >
565
+ < Icon
566
+ name = "thumbs-up"
567
+ style = { {
568
+ color : showOtherFeedback ? "darkblue" : undefined ,
569
+ } }
570
+ />
571
+ </ Tip >
572
+ </ Button >
573
+ </ Tip >
574
+ ) } { " " }
575
+ < Tip
576
+ placement = { "bottom" }
577
+ title = "Select message. Copy URL to link to this message."
578
+ >
579
+ < Button
580
+ onClick = { ( ) => {
581
+ actions ?. setFragment ( message . get ( "date" ) ) ;
582
+ } }
583
+ size = "small"
584
+ type = { "text" }
585
+ style = { {
586
+ float : "right" ,
587
+ marginTop : "-4px" ,
588
+ color : is_viewers_message ? "white" : "#888" ,
589
+ fontSize : "12px" ,
590
+ } }
591
+ >
592
+ < Icon name = "link" />
593
+ </ Button >
594
+ </ Tip >
595
+ </ span >
596
+ < MostlyStaticMarkdown
597
+ style = { MARKDOWN_STYLE }
598
+ value = { value }
599
+ className = { message_class }
600
+ selectedHashtags = { selectedHashtags }
601
+ toggleHashtag = {
602
+ selectedHashtags != null && actions != null
603
+ ? ( tag ) =>
604
+ actions ?. setHashtagState (
605
+ tag ,
606
+ selectedHashtags ?. has ( tag ) ? undefined : 1 ,
607
+ )
608
+ : undefined
609
+ }
610
+ />
611
+ </ >
612
+ ) ;
613
+ }
614
+
615
+ function contentColumn ( ) {
508
616
const { background, color, lighten, message_class } = message_colors (
509
617
account_id ,
510
618
message ,
@@ -533,10 +641,6 @@ export default function Message({
533
641
} as const ;
534
642
535
643
const mainXS = mode === "standalone" ? 20 : 22 ;
536
- const feedback = message . getIn ( [ "feedback" , account_id ] ) ;
537
- const otherFeedback =
538
- isLLMThread && msgWrittenByLLM ? 0 : message . get ( "feedback" ) ?. size ?? 0 ;
539
- const showOtherFeedback = otherFeedback > 0 ;
540
644
541
645
return (
542
646
< Col key = { 1 } xs = { mainXS } >
@@ -567,106 +671,14 @@ export default function Message({
567
671
className = "smc-chat-message"
568
672
onDoubleClick = { edit_message }
569
673
>
570
- { ! isEditing && (
571
- < span style = { lighten } >
572
- < Time message = { message } edit = { edit_message } />
573
- { ! isLLMThread && (
574
- < Tooltip
575
- title = {
576
- ! showOtherFeedback
577
- ? undefined
578
- : ( ) => {
579
- return (
580
- < div >
581
- { Object . keys (
582
- message . get ( "feedback" ) ?. toJS ( ) ?? { } ,
583
- ) . map ( ( account_id ) => (
584
- < div
585
- key = { account_id }
586
- style = { { marginBottom : "2px" } }
587
- >
588
- < Avatar size = { 24 } account_id = { account_id } /> { " " }
589
- < User account_id = { account_id } />
590
- </ div >
591
- ) ) }
592
- </ div >
593
- ) ;
594
- }
595
- }
596
- >
597
- < Button
598
- style = { {
599
- marginRight : "5px" ,
600
- float : "right" ,
601
- marginTop : "-4px" ,
602
- color : ! feedback && is_viewers_message ? "white" : "#888" ,
603
- fontSize : "12px" ,
604
- } }
605
- size = "small"
606
- type = { feedback ? "dashed" : "text" }
607
- onClick = { ( ) => {
608
- actions ?. feedback ( message , feedback ? null : "positive" ) ;
609
- } }
610
- >
611
- { showOtherFeedback ? (
612
- < Badge
613
- count = { otherFeedback }
614
- color = "darkblue"
615
- size = "small"
616
- />
617
- ) : (
618
- ""
619
- ) }
620
- < Tooltip
621
- title = { showOtherFeedback ? undefined : "Like this" }
622
- >
623
- < Icon
624
- name = "thumbs-up"
625
- style = { {
626
- color : showOtherFeedback ? "darkblue" : undefined ,
627
- } }
628
- />
629
- </ Tooltip >
630
- </ Button >
631
- </ Tooltip >
632
- ) } { " " }
633
- < Tooltip title = "Select message. Copy URL to link to this message." >
634
- < Button
635
- onClick = { ( ) => {
636
- actions ?. setFragment ( message . get ( "date" ) ) ;
637
- } }
638
- size = "small"
639
- type = { "text" }
640
- style = { {
641
- float : "right" ,
642
- marginTop : "-4px" ,
643
- color : is_viewers_message ? "white" : "#888" ,
644
- fontSize : "12px" ,
645
- } }
646
- >
647
- < Icon name = "link" />
648
- </ Button >
649
- </ Tooltip >
650
- </ span >
651
- ) }
652
- { ! isEditing && (
653
- < MostlyStaticMarkdown
654
- style = { MARKDOWN_STYLE }
655
- value = { value }
656
- className = { message_class }
657
- selectedHashtags = { selectedHashtags }
658
- toggleHashtag = {
659
- selectedHashtags != null && actions != null
660
- ? ( tag ) =>
661
- actions ?. setHashtagState (
662
- tag ,
663
- selectedHashtags ?. has ( tag ) ? undefined : 1 ,
664
- )
665
- : undefined
666
- }
667
- />
674
+ { isEditing ? (
675
+ renderEditMessage ( )
676
+ ) : (
677
+ < >
678
+ { renderMessageBody ( { lighten, message_class } ) }
679
+ { renderEditControlRow ( ) }
680
+ </ >
668
681
) }
669
- { isEditing ? renderEditMessage ( ) : renderEditControlRow ( ) }
670
682
</ div >
671
683
{ show_history && (
672
684
< div >
@@ -876,7 +888,8 @@ export default function Message({
876
888
877
889
return (
878
890
< div style = { { textAlign : "center" , width : "100%" } } >
879
- < Tooltip
891
+ < Tip
892
+ placement = { "bottom" }
880
893
title = {
881
894
isLLMThread
882
895
? `Reply to ${ modelToName (
@@ -903,25 +916,32 @@ export default function Message({
903
916
/>
904
917
) : undefined }
905
918
</ Button >
906
- </ Tooltip >
919
+ </ Tip >
907
920
{ showAISummarize && is_thread ? (
908
921
< SummarizeThread message = { message } actions = { actions } />
909
922
) : undefined }
910
- { is_thread ? (
911
- < Button
912
- type = "text"
913
- style = { { color : COLORS . GRAY_M } }
914
- icon = { < Icon name = "to-top-outlined" /> }
915
- onClick = { ( ) =>
916
- actions ?. toggleFoldThread (
917
- new Date ( getThreadRootDate ( { date, messages } ) ) ,
918
- index ,
919
- )
923
+ { is_thread && (
924
+ < Tip
925
+ placement = { "bottom" }
926
+ title = {
927
+ "Fold this thread to make the list of messages shorter. You can unfold it again at any time."
920
928
}
921
929
>
922
- Fold Thread…
923
- </ Button >
924
- ) : undefined }
930
+ < Button
931
+ type = "text"
932
+ style = { { color : COLORS . GRAY_M } }
933
+ icon = { < Icon name = "to-top-outlined" /> }
934
+ onClick = { ( ) =>
935
+ actions ?. toggleFoldThread (
936
+ new Date ( getThreadRootDate ( { date, messages } ) ) ,
937
+ index ,
938
+ )
939
+ }
940
+ >
941
+ Fold…
942
+ </ Button >
943
+ </ Tip >
944
+ ) }
925
945
</ div >
926
946
) ;
927
947
}
@@ -998,6 +1018,7 @@ export default function Message({
998
1018
}
999
1019
/>
1000
1020
) ;
1021
+
1001
1022
return (
1002
1023
< Col
1003
1024
xs = { xs }
@@ -1007,7 +1028,8 @@ export default function Message({
1007
1028
{ hideTooltip ? (
1008
1029
button
1009
1030
) : (
1010
- < Tooltip
1031
+ < Tip
1032
+ placement = { "bottom" }
1011
1033
title = {
1012
1034
is_folded ? (
1013
1035
< >
@@ -1026,7 +1048,7 @@ export default function Message({
1026
1048
}
1027
1049
>
1028
1050
{ button }
1029
- </ Tooltip >
1051
+ </ Tip >
1030
1052
) }
1031
1053
</ Col >
1032
1054
) ;
0 commit comments