@@ -15,20 +15,13 @@ import {
15
15
useState ,
16
16
useTypedRedux ,
17
17
} from "@cocalc/frontend/app-framework" ;
18
- import {
19
- Gap ,
20
- Icon ,
21
- Paragraph ,
22
- Text ,
23
- TimeAgo ,
24
- Tip ,
25
- } from "@cocalc/frontend/components" ;
18
+ import { Gap , Icon , TimeAgo , Tip } from "@cocalc/frontend/components" ;
26
19
import { User } from "@cocalc/frontend/users" ;
27
20
import MostlyStaticMarkdown from "@cocalc/frontend/editors/slate/mostly-static-markdown" ;
28
21
import { IS_TOUCH } from "@cocalc/frontend/feature" ;
29
22
import { modelToName } from "@cocalc/frontend/frame-editors/llm/llm-selector" ;
30
23
import { isLanguageModelService } from "@cocalc/util/db-schema/llm-utils" ;
31
- import { unreachable } from "@cocalc/util/misc" ;
24
+ import { plural , unreachable } from "@cocalc/util/misc" ;
32
25
import { COLORS } from "@cocalc/util/theme" ;
33
26
import { ChatActions } from "./actions" ;
34
27
import { getUserName } from "./chat-log" ;
@@ -125,6 +118,10 @@ interface Props {
125
118
costEstimate ;
126
119
127
120
selected ?: boolean ;
121
+
122
+ // for the root of a folded thread, optionally give this number of a
123
+ // more informative message to the user.
124
+ numChildren ?: number ;
128
125
}
129
126
130
127
export default function Message ( {
@@ -149,6 +146,7 @@ export default function Message({
149
146
is_thread_body,
150
147
costEstimate,
151
148
selected,
149
+ numChildren,
152
150
} : Props ) {
153
151
const showAISummarize = redux
154
152
. getStore ( "projects" )
@@ -374,20 +372,14 @@ export default function Message({
374
372
}
375
373
376
374
function contentColumn ( ) {
377
- let marginBottom , marginTop ;
375
+ let marginTop ;
378
376
let value = newest_content ( message ) ;
379
377
380
378
const { background, color, lighten, message_class } = message_colors (
381
379
account_id ,
382
380
message ,
383
381
) ;
384
382
385
- if ( show_avatar ) {
386
- marginBottom = "1vh" ;
387
- } else {
388
- marginBottom = "3px" ;
389
- }
390
-
391
383
if ( ! is_prev_sender && is_viewers_message ) {
392
384
marginTop = MARGIN_TOP_VIEWER ;
393
385
} else {
@@ -399,10 +391,12 @@ export default function Message({
399
391
background,
400
392
wordWrap : "break-word" ,
401
393
borderRadius : "5px" ,
402
- marginBottom,
403
394
marginTop,
404
395
fontSize : `${ font_size } px` ,
405
- padding : selected ? "6px" : "9px" ,
396
+ // no padding on bottom, since message itself is markdown, hence
397
+ // wrapped in <p>'s, which have a big 10px margin on their bottoms
398
+ // already.
399
+ padding : selected ? "6px 6px 0 6px" : "9px 9px 0 9px" ,
406
400
...( mode === "sidechat"
407
401
? { marginLeft : "5px" , marginRight : "5px" }
408
402
: undefined ) ,
@@ -908,20 +902,30 @@ export default function Message({
908
902
return ;
909
903
}
910
904
905
+ let label ;
906
+ if ( numChildren ) {
907
+ label = (
908
+ < >
909
+ { numChildren } { plural ( numChildren , "Reply" , "Replies" ) }
910
+ </ >
911
+ ) ;
912
+ } else {
913
+ label = "View Replies" ;
914
+ }
915
+
911
916
return (
912
917
< Col xs = { 24 } >
913
- < Paragraph type = "secondary" style = { { textAlign : "center" } } >
914
- { mode === "standalone" ? "This thread is folded. " : "" }
918
+ < div style = { { textAlign : "center" } } >
915
919
< Button
916
- type = "text"
917
- icon = { < Icon name = "down-circle-o" /> }
918
920
onClick = { ( ) =>
919
921
actions ?. toggleFoldThread ( message . get ( "date" ) , index )
920
922
}
923
+ type = "link"
924
+ style = { { color : "darkblue" } }
921
925
>
922
- < Text type = "secondary" > Unfold </ Text >
926
+ { label }
923
927
</ Button >
924
- </ Paragraph >
928
+ </ div >
925
929
</ Col >
926
930
) ;
927
931
}
@@ -965,7 +969,7 @@ export default function Message({
965
969
key = { "blankcolumn" }
966
970
style = { { textAlign : reverseRowOrdering ? "left" : "right" } }
967
971
>
968
- { true || hideTooltip ? (
972
+ { hideTooltip ? (
969
973
button
970
974
) : (
971
975
< Tooltip
0 commit comments