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]>
This commit is contained in:
2026-10-19 21:56:31 +01:00
co-authored by Claude Opus 5.5
parent bc499a7466
commit d1b5b6d68a
44 changed files with 1289 additions and 58 deletions
@@ -15,6 +15,11 @@ type Params = {
session_id: number;
workspace_id?: number | null;
text: string;
/**
* The message this one answers, quoted above it. Already checked to
* be in the same conversation.
*/
reply_to?: BUN_SQLITE_COBBLE_BOT_MESSAGES | null;
/**
* Files to attach, already checked to be the user's own
* (`grabAttachableMedia`).
@@ -33,6 +38,7 @@ export default async function insertUserMessage({
session_id,
workspace_id,
text,
reply_to,
media = [],
}: Params): Promise<BotMessageWithAttachments> {
const now = Date.now();
@@ -50,6 +56,7 @@ export default async function insertUserMessage({
author: "user",
text,
needs_you: 0,
reply_to_message_id: reply_to?.id || undefined,
},
],
});
@@ -80,8 +87,16 @@ export default async function insertUserMessage({
author: "user",
text,
needs_you: 0,
reply_to_message_id: reply_to?.id || undefined,
created_at: now,
updated_at: now,
attachments: media.map((file) => mediaToAttachment({ media: file })),
reply_to: reply_to
? {
id: Number(reply_to.id),
author: reply_to.author == "bot" ? "bot" : "user",
text: reply_to.text || "",
}
: null,
};
}