Skip to content

Commit af1fee3

Browse files
committed
add a trivial chat "thumbs up" feature, based on the LLM one, but for non-LLM messages
- also redo the LLM like/unlike to use **standard ANTD** instead bootstrap-style stuff and non-standard unicode symbols
1 parent 2032308 commit af1fee3

File tree

3 files changed

+68
-16
lines changed

3 files changed

+68
-16
lines changed

src/packages/frontend/chat/llm-msg-feedback.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

6-
import { Space } from "antd";
7-
8-
import { Button } from "@cocalc/frontend/antd-bootstrap";
6+
import { Button, Space } from "antd";
97
import { redux } from "@cocalc/frontend/app-framework";
10-
import { HelpIcon, Text } from "@cocalc/frontend/components";
8+
import { HelpIcon, Icon, Text } from "@cocalc/frontend/components";
119
import { useProjectContext } from "../project/context";
1210
import { ChatActions } from "./actions";
1311
import { ChatMessageTyped, Feedback } from "./types";
@@ -27,7 +25,7 @@ export function FeedbackLLM({ actions, message }: FeedackLLMProps) {
2725
const val = message.getIn(["feedback", account_id]);
2826

2927
function feedback(what: Feedback) {
30-
return `Give a ${what} feedback about this answer written by the language model.`;
28+
return `Give ${what} feedback about this answer written by the language model.`;
3129
}
3230

3331
const isNegative = val === "negative";
@@ -61,30 +59,30 @@ export function FeedbackLLM({ actions, message }: FeedackLLMProps) {
6159

6260
return (
6361
<Space size="small" wrap>
64-
<Space.Compact>
62+
<Space>
6563
<Button
66-
bsSize="xsmall"
67-
bsStyle="ghost"
68-
active={isPositive}
64+
style={{ color: "#555" }}
65+
size="small"
66+
type={isPositive ? "dashed" : "text"}
6967
onClick={() =>
7068
actions?.feedback(message, isPositive ? null : "positive")
7169
}
7270
title={feedback("positive")}
7371
>
74-
👍
72+
<Icon name="thumbs-up" />
7573
</Button>
7674
<Button
77-
bsSize="xsmall"
78-
bsStyle="ghost"
79-
active={isNegative}
75+
style={{ color: "#555" }}
76+
size="small"
77+
type={isNegative ? "dashed" : "text"}
8078
onClick={() =>
8179
actions?.feedback(message, isNegative ? null : "negative")
8280
}
8381
title={feedback("negative")}
8482
>
85-
👎
83+
<Icon name="thumbs-down" />
8684
</Button>
87-
</Space.Compact>
85+
</Space>
8886
{renderUnhappy()}
8987
</Space>
9088
);

src/packages/frontend/chat/message.tsx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
TimeAgo,
2424
Tip,
2525
} from "@cocalc/frontend/components";
26+
import { User } from "@cocalc/frontend/users";
2627
import MostlyStaticMarkdown from "@cocalc/frontend/editors/slate/mostly-static-markdown";
2728
import { IS_TOUCH } from "@cocalc/frontend/feature";
2829
import { modelToName } from "@cocalc/frontend/frame-editors/llm/llm-selector";
@@ -413,6 +414,9 @@ export default function Message(props: Readonly<Props>) {
413414

414415
const mainXS = mode === "standalone" ? 20 : 22;
415416
const showEditButton = Date.now() - date < SHOW_EDIT_BUTTON_MS;
417+
const feedback = message.getIn(["feedback", props.account_id]);
418+
const otherFeedback =
419+
isLLMThread && msgWrittenByLLM ? 0 : (message.get("feedback")?.size ?? 0);
416420

417421
return (
418422
<Col key={1} xs={mainXS}>
@@ -441,6 +445,27 @@ export default function Message(props: Readonly<Props>) {
441445
{!isEditing && (
442446
<span style={lighten}>
443447
<Time message={message} edit={edit_message} />
448+
{!isLLMThread && (
449+
<Button
450+
style={{
451+
marginRight: "5px",
452+
float: "right",
453+
marginTop: "-4px",
454+
color: !feedback && is_viewers_message ? "white" : "#888",
455+
fontSize: "12px",
456+
}}
457+
size="small"
458+
type={feedback ? "dashed" : "text"}
459+
onClick={() => {
460+
props.actions?.feedback(
461+
message,
462+
feedback ? null : "positive",
463+
);
464+
}}
465+
>
466+
<Icon name="thumbs-up" />
467+
</Button>
468+
)}{" "}
444469
</span>
445470
)}
446471
{!isEditing && (
@@ -548,6 +573,36 @@ export default function Message(props: Readonly<Props>) {
548573
</>
549574
) : undefined}
550575
</Space>
576+
{otherFeedback > 0 && (
577+
<div
578+
style={{
579+
float: "right",
580+
color: is_viewers_message ? "white" : "#555",
581+
}}
582+
>
583+
<Tooltip
584+
title={() => {
585+
return (
586+
<div>
587+
{Object.keys(
588+
message.get("feedback")?.toJS() ?? {},
589+
).map((account_id) => (
590+
<div
591+
key={account_id}
592+
style={{ marginBottom: "2px" }}
593+
>
594+
<Avatar size={24} account_id={account_id} />{" "}
595+
<User account_id={account_id} />
596+
</div>
597+
))}
598+
</div>
599+
);
600+
}}
601+
>
602+
{otherFeedback} <Icon name="thumbs-up" />
603+
</Tooltip>
604+
</div>
605+
)}
551606
</div>
552607
)}
553608
</div>

src/packages/frontend/collaborators/current-collabs.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { Button, Card, Popconfirm } from "antd";
77
import React from "react";
88
import { FormattedMessage, useIntl } from "react-intl";
9-
109
import { CSS, redux, useRedux } from "@cocalc/frontend/app-framework";
1110
import {
1211
Gap,

0 commit comments

Comments
 (0)