Repository navigation
feat(web): show what bots are doing on their avatars - #150
Conversation
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.
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
| {(["idle", "working", "sleeping"] satisfies BotState[]).map((state) => ( | ||
| <div className="mx-auto flex max-w-92 flex-wrap justify-center gap-4"> | ||
| {( | ||
| [ |
There was a problem hiding this comment.
Isnt there a cleaner way to do this?
There was a problem hiding this comment.
Moved the list to a top-level PREVIEW_STATES: BotState[] constant, so the .map no longer needs the inline satisfies. Fixed in 85f1412.
| import { isBusy, useWorking } from "./working"; | ||
| import { type Working, isBusy, useWorking, workingAvatar } from "./working"; | ||
|
|
||
| /** How long an avatar celebrates after a reply finishes. */ |
| /** 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. */ |
There was a problem hiding this comment.
Removed in 85f1412, along with the other comments this PR added.
| /** Thinking shows the dots, a retry the warning mark; a finished or failed run rests. */ | ||
| export const workingAvatar: Record<Working, BotState> = { | ||
| idle: "idle", | ||
| thinking: "thinking", | ||
| writing: "working", | ||
| searching: "working", |
There was a problem hiding this comment.
There has to be a cleaner way for this aswell. Also, no comments allowed
There was a problem hiding this comment.
Replaced the table with a function, workingAvatar(working): thinking → thinking, struggling → blocked, otherwise isBusy picks working or idle. Comment removed too. Fixed in 85f1412.
| idle: "is here", | ||
| }; | ||
|
|
||
| const MEMBER_AVATAR = { |
There was a problem hiding this comment.
There has to be a cleaner way than this weird typescript magic
There was a problem hiding this comment.
Replaced it with a plain function, memberAvatar(status): running → working, queued → waiting, anything else → idle. Fixed in 85f1412.
| const PREVIEW_STATES: BotState[] = [ | ||
| "idle", | ||
| "thinking", | ||
| "working", | ||
| "waiting", | ||
| "blocked", | ||
| "done", | ||
| ]; | ||
|
|
||
| function AvatarStatePreviews({ value }: { value: BotAvatarDefinition }) { | ||
| return ( | ||
| <div className="grid grid-cols-3 gap-4"> | ||
| {(["idle", "working", "sleeping"] satisfies BotState[]).map((state) => ( | ||
| <div className="mx-auto flex max-w-92 flex-wrap justify-center gap-4"> | ||
| {PREVIEW_STATES.map((state) => ( |
There was a problem hiding this comment.
why is PREVIEW_STATES needed here? Cant we just use BotState[] directly or something else? I feel like we are going to forget to update this arry in the future
There was a problem hiding this comment.
Good point. The library exports STATES, its own list of every avatar state, so the preview now maps over that and the local list is gone. New states from a future open-bot-avatar version show up without a change here. Fixed in 57fa407.
Summary
Upgrades
open-bot-avatarfrom 0.2.0 to 0.3.0 and maps what a bot is doing to the library's new avatar states. Live avatars now mount once per look and switch state withupdate(), so they ease between states instead of being destroyed and remounted.thinkingthinking(three hopping dots)writing,searching,remembering,tinkeringworkingstruggling(retrying)blocked(exclamation mark)idledonefor 4 s, thenidlefailed,idleidlequeuedwaitingidle(the dimmedsleepingavatar is removed)doneplays only on a busy →idletransition seen by the client: not after a failed run, not when a page loads with an idle bot, and it stops as soon as the bot is busy again. Group chats don't celebrate. The/avatarspage previews all six states.Why
Before this change, every busy bot showed the same thinking animation, whatever it was doing, and each state change rebuilt the avatar. 0.3.0 adds states that match the activity the server already reports.
Evidence
bun run checkpasses: lint, format, typecheck,openapi:check, and tests (1323 pass, 0 fail). The pre-push suite and theapps/docsbuild also pass./avatarsin Chrome, all seven states (including the since-removedsleeping) render and animate,workinganddonedraw their ribbons, switching gallery shapes redraws every preview, and the console shows no errors.doneafter a real reply. The test account had no bots.validateAvatarandexamplesare the same in 0.2.0 and 0.3.0 (diffed the published sources), so stored definitions still validate.Risk and rollback
Reversibility: Reversible
Blast radius: Web bot avatars (home, sidebar, bot chat header and details, group chat header,
/avatars). The server only uses the validator and examples, which didn't change.open-bot-avatar0.3.0 was published on 2026-11-20. It installs only becausebunfig.tomlalready exempts this package fromminimumReleaseAge.