Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
MCP servers: finishing the list load no longer crashes a translated page
RGB-loop779ac78e9561
diff --git a/src/components/McpServersPanel.translated.test.ts b/src/components/McpServersPanel.translated.test.tsnew file mode 100644index 0000000000..cee34ffd7c--- /dev/null+++ b/src/components/McpServersPanel.translated.test.ts@@ -0,0 +1,64 @@+// @vitest-environment happy-dom+import { act, createElement } from "react";+import { createRoot, type Root } from "react-dom/client";+import { afterEach, beforeEach, expect, it, vi } from "vitest";++import { setLocale } from "@/lib/i18n";++const api = vi.hoisted(() => vi.fn());+vi.mock("@/state/store", () => ({+ api,+ useStore: () => ({ state: { config: null, bots: [] }, dispatch: vi.fn() }),+}));++import { McpServersPanel } from "./McpServersPanel";++const server = { name: "docs", type: "http", url: "https://mcp.example.test/mcp", headerKeys: ["Authorization"], enabled: true };++function Panel({ embedded }: { embedded: boolean }) {+ return McpServersPanel({ embedded });+}++let root: Root;+let host: HTMLElement;+let listed!: (value: unknown) => void;++// Chrome's page translation swaps each text node for <font><font>translation</font></font>.+function translatePage(node: Node) {+ const walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT);+ const texts: Text[] = [];+ while (walker.nextNode()) texts.push(walker.currentNode as Text);+ for (const text of texts.filter((candidate) => candidate.data.trim())) {+ const outer = document.createElement("font");+ const inner = document.createElement("font");+ inner.textContent = `翻译 ${text.data}`;+ outer.append(inner);+ text.replaceWith(outer);+ }+}++beforeEach(() => {+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;+ setLocale("en");+ api.mockReset();+ api.mockImplementation((path: string) => path === "/api/mcp/servers" ? new Promise((resolve) => { listed = resolve; }) : new Promise(() => {}));+ host = document.createElement("div");+ document.body.append(host);+ root = createRoot(host);+});+afterEach(() => {+ act(() => root.unmount());+ host.remove();+});++it.each([+ ["on its own", false],+ ["inside the Apps pop-up", true],+])("shows the server list after a translated page finishes loading it, %s", async (_where, embedded) => {+ await act(async () => { root.render(createElement(Panel, { embedded })); });+ expect(host.textContent).toContain("Loading MCP servers");+ translatePage(host);+ await act(async () => { listed({ servers: [server] }); });+ expect(host.textContent).not.toContain("Loading MCP servers");+ expect(host.querySelector('[aria-label="Edit docs"]')).not.toBeNull();+});diff --git a/src/components/McpServersPanel.tsx b/src/components/McpServersPanel.tsxindex 9d750de69d..e0f0b5f435 100644--- a/src/components/McpServersPanel.tsx+++ b/src/components/McpServersPanel.tsx@@ -683,7 +683,7 @@ export function McpServersPanel({ embedded = false, hostedCards, hideHosted = fa</div>{servers === null ? (- <div className="flex items-center justify-center gap-2 py-24 text-[13px] text-ink-secondary"><Loader2 size={14} className="animate-spin" /> {t("mcp.loading")}</div>+ <div className="flex items-center justify-center gap-2 py-24 text-[13px] text-ink-secondary"><Loader2 size={14} className="animate-spin" /><span>{t("mcp.loading")}</span></div>) : visibleServers?.length === 0 && !editing ? (<div className="mt-5 flex min-h-32 flex-col items-center justify-center rounded-2xl border border-dashed border-hairline/60 text-center"><div className="flex size-11 items-center justify-center rounded-xl bg-raised text-ink-secondary"><ServerCog size={21} /></div>