Skip to content

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

fix: side switch lands on bots the sidebar lists

AdityaUmale7bc6c7f82d8a
diff --git a/src/components/TeamSideSwitch.dom.test.ts b/src/components/TeamSideSwitch.dom.test.ts
index 95692917eb..0ba0885d01 100644
--- a/src/components/TeamSideSwitch.dom.test.ts
+++ b/src/components/TeamSideSwitch.dom.test.ts
@@ -134,6 +134,14 @@ describe("the Just me / Team switch at the top of a team's sidebar", () => {
expect(fixture.dispatch).toHaveBeenCalledWith({ type: "switchTask", botId: "scout", threadId: "ada-own" });
});
+ it("lands on a regular bot left with a Show switch off, as the sidebar lists it", async () => {
+ setTeamSide("team");
+ sidebar(acme({ selectedId: "room-1", bots: [bot({ sidebarHidden: true }), MINE] }));
+ act(() => option("me")!.click());
+ await settle();
+ expect(fixture.dispatch).toHaveBeenCalledWith({ type: "switchTask", botId: "scout", threadId: "ada-own" });
+ });
+
it("moves no conversation while another screen is up, and does nothing for the side already chosen", async () => {
sidebar(acme({ activeView: "routines" as never }));
act(() => option("me")!.click());
diff --git a/src/components/TeamSideSwitch.tsx b/src/components/TeamSideSwitch.tsx
index fe5635e2c4..eaf964df3c 100644
--- a/src/components/TeamSideSwitch.tsx
+++ b/src/components/TeamSideSwitch.tsx
@@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from "react";
import { Lock, Users } from "lucide-react";
import { cn } from "@/lib/cn";
+import { hiddenFromSidebar } from "@/lib/default-bot";
import { t } from "@/lib/i18n";
import { useShowThreads } from "@/lib/thread-preferences";
import { openBot, useStore, type AppState, type Bot, type Group } from "@/state/store";
@@ -72,7 +73,7 @@ export function TeamSideSwitch({ compact, listOnly = false }: { compact: boolean
if (listOnly || state.activeView !== "chat") return;
const there = teamSideView(state.bots, state.groups, team, next);
if (there.groups.some((group) => group.id === state.selectedId)) return;
- const target = there.bots.find((bot) => bot.id === state.selectedId) ?? there.bots.find((bot) => !bot.sidebarHidden);
+ const target = there.bots.find((bot) => bot.id === state.selectedId) ?? there.bots.find((bot) => !hiddenFromSidebar(bot, team.person));
const bot = target && state.bots.find((candidate) => candidate.id === target.id);
if (bot) openBot(dispatch, bot, showThreads);
else if (there.groups[0]) dispatch({ type: "select", id: there.groups[0].id });
@@ -144,7 +145,7 @@ export function TeamAudienceLabel({ bot, group }: { bot?: Bot; group?: Group })
if (group || movedHere || askedFor || (justMade && side === "me")) { setTeamSide(side, team); return; }
const lists = teamSideView(state.bots, state.groups, team, showing);
const there = lists.switchable ? lists.bots : [];
- const target = there.find((candidate) => candidate.id === chat) ?? there.find((candidate) => !candidate.sidebarHidden);
+ const target = there.find((candidate) => candidate.id === chat) ?? there.find((candidate) => !hiddenFromSidebar(candidate, person));
const landing = target && state.bots.find((candidate) => candidate.id === target.id);
if (landing) openBot(dispatch, landing, showThreads);
else showTeamSide(side, team);