Files
cobble/src/pages/admin/bots/[bot_id]/(partials)/message-reply-quote.tsx
T
tbenandClaude Opus 5.5 d1b5b6d68a Add replies and emoji reactions to chat messages
Every message has a row under it to reply or react. Replying quotes the
message above the composer, and the sent message stores
reply_to_message_id (a plain id, not a foreign key, so deleting the
quoted message only drops the quote). send-message accepts a quote from
any session of the same conversation, so a rollover or a thread that
moved on still sends; the conversation drops a picked quote when its
session changes. The bot reads the quote as "[Replying to ...]" before
the user's turn, file-only replies included, and relayed messages carry
it too.

Reactions are a fixed set (BotMessageReactions) in
bot_message_reactions, one per message, emoji and user or bot. Users
toggle their own through api/admin/bots/react-message, and every bot
gets react_to_message for the session it answers (the user's latest
message by default). Both push the fresh list as server:bot-reaction,
with mine worked out for the session's user.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 21:56:31 +01:00

42 lines
1.5 KiB
TypeScript

import Row from "@moduletrace/twui/layout/Row";
import Stack from "@moduletrace/twui/layout/Stack";
import Span from "@moduletrace/twui/layout/Span";
import { Reply } from "lucide-react";
import type { BotMessageReply } from "@/src/types";
import messagePreview from "@/src/utils/message-preview";
type Props = {
reply_to: BotMessageReply;
bot_name: string;
/**
* Right-align it, for a user message.
*/
align_end?: boolean;
};
/**
* The message a reply answers: who wrote it and a one-line preview. A
* file-only message says so instead of showing an empty line.
*/
export default function MessageReplyQuote({ reply_to, bot_name, align_end }: Props) {
const preview = messagePreview({ text: reply_to.text }) || "A file";
return (
<Stack
className={`w-full max-w-[80%] min-w-0 gap-0.5! overflow-hidden border-0 border-l-2 border-solid border-hairline-strong pl-2.5 ${
align_end ? "items-end text-right" : "items-start"
}`}
>
<Row className="max-w-full min-w-0 gap-1! items-center">
<Reply size={11} aria-hidden className="shrink-0 text-ink-secondary" />
<Span className="min-w-0 truncate text-[11px] font-bold leading-4 text-ink">
{reply_to.author == "user" ? "You" : bot_name}
</Span>
</Row>
<Span className="block w-full max-w-full break-words text-xs leading-4 text-ink-secondary line-clamp-2">
{preview}
</Span>
</Stack>
);
}