Give every user their own bot face

A bot's face and status line live in bot_user_faces, one row per bot and
user, set by jobs for the user whose conversation they're in. Needs-you
and working only show to that user; every bot read overlays the viewer's
face (botFaceSql) and pushes go to the user a face change is for.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-19 13:58:26 +01:00
co-authored by Claude Opus 5.5
parent 47c58bc76b
commit ab25158d87
32 changed files with 448 additions and 181 deletions
+9 -8
View File
@@ -1,14 +1,15 @@
import type {
BUN_SQLITE_COBBLE_BOT_MESSAGES,
BUN_SQLITE_COBBLE_BOTS,
} from "@/db/types/db";
import type { BUN_SQLITE_COBBLE_BOT_MESSAGES } from "@/db/types/db";
import type { BotFaceChange } from "@/src/functions/backend/db/bots/set-bot-face";
import pushBotUpdated from "./push-bot-updated";
import pushToSessionUser from "./push-to-session-user";
type Params = {
bot_id: number | string;
message?: BUN_SQLITE_COBBLE_BOT_MESSAGES | null;
bot?: Pick<BUN_SQLITE_COBBLE_BOTS, "id" | "face" | "status_line" | "computer_id"> | null;
/**
* A face change (`setBotFace`), pushed to the user it's for.
*/
bot?: BotFaceChange | null;
/**
* A job's result reported to the bot that handed it over
* (`relayJobToRequester`): a message in that bot's conversation.
@@ -18,8 +19,8 @@ type Params = {
/**
* Pushes a new bot message to the open tabs of the user whose
* conversation it's in, and a face change to everyone who sees the bot
* (`pushBotUpdated`, each with their own active task). A relayed report
* conversation it's in, and a face change to the user it's for
* (`pushBotUpdated`). A relayed report
* goes to the conversation it was posted in.
*/
export default async function pushBotNotice({ bot_id, message, bot, relay }: Params) {
@@ -38,6 +39,6 @@ export default async function pushBotNotice({ bot_id, message, bot, relay }: Par
}
if (bot) {
await pushBotUpdated({ bot: { ...bot, id: bot.id || Number(bot_id) } });
await pushBotUpdated({ bot_id: bot.id || bot_id, user_id: bot.user_id });
}
}