From 96b75f0413b9d285231c212240354885de927de5 Mon Sep 17 00:00:00 2001 From: viettranx Date: Sat, 18 Apr 2026 17:47:33 +0700 Subject: [PATCH] refactor(ui): remove web_search config section Remove ToolsWebSection from config page and clean up i18n keys for web search provider configuration (duckduckgo, exa, tavily, brave). Web search now configured entirely via builtin_tool_tenant_configs REST API. Delete tools-web-section.tsx component and update locale catalogs (en/vi/zh). --- ui/web/src/i18n/locales/en/config.json | 15 -- ui/web/src/i18n/locales/vi/config.json | 15 -- ui/web/src/i18n/locales/zh/config.json | 15 -- ui/web/src/pages/config/config-page.tsx | 6 - .../config/sections/tools-web-section.tsx | 225 ------------------ 5 files changed, 276 deletions(-) delete mode 100644 ui/web/src/pages/config/sections/tools-web-section.tsx diff --git a/ui/web/src/i18n/locales/en/config.json b/ui/web/src/i18n/locales/en/config.json index 3d5a4b17..105e02b9 100644 --- a/ui/web/src/i18n/locales/en/config.json +++ b/ui/web/src/i18n/locales/en/config.json @@ -208,21 +208,6 @@ "tools.execAskMode": "Ask Mode", "tools.execAskModeTip": "When to prompt the user for approval before executing a command.", "tools.execAllowlistLabel": "Allowed Commands (one pattern per line)", - "tools.webSearch": "Web Search", - "tools.webFetch": "Web fetch and browser automation", - "tools.maxResults": "Max Results", - "tools.braveApiKey": "API key", - "tools.braveApiKeyTip": "Required to use Brave Search. Create a key at https://brave.com/search/api/", - "tools.braveApiKeyPlaceholder": "BSA…", - "tools.braveApiKeyManaged": "A key is already stored on the server and cannot be shown here.", - "tools.webFetchPolicy": "Web Fetch Policy", - "tools.webFetchPolicyTip": "Controls which URLs the agent can fetch. 'Allowlist' restricts to approved domains only.", - "tools.allowedDomains": "Allowed Domains", - "tools.blockedDomains": "Blocked Domains", - "tools.blockedDomainsTip": "Domains always blocked regardless of policy. One entry per line, supports wildcards (*.example.com).", - "tools.browser": "Browser Automation", - "tools.browserEnabled": "Enabled", - "tools.browserHeadless": "Headless", "tools.scrubCredentials": "Scrub Credentials", "tts.title": "Text-to-Speech", diff --git a/ui/web/src/i18n/locales/vi/config.json b/ui/web/src/i18n/locales/vi/config.json index 2dcab871..dabd554c 100644 --- a/ui/web/src/i18n/locales/vi/config.json +++ b/ui/web/src/i18n/locales/vi/config.json @@ -208,21 +208,6 @@ "tools.execAskMode": "Chế độ hỏi", "tools.execAskModeTip": "Khi nào nhắc người dùng phê duyệt trước khi thực thi lệnh.", "tools.execAllowlistLabel": "Lệnh được phép (mỗi dòng một mẫu)", - "tools.webSearch": "Tìm kiếm web", - "tools.webFetch": "Tải web và tự động hóa trình duyệt", - "tools.maxResults": "Kết quả tối đa", - "tools.braveApiKey": "API Key", - "tools.braveApiKeyTip": "Cần thiết để dùng Brave Search. Tạo khóa tại https://brave.com/search/api/", - "tools.braveApiKeyPlaceholder": "BSA…", - "tools.braveApiKeyManaged": "Khóa đã được lưu trên máy chủ và không thể hiển thị tại đây.", - "tools.webFetchPolicy": "Chính sách tải web", - "tools.webFetchPolicyTip": "Kiểm soát URL nào agent có thể tải. 'Danh sách cho phép' giới hạn chỉ các domain được duyệt.", - "tools.allowedDomains": "Domain được phép", - "tools.blockedDomains": "Domain bị chặn", - "tools.blockedDomainsTip": "Các domain luôn bị chặn bất kể chính sách. Mỗi dòng một mục, hỗ trợ ký tự đại diện (*.example.com).", - "tools.browser": "Tự động hóa trình duyệt", - "tools.browserEnabled": "Đã bật", - "tools.browserHeadless": "Không giao diện", "tools.scrubCredentials": "Ẩn thông tin xác thực", "tts.title": "Chuyển văn bản thành giọng nói", diff --git a/ui/web/src/i18n/locales/zh/config.json b/ui/web/src/i18n/locales/zh/config.json index 561b629b..9ededd06 100644 --- a/ui/web/src/i18n/locales/zh/config.json +++ b/ui/web/src/i18n/locales/zh/config.json @@ -208,21 +208,6 @@ "tools.execAskMode": "询问模式", "tools.execAskModeTip": "在执行命令之前何时提示用户审批。", "tools.execAllowlistLabel": "允许的命令(每行一个模式)", - "tools.webSearch": "网页搜索", - "tools.webFetch": "网页抓取和浏览器自动化", - "tools.maxResults": "最大结果数", - "tools.braveApiKey": "API 密钥", - "tools.braveApiKeyTip": "使用 Brave 搜索时需要。可在 https://brave.com/search/api/ 创建密钥", - "tools.braveApiKeyPlaceholder": "BSA…", - "tools.braveApiKeyManaged": "密钥已保存在服务器上,无法在此显示。", - "tools.webFetchPolicy": "网页抓取策略", - "tools.webFetchPolicyTip": "控制 Agent 可以抓取哪些 URL。\"允许列表\"仅限已批准的域名。", - "tools.allowedDomains": "允许的域名", - "tools.blockedDomains": "屏蔽的域名", - "tools.blockedDomainsTip": "无论策略如何都始终屏蔽的域名,每行一条,支持通配符(*.example.com)。", - "tools.browser": "浏览器自动化", - "tools.browserEnabled": "已启用", - "tools.browserHeadless": "无界面模式", "tools.scrubCredentials": "擦除凭证", "tts.title": "文字转语音", diff --git a/ui/web/src/pages/config/config-page.tsx b/ui/web/src/pages/config/config-page.tsx index fa02a038..6bf1c7a3 100644 --- a/ui/web/src/pages/config/config-page.tsx +++ b/ui/web/src/pages/config/config-page.tsx @@ -16,7 +16,6 @@ import { AiDefaultsSection } from "./sections/ai-defaults-section"; import { QuotaSection } from "./sections/quota-section"; import { ToolsProfileSection } from "./sections/tools-profile-section"; import { ToolsExecSection } from "./sections/tools-exec-section"; -import { ToolsWebSection } from "./sections/tools-web-section"; import { ShellSecuritySection } from "./sections/shell-security-section"; import { TtsSection } from "./sections/tts-section"; import { CronSection } from "./sections/cron-section"; @@ -144,11 +143,6 @@ export function ConfigPage() { onSave={(v) => patch({ tools: v })} saving={saving} /> - patch({ tools: v })} - saving={saving} - /> patch({ tools: v })} diff --git a/ui/web/src/pages/config/sections/tools-web-section.tsx b/ui/web/src/pages/config/sections/tools-web-section.tsx deleted file mode 100644 index 8f179a46..00000000 --- a/ui/web/src/pages/config/sections/tools-web-section.tsx +++ /dev/null @@ -1,225 +0,0 @@ -import { useState, useEffect } from "react"; -import { Save } from "lucide-react"; -import { useTranslation } from "react-i18next"; -import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; -import { Switch } from "@/components/ui/switch"; -import { Textarea } from "@/components/ui/textarea"; -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "@/components/ui/card"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select"; -import { Separator } from "@/components/ui/separator"; -import { InfoLabel } from "@/components/shared/info-label"; -import { isSecret } from "@/lib/secret"; - - -type ToolsData = Record; - -interface Props { - data: ToolsData | undefined; - onSave: (value: ToolsData) => Promise; - saving: boolean; -} - -export function ToolsWebSection({ data, onSave, saving }: Props) { - const { t } = useTranslation("config"); - const [draft, setDraft] = useState(data ?? {}); - const [dirty, setDirty] = useState(false); - - useEffect(() => { - setDraft(data ?? {}); - setDirty(false); - }, [data]); - - const updateNested = (section: string, patch: Record) => { - setDraft((prev) => ({ - ...prev, - [section]: { ...(prev[section] ?? {}), ...patch }, - })); - setDirty(true); - }; - - const handleSave = () => { - const toSave: ToolsData = { ...draft }; - const web = { ...(toSave.web ?? {}) }; - const brave = { ...(web.brave ?? {}) }; - if (isSecret(brave.api_key)) { - delete brave.api_key; - } - web.brave = brave; - toSave.web = web; - onSave(toSave); - }; - - if (!data) return null; - - const web = draft.web ?? {}; - const ddg = web.duckduckgo ?? {}; - const brave = web.brave ?? {}; - const webFetch = draft.web_fetch ?? {}; - const browser = draft.browser ?? {}; - - return ( - - - {t("tools.webSearch")} - {t("tools.webFetch")} - - - {/* Web Search */} -
-
-
- - updateNested("web", { duckduckgo: { ...ddg, enabled: v } })} - /> -
-
- - updateNested("web", { duckduckgo: { ...ddg, max_results: Number(e.target.value) } })} - placeholder="5" - min={1} - /> -
-
-
-
- - updateNested("web", { brave: { ...brave, enabled: v } })} - /> -
-
- - updateNested("web", { brave: { ...brave, max_results: Number(e.target.value) } })} - placeholder="5" - min={1} - /> -
- {brave.enabled && ( -
- {t("tools.braveApiKey")} - - updateNested("web", { brave: { ...brave, api_key: e.target.value } }) - } - placeholder={t("tools.braveApiKeyPlaceholder")} - autoComplete="off" - /> - {isSecret(brave.api_key) && ( -

{t("tools.braveApiKeyManaged")}

- )} -
- )} -
-
- - - - {/* Web Fetch */} -
-
- {t("tools.webFetchPolicy")} - -
- {webFetch.policy === "allowlist" && ( -
- -