From 05315f422f838407b3c77c098a14829d89f345bf Mon Sep 17 00:00:00 2001 From: Laura Thiel Date: Fri, 20 Nov 2026 20:32:30 +0100 Subject: [PATCH 1/4] feat(web): show what bots are doing on their avatars Upgrade open-bot-avatar to 0.3.0 and map bot activity to its new avatar states: thinking, working, waiting, blocked, and a short done celebration after a reply. Live avatars ease between states instead of remounting. --- CHANGELOG.md | 1 + THIRD_PARTY_NOTICES.md | 2 +- .../docs/content/getting-started/first-bot.md | 13 ++++-- apps/server/package.json | 2 +- apps/web/components/bot-avatar.tsx | 38 +++++++++++------ apps/web/features/avatars/avatars.tsx | 18 ++++++-- apps/web/features/bot-chat/avatar.tsx | 42 +++++++++++++++++-- apps/web/features/bot-chat/chat.tsx | 9 +++- apps/web/features/bot-chat/working.ts | 13 ++++++ apps/web/features/group-chats/groups.tsx | 11 ++++- apps/web/package.json | 2 +- bun.lock | 6 +-- 12 files changed, 124 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19a4f200..79e772ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Bot avatars show what their bot is doing, using `open-bot-avatar` 0.3.0: three hopping dots while it thinks, bent over the work while it writes, searches, remembers, or uses tools, an exclamation mark while it retries, a short celebration when a reply finishes, and waiting in a group chat while it answers next. Live avatars ease from one state to the next instead of restarting. The `/avatars` page previews every state. - A bot's details in the web chat show **Usage**: tokens and cost for each model and tool its bot chat has used, with a total. Job panes now include tool costs, such as intent checks, in their cost. - When a bot's model can't read images and no vision model is set, the web chat warns as soon as an image is attached and links to the bot's profile and the vision model setting. The server refuses such a message before recording a turn, so the error shows once, names the bot, and the message goes back to the composer. `GET /v1/models` returns `images` for each model. - Pinned conversations are saved on the account, so every app shows the same pins in the same order. The session returns them as `pinnedConversations`, `update-user` saves the whole list (up to nine `agent:` or `group:` keys), and `/v1/events` sends a `pins` event to the account's open apps when they change. On the web, pin or unpin a bot chat or group chat from its **More** menu in the sidebar, and drag pins in the **Pinned** section to reorder them. diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index a7e7313c..00da6394 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -2,7 +2,7 @@ ## Open Bot Avatar -Web avatars use `open-bot-avatar` 0.2.0, by Dominik Scholz, under the MIT License. The generation prompt in `apps/web/features/avatars/generate-avatar-prompt.txt` is copied from `DominikScholz/open-bot-avatar`, commit `386cd20258ae48f2e75345ce3c05e046e04d6ad7`, `skills/generate-avatar/references/system-prompt.md`. +Web avatars use `open-bot-avatar` 0.3.0, by Dominik Scholz, under the MIT License. The generation prompt in `apps/web/features/avatars/generate-avatar-prompt.txt` is copied from `DominikScholz/open-bot-avatar`, commit `386cd20258ae48f2e75345ce3c05e046e04d6ad7`, `skills/generate-avatar/references/system-prompt.md`. ```text MIT License diff --git a/apps/docs/content/getting-started/first-bot.md b/apps/docs/content/getting-started/first-bot.md index 7e6ffc41..80033074 100644 --- a/apps/docs/content/getting-started/first-bot.md +++ b/apps/docs/content/getting-started/first-bot.md @@ -31,9 +31,16 @@ JSON response into **Import**. The copied prompt includes your description. Crumble doesn't call a model from the avatar editor. A bot can also suggest its own definition in chat for you to import. -The `/avatars` page previews idle, working, and sleeping states. Select a bot -and click **Save avatar to bot** to apply your choice. Sleeping avatars use a -dimmed still image. Live avatars respect your system's reduced-motion setting. +The `/avatars` page previews the idle, thinking, working, waiting, blocked, +done, and sleeping states. Select a bot and click **Save avatar to bot** to apply your +choice. Sleeping avatars use a dimmed still image. Live avatars respect your +system's reduced-motion setting. + +An avatar shows what its bot is doing. While the bot thinks, its body turns +into three hopping dots. While it writes, searches, remembers, or uses tools, it +bends over the work. When it retries, it shows an exclamation mark. When a reply +finishes, it celebrates for a few seconds. In a group chat, a bot that answers +next waits its turn. Bots without a saved definition get a fresh gallery avatar with default colors. The bot ID selects the shape; previous avatar shapes and colors don't affect it. diff --git a/apps/server/package.json b/apps/server/package.json index 7136b54d..37843cec 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -38,7 +38,7 @@ "effect": "4.0.6", "hono": "4.13.13", "microsandbox": "0.7.8", - "open-bot-avatar": "0.2.0", + "open-bot-avatar": "0.3.0", "pele": "1.9.0", "pkijs": "4.0.0", "railway": "3.16.0", diff --git a/apps/web/components/bot-avatar.tsx b/apps/web/components/bot-avatar.tsx index 248eef05..a53fae6d 100644 --- a/apps/web/components/bot-avatar.tsx +++ b/apps/web/components/bot-avatar.tsx @@ -1,10 +1,11 @@ import { type CSSProperties, useLayoutEffect, useMemo, useRef } from "react"; -import { renderAvatarSvg } from "open-bot-avatar"; -import { mountAvatar } from "open-bot-avatar/dom"; +import { type AvatarState, renderAvatarSvg } from "open-bot-avatar"; +import { type MountedAvatar, mountAvatar } from "open-bot-avatar/dom"; import type { BotAvatarDefinition } from "@crumble/server/contract/avatar"; import { cn } from "@/lib/utils"; -export type BotState = "idle" | "working" | "sleeping"; +/** An avatar state, or `sleeping`: a paused bot drawn still and dimmed. */ +export type BotState = AvatarState | "sleeping"; export type AvatarBot = { id: string; avatar: BotAvatarDefinition }; @@ -20,23 +21,36 @@ export function botStyle(color: string) { function useLiveAvatar( still: boolean, look: BotAvatarDefinition, - mood: "thinking" | "idle", + state: AvatarState, ) { const host = useRef(null); + const avatar = useRef(null); + const latest = useRef(state); + // Remount only for a new look; state changes ease on the mounted avatar. useLayoutEffect(() => { if (still || !host.current) return; - const avatar = mountAvatar(host.current, { + const mounted = mountAvatar(host.current, { ...look, - mood, + state: latest.current, reducedMotion: "system", followPointer: true, label: "", }); - return () => avatar.destroy(); - }, [still, look, mood]); + avatar.current = mounted; + + return () => { + mounted.destroy(); + avatar.current = null; + }; + }, [still, look]); + + useLayoutEffect(() => { + latest.current = state; + avatar.current?.update({ state }); + }, [state]); return host; } @@ -58,8 +72,8 @@ export function BotAvatar({ const look = bot.avatar; const still = !live || state === "sleeping"; - const mood = state === "working" ? "thinking" : "idle"; - const host = useLiveAvatar(still, look, mood); + const shown = state === "sleeping" ? "idle" : state; + const host = useLiveAvatar(still, look, shown); const svg = useMemo( () => @@ -67,11 +81,11 @@ export function BotAvatar({ ? renderAvatarSvg(look.definition, { color: look.color, eyeColor: look.eyeColor, - motion: mood, + state: shown, reducedMotion: true, }) : "", - [still, look, mood], + [still, look, shown], ); return ( diff --git a/apps/web/features/avatars/avatars.tsx b/apps/web/features/avatars/avatars.tsx index ada94b80..d76e6397 100644 --- a/apps/web/features/avatars/avatars.tsx +++ b/apps/web/features/avatars/avatars.tsx @@ -50,15 +50,25 @@ function useAvatarDraft() { function AvatarStatePreviews({ value }: { value: BotAvatarDefinition }) { return ( -
- {(["idle", "working", "sleeping"] satisfies BotState[]).map((state) => ( +
+ {( + [ + "idle", + "thinking", + "working", + "waiting", + "blocked", + "done", + "sleeping", + ] satisfies BotState[] + ).map((state) => (
diff --git a/apps/web/features/bot-chat/avatar.tsx b/apps/web/features/bot-chat/avatar.tsx index f683a7e8..6d3fb317 100644 --- a/apps/web/features/bot-chat/avatar.tsx +++ b/apps/web/features/bot-chat/avatar.tsx @@ -1,18 +1,51 @@ +import { useEffect, useRef, useState } from "react"; import { type AvatarBot, type BotState, BotAvatar, } from "@/components/bot-avatar"; import type { Bot } from "@/features/bots/api"; -import { isBusy, useWorking } from "./working"; +import { type Working, isBusy, useWorking, workingAvatar } from "./working"; + +/** How long an avatar celebrates after a reply finishes. */ +const DONE_MS = 4000; + +/** True for a few seconds after a run ends well; never for a bot that was already idle on load. */ +function useJustFinished(working: Working) { + const [finished, setFinished] = useState(false); + const previous = useRef(working); + + useEffect(() => { + const was = previous.current; + + previous.current = working; + + if (!isBusy(was) || working !== "idle") { + setFinished(false); + + return; + } + + setFinished(true); + + const timer = setTimeout(() => setFinished(false), DONE_MS); + + return () => clearTimeout(timer); + }, [working]); + + return finished; +} const avatarState = ( enabled: boolean, - working: ReturnType, + working: Working, + finished: boolean, ): BotState => { if (!enabled) return "sleeping"; - return isBusy(working) ? "working" : "idle"; + if (finished) return "done"; + + return workingAvatar[working]; }; export function LiveBotAvatar({ @@ -25,8 +58,9 @@ export function LiveBotAvatar({ className?: string; }) { const working = useWorking(bot.id); + const finished = useJustFinished(working); - const state = avatarState(bot.enabled, working); + const state = avatarState(bot.enabled, working, finished); return ( - + {workingLabel[activity]}… diff --git a/apps/web/features/bot-chat/working.ts b/apps/web/features/bot-chat/working.ts index c6af91b4..335d8d7f 100644 --- a/apps/web/features/bot-chat/working.ts +++ b/apps/web/features/bot-chat/working.ts @@ -2,6 +2,7 @@ import { useSyncExternalStore } from "react"; import { type ChatSnapshot, chatQuery } from "@/features/chat/api"; import { queryClient } from "@/lib/api"; import { type Bot } from "@/features/bots/api"; +import type { BotState } from "@/components/bot-avatar"; export type Working = ChatSnapshot["working"]; @@ -19,6 +20,18 @@ export function useWorking(id: string) { export const isBusy = (working: Working) => working !== "idle" && working !== "failed"; +/** Thinking shows the dots, a retry the warning mark; a finished or failed run rests. */ +export const workingAvatar: Record = { + idle: "idle", + thinking: "thinking", + writing: "working", + searching: "working", + remembering: "working", + tinkering: "working", + struggling: "blocked", + failed: "idle", +}; + export const workingLabel: Record = { idle: "Working", thinking: "Thinking", diff --git a/apps/web/features/group-chats/groups.tsx b/apps/web/features/group-chats/groups.tsx index e356ed19..394d211c 100644 --- a/apps/web/features/group-chats/groups.tsx +++ b/apps/web/features/group-chats/groups.tsx @@ -35,7 +35,7 @@ import { } from "./api"; import type { Message } from "@/features/chat/api"; import { call, queryClient, send } from "@/lib/api"; -import { BotAvatar, botColor } from "@/components/bot-avatar"; +import { BotAvatar, type BotState, botColor } from "@/components/bot-avatar"; import { ConfirmDeleteContent, MobileSidebarTrigger } from "@/components/page"; import { ConversationEmpty, @@ -78,6 +78,13 @@ const MEMBER_STATUS = { idle: "is here", }; +const MEMBER_AVATAR = { + running: "working", + queued: "waiting", + disabled: "idle", + idle: "idle", +} satisfies Record; + const groupConversation = ( id: string, ): ConversationTarget => { @@ -124,7 +131,7 @@ function GroupHeader({ diff --git a/apps/web/package.json b/apps/web/package.json index 5aa9c452..52d26fa6 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -25,7 +25,7 @@ "cmdk": "1.1.1", "cn": "0.5.0", "cuelume": "0.2.8", - "open-bot-avatar": "0.2.0", + "open-bot-avatar": "0.3.0", "pele": "1.9.0", "react": "19.3.1", "react-dom": "19.3.1", diff --git a/bun.lock b/bun.lock index 3af34973..495ded49 100644 --- a/bun.lock +++ b/bun.lock @@ -45,7 +45,7 @@ "effect": "4.0.6", "hono": "4.13.13", "microsandbox": "0.7.8", - "open-bot-avatar": "0.2.0", + "open-bot-avatar": "0.3.0", "pele": "1.9.0", "pkijs": "4.0.0", "railway": "3.16.0", @@ -81,7 +81,7 @@ "cmdk": "1.1.1", "cn": "0.5.0", "cuelume": "0.2.8", - "open-bot-avatar": "0.2.0", + "open-bot-avatar": "0.3.0", "pele": "1.9.0", "react": "19.3.1", "react-dom": "19.3.1", @@ -883,7 +883,7 @@ "once": ["once@1.4.0", "", { "dependencies": { "wrappy": "1" } }, "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w=="], - "open-bot-avatar": ["open-bot-avatar@0.2.0", "", {}, "sha512-NHiTNWkZTCt1BA+x3l6OTqN7qAAaRfk4z6/kwpiIi9/4qHyzFb0syxJEw5PBbk6MbPhBHEltCD0Q/QuY4nxucg=="], + "open-bot-avatar": ["open-bot-avatar@0.3.0", "", {}, "sha512-3P0o8eiClHHiLr7lIFZE/WxUtqHLjVb0xQ0PqYzA48XG/oQlWyeIdcY0egK6H8AgFuoY1aKVhc8QKSaj4z5ZOw=="], "openai": ["openai@7.19.0", "", { "peerDependencies": { "@aws-sdk/credential-provider-node": ">=3.972.0 <4", "@smithy/hash-node": ">=4.3.0 <5", "@smithy/signature-v4": ">=5.4.0 <6", "undici": ">=5 <9", "ws": "^8.21.0", "zod": "^3.25 || ^4.0" }, "optionalPeers": ["@aws-sdk/credential-provider-node", "@smithy/hash-node", "@smithy/signature-v4", "undici", "ws", "zod"] }, "sha512-MX2s3u2L5racTO0CC/SWpCOasJQBCJrqLKXK+l82cAhdeF8mPMBEe/gxMm0ZFa2xpKpOFLRjxv5afYEZbBXmbQ=="], From 85f1412ede739668f3ca3b0dc76c7e8e456bc190 Mon Sep 17 00:00:00 2001 From: Laura Thiel Date: Fri, 20 Nov 2026 20:49:12 +0100 Subject: [PATCH 2/4] refactor(web): simplify avatar state mapping and drop comments --- apps/web/components/bot-avatar.tsx | 2 -- apps/web/features/avatars/avatars.tsx | 22 +++++++++++----------- apps/web/features/bot-chat/avatar.tsx | 4 +--- apps/web/features/bot-chat/chat.tsx | 2 +- apps/web/features/bot-chat/working.ts | 16 ++++++---------- apps/web/features/group-chats/groups.tsx | 13 ++++++------- 6 files changed, 25 insertions(+), 34 deletions(-) diff --git a/apps/web/components/bot-avatar.tsx b/apps/web/components/bot-avatar.tsx index a53fae6d..4f1c18c6 100644 --- a/apps/web/components/bot-avatar.tsx +++ b/apps/web/components/bot-avatar.tsx @@ -4,7 +4,6 @@ import { type MountedAvatar, mountAvatar } from "open-bot-avatar/dom"; import type { BotAvatarDefinition } from "@crumble/server/contract/avatar"; import { cn } from "@/lib/utils"; -/** An avatar state, or `sleeping`: a paused bot drawn still and dimmed. */ export type BotState = AvatarState | "sleeping"; export type AvatarBot = { id: string; avatar: BotAvatarDefinition }; @@ -27,7 +26,6 @@ function useLiveAvatar( const avatar = useRef(null); const latest = useRef(state); - // Remount only for a new look; state changes ease on the mounted avatar. useLayoutEffect(() => { if (still || !host.current) return; diff --git a/apps/web/features/avatars/avatars.tsx b/apps/web/features/avatars/avatars.tsx index d76e6397..393ef181 100644 --- a/apps/web/features/avatars/avatars.tsx +++ b/apps/web/features/avatars/avatars.tsx @@ -48,20 +48,20 @@ function useAvatarDraft() { return { bots, selected, value, save, select, edit }; } +const PREVIEW_STATES: BotState[] = [ + "idle", + "thinking", + "working", + "waiting", + "blocked", + "done", + "sleeping", +]; + function AvatarStatePreviews({ value }: { value: BotAvatarDefinition }) { return (
- {( - [ - "idle", - "thinking", - "working", - "waiting", - "blocked", - "done", - "sleeping", - ] satisfies BotState[] - ).map((state) => ( + {PREVIEW_STATES.map((state) => (
{workingLabel[activity]}… diff --git a/apps/web/features/bot-chat/working.ts b/apps/web/features/bot-chat/working.ts index 335d8d7f..dcc2fb7c 100644 --- a/apps/web/features/bot-chat/working.ts +++ b/apps/web/features/bot-chat/working.ts @@ -20,16 +20,12 @@ export function useWorking(id: string) { export const isBusy = (working: Working) => working !== "idle" && working !== "failed"; -/** Thinking shows the dots, a retry the warning mark; a finished or failed run rests. */ -export const workingAvatar: Record = { - idle: "idle", - thinking: "thinking", - writing: "working", - searching: "working", - remembering: "working", - tinkering: "working", - struggling: "blocked", - failed: "idle", +export const workingAvatar = (working: Working): BotState => { + if (working === "thinking") return "thinking"; + + if (working === "struggling") return "blocked"; + + return isBusy(working) ? "working" : "idle"; }; export const workingLabel: Record = { diff --git a/apps/web/features/group-chats/groups.tsx b/apps/web/features/group-chats/groups.tsx index 394d211c..3cd3d733 100644 --- a/apps/web/features/group-chats/groups.tsx +++ b/apps/web/features/group-chats/groups.tsx @@ -78,12 +78,11 @@ const MEMBER_STATUS = { idle: "is here", }; -const MEMBER_AVATAR = { - running: "working", - queued: "waiting", - disabled: "idle", - idle: "idle", -} satisfies Record; +const memberAvatar = (status: keyof typeof MEMBER_STATUS): BotState => { + if (status === "running") return "working"; + + return status === "queued" ? "waiting" : "idle"; +}; const groupConversation = ( id: string, @@ -131,7 +130,7 @@ function GroupHeader({ From 86759ee5ebc5ad564d2129f10be41f0c3beec90d Mon Sep 17 00:00:00 2001 From: Laura Thiel Date: Fri, 20 Nov 2026 20:56:27 +0100 Subject: [PATCH 3/4] refactor(web): remove the sleeping avatar state --- CHANGELOG.md | 2 +- apps/docs/content/getting-started/first-bot.md | 5 ++--- apps/web/components/bot-avatar.test.tsx | 13 +------------ apps/web/components/bot-avatar.tsx | 17 ++++++----------- apps/web/features/automations/automations.tsx | 6 +----- apps/web/features/avatars/avatars.tsx | 1 - apps/web/features/bot-chat/avatar.tsx | 18 ++++-------------- 7 files changed, 15 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79e772ac..ded79881 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- Bot avatars show what their bot is doing, using `open-bot-avatar` 0.3.0: three hopping dots while it thinks, bent over the work while it writes, searches, remembers, or uses tools, an exclamation mark while it retries, a short celebration when a reply finishes, and waiting in a group chat while it answers next. Live avatars ease from one state to the next instead of restarting. The `/avatars` page previews every state. +- Bot avatars show what their bot is doing, using `open-bot-avatar` 0.3.0: three hopping dots while it thinks, bent over the work while it writes, searches, remembers, or uses tools, an exclamation mark while it retries, a short celebration when a reply finishes, and waiting in a group chat while it answers next. Live avatars ease from one state to the next instead of restarting. The `/avatars` page previews every state. Paused bots and disabled automations no longer show a dimmed, still avatar. - A bot's details in the web chat show **Usage**: tokens and cost for each model and tool its bot chat has used, with a total. Job panes now include tool costs, such as intent checks, in their cost. - When a bot's model can't read images and no vision model is set, the web chat warns as soon as an image is attached and links to the bot's profile and the vision model setting. The server refuses such a message before recording a turn, so the error shows once, names the bot, and the message goes back to the composer. `GET /v1/models` returns `images` for each model. - Pinned conversations are saved on the account, so every app shows the same pins in the same order. The session returns them as `pinnedConversations`, `update-user` saves the whole list (up to nine `agent:` or `group:` keys), and `/v1/events` sends a `pins` event to the account's open apps when they change. On the web, pin or unpin a bot chat or group chat from its **More** menu in the sidebar, and drag pins in the **Pinned** section to reorder them. diff --git a/apps/docs/content/getting-started/first-bot.md b/apps/docs/content/getting-started/first-bot.md index 80033074..9e72536d 100644 --- a/apps/docs/content/getting-started/first-bot.md +++ b/apps/docs/content/getting-started/first-bot.md @@ -32,9 +32,8 @@ Crumble doesn't call a model from the avatar editor. A bot can also suggest its own definition in chat for you to import. The `/avatars` page previews the idle, thinking, working, waiting, blocked, -done, and sleeping states. Select a bot and click **Save avatar to bot** to apply your -choice. Sleeping avatars use a dimmed still image. Live avatars respect your -system's reduced-motion setting. +and done states. Select a bot and click **Save avatar to bot** to apply your +choice. Live avatars respect your system's reduced-motion setting. An avatar shows what its bot is doing. While the bot thinks, its body turns into three hopping dots. While it writes, searches, remembers, or uses tools, it diff --git a/apps/web/components/bot-avatar.test.tsx b/apps/web/components/bot-avatar.test.tsx index 6bbd73cf..afc47363 100644 --- a/apps/web/components/bot-avatar.test.tsx +++ b/apps/web/components/bot-avatar.test.tsx @@ -3,7 +3,7 @@ import { Window } from "happy-dom"; import { act } from "react"; import { defaultAvatarDefinition } from "@crumble/server/contract/avatar"; -test("static and live avatars update geometry, moods and colors, stop sleeping, and honor reduced motion", async () => { +test("static and live avatars update geometry, moods and colors, and honor reduced motion", async () => { const window = new Window(); const globals = Object.getOwnPropertyDescriptors(globalThis); const frames = new Map(); @@ -82,17 +82,6 @@ test("static and live avatars update geometry, moods and colors, stop sleeping, for (const fn of changes) fn(); await tick(); expect(frames.size).toBe(1); - await act(async () => - root.render(), - ); - expect(container.querySelector("[data-avatar-scene]")).toBeNull(); - expect(container.querySelector("img")!.src).toBe(idle); - expect( - Number( - container.querySelector("[data-state]")!.style.opacity, - ), - ).toBeLessThan(1); - expect(frames.size).toBe(0); const next = { ...bot, diff --git a/apps/web/components/bot-avatar.tsx b/apps/web/components/bot-avatar.tsx index 4f1c18c6..c227c91e 100644 --- a/apps/web/components/bot-avatar.tsx +++ b/apps/web/components/bot-avatar.tsx @@ -4,7 +4,7 @@ import { type MountedAvatar, mountAvatar } from "open-bot-avatar/dom"; import type { BotAvatarDefinition } from "@crumble/server/contract/avatar"; import { cn } from "@/lib/utils"; -export type BotState = AvatarState | "sleeping"; +export type BotState = AvatarState; export type AvatarBot = { id: string; avatar: BotAvatarDefinition }; @@ -69,9 +69,8 @@ export function BotAvatar({ }) { const look = bot.avatar; - const still = !live || state === "sleeping"; - const shown = state === "sleeping" ? "idle" : state; - const host = useLiveAvatar(still, look, shown); + const still = !live; + const host = useLiveAvatar(still, look, state); const svg = useMemo( () => @@ -79,11 +78,11 @@ export function BotAvatar({ ? renderAvatarSvg(look.definition, { color: look.color, eyeColor: look.eyeColor, - state: shown, + state, reducedMotion: true, }) : "", - [still, look, shown], + [still, look, state], ); return ( @@ -91,11 +90,7 @@ export function BotAvatar({ aria-hidden="true" data-state={state} className={cn("inline-block shrink-0", className)} - style={{ - width: size, - height: size, - opacity: state === "sleeping" ? 0.45 : 1, - }} + style={{ width: size, height: size }} > {still ? ( - +
{schedule.name} diff --git a/apps/web/features/avatars/avatars.tsx b/apps/web/features/avatars/avatars.tsx index 393ef181..8c8c5b26 100644 --- a/apps/web/features/avatars/avatars.tsx +++ b/apps/web/features/avatars/avatars.tsx @@ -55,7 +55,6 @@ const PREVIEW_STATES: BotState[] = [ "waiting", "blocked", "done", - "sleeping", ]; function AvatarStatePreviews({ value }: { value: BotAvatarDefinition }) { diff --git a/apps/web/features/bot-chat/avatar.tsx b/apps/web/features/bot-chat/avatar.tsx index dd1c581f..fdf06081 100644 --- a/apps/web/features/bot-chat/avatar.tsx +++ b/apps/web/features/bot-chat/avatar.tsx @@ -4,7 +4,6 @@ import { type BotState, BotAvatar, } from "@/components/bot-avatar"; -import type { Bot } from "@/features/bots/api"; import { type Working, isBusy, useWorking, workingAvatar } from "./working"; const DONE_MS = 4000; @@ -34,31 +33,22 @@ function useJustFinished(working: Working) { return finished; } -const avatarState = ( - enabled: boolean, - working: Working, - finished: boolean, -): BotState => { - if (!enabled) return "sleeping"; - - if (finished) return "done"; - - return workingAvatar(working); -}; +const avatarState = (working: Working, finished: boolean): BotState => + finished ? "done" : workingAvatar(working); export function LiveBotAvatar({ bot, size, className, }: { - bot: AvatarBot & Pick; + bot: AvatarBot; size: number; className?: string; }) { const working = useWorking(bot.id); const finished = useJustFinished(working); - const state = avatarState(bot.enabled, working, finished); + const state = avatarState(working, finished); return ( Date: Fri, 20 Nov 2026 21:01:52 +0100 Subject: [PATCH 4/4] refactor(web): preview every avatar state from the library's list --- apps/web/features/avatars/avatars.tsx | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/apps/web/features/avatars/avatars.tsx b/apps/web/features/avatars/avatars.tsx index 8c8c5b26..dff54c7d 100644 --- a/apps/web/features/avatars/avatars.tsx +++ b/apps/web/features/avatars/avatars.tsx @@ -14,7 +14,8 @@ import { invalidateBots, } from "@/features/bots/api"; import { send } from "@/lib/api"; -import { BotAvatar, type BotState } from "@/components/bot-avatar"; +import { STATES } from "open-bot-avatar"; +import { BotAvatar } from "@/components/bot-avatar"; import { AvatarEditor } from "./avatar-editor"; function useAvatarDraft() { @@ -48,19 +49,10 @@ function useAvatarDraft() { return { bots, selected, value, save, select, edit }; } -const PREVIEW_STATES: BotState[] = [ - "idle", - "thinking", - "working", - "waiting", - "blocked", - "done", -]; - function AvatarStatePreviews({ value }: { value: BotAvatarDefinition }) { return (
- {PREVIEW_STATES.map((state) => ( + {STATES.map((state) => (