Skip to content
Python

Customization: fetch option sits under the active provider

Rohit C Prasad7219e3a3c902
diff --git a/surfaces/gui/e2e/customization.spec.ts b/surfaces/gui/e2e/customization.spec.ts
index a584930a..19b53dae 100644
--- a/surfaces/gui/e2e/customization.spec.ts
+++ b/surfaces/gui/e2e/customization.spec.ts
@@ -1,11 +1,11 @@
// Settings ▸ Customization (UX-058): the Web search providers as radio rows with a key per
-// service, and the "Fetch pages through the search service" switch. The fixture answers
+// service, and the "Also fetch pages through …" option under the active one. The fixture answers
// GET/POST /v1/web-search, PUT/DELETE /v1/web-search/keys/{name} and
// POST /v1/web-search/fetch-via-provider from per-test state.
import { expect } from "@playwright/test";
import { test } from "./fixtures";
-test("customization: open the tab, add a key, pick the provider, flip the fetch switch", async ({ page }) => {
+test("customization: open the tab, add a key, pick the provider, tick the fetch option", async ({ page }) => {
await page.goto("/#/settings/customization");
const tab = page.getByTestId("customization-tab");
await expect(tab).toBeVisible();
@@ -38,25 +38,31 @@ test("customization: open the tab, add a key, pick the provider, flip the fetch
await expect(page.getByTestId("websearch-status-exa")).toHaveText("Key saved");
await expect(page.getByTestId("websearch-key-button-exa")).toHaveText("Update key");
- // Now it can be picked; the pill moves and the fetch switch comes alive (Exa offers it).
- const fetchSwitch = page.getByTestId("websearch-fetch-toggle").getByRole("switch");
- await expect(fetchSwitch).toBeDisabled();
- await expect(page.getByTestId("websearch-fetch-note")).toContainText("DuckDuckGo doesn't offer this.");
+ // Now it can be picked; the pill moves and, since Exa reads pages, its row gains the option.
+ await expect(page.getByTestId("websearch-fetch-row")).toHaveCount(0);
await page.getByTestId("websearch-radio-exa").click();
await expect(page.getByTestId("websearch-in-use-exa")).toHaveText("In use");
await expect(page.getByTestId("websearch-in-use-duckduckgo")).toHaveCount(0);
- await expect(fetchSwitch).toBeEnabled();
- await expect(page.getByTestId("websearch-fetch-note")).toHaveCount(0);
- await expect(page.getByText(/On: Exa fetches them, and sees each page address\./)).toBeVisible();
-
- await expect(fetchSwitch).toHaveAttribute("aria-checked", "false");
- await fetchSwitch.click();
- await expect(fetchSwitch).toHaveAttribute("aria-checked", "true");
+ const exaRow = page.getByTestId("websearch-row-exa");
+ await expect(exaRow.getByTestId("websearch-fetch-row")).toBeVisible();
+ await expect(exaRow.getByText("Also fetch pages through Exa")).toBeVisible();
+ await expect(exaRow.getByText("Exa then sees the address of every page the agent opens.")).toBeVisible();
+ const fetchBox = page.getByTestId("websearch-fetch-toggle");
+ await expect(fetchBox).not.toBeChecked();
+ await fetchBox.click();
+ await expect(fetchBox).toBeChecked();
// The choice survives a reload: the fixture holds it like the server would.
await page.reload();
await expect(page.getByTestId("websearch-in-use-exa")).toBeVisible();
- await expect(page.getByTestId("websearch-fetch-toggle").getByRole("switch")).toHaveAttribute("aria-checked", "true");
+ await expect(page.getByTestId("websearch-fetch-toggle")).toBeChecked();
+ // Under a provider that does not read pages the option is not shown (the flag stays stored).
+ await page.getByTestId("websearch-radio-tavily").click();
+ await expect(page.getByTestId("websearch-in-use-tavily")).toBeVisible();
+ await expect(page.getByTestId("websearch-row-tavily").getByTestId("websearch-fetch-toggle")).toBeChecked();
+ await page.getByTestId("websearch-radio-you").click();
+ await expect(page.getByTestId("websearch-in-use-you")).toBeVisible();
+ await expect(page.getByTestId("websearch-fetch-row")).toHaveCount(0);
});
test("customization: removing the active provider's only key falls back to DuckDuckGo", async ({ page }) => {
diff --git a/surfaces/gui/src/components/ApprovalCard.test.tsx b/surfaces/gui/src/components/ApprovalCard.test.tsx
index 85ce498a..99027134 100644
--- a/surfaces/gui/src/components/ApprovalCard.test.tsx
+++ b/surfaces/gui/src/components/ApprovalCard.test.tsx
@@ -626,7 +626,7 @@ describe("ApprovalCard — §1.9 egress cards", () => {
cleanup();
render(<ApprovalCard item={fetchApproval({ fetchProvider: "exa" })} onApprove={vi.fn()} />);
expect(screen.getByTestId("approval-fetch-provider").textContent).toBe(
- "The page is fetched through exa, which sees its address.",
+ "The page is fetched by your search service, exa, which sees its address.",
);
// The page's own host still names the destination for the domain-shaped grant.
expect(screen.getByText(/leaves this computer → bbc\.com/)).toBeTruthy();
diff --git a/surfaces/gui/src/components/CustomizationTab.test.tsx b/surfaces/gui/src/components/CustomizationTab.test.tsx
index 54d2307b..16872ef6 100644
--- a/surfaces/gui/src/components/CustomizationTab.test.tsx
+++ b/surfaces/gui/src/components/CustomizationTab.test.tsx
@@ -1,7 +1,7 @@
// Settings ▸ Customization (UX-058): the Web search card lists the providers as radio rows
// from GET /v1/web-search; a keyed provider without a key cannot be chosen; the right-hand
// control reads Add key / Update key / In use; "Test and save" sends the key; the fetch
-// switch is live only while the active provider offers it.
+// option sits under the active provider only while it offers it.
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
@@ -79,7 +79,7 @@ vi.mock("../tauri", async (importOriginal) => {
import { CustomizationTab } from "./CustomizationTab";
const radio = (name: string) => screen.getByTestId(`websearch-radio-${name}`) as HTMLInputElement;
-const fetchSwitch = () => within(screen.getByTestId("websearch-fetch-toggle")).getByRole("switch");
+const fetchBox = () => screen.getByTestId("websearch-fetch-toggle") as HTMLInputElement;
describe("Settings ▸ Customization ▸ Web search", () => {
beforeEach(() => {
@@ -188,24 +188,33 @@ describe("Settings ▸ Customization ▸ Web search", () => {
expect(screen.queryByTestId("websearch-key-remove")).toBeNull();
});
- it("the fetch switch is disabled with a note until the active provider offers it", async () => {
+ it("the fetch option appears under the active provider only when it offers it", async () => {
render(<CustomizationTab />);
- await screen.findByTestId("websearch-fetch-card");
- expect(screen.getByText("Fetch pages through the search service")).toBeTruthy();
- expect(screen.getByText("Off: pages are fetched from this machine. On: the search service fetches them, and sees each page address. Offered by Exa, Firecrawl and Tavily.")).toBeTruthy();
- expect(screen.getByTestId("websearch-fetch-note").textContent).toBe("DuckDuckGo doesn't offer this. Choose Exa, Firecrawl or Tavily to turn it on.");
- expect((fetchSwitch() as HTMLButtonElement).disabled).toBe(true);
- fireEvent.click(fetchSwitch());
- expect(setFetchViaProvider).not.toHaveBeenCalled();
+ await screen.findByTestId("websearch-providers");
+ // DuckDuckGo is active and does not fetch pages; Exa would, but is not active.
+ expect(screen.queryByTestId("websearch-fetch-row")).toBeNull();
+ expect(screen.queryByTestId("websearch-fetch-toggle")).toBeNull();
fireEvent.click(radio("tavily"));
- await waitFor(() => expect((fetchSwitch() as HTMLButtonElement).disabled).toBe(false));
- expect(screen.queryByTestId("websearch-fetch-note")).toBeNull();
- expect(screen.getByText(/On: Tavily fetches them/)).toBeTruthy();
- expect(fetchSwitch().getAttribute("aria-checked")).toBe("false");
- fireEvent.click(fetchSwitch());
+ await screen.findByTestId("websearch-fetch-row");
+ const row = screen.getByTestId("websearch-row-tavily");
+ expect(within(row).getByTestId("websearch-fetch-row")).toBeTruthy();
+ expect(within(row).getByText("Also fetch pages through Tavily")).toBeTruthy();
+ expect(within(row).getByText("Tavily then sees the address of every page the agent opens.")).toBeTruthy();
+ expect(fetchBox().checked).toBe(false);
+ fireEvent.click(fetchBox());
await waitFor(() => expect(setFetchViaProvider).toHaveBeenCalledWith(true));
- await waitFor(() => expect(fetchSwitch().getAttribute("aria-checked")).toBe("true"));
+ await waitFor(() => expect(fetchBox().checked).toBe(true));
+
+ // Moving to a provider without page fetching hides the option; the flag stays stored
+ // and comes back when a fetching provider is active again.
+ fireEvent.click(radio("brave"));
+ await waitFor(() => expect(radio("brave").checked).toBe(true));
+ expect(screen.queryByTestId("websearch-fetch-row")).toBeNull();
+ fireEvent.click(radio("tavily"));
+ await screen.findByTestId("websearch-fetch-row");
+ expect(fetchBox().checked).toBe(true);
+ expect(setFetchViaProvider).toHaveBeenCalledTimes(1);
});
it("an unreachable server shows one line instead of an empty page", async () => {
diff --git a/surfaces/gui/src/components/CustomizationTab.tsx b/surfaces/gui/src/components/CustomizationTab.tsx
index 07e10a14..9e61bf20 100644
--- a/surfaces/gui/src/components/CustomizationTab.tsx
+++ b/surfaces/gui/src/components/CustomizationTab.tsx
@@ -12,12 +12,12 @@ import {
} from "../api";
import { openExternal } from "../tauri";
import { PanelHead } from "./IntegrationsView";
-import { Toggle } from "./Toggle";
// Settings ▸ Customization (UX-058): the services OpenWorker uses behind its tools. Today
// one section, Web search — the provider behind `web_search` as radio rows with a key per
-// service (kept in the machine's secret store; "Test and save" runs one search first) — and
-// the "Fetch pages through the search service" switch for `web_fetch`. Memory, speech
+// service (kept in the machine's secret store; "Test and save" runs one search first). The
+// active provider, when it can also read pages (Exa, Firecrawl, Tavily), carries one
+// indented option: "Also fetch pages through …" for `web_fetch`. Memory, speech
// recognition and the browser come here later, as placeholders in the approved mock.
// Same card idiom as the Sandbox page: one bordered card, hairline-divided rows, ghost
// controls on the right, no new card types.
@@ -115,10 +115,12 @@ export function CustomizationTab({ machine }: { machine?: Machine | null }) {
}
};
- const flipFetch = async (next: boolean) => {
+ // The flag is stored once; the server honours it only while the active provider offers
+ // page fetching, so it sits inert (and unseen here) under any other provider.
+ const flipFetch = async (p: WebSearchProviderInfo, next: boolean) => {
if (!info) return;
setInfo({ ...info, fetch_via_provider: next }); // optimistic; the reply settles it
- apply(await setFetchViaProvider(next, machineId), "fetch");
+ apply(await setFetchViaProvider(next, machineId), p.name);
};
const statusLine = (p: WebSearchProviderInfo): string => {
@@ -128,10 +130,6 @@ export function CustomizationTab({ machine }: { machine?: Machine | null }) {
return fixed ? t(fixed) : "";
};
- const active = info?.providers.find((p) => p.name === info.provider) ?? null;
- const fetchOffered = !!active?.supports_fetch;
- const fetchService = fetchOffered && active ? active.display_name : t("customization.fetch.service_generic");
-
return (
<section data-testid="customization-tab">
<PanelHead
@@ -259,6 +257,21 @@ export function CustomizationTab({ machine }: { machine?: Machine | null }) {
) : null}
</div>
) : null}
+ {isActive && p.supports_fetch ? (
+ <label className="mt-2 pl-7 flex items-start gap-2.5 cursor-pointer" data-testid="websearch-fetch-row">
+ <input
+ type="checkbox"
+ className="mt-0.5"
+ checked={info.fetch_via_provider}
+ onChange={(e) => void flipFetch(p, e.target.checked)}
+ data-testid="websearch-fetch-toggle"
+ />
+ <span className="min-w-0">
+ <span className="block text-ui text-ink">{t("customization.fetch.row", { name: p.display_name })}</span>
+ <span className="block text-meta text-muted">{t("customization.fetch.caution", { name: p.display_name })}</span>
+ </span>
+ </label>
+ ) : null}
{rowError ? (
<div className="mt-1.5 pl-7 text-meta text-danger" data-testid="websearch-error">
{rowError}
@@ -270,32 +283,6 @@ export function CustomizationTab({ machine }: { machine?: Machine | null }) {
</div>
<p className="text-meta text-faint mt-2.5">{t("customization.websearch.footnote")}</p>
- <div className={CARD + " mt-3.5 px-4 py-3 flex items-start gap-3"} data-testid="websearch-fetch-card">
- <div className="flex-1 min-w-0">
- <div className="text-ui font-medium text-ink">{t("customization.fetch.title")}</div>
- <div className="text-meta text-muted leading-relaxed">
- {t("customization.fetch.desc", { service: fetchService })}
- </div>
- {!fetchOffered ? (
- <div className="text-meta text-faint mt-1" data-testid="websearch-fetch-note">
- {t("customization.fetch.unsupported", { service: active?.display_name ?? info.provider })}
- </div>
- ) : null}
- {error && error.name === "fetch" ? (
- <div className="mt-1.5 text-meta text-danger" data-testid="websearch-error">
- {error.text}
- </div>
- ) : null}
- </div>
- <span data-testid="websearch-fetch-toggle">
- <Toggle
- checked={fetchOffered && info.fetch_via_provider}
- disabled={!fetchOffered}
- onChange={(next) => void flipFetch(next)}
- title={t("customization.fetch.title")}
- />
- </span>
- </div>
</>
)}
</section>
diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.json
index b9b4221e..51709c75 100644
--- a/surfaces/gui/src/locales/en.json
+++ b/surfaces/gui/src/locales/en.json
@@ -727,7 +727,7 @@
"save_skill_footer": "Approving adds it to your skills on this computer — usable in every conversation from then on.",
"search_note": "Queries go to your configured search provider.",
"search_note_current": "Queries go to your configured search provider (currently: {{provider}}).",
- "fetch_note_current": "The page is fetched through {{provider}}, which sees its address.",
+ "fetch_note_current": "The page is fetched by your search service, {{provider}}, which sees its address.",
"reviewer_unsure": "reviewer wasn’t sure: {{note}}",
"site_wall_note": "{{host}} is not on your allowed sites.",
"network": {
@@ -2871,10 +2871,8 @@
"failed": "That didn't work. Try again."
},
"fetch": {
- "title": "Fetch pages through the search service",
- "desc": "Off: pages are fetched from this machine. On: {{service}} fetches them, and sees each page address. Offered by Exa, Firecrawl and Tavily.",
- "service_generic": "the search service",
- "unsupported": "{{service}} doesn't offer this. Choose Exa, Firecrawl or Tavily to turn it on."
+ "row": "Also fetch pages through {{name}}",
+ "caution": "{{name}} then sees the address of every page the agent opens."
}
}
}
diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.json
index c80bbec7..534f68c9 100644
--- a/surfaces/gui/src/locales/zh.json
+++ b/surfaces/gui/src/locales/zh.json
@@ -716,7 +716,7 @@
"save_skill_footer": "批准后会将其添加到本机的技能中 —— 此后每个会话都可使用。",
"search_note": "查询会发送到你配置的搜索服务商。",
"search_note_current": "查询会发送到你配置的搜索服务商(当前:{{provider}})。",
- "fetch_note_current": "该网页通过 {{provider}} 抓取,它会看到网页地址。",
+ "fetch_note_current": "该网页由你的搜索服务 {{provider}} 抓取,它会看到网页地址。",
"reviewer_unsure": "审查器不确定:{{note}}",
"site_wall_note": "{{host}} 不在你允许的网站列表中。",
"network": {
@@ -2831,10 +2831,8 @@
"failed": "操作未成功,请重试。"
},
"fetch": {
- "title": "通过搜索服务抓取网页",
- "desc": "关闭:网页由本机抓取。开启:由 {{service}} 抓取,它会看到每个网页地址。Exa、Firecrawl 和 Tavily 提供此功能。",
- "service_generic": "搜索服务",
- "unsupported": "{{service}} 不提供此功能。选择 Exa、Firecrawl 或 Tavily 后即可开启。"
+ "row": "也通过 {{name}} 抓取网页",
+ "caution": "{{name}} 届时会看到智能体打开的每个网页的地址。"
}
}
}