Skip to content

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

fix: show a hidden MausBot again after profile rename or department move; search lists only default bots

AdityaUmalefe96a86e84d5
diff --git a/server/default-bot.test.ts b/server/default-bot.test.ts
index d04969059c..4b1f141b69 100644
--- a/server/default-bot.test.ts
+++ b/server/default-bot.test.ts
@@ -143,6 +143,22 @@ describe("MausBot, every person's helper", () => {
expect(briefChief(restarted)?.id).toBe(maus.id);
});
+ it("shows a hidden MausBot again after a profile rename or a department move", () => {
+ const store = new Store(selection);
+ const maus = boot(store)!;
+ const hiddenAfter = (change: () => unknown) => {
+ store.patchBot(maus.id, { sidebarHidden: true });
+ change();
+ return store.bot(maus.id)?.sidebarHidden;
+ };
+ expect(hiddenAfter(() => store.patchBotProfile(maus.id, { title: "Helper" }))).toBe(true);
+ expect(hiddenAfter(() => store.patchBotProfile(maus.id, { name: "Nova" }))).toBe(false);
+ expect(hiddenAfter(() => store.setBotsSection([maus.id], "Work"))).toBe(false);
+ expect(hiddenAfter(() => store.setBotsSection([maus.id], "Work"))).toBe(true);
+ expect(hiddenAfter(() => store.updateTeamMembers("Work", [], [maus.id]))).toBe(false);
+ expect(hiddenAfter(() => store.updateTeamMembers("Work", [maus.id], []))).toBe(false);
+ });
+
it("knows a renamed MausBot by its mark: no second one on update, Chief tools kept", () => {
const store = new Store(selection);
store.createBot({ name: "Writer" });
diff --git a/server/store.ts b/server/store.ts
index 053ca33802..c1b075a902 100644
--- a/server/store.ts
+++ b/server/store.ts
@@ -1562,7 +1562,7 @@ export class Store {
patchBotProfile(id: string, patch: BotProfilePatch & Partial<Pick<BotRecord, "cwd" | "lastProfileRequestId">>): BotRecord | null {
const bot = this.bot(id);
if (!bot) return null;
- const next = { ...bot, ...patch };
+ const next = { ...bot, ...reshowWhenMoved(bot, patch) };
if (patch.soul !== undefined) {
next.soulHash = soulHash(patch.soul);
next.soulDrift = false;
@@ -1594,7 +1594,7 @@ export class Store {
const selected = targets as BotRecord[];
const patches = new Map<string, Partial<BotRecord>>();
for (const bot of selected) {
- patches.set(bot.id, { section: targetSection || undefined });
+ patches.set(bot.id, reshowWhenMoved(bot, { section: targetSection || undefined }));
}
if (chiefConflict(this.bots.map((bot) => ({ ...bot, ...patches.get(bot.id) })))) return { ok: false, reason: "chief-conflict" };
@@ -1631,7 +1631,7 @@ export class Store {
if (removes.has(id) && sectionKey(bot.section) !== key) return { ok: false, reason: "membership-changed" };
}
const next = this.bots.map(bot => ids.has(bot.id)
- ? { ...bot, section: adds.has(bot.id) ? key : undefined } : bot);
+ ? { ...bot, ...reshowWhenMoved(bot, { section: adds.has(bot.id) ? key : undefined }) } : bot);
if (chiefConflict(next)) return { ok: false, reason: "chief-conflict" };
if (ids.size) {
this.saveBots(next);
diff --git a/src/lib/sidebar-layout.test.ts b/src/lib/sidebar-layout.test.ts
index d0758a7202..45758cd881 100644
--- a/src/lib/sidebar-layout.test.ts
+++ b/src/lib/sidebar-layout.test.ts
@@ -122,6 +122,8 @@ describe("sidebar virtual sections", () => {
const theirs = { id: "theirs", defaultBot: { person: "[email protected]" }, section: "C Suite" };
expect(partitionSidebarBots([mine, theirs], { viewerEmail: null }).sectionedBots).toEqual([]);
expect(partitionSidebarBots([mine, theirs], { viewerEmail: null, searching: true }).sectionedBots).toEqual([mine]);
+ const plain = { id: "plain", sidebarHidden: true, section: "C Suite" };
+ expect(partitionSidebarBots([plain], { viewerEmail: null, searching: true }).sectionedBots).toEqual([]);
});
it("lists a group's pinned Chief with the pinned bots on every client; the main Chief keeps its own top slot", () => {
diff --git a/src/lib/sidebar-layout.ts b/src/lib/sidebar-layout.ts
index 02c60fb365..6c78fa7512 100644
--- a/src/lib/sidebar-layout.ts
+++ b/src/lib/sidebar-layout.ts
@@ -113,7 +113,7 @@ export function partitionSidebarBots<T extends SidebarBot>(
) {
const universalPins = options?.universalPins === true;
// A search also finds the viewer's own MausBot when it is hidden from the sidebar, so it can always be reached.
- const listed = (bot: T) => !hiddenFromSidebar(bot, options?.viewerEmail) || (options?.searching === true && !someoneElsesDefaultBot(bot, options.viewerEmail));
+ const listed = (bot: T) => !hiddenFromSidebar(bot, options?.viewerEmail) || (options?.searching === true && Boolean(bot.defaultBot) && !someoneElsesDefaultBot(bot, options.viewerEmail));
const visible = bots.filter((bot) => !bot.hidden && listed(bot) && bot.id !== options?.welcoming);
// The pin flag is the server's, the same on every client. Only the main Chief keeps its own top slot when pins are
// not universal (a device's layout choice); a pinned Chief of a group is listed with the other pinned bots.