diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index ba0f370de9dca..50ee2cf4aa0ee 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -1,3 +1,6 @@
+import { resolveBotPresence } from "./bots/botPresence";
+import { resolveThreadLastVisitedAt, resolveThreadStatusPill } from "./Sidebar.logic";
+import { useUiStateStore } from "../uiStateStore";
import { ChildThreadApprovals } from "./chat/ChildThreadApprovals";
import { workspaceAreaProps } from "../lib/workspaceFocus";
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
@@ -1816,6 +1819,25 @@ export default function ChatView(props: ChatViewProps) {
reportedModelSelection,
);
const activeStanding = activeThreadShell?.standing ?? null;
+ const activeLocalLastVisitedAt = useUiStateStore((state) =>
+ activeThreadKey === null ? undefined : state.threadLastVisitedAtById[activeThreadKey],
+ );
+ const activeBotAvatarState = (() => {
+ if (!activeStanding || activeThreadShell === null) return undefined;
+ const pill = resolveThreadStatusPill({
+ thread: {
+ ...activeThreadShell,
+ lastVisitedAt: resolveThreadLastVisitedAt(
+ activeThreadShell.lastVisitedAt,
+ activeLocalLastVisitedAt,
+ ),
+ },
+ });
+ return resolveBotPresence(
+ pill === null ? null : { ...pill, errorClass: activeThreadShell.runtime?.lastErrorClass },
+ activeStanding.role,
+ ).avatarState;
+ })();
const botDetailsOpen = useRightPanelStore(
(state) =>
activeStanding !== null &&
@@ -3447,6 +3469,7 @@ export default function ChatView(props: ChatViewProps) {
: {})}
{...(threadFindEnabled ? { onFindInThread: openThreadFindStable } : {})}
standing={activeStanding}
+ botAvatarState={activeBotAvatarState}
activityCollapsed={
isStandingBot && activeThreadKey !== null
? { on: activityCollapsed, onToggle: toggleActivityCollapsed }
diff --git a/apps/web/src/components/bots/BotAvatar.test.tsx b/apps/web/src/components/bots/BotAvatar.test.tsx
index 963f847b4dfce..996f041f1c44b 100644
--- a/apps/web/src/components/bots/BotAvatar.test.tsx
+++ b/apps/web/src/components/bots/BotAvatar.test.tsx
@@ -18,13 +18,39 @@ describe("BotAvatar", () => {
);
});
- it("blinks only while running, and only when motion is allowed", () => {
- expect(
- renderToStaticMarkup(),
- ).toContain("motion-safe:animate-bot-blink");
- expect(renderToStaticMarkup()).not.toContain(
- "animate-bot-blink",
- );
+ it("blinks only while idle or running, and only when motion is allowed", () => {
+ for (const state of ["idle", "running"] as const) {
+ expect(
+ renderToStaticMarkup(),
+ ).toContain("motion-safe:animate-bot-blink");
+ }
+ for (const state of ["waiting", "needs-you", "failed"] as const) {
+ expect(
+ renderToStaticMarkup(),
+ ).not.toContain("animate-bot-blink");
+ }
+ });
+
+ it("gives each state its own motion, and never animates under reduced motion", () => {
+ const markup = (state: "idle" | "running" | "waiting" | "needs-you" | "failed") =>
+ renderToStaticMarkup();
+ expect(markup("idle")).toContain("motion-safe:animate-bot-breathe");
+ const running = markup("running");
+ expect(running).toContain("motion-safe:animate-bot-scan");
+ expect(running).toContain("motion-safe:animate-bot-antenna");
+ expect(running).toContain("motion-safe:animate-status-pulse");
+ expect(markup("waiting")).toContain("motion-safe:animate-bot-wait");
+ for (const state of ["idle", "running", "waiting"] as const) {
+ expect(markup(state)).not.toMatch(/(^|\s)animate-/);
+ }
+ });
+
+ it("marks an antenna on every avatar so the working pulse has something to move", () => {
+ for (const avatarId of THREAD_STANDING_AVATAR_IDS) {
+ expect(
+ renderToStaticMarkup(),
+ ).toContain("data-bot-antenna");
+ }
});
it("draws every avatar and falls back for unknown ids", () => {
diff --git a/apps/web/src/components/bots/BotAvatar.tsx b/apps/web/src/components/bots/BotAvatar.tsx
index ccbadb1d99d55..5e1ce178e706e 100644
--- a/apps/web/src/components/bots/BotAvatar.tsx
+++ b/apps/web/src/components/bots/BotAvatar.tsx
@@ -25,7 +25,7 @@ const AVATARS: Record<
head: (
<>
{FACE}
-
+
>
),
@@ -40,8 +40,8 @@ const AVATARS: Record<
head: (
<>
{FACE}
-
-
+
+
>
),
@@ -56,8 +56,8 @@ const AVATARS: Record<
head: (
<>
{FACE}
-
-
+
+
>
),
@@ -69,7 +69,7 @@ const AVATARS: Record<
head: (
<>
{FACE}
-
+
>
),
@@ -84,8 +84,8 @@ const AVATARS: Record<
head: (
<>
{FACE}
-
-
+
+
>
),
@@ -100,9 +100,9 @@ const AVATARS: Record<
head: (
<>
{FACE}
-
-
-
+
+
+
>
),
@@ -117,9 +117,9 @@ const AVATARS: Record<
head: (
<>
{FACE}
-
-
-
+
+
+
>
),
@@ -134,7 +134,7 @@ const AVATARS: Record<
head: (
<>
{FACE}
-
+
>
),
@@ -149,7 +149,7 @@ const AVATARS: Record<
<>
{FACE}
-
+
>
),
@@ -164,7 +164,7 @@ const AVATARS: Record<
head: (
<>
{FACE}
-
+
>
@@ -226,7 +226,7 @@ export const BOT_ACCENT_CLASSES: Record<
},
};
-export type BotAvatarState = "idle" | "running" | "needs-you" | "failed";
+export type BotAvatarState = "idle" | "running" | "waiting" | "needs-you" | "failed";
export function BotAvatar(props: {
readonly avatarId: string;
@@ -246,6 +246,9 @@ export function BotAvatar(props: {
"inline-flex shrink-0 items-center justify-center rounded-full bg-current/8",
props.size === "lg" ? "size-9" : props.size === "md" ? "size-7" : "size-5",
accent.text,
+ state === "idle" && "motion-safe:animate-bot-breathe",
+ state === "running" && "motion-safe:animate-status-pulse",
+ state === "waiting" && "motion-safe:animate-bot-wait",
state === "needs-you" && cn("ring-2", accent.ring),
state === "failed" && "ring-2 ring-destructive/80",
props.className,
@@ -260,11 +263,18 @@ export function BotAvatar(props: {
strokeLinejoin="round"
className={props.size === "lg" ? "size-7" : props.size === "md" ? "size-5.5" : "size-4"}
>
- {avatar.head}
+
+ {avatar.head}
+
+ {state === "running" ? (
+
+
+
+ ) : null}
{avatar.eyes}
diff --git a/apps/web/src/components/bots/botPresence.test.ts b/apps/web/src/components/bots/botPresence.test.ts
index 1db96abf47281..c291982714efd 100644
--- a/apps/web/src/components/bots/botPresence.test.ts
+++ b/apps/web/src/components/bots/botPresence.test.ts
@@ -24,6 +24,24 @@ describe("resolveBotPresence", () => {
});
});
+ it("holds a calm waiting state for waiting and usage-limited bots", () => {
+ expect(resolveBotPresence({ label: "Waiting" }, "Ops")).toEqual({
+ avatarState: "waiting",
+ line: "Waiting",
+ badge: null,
+ });
+ expect(resolveBotPresence({ label: "Failed", errorClass: "usage_limit" }, "Ops")).toEqual({
+ avatarState: "waiting",
+ line: "Limited",
+ badge: null,
+ });
+ expect(
+ resolveBotPresence({ label: "Failed", errorClass: "provider_error" }, "Ops").avatarState,
+ ).toBe(
+ "failed",
+ );
+ });
+
it("falls back to the role line when idle", () => {
expect(resolveBotPresence(null, "Daily digest")).toEqual({
avatarState: "idle",
diff --git a/apps/web/src/components/bots/botPresence.ts b/apps/web/src/components/bots/botPresence.ts
index fb640fba83378..5fc7bd22e048b 100644
--- a/apps/web/src/components/bots/botPresence.ts
+++ b/apps/web/src/components/bots/botPresence.ts
@@ -1,3 +1,5 @@
+import type { OrchestrationV2ProviderFailureClass } from "@t3tools/contracts";
+
import type { ThreadStatusPill } from "../Sidebar.logic";
import type { BotAvatarState } from "./BotAvatar";
@@ -11,9 +13,14 @@ export interface BotPresence {
const NEEDS_YOU = new Set(["Pending Approval", "Awaiting Input", "Guest Request", "Plan Ready"]);
+/** The pill plus the failure class, which the pill label does not carry. */
+export type BotPresenceInput = Pick & {
+ readonly errorClass?: OrchestrationV2ProviderFailureClass | null | undefined;
+};
+
/** Maps the thread's status pill onto a bot's quieter vocabulary. */
export function resolveBotPresence(
- pill: Pick | null,
+ pill: BotPresenceInput | null,
role: string | null | undefined,
): BotPresence {
const label = pill?.label ?? null;
@@ -21,10 +28,13 @@ export function resolveBotPresence(
return { avatarState: "needs-you", line: label, badge: "needs-you" };
if (label === "Working" || label === "Connecting")
return { avatarState: "running", line: label, badge: null };
+ // A usage limit is the bot waiting, not a failure: a calm glow, no failure ring.
+ if (label === "Failed" && pill?.errorClass === "usage_limit")
+ return { avatarState: "waiting", line: "Limited", badge: null };
if (label === "Failed") return { avatarState: "failed", line: "Failed", badge: null };
if (label === "Completed")
return { avatarState: "idle", line: role ?? "New reply", badge: "unread" };
- if (label === "Waiting") return { avatarState: "idle", line: "Waiting", badge: null };
+ if (label === "Waiting") return { avatarState: "waiting", line: "Waiting", badge: null };
return { avatarState: "idle", line: role ?? null, badge: null };
}
diff --git a/apps/web/src/components/chat/ChatHeader.tsx b/apps/web/src/components/chat/ChatHeader.tsx
index d79b59214744c..0cad8953de62f 100644
--- a/apps/web/src/components/chat/ChatHeader.tsx
+++ b/apps/web/src/components/chat/ChatHeader.tsx
@@ -44,7 +44,7 @@ import { cn } from "~/lib/utils";
import { textDirection } from "~/textDirection";
import { useClientSettings } from "../../hooks/useSettings";
import { GuestShareIndicator } from "./GuestShareControls";
-import { BotAvatar } from "../bots/BotAvatar";
+import { BotAvatar, type BotAvatarState } from "../bots/BotAvatar";
interface ChatHeaderProps {
activeThreadEnvironmentId: EnvironmentId;
@@ -61,6 +61,8 @@ interface ChatHeaderProps {
onFindInThread?: ((threadRef: ScopedThreadRef) => void) | undefined;
/** A standing bot shows who it is instead of the project/thread breadcrumb. */
standing?: ThreadStanding | null | undefined;
+ /** Drives the bot avatar's motion in the header; idle when absent. */
+ botAvatarState?: BotAvatarState | undefined;
/**
* Collapse agent, automation and system activity, or null when the thread has
* no toggle. A standing thread passes it.
@@ -92,6 +94,7 @@ export const ChatHeader = memo(function ChatHeader({
onOpenProjectSettings,
onFindInThread,
standing,
+ botAvatarState,
activityCollapsed = null,
}: ChatHeaderProps) {
const activeProjectName = activeProject?.isScratch ? "No project" : activeProject?.title;
@@ -266,7 +269,12 @@ export const ChatHeader = memo(function ChatHeader({
data-testid="bot-thread-header"
onContextMenu={handleHeaderContextMenu}
>
-
+