Skip to content

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

Hide the Chief-absent notice when another Chief is in the room

Bugfixer 2b477a15dd5b7
diff --git a/server/host/chief-rooms.test.ts b/server/host/chief-rooms.test.ts
index f912eac38b..d93670a788 100644
--- a/server/host/chief-rooms.test.ts
+++ b/server/host/chief-rooms.test.ts
@@ -83,4 +83,13 @@ describe("a room without its department's Chief", () => {
expect(chiefAbsentFrom(room("r", ["mira"], { kind: "mentions" }, { dm: true }), [chief])).toBeUndefined();
expect(chiefAbsentFrom(room("r", ["mira"], { kind: "mentions" }), [{ ...chief, hidden: true } as BotRecord])).toBeUndefined();
});
+
+ it("says nothing when another Chief of Staff is in the room, since work it hands out comes down at its level", () => {
+ const global = bot("global", true, "");
+ const teamChief = bot("lead", true, "Growth");
+ const general = (members: string[]) => room("r", members, { kind: "member", botId: members[0]! }, { section: "" });
+ expect(chiefAbsentFrom(general(["lead", "mira"]), [global, teamChief, bot("mira")])).toBeUndefined();
+ expect(chiefAbsentFrom(general(["mira"]), [global, teamChief, bot("mira")])).toEqual({ botId: "global", name: "GLOBAL" });
+ expect(chiefAbsentFrom(general(["lead"]), [global, { ...teamChief, hidden: true } as BotRecord])).toEqual({ botId: "global", name: "GLOBAL" });
+ });
});
diff --git a/server/host/chief-rooms.ts b/server/host/chief-rooms.ts
index 5bd80baf6a..bf7387f782 100644
--- a/server/host/chief-rooms.ts
+++ b/server/host/chief-rooms.ts
@@ -2,6 +2,7 @@
// that can't be changed then, or that never had its Chief, says so to the person instead.
import { chiefScope } from "../../shared/bot-owner.ts";
import type { GroupDefaultResponder } from "../../shared/wire.ts";
+import { chiefLevel } from "../chief-level.ts";
import { conversationLanguage, serverLine } from "../server-lines.ts";
import type { BotRecord, GroupRecord, Store } from "../store.ts";
@@ -17,12 +18,14 @@ const ledBy = (room: Pick<GroupRecord, "defaultResponder">, botId: string): bool
return lead.kind === "member" ? lead.botId === botId : lead.kind === "auto" && lead.fallbackBotId === botId;
};
-/** The department's Chief, when this room is a department's room and that Chief is not in it. */
+/** The department's Chief, when this room is a department's room and no Chief-level bot is in it (work a Chief-level
+ * member hands out already runs at its level). */
export function chiefAbsentFrom(room: Pick<GroupRecord, "dm" | "section" | "memberIds">, bots: readonly BotRecord[]): { botId: string; name: string } | undefined {
if (room.dm) return undefined;
const scope = chiefScope({ section: room.section });
const chief = bots.find((bot) => bot.chiefOfStaff && !bot.hidden && chiefScope(bot) === scope);
- return chief && !room.memberIds.includes(chief.id) ? { botId: chief.id, name: chief.name } : undefined;
+ const chiefHere = bots.some((bot) => !bot.hidden && room.memberIds.includes(bot.id) && chiefLevel(bot));
+ return chief && !chiefHere ? { botId: chief.id, name: chief.name } : undefined;
}
export function createChiefRooms(deps: ChiefRoomsDeps) {