Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Sidebar: red dot for a bot whose last turn failed (#6105)

Bugfixer 2b3f370a30176
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 1a3ab11863..c6126aae21 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -91,7 +91,7 @@ import { attentionHasRunningWork, attentionJumpAction, attentionUnpinAction, cro
import { SidebarNoBots, SidebarTileGrid } from "./SidebarTiles";
import { BotContextMenu } from "./SidebarBotMenu";
export { BotContextMenu };
-import { AvatarActivityDot, RowDot, RowStatusText, rowSurface } from "./SidebarRowMarkers";
+import { AvatarActivityDot, AvatarCornerDot, RowDot, RowStatusText, rowSurface } from "./SidebarRowMarkers";
import { SidebarAttentionPanel } from "./SidebarAttentionPanel";
@@ -728,7 +728,7 @@ export const BotListItem = memo(function BotListItem(props: BotRowProps) {
selected ? "bg-raised" : "hover:bg-raised/50",
simpleRow && rowSurface(selected),
);
- const { waiting, working, teammateWait, queued } = sidebarBotStatus(bot, pendingQueued);
+ const { waiting, working, failed, teammateWait, queued } = sidebarBotStatus(bot, pendingQueued, visible);
const { unread, noticing } = useBotUnread(bot);
const onLiveCall = liveBadgeFor(bot.id, liveMedia, liveCall);
const body = (
@@ -744,7 +744,7 @@ export const BotListItem = memo(function BotListItem(props: BotRowProps) {
/>
{/* Bottom-left, clear of the status dots on the right and of the row's hover actions. */}
{(iconOnly || !simpleList) && <BotModelBadge bot={bot} instances={instances} avatarSize={avatarSize} />}
- {simpleRow && <AvatarActivityDot activity={working ? "working" : teammateWait ? "teammate" : queued && !waiting ? "queued" : null} />}
+ {simpleRow && <AvatarActivityDot activity={working ? "working" : failed ? "failed" : teammateWait ? "teammate" : queued && !waiting ? "queued" : null} />}
{!simpleRow && working && (
<span
data-testid="working-dot"
@@ -756,10 +756,7 @@ export const BotListItem = memo(function BotListItem(props: BotRowProps) {
)}
{!simpleRow && waiting && <span data-testid="waiting-dot" role="status" aria-label={t("sidebar.preview.waiting")} title={t("sidebar.preview.waiting")}
className={cn("absolute -right-0.5 -bottom-0.5 flex items-center justify-center overflow-hidden rounded-full border-2 border-panel bg-warning font-black text-panel", iconOnly ? "size-5 text-[14px]" : "size-4 text-[12px]")}><span aria-hidden="true">!</span></span>}
- {!simpleRow && teammateWait && <span data-testid="teammate-wait-dot" role="status" aria-label={t("sidebar.preview.waitingOnTeammate")} title={t("sidebar.preview.waitingOnTeammate")}
- className={cn("absolute -right-0.5 -bottom-0.5 rounded-full border-2 border-panel bg-accent", iconOnly ? "size-3" : "size-2.5")} />}
- {!simpleRow && !teammateWait && !waiting && !working && queued && <span data-testid="queued-dot" role="status" aria-label={t("task.queued")} title={t("task.queued")}
- className={cn("absolute -right-0.5 -bottom-0.5 rounded-full border-2 border-panel bg-ink-secondary", iconOnly ? "size-3" : "size-2.5")} />}
+ {!simpleRow && <AvatarCornerDot activity={failed ? "failed" : teammateWait ? "teammate" : queued && !waiting && !working ? "queued" : null} large={iconOnly} />}
{bot.chiefOfStaff && (iconOnly || simpleRow) && (
<span className="absolute -left-1 -top-1 flex rounded-full bg-raised p-[3px]">
<Crown size={11} strokeWidth={2.25} className="shrink-0 text-accent" role="img" aria-label={t("sidebar.bot.chiefOfStaff")} data-testid="chief-crown">
@@ -839,7 +836,7 @@ export const BotListItem = memo(function BotListItem(props: BotRowProps) {
{simpleRow && <BotEngineMark bot={bot} instances={instances} className="ms-auto" />}
{!simpleRow && unread && <span className="size-2 shrink-0 rounded-full bg-accent" aria-label={t("task.unreadMany")} />}
</div>}
- {simpleRow && <RowStatusText working={working} unread={unread} />}
+ {simpleRow && <RowStatusText working={working} failed={failed} unread={unread} />}
</div>
</>
);
diff --git a/src/components/SidebarBotActivity.tsx b/src/components/SidebarBotActivity.tsx
index d86e2cfc36..d918f5f194 100644
--- a/src/components/SidebarBotActivity.tsx
+++ b/src/components/SidebarBotActivity.tsx
@@ -7,6 +7,7 @@ import { t } from "@/lib/i18n";
import { isArchived, orderedSidebarThreads, orderedThreadList, threadRecency, threadUpdatedLabel } from "./SidebarThreadRow";
import type { SidebarDensity } from "@/lib/sidebar-preferences";
import { localizedTaskTitle } from "@/lib/task-title";
+import { endedOnFailure } from "@/lib/mascot";
export function sidebarBotActivityTasks(bot: Bot, queued: Record<string, unknown[]>, archivedApprovals = false): Array<Task & { queued: boolean }> {
const tasks = bot.tasks ?? [{
@@ -29,12 +30,15 @@ export function runningRoutineRuns(bot: Bot): Array<Task & { queued: boolean }>
return orderedThreadList((bot.tasks ?? []).filter(runningRoutineRun).map((task) => ({ ...task, queued: false })));
}
-export function sidebarBotStatus(bot: Bot, queued: Record<string, unknown[]>) {
+/** `visible` is the bot's shown conversation: when it ended on an error (a turn that failed, or an engine that could not
+ * start, both end on the failed-turn row), the bot is `failed` (red), kept apart from `waiting` (orange, it needs your answer). */
+export function sidebarBotStatus(bot: Bot, queued: Record<string, unknown[]>, visible?: Bot["messages"]) {
const tasks = sidebarBotActivityTasks(bot, queued);
const waiting = bot.activity === "waiting-on-you" || tasks.some((task) => task.activity === "waiting-on-you");
const working = !waiting && (Boolean(bot.busy) || tasks.some((task) => task.busy || task.activity === "working"));
- const teammateWait = !waiting && !working && (Boolean(bot.waitingForTeammates) || tasks.some((task) => Boolean(task.waitingForTeammates)));
- return { waiting, working, teammateWait, queued: tasks.some((task) => task.queued) };
+ const failed = !waiting && !working && endedOnFailure(visible);
+ const teammateWait = !waiting && !working && !failed && (Boolean(bot.waitingForTeammates) || tasks.some((task) => Boolean(task.waitingForTeammates)));
+ return { waiting, working, failed, teammateWait, queued: tasks.some((task) => task.queued) };
}
export function threadsWhenTreeHidden(bot: Bot, queued: Record<string, unknown[]>) {
diff --git a/src/components/SidebarBotListItem.test.ts b/src/components/SidebarBotListItem.test.ts
index d1e73caad8..9112b9f4bd 100644
--- a/src/components/SidebarBotListItem.test.ts
+++ b/src/components/SidebarBotListItem.test.ts
@@ -351,6 +351,36 @@ describe("BotListItem", () => {
expect(markup).toContain("Waiting on a teammate…");
});
+ it("marks a bot whose last turn failed with a red dot, kept apart from the orange waiting badge", () => {
+ const failedTurn = [
+ { id: "u1", role: "user", kind: "text", text: "check the site", at: 1 },
+ { id: "e1", role: "bot", kind: "activity", at: 2, tool: { name: "error: The site did not answer.", ok: false } },
+ ] as Bot["messages"];
+ const opening = (markup: string, testId: string) => markup.match(new RegExp(`<span[^>]*data-testid="${testId}"[^>]*>`))?.[0] ?? "";
+ const failed = renderRow(bot({ messages: failedTurn }));
+ const dot = opening(failed, "failed-dot");
+ expect(dot).toContain("bg-danger");
+ expect(dot).toContain('role="status"');
+ expect(dot).toContain('aria-label="Ran into a problem"');
+ expect(dot).toContain("size-2.5");
+ expect(failed).not.toContain('data-testid="waiting-dot"');
+ expect(failed).not.toContain("bg-warning");
+ expect(opening(renderRow(bot({ messages: failedTurn }), "icons"), "failed-dot")).toContain("size-3");
+ // An engine that could not start writes the same row in its own thread; another thread's state alone paints nothing.
+ expect(renderRow(bot({ activity: "dead" }))).not.toContain('data-testid="failed-dot"');
+ // A failure outranks a teammate wait, but a question for you or a new turn already running wins.
+ const teammate = renderRow(bot({ messages: failedTurn, waitingForTeammates: true }));
+ expect(teammate).toContain('data-testid="failed-dot"');
+ expect(teammate).not.toContain('data-testid="teammate-wait-dot"');
+ const waiting = renderRow(bot({ messages: failedTurn, activity: "waiting-on-you" }));
+ expect(waiting).toContain('data-testid="waiting-dot"');
+ expect(waiting).not.toContain('data-testid="failed-dot"');
+ const retrying = renderRow(bot({ messages: failedTurn, busy: true }));
+ expect(retrying).toContain('data-testid="working-dot"');
+ expect(retrying).not.toContain('data-testid="failed-dot"');
+ expect(renderRow(bot({ messages: [{ ...failedTurn[1]!, tool: { name: "Read", ok: true } }] }))).not.toContain('data-testid="failed-dot"');
+ });
+
it("keeps real sibling work visible while another thread waits for a teammate", () => {
const markup = renderRow(bot({ waitingForTeammates: true, busy: true, activity: "working" }));
expect(markup).toContain('data-testid="working-dot"');
diff --git a/src/components/SidebarRowMarkers.tsx b/src/components/SidebarRowMarkers.tsx
index 991acb3c08..9af8f533cf 100644
--- a/src/components/SidebarRowMarkers.tsx
+++ b/src/components/SidebarRowMarkers.tsx
@@ -8,10 +8,11 @@ export function rowSurface(selected: boolean): string {
: "[--row:var(--color-panel)] max-md:[--row:var(--color-app)] hover:[--row:color-mix(in_srgb,var(--color-raised)_50%,var(--color-panel))]";
}
-export type RowActivity = "working" | "teammate" | "queued";
+export type RowActivity = "working" | "failed" | "teammate" | "queued";
const ACTIVITY = {
working: { tone: "bg-success", label: () => t("chat.activity.working"), testId: "working-dot" },
+ failed: { tone: "bg-danger", label: () => t("sidebar.preview.failed"), testId: "failed-dot" },
teammate: { tone: "bg-accent", label: () => t("sidebar.preview.waitingOnTeammate"), testId: "teammate-wait-dot" },
queued: { tone: "bg-ink-secondary", label: () => t("task.queued"), testId: "queued-dot" },
} as const satisfies Record<RowActivity, { tone: string; label: () => string; testId: string }>;
@@ -23,6 +24,14 @@ export function AvatarActivityDot({ activity }: { activity: RowActivity | null }
return <span aria-hidden="true" data-testid={testId} title={label()} className={cn("absolute bottom-0.5 right-0.5 size-2 rounded-full ring-2 ring-[var(--row)]", tone)} />;
}
+/** The same marker on a full row's avatar: a larger dot on its bottom-right corner, cut against the panel. */
+export function AvatarCornerDot({ activity, large }: { activity: Exclude<RowActivity, "working"> | null; large: boolean }) {
+ if (!activity) return null;
+ const { tone, label, testId } = ACTIVITY[activity];
+ return <span data-testid={testId} role="status" aria-label={label()} title={label()}
+ className={cn("absolute -right-0.5 -bottom-0.5 rounded-full border-2 border-panel", tone, large ? "size-3" : "size-2.5")} />;
+}
+
/** Unread, or waiting for the person (which wins): one dot at the row's top right, in the spot its ⋯ takes on hover
* or focus. A touch screen always shows the ⋯, so there the dot sits just before it, at the end of the name line. */
export function RowDot({ waiting = false }: { waiting?: boolean }) {
@@ -39,7 +48,7 @@ export function RowDot({ waiting = false }: { waiting?: boolean }) {
}
/** What the row's markers show, said once for a screen reader; a waiting row's preview already says it. */
-export function RowStatusText({ working = false, unread }: { working?: boolean; unread: boolean }) {
- const text = [working ? t("chat.activity.working") : "", unread ? t("task.unread") : ""].filter(Boolean).join(", ");
+export function RowStatusText({ working = false, failed = false, unread }: { working?: boolean; failed?: boolean; unread: boolean }) {
+ const text = [working ? t("chat.activity.working") : "", failed ? t("sidebar.preview.failed") : "", unread ? t("task.unread") : ""].filter(Boolean).join(", ");
return text ? <span className="sr-only">{text}</span> : null;
}
diff --git a/src/components/SidebarTiles.test.ts b/src/components/SidebarTiles.test.ts
index 2c779ed42b..6ee17f09b9 100644
--- a/src/components/SidebarTiles.test.ts
+++ b/src/components/SidebarTiles.test.ts
@@ -11,7 +11,7 @@ vi.mock("@/lib/interface-mode", async (original) => ({
}));
vi.mock("./DesktopCapabilities", () => ({ useDesktopCapabilities: () => ({}) }));
-import { botRowProps } from "./Sidebar";
+import { BotListItem, botRowProps } from "./Sidebar";
import { SidebarBotTile, SidebarTileGrid } from "./SidebarTiles";
const bot = (extra: Partial<Bot> = {}): Bot => ({
@@ -70,6 +70,18 @@ describe("the sidebar tiles", () => {
expect(unread).toContain('aria-label="MausBot · Unread"');
});
+ it("shows a failed last turn as a red dot on the tile and on a Simple row, never the orange waiting one", () => {
+ const failed = bot({ messages: [{ id: "e1", role: "bot", kind: "activity", at: 2, tool: { name: "error: The site did not answer.", ok: false } }] as Bot["messages"] });
+ const html = renderToStaticMarkup(createElement(SidebarBotTile, props(failed)));
+ expect(html).toMatch(/data-testid="failed-dot"[^>]*class="[^"]*\bbg-danger\b/);
+ expect(html).toContain('aria-label="MausBot · Ran into a problem"');
+ expect(html).not.toContain('data-testid="waiting-dot"');
+ const row = renderToStaticMarkup(createElement(BotListItem, props(failed)));
+ expect(row).toMatch(/data-testid="failed-dot"[^>]*class="[^"]*\bbg-danger\b/);
+ expect(row).not.toContain('data-testid="waiting-dot"');
+ expect(row).toContain('<span class="sr-only">Ran into a problem</span>');
+ });
+
it("opens the bot on Enter and its menu from the ContextMenu key", () => {
let tree: ReactNode;
function Capture() { tree = tile({ ...props(bot()), primary: true }); return tree; }
diff --git a/src/components/SidebarTiles.tsx b/src/components/SidebarTiles.tsx
index 514eb65b3c..3bf2f2aa1f 100644
--- a/src/components/SidebarTiles.tsx
+++ b/src/components/SidebarTiles.tsx
@@ -30,11 +30,11 @@ export const SidebarBotTile = memo(function SidebarBotTile({ primary = false, dr
const remoteClient = typeof window !== "undefined" && window.ogb?.remoteClient?.active === true;
const [renaming, setRenaming] = useState(false);
const visible = useVisibleMessages(bot);
- const { waiting, working, teammateWait, queued } = sidebarBotStatus(bot, pendingQueued);
+ const { waiting, working, failed, teammateWait, queued } = sidebarBotStatus(bot, pendingQueued, visible);
const { unread, noticing } = useBotUnread(bot);
const onLiveCall = liveBadgeFor(bot.id, liveMedia, liveCall);
const tooltip = botTooltip(bot, instances);
- const status = waiting ? t("sidebar.preview.waiting") : working ? t("chat.activity.working") : teammateWait ? t("sidebar.preview.waitingOnTeammate") : queued ? t("task.queued") : "";
+ const status = waiting ? t("sidebar.preview.waiting") : working ? t("chat.activity.working") : failed ? t("sidebar.preview.failed") : teammateWait ? t("sidebar.preview.waitingOnTeammate") : queued ? t("task.queued") : "";
const label = [bot.name, bot.chiefOfStaff ? t("sidebar.bot.chiefOfStaff") : "", onLiveCall ? t("call.live.badge") : "", status, unread ? t("task.unread") : ""].filter(Boolean).join(" · ");
const reorder = pinnedCircleDragHandlers(bot.id, { drag, dragging, prevId, nextId });
const open = () => openBotRow(dispatch, bot, showThreads, selected);
@@ -101,6 +101,7 @@ export const SidebarBotTile = memo(function SidebarBotTile({ primary = false, dr
) : waiting ? (
<span data-testid="waiting-dot" aria-hidden="true" className={cn("absolute -right-1 -top-1 flex size-4 items-center justify-center rounded-full bg-warning text-[11px] font-black leading-none text-panel", RING)}>!</span>
) : working ? dot("working-dot", "bg-success")
+ : failed ? dot("failed-dot", "bg-danger")
: teammateWait ? dot("teammate-wait-dot", "bg-accent")
: queued ? dot("queued-dot", "bg-ink-tertiary")
: unread ? dot("unread-dot", "bg-accent")
diff --git a/src/lib/mascot.ts b/src/lib/mascot.ts
index 5b79291c48..4a71852fed 100644
--- a/src/lib/mascot.ts
+++ b/src/lib/mascot.ts
@@ -150,13 +150,20 @@ export type MascotBotProfile = {
messages?: MascotMessage[];
};
+const isFailedStep = (message: MascotMessage | undefined) => message?.kind === "activity" && message.tool?.ok === false;
+
+/** The conversation ended on a failed step: the turn's error row, or a tool that failed with nothing after it. */
+export function endedOnFailure(messages: readonly MascotMessage[] | undefined): boolean {
+ return isFailedStep(lastNonReceipt(messages));
+}
+
export function stateForBot(bot: MascotBotProfile): MausState {
const pinned = normalizeState(bot.mascotExpression);
if (pinned) return pinned;
const last = lastNonReceipt(bot.messages);
- if (last?.kind === "activity" && last.tool?.ok === false) return "alerting";
+ if (isFailedStep(last)) return "alerting";
if (bot.busy) return "working";
if (botShowsUnread(bot)) return "notifying";
if (last?.kind === "options") return "curious";
diff --git a/src/locales/de.json b/src/locales/de.json
index e248273afa..bf50df1185 100644
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@ -791,6 +791,7 @@
"sidebar.noMatch": "Nichts passt zu „{query}“",
"sidebar.preview.waiting": "Wartet auf dich…",
"sidebar.preview.waitingOnTeammate": "Wartet auf einen Kollegen…",
+ "sidebar.preview.failed": "Ist auf ein Problem gestoßen",
"sidebar.preview.working": "Arbeitet…",
"sidebar.preview.botWorking": "{name} arbeitet…",
"sidebar.preview.aBot": "Ein Bot",
diff --git a/src/locales/en.json b/src/locales/en.json
index 721b0bfdaf..f1f1a7c64d 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -2267,6 +2267,7 @@
"sidebar.noMatch": "Nothing matches “{query}”",
"sidebar.preview.waiting": "Waiting for you…",
"sidebar.preview.waitingOnTeammate": "Waiting on a teammate…",
+ "sidebar.preview.failed": "Ran into a problem",
"sidebar.preview.working": "Working…",
"sidebar.preview.botWorking": "{name} is working…",
"sidebar.preview.botWorkingQueued": "{name} is working… · {count} queued",
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index 99eb7ae562..1dddd4ccd0 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -2100,6 +2100,7 @@
"sidebar.noMatch": "Nenhum resultado para “{query}”",
"sidebar.preview.waiting": "Esperando por você…",
"sidebar.preview.waitingOnTeammate": "Esperando um colega…",
+ "sidebar.preview.failed": "Teve um problema",
"sidebar.preview.working": "Trabalhando…",
"sidebar.preview.botWorking": "{name} está trabalhando…",
"sidebar.preview.botWorkingQueued": "{name} está trabalhando… · {count} na fila",
diff --git a/src/locales/source-hashes.json b/src/locales/source-hashes.json
index 8ef3cf2950..c252f0320d 100644
--- a/src/locales/source-hashes.json
+++ b/src/locales/source-hashes.json
@@ -363,6 +363,7 @@
"sidebar.searchAria": "71468c6a111dcb536d73c3a5dbf90cd78c31371e3139d180b59ebd0050ec2acf",
"sidebar.noMatch": "5bb5e3f3f8eaec582b5d4972b1a1007e7c7704cf3c2f998524b473ac56f29eb9",
"sidebar.preview.waiting": "3df1d52ccc2543a1a9baf123d11ebffea62659924e477be09cfec067c593652a",
+ "sidebar.preview.failed": "213bff15eaf6048215a9f4732b2bce9b6edc2041470139400d7eb11bfaf8e7e4",
"sidebar.preview.waitingOnTeammate": "7b23fdce858e5972dca42cc31b29d48a8f40046bcf701e99b7fec5719c988663",
"sidebar.preview.working": "5474eef8d0f179c707cf418e2bbb468c77cc24edc5e9f5f4e137e85e06a8eea0",
"sidebar.preview.botWorking": "f60b4f8135768df2676ba2eb1157673285ee255578083d01b016f8d302746b95",
@@ -28000,6 +28001,7 @@
"sidebar.searchClose": "55656b5e434f4c069877f0c12174a14e67ef9619d30e796834b1216a03d9f677",
"sidebar.noMatch": "5bb5e3f3f8eaec582b5d4972b1a1007e7c7704cf3c2f998524b473ac56f29eb9",
"sidebar.preview.waiting": "3df1d52ccc2543a1a9baf123d11ebffea62659924e477be09cfec067c593652a",
+ "sidebar.preview.failed": "213bff15eaf6048215a9f4732b2bce9b6edc2041470139400d7eb11bfaf8e7e4",
"sidebar.preview.waitingOnTeammate": "7b23fdce858e5972dca42cc31b29d48a8f40046bcf701e99b7fec5719c988663",
"sidebar.preview.working": "5474eef8d0f179c707cf418e2bbb468c77cc24edc5e9f5f4e137e85e06a8eea0",
"sidebar.preview.botWorking": "f60b4f8135768df2676ba2eb1157673285ee255578083d01b016f8d302746b95",