Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(automations): reset the department and bot filters when a department disappears
Renato Ramosb229d5a2b6af
diff --git a/src/components/TriggersPage.tsx b/src/components/TriggersPage.tsxindex e5ad4c4bdf..43f4f5c84b 100644--- a/src/components/TriggersPage.tsx+++ b/src/components/TriggersPage.tsx@@ -55,6 +55,11 @@ export function TriggersPage({ onBack, onOpenRoom }: { onBack: () => void; onOpeconst departments = filterableDepartments(state.bots, [...new Set([...(state.sections ?? []), ...state.bots.flatMap((bot) => bot.section ? [bot.section] : [])])]);const showDepartments = departments.names.length > 0;const activeDepartment = department === "all" || (department === GENERAL_DEPARTMENT ? departments.hasGeneral : departments.names.includes(department)) ? department : "all";+ useEffect(() => {+ if (activeDepartment === department) return;+ setDepartment("all");+ setBotFilter("all");+ }, [activeDepartment, department]);const inDepartment = (botId: string) => botInDepartment(state.bots.find((bot) => bot.id === botId), activeDepartment);const departmentBots = visibleBots.filter((bot) => botInDepartment(bot, activeDepartment));const showFilter = all.length >= FILTER_FROM && new Set(all.map((automation) => automation.botId)).size > 1;diff --git a/src/components/automations/automations.test.ts b/src/components/automations/automations.test.tsindex f87de6f914..3daaa5f032 100644--- a/src/components/automations/automations.test.ts+++ b/src/components/automations/automations.test.ts@@ -310,6 +310,23 @@ describe("the Automations list switch", () => {expect([...bots().options].map((option) => option.textContent)).toEqual(["All bots", "Ledger"]);expect(container.querySelectorAll("[data-automation]")).toHaveLength(4);});++ it("clears a bot picked in a department that then disappears, so nothing stays filtered under All departments", async () => {+ fixture.state.bots = sectioned;+ fixture.state.sections = ["Dev", "Social"];+ fixture.state.webhooks = [];+ fixture.state.routines = Array.from({ length: 9 }, (_, index) => ({ ...routine, id: `r-${index}`, name: `Check ${index}`, botId: index < 5 ? "bot-a" : "bot-b" }));+ mountPage();+ const bots = () => container.querySelector<HTMLSelectElement>('select[aria-label="All bots"]')!;+ flushSync(() => pick("Dev"));+ flushSync(() => { bots().value = "bot-b"; bots().dispatchEvent(new Event("change", { bubbles: true })); });+ expect(container.querySelectorAll("[data-automation]")).toHaveLength(4);+ fixture.state.bots = sectioned.map((bot) => bot.id === "bot-b" ? { ...bot, section: "Social" } : bot);+ flushSync(() => root!.render(createElement(TriggersPage, { onBack: vi.fn(), onOpenRoom: vi.fn() })));+ await vi.waitFor(() => expect(container.querySelectorAll("[data-automation]")).toHaveLength(9));+ expect(department()!.value).toBe("all");+ expect(bots().value).toBe("all");+ });});});