Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix: isolate agent settings radio groups across layouts

tianma-if9b20397f1446
diff --git a/apps/web/src/components/settings/DesktopAcpAgentCard.test.mjs b/apps/web/src/components/settings/DesktopAcpAgentCard.test.mjs
new file mode 100644
index 00000000..26a3714f
--- /dev/null
+++ b/apps/web/src/components/settings/DesktopAcpAgentCard.test.mjs
@@ -0,0 +1,19 @@
+import { expect, test } from "bun:test";
+import { createElement, Fragment } from "react";
+import { renderToStaticMarkup } from "react-dom/server";
+import { createInstance } from "i18next";
+import { I18nextProvider } from "react-i18next";
+import { zhCN } from "@edgeever/shared/i18n";
+import { DesktopAcpAgentCard } from "./DesktopAcpAgentCard.tsx";
+
+test("desktop and hidden mobile cards have independent native radio groups", async () => {
+ const i18n = createInstance();
+ await i18n.init({ lng: "zh-CN", resources: { "zh-CN": { translation: zhCN } } });
+ const html = renderToStaticMarkup(createElement(I18nextProvider, { i18n },
+ createElement(Fragment, null, createElement(DesktopAcpAgentCard), createElement(DesktopAcpAgentCard))));
+ const names = [...html.matchAll(/name="(edgeever-acp-source-[^"]+)"/g)].map((match) => match[1]);
+ expect(names).toHaveLength(4);
+ expect(names[0]).toBe(names[1]);
+ expect(names[2]).toBe(names[3]);
+ expect(names[0]).not.toBe(names[2]);
+});
diff --git a/apps/web/src/components/settings/DesktopAcpAgentCard.tsx b/apps/web/src/components/settings/DesktopAcpAgentCard.tsx
index 527827a5..3b20cf36 100644
--- a/apps/web/src/components/settings/DesktopAcpAgentCard.tsx
+++ b/apps/web/src/components/settings/DesktopAcpAgentCard.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useState } from "react";
+import { useEffect, useId, useState } from "react";
import { useTranslation } from "react-i18next";
import { Bot, Info } from "lucide-react";
import { Button } from "@/components/ui/button";
@@ -83,6 +83,7 @@ const desktopBridgeAvailable = () => (
const DesktopAcpAgentCardBody = ({ bridge }: { bridge: boolean }) => {
const { t } = useTranslation();
+ const instanceId = useId();
const [source, setSource] = useState<AiSidebarSource>("builtin");
const [adapterId, setAdapterId] = useState<DesktopAcpAdapterId>("codex");
const [adapterPath, setAdapterPath] = useState("");
@@ -235,7 +236,7 @@ const DesktopAcpAgentCardBody = ({ bridge }: { bridge: boolean }) => {
<input
className="mt-0.5"
type="radio"
- name="edgeever-acp-source"
+ name={`edgeever-acp-source-${instanceId}`}
value={option}
checked={checked}
disabled={disabled}
@@ -279,7 +280,7 @@ const DesktopAcpAgentCardBody = ({ bridge }: { bridge: boolean }) => {
<input
className="sr-only"
type="radio"
- name="edgeever-acp-adapter"
+ name={`edgeever-acp-adapter-${instanceId}`}
value={id}
checked={checked}
onChange={() => selectAdapter(id)}