Skip to content

Commit 0e8a70b

Browse files
committed
chat: more useful info about folded thread
1 parent 3326d7c commit 0e8a70b

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

src/packages/frontend/chat/chat-log.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ export function MessageList({
551551
<DivTempHeight height={h ? `${h}px` : undefined}>
552552
<Message
553553
messages={messages}
554+
numChildren={numChildren[message.get("date").valueOf()]}
554555
key={date}
555556
index={index}
556557
account_id={account_id}

src/packages/frontend/chat/message.tsx

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,13 @@ import {
1515
useState,
1616
useTypedRedux,
1717
} 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";
2619
import { User } from "@cocalc/frontend/users";
2720
import MostlyStaticMarkdown from "@cocalc/frontend/editors/slate/mostly-static-markdown";
2821
import { IS_TOUCH } from "@cocalc/frontend/feature";
2922
import { modelToName } from "@cocalc/frontend/frame-editors/llm/llm-selector";
3023
import { isLanguageModelService } from "@cocalc/util/db-schema/llm-utils";
31-
import { unreachable } from "@cocalc/util/misc";
24+
import { plural, unreachable } from "@cocalc/util/misc";
3225
import { COLORS } from "@cocalc/util/theme";
3326
import { ChatActions } from "./actions";
3427
import { getUserName } from "./chat-log";
@@ -125,6 +118,10 @@ interface Props {
125118
costEstimate;
126119

127120
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;
128125
}
129126

130127
export default function Message({
@@ -149,6 +146,7 @@ export default function Message({
149146
is_thread_body,
150147
costEstimate,
151148
selected,
149+
numChildren,
152150
}: Props) {
153151
const showAISummarize = redux
154152
.getStore("projects")
@@ -374,20 +372,14 @@ export default function Message({
374372
}
375373

376374
function contentColumn() {
377-
let marginBottom, marginTop;
375+
let marginTop;
378376
let value = newest_content(message);
379377

380378
const { background, color, lighten, message_class } = message_colors(
381379
account_id,
382380
message,
383381
);
384382

385-
if (show_avatar) {
386-
marginBottom = "1vh";
387-
} else {
388-
marginBottom = "3px";
389-
}
390-
391383
if (!is_prev_sender && is_viewers_message) {
392384
marginTop = MARGIN_TOP_VIEWER;
393385
} else {
@@ -399,10 +391,12 @@ export default function Message({
399391
background,
400392
wordWrap: "break-word",
401393
borderRadius: "5px",
402-
marginBottom,
403394
marginTop,
404395
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",
406400
...(mode === "sidechat"
407401
? { marginLeft: "5px", marginRight: "5px" }
408402
: undefined),
@@ -908,20 +902,30 @@ export default function Message({
908902
return;
909903
}
910904

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+
911916
return (
912917
<Col xs={24}>
913-
<Paragraph type="secondary" style={{ textAlign: "center" }}>
914-
{mode === "standalone" ? "This thread is folded. " : ""}
918+
<div style={{ textAlign: "center" }}>
915919
<Button
916-
type="text"
917-
icon={<Icon name="down-circle-o" />}
918920
onClick={() =>
919921
actions?.toggleFoldThread(message.get("date"), index)
920922
}
923+
type="link"
924+
style={{ color: "darkblue" }}
921925
>
922-
<Text type="secondary">Unfold</Text>
926+
{label}
923927
</Button>
924-
</Paragraph>
928+
</div>
925929
</Col>
926930
);
927931
}
@@ -965,7 +969,7 @@ export default function Message({
965969
key={"blankcolumn"}
966970
style={{ textAlign: reverseRowOrdering ? "left" : "right" }}
967971
>
968-
{true || hideTooltip ? (
972+
{hideTooltip ? (
969973
button
970974
) : (
971975
<Tooltip

0 commit comments

Comments
 (0)