Skip to content

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

Settings search finds sections by their inner headings and connected app names

AdityaUmale2aeab2f4218a
diff --git a/src/components/BotSettingsDialog.tsx b/src/components/BotSettingsDialog.tsx
index 720454c562..7d182e0dbd 100644
--- a/src/components/BotSettingsDialog.tsx
+++ b/src/components/BotSettingsDialog.tsx
@@ -4,7 +4,8 @@ import { ChevronDown, Search, X } from "lucide-react";
import { useStore, type Bot, type BotSettingsSection } from "@/state/store";
import { cn } from "@/lib/cn";
import { useCaptionChrome } from "./DesktopCapabilities";
-import { BOT_SECTIONS } from "./bot-settings/sections";
+import { BOT_SECTIONS, sectionLabel, sectionMatches } from "./bot-settings/sections";
+import { useBotApps } from "./bot-settings/useBotApps";
import { useBotSettingsDerived } from "./bot-settings/useBotSettingsDerived";
import { OverviewSection } from "./bot-settings/OverviewSection";
import { IdentitySection } from "./bot-settings/IdentitySection";
@@ -34,13 +35,6 @@ import { ShareBotButton, useTeamName } from "./bot-access/ShareBotButton";
/** Where the Library's memory, skills and folder rows lead in Advanced settings. */
const LIBRARY_LINKS: Partial<Record<SimplePageId, BotSettingsSection>> = { memory: "memory", skills: "skills", folder: "access" };
-const sectionLabel = (entry: (typeof BOT_SECTIONS)[number]) => (entry.labelKey ? t(entry.labelKey) : entry.label);
-
-function sectionMatches(entry: (typeof BOT_SECTIONS)[number], query: string): boolean {
- if (!query) return true;
- return [entry.label, sectionLabel(entry), ...entry.keywords].some((part) => part.toLowerCase().includes(query));
-}
-
export function BotSettingsDialog({ bot, overlay = false }: {
bot: Bot;
overlay?: boolean;
@@ -62,7 +56,10 @@ export function BotSettingsDialog({ bot, overlay = false }: {
const sections = BOT_SECTIONS
.filter((entry) => entry.id !== "slack" || slackUrl !== null)
.filter((entry) => entry.id !== "visibility" || (!window.ogb && ownerOrAdmin === true && !teamName));
- const visibleSections = sections.filter((entry) => sectionMatches(entry, q));
+ // Connected apps load only once the person searches; their names find the Access section.
+ const searchApps = useBotApps(bot, q !== "");
+ const appNames = searchApps.apps.flatMap((app) => [app.label, app.slug]);
+ const visibleSections = sections.filter((entry) => sectionMatches(entry, q, appNames));
const { overview, overviewError, prompt, promptError } = useBotOverview(bot, {
overview: section === "overview" && !simpleView,
@@ -233,7 +230,7 @@ export function BotSettingsDialog({ bot, overlay = false }: {
{sections.map((entry) => {
const { id, icon: Icon } = entry;
const label = sectionLabel(entry);
- const matched = sectionMatches(entry, q);
+ const matched = sectionMatches(entry, q, appNames);
if (!matched && id !== "memory") return null;
const open = !collapsed && section === id;
return (
diff --git a/src/components/bot-settings/sections.test.ts b/src/components/bot-settings/sections.test.ts
new file mode 100644
index 0000000000..60f4be2b1c
--- /dev/null
+++ b/src/components/bot-settings/sections.test.ts
@@ -0,0 +1,36 @@
+import { afterEach, describe, expect, it } from "vitest";
+
+import { setLocale } from "@/lib/i18n";
+import { BOT_SECTIONS, sectionMatches } from "./sections";
+
+const section = (id: string) => {
+ const entry = BOT_SECTIONS.find((candidate) => candidate.id === id);
+ if (!entry) throw new Error(`no section ${id}`);
+ return entry;
+};
+const found = (query: string, appNames: string[] = []) =>
+ BOT_SECTIONS.filter((entry) => sectionMatches(entry, query.trim().toLowerCase(), appNames)).map((entry) => entry.id);
+
+describe("bot settings search", () => {
+ afterEach(() => {
+ setLocale("en");
+ });
+
+ it("finds Access by a connected app's name, and only when that app is connected", () => {
+ expect(found("github", ["GitHub", "github"])).toContain("access");
+ expect(found("github")).not.toContain("access");
+ expect(sectionMatches(section("permissions"), "github", ["GitHub"])).toBe(false);
+ });
+
+ it("finds Access by the headings inside it in the person's language", () => {
+ setLocale("zh");
+ expect(found("应用")).toContain("access");
+ expect(found("浏览器")).toContain("access");
+ expect(found("权限")).toContain("permissions");
+ });
+
+ it("keeps the English keywords and shows everything for an empty search", () => {
+ expect(found("composio")).toEqual(["access"]);
+ expect(found("")).toHaveLength(BOT_SECTIONS.length);
+ });
+});
diff --git a/src/components/bot-settings/sections.ts b/src/components/bot-settings/sections.ts
index 0d96eae252..2e4779089f 100644
--- a/src/components/bot-settings/sections.ts
+++ b/src/components/bot-settings/sections.ts
@@ -19,6 +19,7 @@ import {
import type { BotSettingsSection } from "@/state/store";
import type { LocaleKey } from "@/locales";
+import { t } from "@/lib/i18n";
export const BOT_SECTIONS: Array<{
id: BotSettingsSection;
@@ -26,6 +27,8 @@ export const BOT_SECTIONS: Array<{
labelKey?: LocaleKey;
icon: LucideIcon;
keywords: string[];
+ /** Headings shown inside the section, matched in the person's language. */
+ headingKeys?: LocaleKey[];
}> = [
{ id: "overview", label: "Overview", labelKey: "botSettings.sections.overview", icon: LayoutDashboard, keywords: ["summary", "status", "what it does", "won't", "prompt", "what the model sees"] },
{ id: "identity", label: "Identity", labelKey: "botSettings.sections.identity", icon: User, keywords: ["name", "title", "avatar", "blurb", "instructions"] },
@@ -35,7 +38,11 @@ export const BOT_SECTIONS: Array<{
{ id: "memory", label: "Memory", labelKey: "botSettings.sections.memory", icon: Brain, keywords: ["memory", "notes", "remember", "topics"] },
{ id: "library", label: "Library", labelKey: "botPanel.tab.library", icon: Library, keywords: ["library", "made", "pages", "apps", "files", "published"] },
{ id: "routines", label: "Routines", labelKey: "botSettings.sections.routines", icon: CalendarClock, keywords: ["schedule", "routines", "cron", "tasks"] },
- { id: "access", label: "Access", labelKey: "botSettings.sections.access", icon: Network, keywords: ["works on", "computer", "vm", "cloud", "vps", "folder", "workspace", "browser", "connected apps", "composio", "webhooks", "always allow", "grants", "tool selection", "tools", "mcp", "allow", "exclude"] },
+ { id: "access", label: "Access", labelKey: "botSettings.sections.access", icon: Network, keywords: ["works on", "computer", "vm", "cloud", "vps", "folder", "workspace", "browser", "connected apps", "composio", "webhooks", "always allow", "grants", "tool selection", "tools", "mcp", "allow", "exclude"], headingKeys: [
+ "computer.worksOn", "botAccess.folder.title", "botAccess.apps.title", "botAccess.grants.header", "botAccess.phone.title",
+ "research.title", "connectors.tab.mcp", "botAccess.tools.title", "botAccess.browser.title", "botAccess.recordSteps.title",
+ "botAccess.webhooks.title", "botAccess.always.title",
+ ] },
{ id: "model", label: "Model", labelKey: "botSettings.sections.model", icon: Cpu, keywords: ["engine", "model", "provider", "cli", "effort"] },
{ id: "permissions", label: "Permissions", labelKey: "botSettings.sections.permissions", icon: ShieldCheck, keywords: ["auto mode", "approve", "auto approve", "review", "routine approvals", "coordination", "chief of staff", "section"] },
{ id: "voice", label: "Voice & alerts", labelKey: "botSettings.sections.voice", icon: Mic, keywords: ["voice", "alerts", "notifications", "speak"] },
@@ -43,3 +50,17 @@ export const BOT_SECTIONS: Array<{
{ id: "history", label: "History", labelKey: "botSettings.sections.history", icon: History, keywords: ["history", "changes", "undo", "rollback", "log"] },
{ id: "usage", label: "Usage", labelKey: "botSettings.sections.usage", icon: Coins, keywords: ["tokens", "cost", "billing"] },
];
+
+export type BotSectionEntry = (typeof BOT_SECTIONS)[number];
+
+export const sectionLabel = (entry: BotSectionEntry) => (entry.labelKey ? t(entry.labelKey) : entry.label);
+
+/** Whether a settings search (already trimmed and lowercased) finds this section. `appNames` are the bot's connected
+ * apps, whose switches live in Access, so "github" finds Access when GitHub is connected. */
+export function sectionMatches(entry: BotSectionEntry, query: string, appNames: readonly string[] = []): boolean {
+ if (!query) return true;
+ const headings = (entry.headingKeys ?? []).map((key) => t(key));
+ const apps = entry.id === "access" ? appNames : [];
+ return [entry.label, sectionLabel(entry), ...entry.keywords, ...headings, ...apps]
+ .some((part) => part.toLowerCase().includes(query));
+}
diff --git a/src/components/bot-settings/useBotApps.ts b/src/components/bot-settings/useBotApps.ts
index d7a5d0ec74..883bf4c1da 100644
--- a/src/components/bot-settings/useBotApps.ts
+++ b/src/components/bot-settings/useBotApps.ts
@@ -73,12 +73,14 @@ export function botAppsFrom(
return { phase: "ready", apps, connectedSlugs };
}
-export function useBotApps(bot: Bot): BotApps {
+/** `load` false skips the requests until it turns true (the settings search loads apps only once someone searches). */
+export function useBotApps(bot: Bot, load = true): BotApps {
const [inventory, setInventory] = useState<ConnectorInventory | null>(null);
const [cards, setCards] = useState<ReadonlyMap<string, ToolkitCard>>(() => new Map());
const [email, setEmail] = useState<EmailStatus | null>(null);
useEffect(() => {
+ if (!load) return;
let cancelled = false;
void preloadConnectedApps().then((result) => {
if (!cancelled) setInventory(result);
@@ -90,7 +92,7 @@ export function useBotApps(bot: Bot): BotApps {
return () => {
cancelled = true;
};
- }, []);
+ }, [load]);
return botAppsFrom(bot, inventory, cards, email);
}