Skip to content

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

fix(web): show the local agent option as disabled in the browser

tianma-ifcb1c56ef9722
diff --git a/apps/web/src/components/settings/AiModelCard.tsx b/apps/web/src/components/settings/AiModelCard.tsx
index f83399d7..f7d6ee62 100644
--- a/apps/web/src/components/settings/AiModelCard.tsx
+++ b/apps/web/src/components/settings/AiModelCard.tsx
@@ -1,7 +1,7 @@
import { useState, type FormEvent, type ReactNode } from "react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import type { AiProvider } from "@edgeever/shared";
-import { ChevronDown, Loader2, Plus, Server, ShieldCheck, Sparkles, TriangleAlert } from "lucide-react";
+import { ChevronDown, Loader2, Plus, Server, Sparkles, TriangleAlert } from "lucide-react";
import { useTranslation } from "react-i18next";
import { AiProviderCard } from "@/components/settings/AiProviderCard";
import {
@@ -212,13 +212,6 @@ export const AiModelCard = () => {
)}
</section>
- <div className="flex items-start gap-2 border-t border-slate-200/60 pt-3 ">
- <ShieldCheck className="mt-0.5 h-3.5 w-3.5 shrink-0 text-slate-900" />
- <p className="text-xs leading-relaxed text-slate-500 ">
- {t("aiModel.privacyNotice")}
- </p>
- </div>
-
<Dialog open={showAdd} onOpenChange={handleAddDialogChange}>
<DialogContent className="max-h-[calc(100vh-2rem)] overflow-y-auto sm:max-w-2xl">
<form className="grid gap-5" onSubmit={(event: FormEvent) => { event.preventDefault(); if (!canAddProvider) return; createMutation.mutate(); }}>
diff --git a/apps/web/src/components/settings/DesktopAcpAgentCard.tsx b/apps/web/src/components/settings/DesktopAcpAgentCard.tsx
index f343fa26..245536f4 100644
--- a/apps/web/src/components/settings/DesktopAcpAgentCard.tsx
+++ b/apps/web/src/components/settings/DesktopAcpAgentCard.tsx
@@ -39,10 +39,15 @@ const statusKey = (adapter: DesktopAcpAdapter | undefined, probing: boolean) =>
if (probing) return "aiAssistant.agentSource.probing";
if (!adapter || adapter.detail === "not_probed") return "aiAssistant.agentSource.notProbed";
if (adapter.detail === "invalid_path") return "aiAssistant.agentSource.invalidPath";
+ if (adapter.detail === "desktop_unavailable") return "aiAssistant.agentSource.localDisabled";
return `aiAssistant.agentSource.states.${adapter.state}`;
};
-const DesktopAcpAgentCardBody = () => {
+const desktopBridgeAvailable = () => (
+ typeof window !== "undefined" && typeof window.edgeeverDesktop?.listAcpAdapters === "function"
+);
+
+const DesktopAcpAgentCardBody = ({ bridge }: { bridge: boolean }) => {
const { t } = useTranslation();
const [source, setSource] = useState<AiSidebarSource>("builtin");
const [adapterId, setAdapterId] = useState<DesktopAcpAdapterId>("codex");
@@ -53,11 +58,12 @@ const DesktopAcpAgentCardBody = () => {
const [probing, setProbing] = useState(false);
useEffect(() => {
- setSource(readSource());
+ const stored = readSource();
+ setSource(bridge && stored === "local" ? "local" : "builtin");
setAdapterId(readAdapterId());
setAdapterPath(localStorage.getItem(AI_SIDEBAR_ADAPTER_PATH_KEY) ?? "");
setReady(true);
- }, []);
+ }, [bridge]);
useEffect(() => {
if (!ready) return;
@@ -113,20 +119,24 @@ const DesktopAcpAgentCardBody = () => {
<CardContent className="grid gap-4 p-4 pt-0">
<div role="radiogroup" aria-label={t("aiAssistant.agentSource.title")} className="overflow-hidden rounded-lg border border-slate-200/70 divide-y divide-slate-200/70">
{(["builtin", "local"] as const).map((option) => {
+ const disabled = option === "local" && !bridge;
const checked = source === option;
return (
- <label key={option} className={cn("flex cursor-pointer items-start gap-3 px-3.5 py-2.5", checked && "bg-slate-50/80")}>
+ <label key={option} className={cn("flex items-start gap-3 px-3.5 py-2.5", disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer", checked && "bg-slate-50/80")}>
<input
className="mt-0.5"
type="radio"
name="edgeever-acp-source"
value={option}
checked={checked}
- onChange={() => setSource(option)}
+ disabled={disabled}
+ onChange={() => { if (!disabled) setSource(option); }}
/>
<span className="min-w-0">
<span className={SETTINGS_ITEM_TITLE_CLASSNAME}>{t(`aiAssistant.agentSource.${option}`)}</span>
- <span className={cn(SETTINGS_ITEM_DESCRIPTION_CLASSNAME, "block")}>{t(`aiAssistant.agentSource.${option}Hint`)}</span>
+ <span className={cn(SETTINGS_ITEM_DESCRIPTION_CLASSNAME, "block")}>
+ {disabled ? t("aiAssistant.agentSource.localDisabled") : t(`aiAssistant.agentSource.${option}Hint`)}
+ </span>
</span>
</label>
);
@@ -204,7 +214,6 @@ const DesktopAcpAgentCardBody = () => {
);
};
-export const DesktopAcpAgentCard = () => {
- if (typeof window === "undefined" || typeof window.edgeeverDesktop?.listAcpAdapters !== "function") return null;
- return <DesktopAcpAgentCardBody />;
-};
+export const DesktopAcpAgentCard = () => (
+ <DesktopAcpAgentCardBody bridge={desktopBridgeAvailable()} />
+);
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index a510bd49..96cb2cc6 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -1130,7 +1130,6 @@ export const enUS = {
addDisabledReason: "Configure the instance authentication secret before adding a model service",
savedCredentialsUnavailable: "Saved model credentials cannot be decrypted. Open the service and enter the API key again.",
savedCredentialsUnavailableBadge: "Re-enter API key",
- privacyNotice: "Please use trusted model providers or API proxies to protect your personal privacy.",
},
aiPrompts: {
title: "Prompt library",
@@ -1336,6 +1335,7 @@ export const enUS = {
agentSource: {
title: "Agent source",
description: "Use the built-in companion, or a local ACP agent on this computer.",
+ localDisabled: "Needs the desktop app. A browser cannot use a local agent.",
builtin: "Built-in companion",
builtinHint: "Uses the AI model configured above.",
local: "Local ACP agent",
diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.ts
index 4ec0a5a2..74ba084b 100644
--- a/packages/shared/src/i18n/ja.ts
+++ b/packages/shared/src/i18n/ja.ts
@@ -1130,7 +1130,6 @@ export const ja = {
addDisabledReason: "モデルサービスを追加する前に、インスタンス認証シークレットを設定してください",
savedCredentialsUnavailable: "保存済みのモデル認証情報を復号できません。サービスを開いて API Key を再入力してください。",
savedCredentialsUnavailableBadge: "API Key を再入力",
- privacyNotice: "個人のプライバシーを守るため、信頼できるモデル提供元または API プロキシを使ってください。",
},
aiPrompts: {
title: "プロンプトライブラリ",
@@ -1336,6 +1335,7 @@ export const ja = {
agentSource: {
title: "エージェントの接続先",
description: "内蔵コンパニオンか、このコンピュータ上のローカル ACP エージェントを使います。",
+ localDisabled: "デスクトップアプリが必要です。ブラウザではローカルエージェントを使えません。",
builtin: "内蔵コンパニオン",
builtinHint: "上で設定した AI モデルを使います。",
local: "ローカル ACP エージェント",
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 6b56b3eb..be29b4fc 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -1130,7 +1130,6 @@ export const zhCN = {
addDisabledReason: "需要先配置实例认证密钥才能添加模型服务",
savedCredentialsUnavailable: "已保存的模型凭据无法解密,请打开该服务并重新填写 API Key。",
savedCredentialsUnavailableBadge: "需重新填写密钥",
- privacyNotice: "请务必选用可信赖的模型服务商或 API 代理节点,避免个人隐私泄露。",
},
aiPrompts: {
title: "指令库",
@@ -1336,6 +1335,7 @@ export const zhCN = {
agentSource: {
title: "代理来源",
description: "使用内置助手,或使用这台电脑上的本地 ACP 代理。",
+ localDisabled: "需要桌面客户端。网页里不能使用本机代理。",
builtin: "内置助手",
builtinHint: "使用上方配置的 AI 模型。",
local: "本地 ACP 代理",