Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix: keep a bot demoted from a hidden MausBot in the sidebar
AdityaUmale3b3089b0dc9c
diff --git a/server/routes/bot-patch.test.ts b/server/routes/bot-patch.test.tsindex 218eecc65f..85b3aa88c8 100644--- a/server/routes/bot-patch.test.ts+++ b/server/routes/bot-patch.test.ts@@ -248,6 +248,16 @@ describe("PATCH /api/bots/:id vpsAlias relocation guard", () => {});});+describe("PATCH /api/bots/:id defaultBot: null", () => {+ it("demotes a hidden MausBot to a regular bot that shows in the sidebar again", async () => {+ const { store, bot, patch } = fixture();+ store.patchBot(bot.id, { defaultBot: {}, sidebarHidden: true });+ expect((await patch(bot.id, { defaultBot: null })).status).toBe(200);+ expect(store.bot(bot.id)?.defaultBot).toBeUndefined();+ expect(store.bot(bot.id)?.sidebarHidden).toBeUndefined();+ });+});+describe("PATCH /api/bots/:id toolsOff", () => {it("stores known groups once each in one order, clears them with null or an empty list, and refuses anything else", async () => {const { store, bot, patch } = fixture();diff --git a/server/routes/bot-patch.ts b/server/routes/bot-patch.tsindex b36ecaffe8..d46c787ba1 100644--- a/server/routes/bot-patch.ts+++ b/server/routes/bot-patch.ts@@ -207,8 +207,9 @@ export function createBotPatchRoutes(deps: BotPatchRouteDeps): RouteHandler {for (const key of ["unread", "cloudBackend", "color", "mascotExpression", "mascotBody", "pinned", "hidden", "sidebarHidden", "welcomed"] as const) {if (body[key] !== undefined) patch[key] = body[key];}- // null clears the default-bot mark, demoting the bot to a regular (deletable) one.- if (body.defaultBot === null && existingBot?.defaultBot) patch.defaultBot = undefined;+ // null clears the default-bot mark, demoting the bot to a regular (deletable) one. MausBot's Show switch goes+ // with it: a regular bot is never hidden this way, and has no switch to show it again.+ if (body.defaultBot === null && existingBot?.defaultBot) Object.assign(patch, { defaultBot: undefined, sidebarHidden: undefined });const computerSpecified = Object.prototype.hasOwnProperty.call(body, "computer");let requestedComputer = existingBot?.computer;if (computerSpecified) {diff --git a/src/lib/default-bot.test.ts b/src/lib/default-bot.test.tsindex c9805998e3..4c252d45ce 100644--- a/src/lib/default-bot.test.ts+++ b/src/lib/default-bot.test.ts@@ -23,6 +23,12 @@ describe("MausBot in the sidebar", () => {expect(someoneElsesDefaultBot(bots[2]!, "[email protected]".toLowerCase())).toBe(true);});+ it("keeps a regular bot left with MausBot's Show switch off (demoted while hidden) in the sidebar", () => {+ const bots = [bot("demoted", { sidebarHidden: true }), bot("writer")];+ expect(hiddenFromSidebar(bots[0]!, null)).toBe(false);+ expect(partitionSidebarBots(bots, { viewerEmail: null }).unsectionedBots.map((entry) => entry.id)).toEqual(["demoted", "writer"]);+ });+it("finds the viewer's own MausBot: their own on a team, the place's otherwise, none until the viewer is known", () => {const team = [bot("ada-maus", { defaultBot: { person: "[email protected]" } }), bot("writer")];expect(myDefaultBot(team, undefined)).toBeUndefined();diff --git a/src/lib/default-bot.ts b/src/lib/default-bot.tsindex 4e729e1460..da9310bb5e 100644--- a/src/lib/default-bot.ts+++ b/src/lib/default-bot.ts@@ -34,8 +34,10 @@ export function someoneElsesDefaultBot(bot: DefaultBotFields, viewer: string | nreturn Boolean(bot.defaultBot && person && person !== (viewer ?? ""));}+/** MausBot with its Show switch off, or someone else's. The switch is MausBot's alone: a bot demoted while it was off+ * stays listed. */export function hiddenFromSidebar(bot: DefaultBotFields, viewer: string | null | undefined): boolean {- return Boolean(bot.sidebarHidden) || someoneElsesDefaultBot(bot, viewer);+ return Boolean(bot.defaultBot && bot.sidebarHidden) || someoneElsesDefaultBot(bot, viewer);}export function myDefaultBot<T extends DefaultBotFields>(bots: readonly T[], viewer: string | null | undefined): T | undefined {