Skip to content

Commit a6bfe45

Browse files
committed
frontend/chat/message: progress cleaning up top buttons inside of message
1 parent 4d8aa8e commit a6bfe45

File tree

1 file changed

+91
-86
lines changed

1 file changed

+91
-86
lines changed

src/packages/frontend/chat/message.tsx

Lines changed: 91 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -514,84 +514,87 @@ export default function Message({
514514
<>
515515
<span style={lighten}>
516516
<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-
}}
517+
<Space
518+
size={"small"}
519+
align="baseline"
520+
style={{ float: "right", marginRight: "10px" }}
521+
>
522+
{!isLLMThread && (
523+
<Tip
524+
placement={"top"}
525+
title={
526+
!showOtherFeedback
527+
? "Like this"
528+
: () => {
529+
return (
530+
<div>
531+
{Object.keys(
532+
message.get("feedback")?.toJS() ?? {},
533+
).map((account_id) => (
534+
<div
535+
key={account_id}
536+
style={{ marginBottom: "2px" }}
537+
>
538+
<Avatar size={24} account_id={account_id} />{" "}
539+
<User account_id={account_id} />
540+
</div>
541+
))}
542+
</div>
543+
);
544+
}
545+
}
555546
>
556-
{showOtherFeedback ? (
557-
<Badge count={otherFeedback} color="darkblue" size="small" />
558-
) : (
559-
""
560-
)}
561-
<Tip
562-
placement={"bottom"}
563-
title={showOtherFeedback ? undefined : "Like this"}
547+
<Button
548+
style={{
549+
color: !feedback && is_viewers_message ? "white" : "#888",
550+
fontSize: "12px",
551+
marginTop: "-4px",
552+
...(feedback ? {} : { position: "relative", top: "-5px" }),
553+
}}
554+
size="small"
555+
type={feedback ? "dashed" : "text"}
556+
onClick={() => {
557+
actions?.feedback(message, feedback ? null : "positive");
558+
}}
564559
>
560+
{showOtherFeedback ? (
561+
<Badge
562+
count={otherFeedback}
563+
color="darkblue"
564+
size="small"
565+
/>
566+
) : (
567+
""
568+
)}
565569
<Icon
566570
name="thumbs-up"
567571
style={{
568572
color: showOtherFeedback ? "darkblue" : undefined,
569573
}}
570574
/>
571-
</Tip>
575+
</Button>
576+
</Tip>
577+
)}
578+
<Tip
579+
placement={"top"}
580+
title="Select message. Copy URL to link to this message."
581+
>
582+
<Button
583+
onClick={() => {
584+
actions?.setFragment(message.get("date"));
585+
}}
586+
size="small"
587+
type={"text"}
588+
style={{
589+
color: is_viewers_message ? "white" : "#888",
590+
fontSize: "12px",
591+
marginTop: "-4px",
592+
}}
593+
>
594+
<Icon name="link" />
572595
</Button>
573596
</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>
597+
</Space>
595598
</span>
596599
<MostlyStaticMarkdown
597600
style={MARKDOWN_STYLE}
@@ -608,6 +611,7 @@ export default function Message({
608611
: undefined
609612
}
610613
/>
614+
{renderEditControlRow()}
611615
</>
612616
);
613617
}
@@ -636,8 +640,6 @@ export default function Message({
636640
? { marginLeft: "5px", marginRight: "5px" }
637641
: undefined),
638642
...(selected ? { border: "3px solid #66bb6a" } : undefined),
639-
maxHeight: is_folded ? "100px" : undefined,
640-
overflowY: is_folded ? "auto" : undefined,
641643
} as const;
642644

643645
const mainXS = mode === "standalone" ? 20 : 22;
@@ -671,27 +673,27 @@ export default function Message({
671673
className="smc-chat-message"
672674
onDoubleClick={edit_message}
673675
>
674-
{isEditing ? (
675-
renderEditMessage()
676-
) : (
677-
<>
678-
{renderMessageBody({ lighten, message_class })}
679-
{renderEditControlRow()}
680-
</>
681-
)}
676+
{isEditing
677+
? renderEditMessage()
678+
: renderMessageBody({ lighten, message_class })}
682679
</div>
683-
{show_history && (
684-
<div>
685-
<HistoryTitle />
686-
<History history={message.get("history")} user_map={user_map} />
687-
<HistoryFooter />
688-
</div>
689-
)}
690-
{replying ? renderComposeReply() : undefined}
680+
{renderHistory()}
681+
{renderComposeReply()}
691682
</Col>
692683
);
693684
}
694685

686+
function renderHistory() {
687+
if (!show_history) return;
688+
return (
689+
<div>
690+
<HistoryTitle />
691+
<History history={message.get("history")} user_map={user_map} />
692+
<HistoryFooter />
693+
</div>
694+
);
695+
}
696+
695697
function saveEditedMessage(): void {
696698
if (actions == null) return;
697699
const mesg =
@@ -768,11 +770,14 @@ export default function Message({
768770
}
769771

770772
function renderComposeReply() {
773+
if (!replying) return;
774+
771775
if (project_id == null || path == null || actions?.syncdb == null) {
772776
// should never get into this position
773777
// when null.
774778
return;
775779
}
780+
776781
const replyDate = -getThreadRootDate({ date, messages });
777782
let input;
778783
let moveCursorToEndOfLine = false;

0 commit comments

Comments
 (0)