Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(avatar): on a Team Cloud, give the body only to bots this person may restyle
mantrandeve339169130c8
diff --git a/src/components/bot-panel/AvatarEditorCard.tsx b/src/components/bot-panel/AvatarEditorCard.tsxindex f0530d9d75..305934170e 100644--- a/src/components/bot-panel/AvatarEditorCard.tsx+++ b/src/components/bot-panel/AvatarEditorCard.tsx@@ -7,6 +7,7 @@ import { bodyName, colorName, festivalName } from "@/lib/mascot-names";import type { LocaleKey } from "@/locales";import { colorSwatch, MAUS_COLOR_LABEL, MAUS_COLOR_NAMES, PICKABLE_STATES, type MausState } from "@/lib/mascot";import { useStore, type Bot } from "@/state/store";+import { mayRename, useTeamPeople } from "@/state/team-people";import { MASCOT_BODY_IDS } from "../../../shared/mascot-bodies";import { FESTIVAL_IDS, FESTIVALS, isCarvedBody, type BotBodyId } from "../../../shared/bot-body";import { useFestivalDress, wornBody } from "@/lib/festival-dress";@@ -67,7 +68,9 @@ export function AvatarEditorCard({ bot, activeState, onPatch, onClose }: {const pickMascot = (patch: AvatarPatch) => onPatch(crop === "mascot" ? patch : { ...patch, avatarCrop: "mascot" });const body = bot.mascotBody ?? "cursor";const { state, dispatch } = useStore();- const othersToMatch = state.bots.filter((other) => other.id !== bot.id && (other.mascotBody ?? "cursor") !== body);+ const team = useTeamPeople();+ const othersToMatch = state.bots.filter((other) => other.id !== bot.id && (other.mascotBody ?? "cursor") !== body+ && (team ? mayRename(other, team) : !state.config?.team));const festival = useFestivalDress();const costume = wornBody(bot.mascotBody, bot.color, festival);const [moreLooks, setMoreLooks] = useState(() => Boolean(festival) || isCarvedBody(body) || Boolean(bot.mascotExpression && bot.mascotExpression !== "idle"));diff --git a/src/components/bot-panel/PanelShell.dom.test.ts b/src/components/bot-panel/PanelShell.dom.test.tsindex 4dfd076574..17e7da142b 100644--- a/src/components/bot-panel/PanelShell.dom.test.ts+++ b/src/components/bot-panel/PanelShell.dom.test.ts@@ -7,7 +7,7 @@ import { createRoot, type Root } from "react-dom/client";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import type { Bot, BotSettingsSection } from "@/state/store";-const fixture = vi.hoisted(() => ({ dispatch: vi.fn(), settingsOpen: false, bots: [] as Bot[] }));+const fixture = vi.hoisted(() => ({ dispatch: vi.fn(), settingsOpen: false, bots: [] as Bot[], team: null as null | { admin: boolean; me: { email: string } } }));vi.mock("@/state/store", async (importOriginal) => {const original = await importOriginal<typeof import("@/state/store")>();return {@@ -15,6 +15,10 @@ vi.mock("@/state/store", async (importOriginal) => {useStore: () => ({ state: { ...original.initialState, settingsOpen: fixture.settingsOpen, bots: fixture.bots }, dispatch: fixture.dispatch, flushBotPatches: () => Promise.resolve(null) }),};});+vi.mock("@/state/team-people", async (importOriginal) => ({+ ...await importOriginal<typeof import("@/state/team-people")>(),+ useTeamPeople: () => fixture.team,+}));vi.mock("@/lib/interface-mode", () => ({ useAdvancedMode: () => false, readAdvancedMode: () => false, setAdvancedMode: vi.fn() }));vi.mock("../DesktopCapabilities", async (importOriginal) => ({...await importOriginal<typeof import("../DesktopCapabilities")>(),@@ -79,6 +83,7 @@ const onWindowKey = (event: KeyboardEvent) => {beforeEach(() => {fixture.dispatch.mockReset();fixture.bots = [];+ fixture.team = null;onClose.mockReset();dialogCloses.mockReset();window.addEventListener("keydown", onWindowKey);@@ -409,6 +414,21 @@ describe("one body for every bot", () => {]);});+ it("on a Team Cloud, leaves out the bots this person may not restyle", async () => {+ fixture.team = { admin: false, me: { email: "[email protected]" } };+ fixture.bots = [+ roundBot,+ { ...bot, id: "edits", yourAccess: "edit" },+ { ...bot, id: "chats", yourAccess: "chat" },+ { ...bot, id: "my-mausbot", yourAccess: "chat", defaultBot: { person: "[email protected]" } },+ { ...bot, id: "their-mausbot", yourAccess: "chat", defaultBot: { person: "[email protected]" } },+ ] as Bot[];+ await openEditor(roundBot);+ expect(everywhere()?.textContent).toBe("Give this body to the other bots (2)");+ click(everywhere());+ expect(fixture.dispatch.mock.calls.map(([action]) => action.botId)).toEqual(["edits", "my-mausbot"]);+ });+it("is not offered once every bot wears this body, or while the bot shows a picture", async () => {fixture.bots = [roundBot, { ...bot, id: "cara", mascotBody: "circle" }];await openEditor(roundBot);